2008年4月7日 星期一

Makefile.am, Makefile.in, Makefile文件之間關係

REF:
http://cax.bloghi.com/2006/08/03/makefile-am-makefile-in-makefilea-a-a-e-a-c.html
http://www.ccw.com.cn/htm/app/linux/develop/01_7_25_7.asp



Makefile.am, Makefile.in, Makefile文件之間關係以及aclocal, automake, autoconf等命令作用的探究

aclocal # 產生 aclocal.m4
libtoolize --force
automake --add-missing # 根據Makefile.am生成Makefile.in
autoconf # 根據configure.in 生成configure
autoheader

為了弄清楚automake等一系列命令的作用,專門蒐集並閱讀了一些相關資料。並通過下面一個小例子,熟悉了一下這些GNU工具的使用:

例子:在/hello/目錄下創建一個hello.c文件,並編譯運行它:

#cd /hello/

(1) 編寫源文件hello.c:

include
int main(int argc, char** argv)
{
printf("Hello, GNU!n");
return 0;
}

(2) #autoscan
->生成 configure.scan 和 autoscan.log

(3) 將configure.scan 修改為 configure.in:

# Process this file with autoconf to produce a configure script.
AC_INIT(hello.c)
AM_INIT_AUTOMAKE(hello, 1.0)

# Checks for programs.
AC_PROG_CC

# Checks for library functions.
AC_OUTPUT(Makefile)

(4) #aclocal
->生成 aclocal.m4 和 autom4te.cache (生成aclocal.m4的過程中涉及到configure.in)

(5) #autoconf
->生成 configure (根據 configure.in, 和 aclocal.m4)

(6) 編寫Makefile.am:

AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS= hello
hello_SOURCES= hello.c

(7) #automake --add-missing
->生成 Makefile.in, depcomp, install-sh, 和 missing (根據 Makefile.am, 和 aclocal.m4)

(8) #./configure
->生成 Makefile, config.log, 和 config.status

沒有留言: