Ubuntu系统下autoconf生成Makefile的文件过程
1.安装必要的工具软件
- $ sudo apt-get install autoconf automake gettext
2.编写样例程序
- $ mkdir helloworld
- $ cd helloworld
- $ vim helloworld.c
- #include <stdio.h>
- int main(int argc, char **argv)
- {
- printf("Hello, Linux World!\n");
- return 0;
- }
3.生成configure.scan并改名为configure.in
- $ autoscan
- $ mv configure.scan configure.in
- $ vim configure.in
- # -*- Autoconf -*-
- # Process this file with autoconf to produce a configure script.
- AC_PREREQ(2.61)
- AC_INIT(helloworld, 1.1, xxx@sina.cn)
- AC_CONFIG_SRCDIR([helloworld.c])
- AC_CONFIG_HEADER([config.h])
- AM_INIT_AUTOMAKE(helloworld, 1.1)
- # 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)
4.生成aclocal.m4和configure两个文件
5.新建Makefile.am文件并添加以下内容
- UTOMAKE_OPTIONS=foreign
- bin_PROGRAMS=helloworld
- helloworld_SOURCES=helloworld.c
6.生成config.h.in文件
7.生成Makefile.in文件
- $ touch NEWS README AUTHORS ChangeLog
- $ automake --add-missing
8.执行configure生成Makefile文件
9.使用Makefile编译代码
10.运行helloworld代码
阅读(2056) | 评论(0) | 转发(0) |