Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

第 21 章 Build tool

目錄

21.1. make - GNU make utility to maintain groups of programs
21.1.1. autoconf - Generate configuration scripts
21.2. CMake
21.2.1. helloworld
21.2.2. cmake_minimum_required
21.2.3. SET
21.2.4. ADD_SUBDIRECTORY
21.2.5. INCLUDE_DIRECTORIES
21.2.6. 編譯檔案
21.2.6.1. ADD_EXECUTABLE 編譯可執行
21.2.6.2. ADD_LIBRARY 編譯庫檔案
21.2.7. EXECUTABLE_OUTPUT_PATH / LIBRARY_OUTPUT_PATH
21.2.8. TARGET_LINK_LIBRARIES
21.2.9. INSTALL
21.3. scons - a software construction tool
21.4. Phing

21.1. make - GNU make utility to maintain groups of programs

Makefile

$ sudo apt-get install make
		

使用make命令測試

21.1.1. autoconf - Generate configuration scripts

autoconf

$ sudo apt-get install autoconf
			

automake

$ sudo apt-get install automake
			

example

過程 21.1. autoconf and automake step by step

  1. create directory

    % mkdir devel
    % cd devel
    % mkdir hello
    % cd hello
    					

    create a file

    vim hello.c
    
      #include
      int main(int argc, char** argv)
      {
      printf(``Hello, GNU!\n'');
      return 0;
      }
    					
  2. autoscan

    neo@debian:~/workspace/devel/hello$ autoscan
    neo@debian:~/workspace/devel/hello$ ls
    autoscan.log  configure.scan  hello.c
    					
  3. configure.in

    cp configure.scan configure.in
    
    neo@debian:~/workspace/devel/hello$ aclocal
    neo@debian:~/workspace/devel/hello$ autoconf
    neo@debian:~/workspace/devel/hello$ ls
    autom4te.cache  autoscan.log  configure  configure.in  configure.scan  hello.c
    					
  4. Makefile.am

    neo@debian:~/workspace/devel/hello$ vim Makefile.am
    neo@debian:~/workspace/devel/hello$ cat Makefile.am
    AUTOMAKE_OPTIONS= foreign
    bin_PROGRAMS= hello
    hello_SOURCES= hello.c
    neo@debian:~/workspace/devel/hello$
    					

    $ automake --add-missing
    configure.in: no proper invocation of AM_INIT_AUTOMAKE was found.
    configure.in: You should verify that configure.in invokes AM_INIT_AUTOMAKE,
    configure.in: that aclocal.m4 is present in the top-level directory,
    configure.in: and that aclocal.m4 was recently regenerated (using aclocal).
    automake: no `Makefile.am' found for any configure output
    automake: Did you forget AC_CONFIG_FILES([Makefile]) in configure.in?