Operating System/System Programming(Arif Butt)

Lec05) GNU autotools and cmake

Tony Lim 2021. 6. 13. 13:41
728x90

Open source packages

magic spell to install open source packages

./configure

make

sudo make install

command "configure" checks for all the needed dependency.

command "make" build package with makefile and outputs .o file.

after command "sudo make install" you can use hello package. 

 

GNU autotools

m4 = macros , circled words are command.

myexe = executable name  

will use automake for this project

gcc ,cl ,cc  / any compiler will be fine

Makefile.in -> makefile 

acolocal.m4 and configure are generated. 

by foreign it will not work as GNU standards.

by command "automake --add-missing" makefile.am generated makefile.in

and than we type command "./configure" and then "make dist" we will get myexe-1.0.tar.gz

 

Cmake

a cross platform Makefile generator.

CMakeLists.txt is the only file we need to write in order to make cmake work.

 

by make build directory 

  1. all the generated files are seperated from source file
  2. can have several build tree for same source tree
  3. can perform clean build

 

with "cmake --help-command proejct"  we can check what is project keyword.

include_directories = where to look for inlcude file.

link_directories = where to look for library.

set = create variable in this case SOURCE

add executable = create executable named myexe in the followling directory.

target_link_libraries = first executable and then following is libraries. same as command "gcc -l". 

install = myexe will be installed in /usr/bin

 

after "cmake" , inside build folder Makefile is created. and with "make" we can use our myexe exectuable.

 

there are other things like "cpack --config CPackSourceConfig.cmake". and will create packages with many distribution type.

 

 

 

728x90