Skip to content

automake cmake

cheyiliu edited this page Dec 9, 2014 · 8 revisions

automake usage

(1)首先,编写源文件hello.c。

[cpp] view plaincopy

#include <stdio.h>  
  
int main(int argc, char** argv[])  
{  
    printf("hello, world!\n");  
    return 1;  
}  

(2)接下来,我们需要创建一个Makefile.am,同时编写上脚本。 [cpp] view plaincopy

SUBDIRS=  
  
bin_PROGRAMS=hello  
hello_SOURCES=hello.c    

(3)直接输入autoscan,生成文件configure.scan,再改名为configure.in。

修改脚本AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) 为AC_INIT(hello, 1.0, [email protected]) ---comment, optional

同时,在AC_CONFIG_HEADER([config.h])后面添加 AM_INIT_AUTOMAKE(hello, 0.1) ---comment, or just add AM_INIT_AUTOMAKE

(4)依次输入aclocal命令、autoheader命令

(5)创建4个文件,分别为README、NEWS、AUTHORS和ChangeLog

(6)依次输入automake -a、autoconf命令

(7)输入./configure,生成最终的Makefile

(8)如果需要编译,输入make;如果需要安装, 输入make install;如果需要发布软件包,输入make dist

补充:

若再增加新模块

1.编写源文件并修改Makefile.am

2.执行autoreconf

3.执行./configure

4.make

cmake

Usage Linux:

$ export ANDROID_NDK=/absolute/path/to/the/android-ndk

$ mkdir build && cd build

$ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake ..

$ make -j8

Usage Linux (using standalone toolchain):

$ export ANDROID_STANDALONE_TOOLCHAIN=/absolute/path/to/android-toolchain

$ mkdir build && cd build

$ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake ..

$ make -j8

Usage Windows:

You need native port of make to build your project.

Android NDK r7 (and newer) already has make.exe on board.

For older NDK you have to install it separately.

$ SET ANDROID_NDK=C:\absolute\path\to\the\android-ndk

$ mkdir build && cd build

$ cmake.exe -G"MinGW Makefiles"

-DCMAKE_TOOLCHAIN_FILE=path\to\the\android.toolchain.cmake

-DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows\bin\make.exe" ..

$ cmake.exe --build .


* cmake-tutorial 
* http://www.cmake.org/cmake-tutorial/
* http://www.cs.swarthmore.edu/~adanner/tips/cmake.php

### ref
* http://blog.csdn.net/feixiaoxing/article/details/7211487
* http://blog.csdn.net/cnsword/article/details/7542696
* http://mogoweb.net/archives/126
* https://github.com/taka-no-me/android-cmake
Clone this wiki locally