您的位置:首页 > 其它

利用automake工具自动生成makefile[总结]

2009-10-15 11:08 381 查看
看了一些网上的资料,然后自己总结了一下:

kernel:2.6.27.30-170.2.82_ND5_1.i686.PAE

1.you should create your source code by hand.

e.g. you can write a simple code, like main.c"main(void) {}";

2.use the command autoscan, this command will generate two files:autoscan.log, configure.scan;

3.next step is the most important, you should change the name of the configure.scan instead of configure.in;

and then edit the file configure.in, you should place the FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS in your own definations, and the most important step is to add a sentence "AM_INIT_MAKE(PACKAGE-NAME, VERSION)" into configure.in, and replace the AC_OUTPUT to AC_OUTPUT([Makefile])

4.use aclocal to generate the "aclocal.m4" and "autom4te.cache", these files are used to deine the local marco

5.use autoconf to generate the configure file

6.use autoheader to generate the config.h.in.This tool is used to copy the additional symbols from user usually, if you do not add the additional symbols, then you needn't execute this command.

7.Before automake.

Create a new file Makefile.am, this file will be used by automake command. It's the configuration files, and we need create it by self.

The content like the following:

-----------------------------

AUTOMAKE_OPTIONS=foreign

bin_PROGRAMS=bin-name

bin-name_SOURCES=sourcecode

-----------------------------

==========================================================================

Tip:

1).the AUTOMAKE_OPTION can used to configure the automake, the 'foreign' means only check the requires file. another is 'gnits', the default is 'gnu'. If default, you should create these files 'COPYING,NEWS,INSTALL,README' and so on;

2).bin_PROGRAMS used to define the execute filename, if you have a lot, you should use space to split them. for example: bin_PROGRAMS=a b c

3).exec-name_SOURCES to define the source code that can be used to generate the exec-name. If the target exec-name needs 1.c 1.h, then you should write like this: exec-name_SOURCES=1.c 1.h

==========================================================================

Caution: if you define a lot exe-names, you should write the exe-name_SOURCES for each.

for a instance, bin_PROGRAMS=a b c

a_SOURCES=a.c

b_SOURCES=b.c

c_SOURCES=c.c

8.use automake to generate the Makefile.in

#automake --add-missing

option '--add-missing' let automake add the requires scripts when running.

9.Verify, use ./configure to generate the Makefile.

10.test it. #make && make install
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: