Welcome 微信登录

首页 / 操作系统 / Linux / 使用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]# ls
autoscan.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_CXX
AC_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_STDBOOL
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_STRERROR_R
AC_FUNC_STRTOD
AC_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]# ls
aclocal.m4 autom4te.cache
autoscan.log configure.in configure.in~ main.c
[root@localhost main]#
------------------------------------------
运行 autoconf, 目的是生成 configure
此时的状态是:
[root@localhost main]# autoconf
[root@localhost main]# ls
aclocal.m4      autoscan.log configure.in   main.c
autom4te.cache configure     configure.in~
[root@localhost main]#
------------------------------------------
  • 1
  • 2
  • 下一页
Linux的三种线程实现模型漫谈Linux下启动护眼程序的方法相关资讯      Linux资料 
  • Linux触发连锁反应,惠及全球  (04/25/2012 05:49:29)
  • 【Linux】pam常用模块及意义  (04/18/2012 09:42:50)
  • 【Linux】配置Apache的别名的pam认  (04/18/2012 09:40:21)
  • 如何挂载只读的Linux文件系统  (04/19/2012 06:10:57)
  • 【Linux】ftp服务的ftpusers黑名单  (04/18/2012 09:42:02)
  • Linux 0.11 在Ubuntu-11和gcc-4.6.  (04/14/2012 11:06:44)
本文评论 查看全部评论 (0)
表情: 姓名: 字数