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

看了一些网上的资料,然后自己总结了一下:

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值