1. Install the tool automake and Autoconf. Compile the source program: mycc. C.
#include <stdio.h>#include "config.h"int main(int argc, char** argv){ if(argv == 1) { printf("version: %s\n", PACKAGE_STRING); } else { printf("name : %s\n", PACKAGE); printf("version : %s\n", VERSION); printf("bugreport: %s\n", PACKAGE_BUGREPORT); } return 0;}
It should be noted that the macro used in mycc. C is from config. H, and config. H is generated by the tool (see the following article)
2. Run autoscan to generate Configure. Scan
[root@waf mypkg]# autoscan[root@waf mypkg]# lsautoscan.log configure.scan mycc.c[root@waf mypkg]#
Rename Configure. Scan to configure. In and edit Configure. In.
# -*- Autoconf -*-# Process this file with autoconf to produce a configure script.AC_PREREQ([2.63])AC_INIT([mycc], [1.0.0], [www.mycc.org])AC_CONFIG_SRCDIR([mycc.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([mycc], [1.0.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)
3. Run aclocal and Autoconf
[root@waf mypkg]# aclocal[root@waf mypkg]# lsaclocal.m4 autom4te.cache autoscan.log configure.in mycc.c[root@waf mypkg]# autoconf[root@waf mypkg]# lsaclocal.m4 autom4te.cache autoscan.log configure configure.in mycc.c
4. Create makefile. Am. content:
AUTOMAKE_OPTIONS=foreignbin_PROGRAMS=myccmycc_SOURCES=mycc.c
5. Run autoheader to generate config. H. In (automake is required)
[root@waf mypkg]# lsaclocal.m4 autom4te.cache autoscan.log configure configure.in mycc.c[root@waf mypkg]# vim Makefile.am[root@waf mypkg]# autoheader[root@waf mypkg]# lsaclocal.m4 autoscan.log configure Makefile.amautom4te.cache config.h.in configure.in mycc.c
6. Run automake to generate configure
[root@waf mypkg]# automake --add-missingconfigure.in:8: installing `./install-sh'configure.in:8: installing `./missing'Makefile.am: installing `./depcomp'[root@waf mypkg]#
7. Try configure.
./configuremakemake install
Refer:
Http://www.ibm.com/developerworks/cn/linux/l-makefile/