`
lijunaccp
  • 浏览: 153541 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

makefile文件生成

    博客分类:
  • C
阅读更多
前段时间,学习C,用autoconf和automake生成了一个简单的makefile文件。
autoconf是一个用于生成可以自动地配置软件源码包,用以适应多种UNIX类系统的shell脚本工具,其中autoconf需要用到 m4,便于生成脚本。automake是一个从Makefile.am文件自动生成Makefile.in的工具。为了生成Makefile.in,automake还需用到perl,由于automake创建的发布完全遵循GNU标准,所以在创建中不需要perl。
具体步骤如下:
1.在linux下新建一个helloworld目录。
2.在helloworld下新建一个helloworld.c文件,内容如下:
int main(int argc,char **argv){
     printf("Hello,Linux World!\n");
     return 0;
}
3.生成configure
3.1 先用autoscan命令根据源码生成configure.scan,把configure.scan重命名为configure.in,编辑此文件,找到
#Process this file with autoconif to ...
...<1>
#Checks for programs ...
...
AC_OUTPUT<2>
把<1>标注的内容改为:
AC_INIT(helloworld.c)
AM_INIT_AUTOMAKE(helloworld,1.0)
把<2>标注的内容改为:
AC_OUTPUT(makefile)
3.2 执行aclocal生成aclocal.m4文件
3.3 执行autoconf生成configure文件
4.新建Makefile.am,内容如下:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=helloworld
helloworld_SOURCES=helloworld.c
5.运行automake --add-missing 生成Makefile.in
6.执行configure生成Makefile
7.执行make生成helloworld.o,helloworld文件
8.运行程序,执行./helloworld
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics