- 論壇徽章:
- 0
|
自動生成Makefile文件并最終生成發(fā)布包需要一次執(zhí)行下面幾個命令:
1、autoscan ;
2、aclocal ;
3、autoconf ;
4、autoheader ;
5、automake ;
6、./configure ;
7、make ;
8、make install ;
9、make distcheck ;
10、make distclean ;
具體操作細節(jié)如下:
首先,要創(chuàng)建一個用來進行操作的目錄,如:hello,并將源文件hello.c復制到這個目錄下。
執(zhí)行autoscan命令,hello目錄下會生產(chǎn)configure.scan文件,將此文件名稱改為configure.in或者configure.ac,修改configure.in文件為:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE(hello,1.0)
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT(Makefile)
接下來
執(zhí)行aclocal命令,系統(tǒng)會在hello目錄下生成aclocal.m4文件
創(chuàng)建Makefile.am文件,文件內(nèi)容為:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
執(zhí)行autoconf命令,系統(tǒng)在hello目錄下生成configure可執(zhí)行文件
執(zhí)行autoheader命令,系統(tǒng)在hello目錄下生成config.h.in文件
執(zhí)行automake -a命令,系統(tǒng)在hello目錄下生成depcomp install-sh Makefile.in missing等文件
執(zhí)行./configure命令,系統(tǒng)在hello目錄下生成Makefile文件
執(zhí)行make && make install命令,系統(tǒng)編譯并安裝hello程序
執(zhí)行make distcheck命令,系統(tǒng)將安裝程序打包成軟件發(fā)布包
執(zhí)行make distclean命令,系統(tǒng)將刪除./configure命令執(zhí)行時產(chǎn)生的文件和Makefile.in文件
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u/18280/showart_1976410.html |
|