使用automake自动生成Makefile

第一回用automake,而不是自己写makefile,感觉技术高了一个档次(其实还是老样子。。。)我用的电脑主要是 Fedora14 还有Red Ha Enterprise 5…

首先编写自己需要的源代码,我的工程是编写好了server还有client的程序,还有其他要用到的一些自定义的头文件等等,最终是要生成server和client的可执行程序。

——————————————

运行 autoscan , 自动创建两个文件: autoscan.log configure.scan此时状态如下:[root@localhost main]# autoscan[root@localhost main]# lsautoscan.log configure.scan …[root@localhost main]# ——————————————

修改configure.scan的文件名为configure.in

修改: 1.修改AC_INIT里面的参数: AC_INIT(v1.4,.2.8, naturebe@163.com) 2.添加宏AM_INIT_AUTOMAKE, 它是automake所必备的宏,,也同前面一样,PACKAGE是所要产生软件套件的名称,VERSION是版本编号。

查看configure.in的内容:——————————————# -*- Autoconf -*-# Process this file with autoconf to produce a configure script.AC_PREREQ([2.66])AC_INIT([v1.4], [2.8] , naturebe@126.com)AC_CONFIG_SRCDIR([soapC.cpp])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE(v1.4, 2.8)# Checks for programs.AC_PROG_CXXAC_PROG_CC# Checks for libraries.# Checks for header files.AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h limits.h locale.h memory.h netdb.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/socket.h sys/time.h sys/timeb.h unistd.h])# Checks for typedefs, structures, and compiler characteristics.AC_HEADER_STDBOOLAC_TYPE_SIZE_T# Checks for library functions.AC_FUNC_MALLOCAC_FUNC_MKTIMEAC_FUNC_STRERROR_RAC_FUNC_STRTODAC_CHECK_FUNCS([ftime gethostbyname gettimeofday localtime_r memmove memset select socket strchr strerror strrchr strstr strtoull])AC_CONFIG_FILES([Makefile])AC_OUTPUT——————————————解读以上的文件:# -*- Autoconf -*-# Process this file with autoconf to produce a configure script.# AC_PREREQ:# 确保使用的是足够新的Autoconf版本。如果用于创建configure的Autoconf的版# 本比version 要早,就在标准错误输出打印一条错误消息并不会创建configure。AC_PREREQ()# 初始化,定义软件的基本信息,包括设置包的全称,版本号以及报告BUG时需要用的邮箱地址AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)# 用来侦测所指定的源码文件是否存在,来确定源码目录的有效性AC_CONFIG_SRCDIR([main.c])# 用于生成config.h文件,以便autoheader使用AC_CONFIG_HEADER([config.h])# Checks for programs.AC_PROG_CC# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.# 创建输出文件。在`configure.in’的末尾调用本宏一次。AC_OUTPUT——————————————运行 aclocal, 生成一个“aclocal.m4”文件和一个缓冲文件夹autom4te.cache,该文件主要处理本地的宏定义。此时的状态是:[root@localhost main]# aclocal[root@localhost main]# lsaclocal.m4 autom4te.cache autoscan.log configure.in configure.in~ main.c[root@localhost main]# ——————————————运行 autoconf, 目的是生成 configure 此时的状态是:[root@localhost main]# autoconf[root@localhost main]# lsaclocal.m4 autoscan.log configure.in main.cautom4te.cache configure configure.in~[root@localhost main]#

——————————————

午餐,晚餐。或许吃得不好,可是却依旧为对方擦去嘴角的油渍。

使用automake自动生成Makefile

相关文章:

你感兴趣的文章:

标签云: