AutoMake 学习笔记---使用过程 | 互联网,请记住我
AutoMake 学习笔记---使用过程
过程记录:
1.autoscan
2.修改configure.scan,重命名为configure.in,编辑Makefile.am
3.运行aclocal
4.autoconf
5.automake –add-missing
6.好了,你可以configure && make && make install了。实例记录:
1. mkdir h2
2.cd h2
3. vim h2.c,内容如下:
- #include <stdio.h>
- int main()
- {
- printf("hi, This is jerry");
- return 0;
- }
4.运行autoscan,将生成autoscan.log和configure.scan
5.将configure.scan命名为configure.in,并修改:我这里内容如下:
- # -*- Autoconf -*-
- # Process this file with autoconf to produce a configure script.
- AC_PREREQ(2.61)
- AC_INIT(h2, 1.0,xurenlu@gmail.com)
- AC_CONFIG_SRCDIR([h2.c])
- AC_CONFIG_HEADER([config.h])
- AM_INIT_AUTOMAKE(h2,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_CONFIG_FILES(Makefile)
- AC_OUTPUT
与autoscan生成的文件相比,我加了这两行:
- AM_INIT_AUTOMAKE(h2,1.0)
- AC_CONFIG_FILES(Makefile)
同时改了这样几行:
- AC_INIT(h2, 1.0,xurenlu@gmail.com)
现在我们编辑Makefile.am:
内容如下:
- AUTOMAKE_OPTIONS=foreign
- bin_PROGRAMS=h2
- h2_SOURCES=h2.c
接下来运行aclocal
此时会生成aclocal.m4和autom4te.cache。
我们运行:autoconf生成configure文件.
再运行autohead 生成config.h.in
最后运行automake –add-missing 就能得到Makefile.in了
有了这个,就可以configure了。
在网上搜到这样一个图: