用autotools为westworld生成makefile - 备忘录
一、开发环境
mild:~/program/finite-state-machine/WestWorldWithWoman2$ uname -a
Linux mild-F80L 2.6.35-28-generic #49-Ubuntu SMP Tue Mar 1 14:40:58 UTC 2011 i686 GNU/Linux
mild:~/program/finite-state-machine/WestWorldWithWoman2$ g++ --version
g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
mild:~/program/finite-state-machine/WestWorldWithWoman2$ automake --version
automake (GNU automake) 1.11.1
Copyright (C) 2009 Free Software Foundation, Inc.
mild:~/program/finite-state-machine/WestWorldWithWoman2$ autoconf --version
autoconf (GNU Autoconf) 2.6
二、源文件目录结构
ProjectName
- src
- *.h, *.cpp
三、生成步骤
1、mild:~/program/finite-state-machine/WestWorldWithWoman2$ autoscan //生成autoscan.log与configure.scan
mild:~/program/finite-state-machine/WestWorldWithWoman2$ cp configure.scan configure.ac
mild:~/program/finite-state-machine/WestWorldWithWoman2$ vim configure.ac
1
#
-*-
Autoconf
-*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ( [ 2.67 ] )
5 AC_INIT(westworld, 1.2 , wenhl @gmail .com) # 修改
6 AM_INIT_AUTOMAKE # 添加
7 AC_CONFIG_SRCDIR( [ src/main.cpp ] ) #修改
8 AC_CONFIG_HEADERS( [ config.h ] )
9
10 # Checks for programs.
11 AC_PROG_CXX
12 AC_PROG_CC
13
14 # Checks for libraries.
15
16 # Checks for header files.
17 AC_CHECK_HEADERS( [ unistd.h ] )
18
19 # Checks for typedefs, structures, and compiler characteristics.
20 AC_HEADER_STDBOOL
21 AC_C_INLINE
22
23 # Checks for library functions.
24 AC_CHECK_FUNCS( [ sqrt ] )
25
26 AC_CONFIG_FILES( [ Makefile src/Makefile ] ) #修改
27
28 AC_OUTPUT
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ( [ 2.67 ] )
5 AC_INIT(westworld, 1.2 , wenhl @gmail .com) # 修改
6 AM_INIT_AUTOMAKE # 添加
7 AC_CONFIG_SRCDIR( [ src/main.cpp ] ) #修改
8 AC_CONFIG_HEADERS( [ config.h ] )
9
10 # Checks for programs.
11 AC_PROG_CXX
12 AC_PROG_CC
13
14 # Checks for libraries.
15
16 # Checks for header files.
17 AC_CHECK_HEADERS( [ unistd.h ] )
18
19 # Checks for typedefs, structures, and compiler characteristics.
20 AC_HEADER_STDBOOL
21 AC_C_INLINE
22
23 # Checks for library functions.
24 AC_CHECK_FUNCS( [ sqrt ] )
25
26 AC_CONFIG_FILES( [ Makefile src/Makefile ] ) #修改
27
28 AC_OUTPUT
2、mild:~/program/finite-state-machine/WestWorldWithWoman2$ aclocal //生成aclocal.m4与autom4te.cache文件
mild:~/program/finite-state-machine/WestWorldWithWoman2$ autoheader //生成config.h.in文件
3、添加Makefile.am、src/Makefile.am
Makefile.am
1
AUTOMAKE_OPTIONS
=
foreign
2 SUBDIRS = src
2 SUBDIRS = src
src/Makefile.am
1
bin_PROGRAMS
=
westworld
2 westworld_SOURCES = BaseGameEntity.cpp \
3 main.cpp \
4 Miner.cpp \
5 MinerOwnedStates.cpp \
6 MinersWife.cpp \
7 MinersWifeOwnedStates.cpp
2 westworld_SOURCES = BaseGameEntity.cpp \
3 main.cpp \
4 Miner.cpp \
5 MinerOwnedStates.cpp \
6 MinersWife.cpp \
7 MinersWifeOwnedStates.cpp
4、mild:~/program/finite-state-machine/WestWorldWithWoman2$ automake --add-missing //生成install-sh, missing, depcomp文件
5、mild:~/program/finite-state-machine/WestWorldWithWoman2$ autoconf //生成configure脚本
6、mild:~/program/finite-state-machine/WestWorldWithWoman2$ ./configure
四、make、make install...
五、深入了解autotools。
源码工程下载
六、参考
http://hi.baidu.com/yzkuang/blog/item/557e4f24423d8136c9955908.html
http://blogold.chinaunix.net/u1/51541/showart_2255373.html