新建helloworld目录,里边有一个源码文件helloworld.c。 $ autoscan |
新生成的文件configure.scan改名为configure.in,并编辑修改内容,去掉无关的语句:
===================configure.in内容开始============= # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_INIT(helloworld.c) AM_INIT_AUTOMAKE(helloworld, 1.0) # Checks for programs. AC_PROG_CC # Checks for libraries. # Checks for header files. # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. AC_OUTPUT(Makefile) =====================configure.in内容结束================== |
$ aclocal 新产生aclocal.m4及configure两个文件。 aclocal是一个perl 脚本程序,它的定义是:“aclocal - create aclocal.m4 by scanning configure.ac”。 aclocal根据configure.in文件的内容,自动生成aclocal.m4文件。 autoconf 是用来生成自动配置软件源代码脚本(configure)的工具。autoconf从configure.in这个列举编译软件时所需要各种参数的模板文件中创建configure。 autoconf需要GNU m4宏处理器来处理aclocal.m4,生成configure脚本。 m4是一个宏处理器。 |
新建Makefile.am文件,内容如下: automake会根据你写的Makefile.am来自动生成Makefile.in。 |
运行automake命令如下:将会生成configure文件 $ automake --add-missing configure.in: installing `./install-sh' configure.in: installing `./mkinstalldirs' configure.in: installing `./missing' Makefile.am: installing `./depcomp' automake会根据Makefile.am文件产生一些文件,包含最重要的Makefile.in。 |
执行configure生成Makefile
$ ./configure
使用Makefile编译代码
$ make
运行helloworld
$ ./helloworld