linux 下C/C++ 生成Configure 和Makefile
前提:
automake
简要步骤
-
编写test.c
-
运行
autoscan
-
运行
mv configure.scan configure.ac
-
修改
configure.ac
中内容# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) AC_INIT(test, 1.0, sizaif@mail.com) AC_CONFIG_SRCDIR([test.cpp]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE # 增加 # Checks for programs. AC_PROG_CXX AC_PROG_CC # Checks for libraries. # Checks for header files. # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T # Checks for library functions. AC_CONFIG_FILES([Makefile])
-
运行
aclocal
-
创建
Makefile.am
AUTOMAKE_OPTIONS=foreign # 固定写法 bin_PROGRAMS=test # 生成的可执行文件名称 test_SOURCES=test.c # 可执行文件名称_SOURCES
-
运行
automake --add-missing
-
运行
autoconf
生成configure
文件 -
执行
./configure
就可以得到Makefile
, 以及config.h
文件