用autoconf和automake自动生成Makefile
本文是以下面的目录结构阐述Makefile生成及其中遇到的问题,并讲述解决问题的方法
生成Makefile主要需要经历以下几个步骤:
- 运行autoscan命令
- 将configure.scan 文件重命名为configure.ac,并修改configure.ac文件
- 在charge_automake目录下新建Makefile.am文件,并在android_mgr和public_func目录下也新建makefile.am文件
- 在charge_automake目录下新建NEWS、 README、 ChangeLog 、AUTHORS文件
- 运行aclocal命令
- 运行autoconf命令
- 运行autoheader命令
- 运行libtoolize –automake –copy –debug –force命令
- 运行automake –add-missing命令(参数要加,自动加载所需要而缺失的包)
- 运行./confiugre脚本
最主要的工作内容是编写configure.ac和Makefile.am
编写configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([android_mgr/src/android_shm_mgr.h])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_TYPE_INT8_T
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([getcwd memset mkdir strcasecmp strrchr])
AC_OUTPUT
根据实际情况,需要修改几个地方,修改如下:
# -*- Autoconf -*-
# Pro