Lesson 11

Dates: 4/5/2017
Application compilation and installation on Linux
Linux System Administration


Exercises with Makefiles.


  • Simple Makefile:
    Download Makefile1 into directory code_static, created during the exercises with the static library compilation.
    cd code_static
    rm *.o app.x *.a
    wget http://linuxcourse.rutgers.edu/lessons/application_compilation/downloads/Makefile1
    
    Check the content of the Makefile:
    less Makefile1
    
    Run make for compilation:
    make -f Makefile1
    
    Notice the sequence of the compilation steps. Run the command make again.
    Modify the time stamps of main.c then re-run make and notice the compilation steps made:
    touch main.c
    make -f Makefile1
    
    Modify the time stamps of Scalar_Product.h then re-run make and notice the compilation steps made:
    touch Scalar_Product.h 
    make -f Makefile1
    
    Modify the time stamps of Scalar_Product.c then re-run make and notice the compilation steps made:
    touch Scalar_Product.c
    make -f Makefile1
    

  • Makefile containing macros, suffix rules, and phony targets. Download Makefile6 into directory code_static:
    wget http://linuxcourse.rutgers.edu/lessons/application_compilation/downloads/Makefile6
    
    See the content of Makefile6:
    less Makefile6
    
    Run the following command to remove the compiled files:
    make -f Makefile6 clean
    
    Verify there is no longer files app.x, *.o, and libScalar_Product.a in directory code_static.
    Run compilation:
    make -f Makefile6
    
    Install the compiled binary, app.x and the library, libScalar_Product.a into /usr/local:
    sudo make -f Makefile6 install
    
    Check if files /usr/local/bin/app.x and /usr/local/lib/libScalar_Product.a have been created.
    ls -l /usr/local/bin
    ls -l /usr/local/lib
    
    Remove the installed files:
    sudo make -f Makefile6 uninstall
    
    Verify taht the files have been removed:
    ls -l /usr/local/bin
    ls -l /usr/local/lib
    



  • Take me to the Course Website