Automake 主要是用于 Linux 或者 windows 平台下 makefile 文件的自动生成的工具。Automake 的使用步骤如下:
创建文件夹:
mkdir doc mkdir etc mkdir src mkdir src/test
在除了 doc 文件夹下,创建 Makefile.am 文件,包括子文件夹:
touch Makefile.am touch etc/Makefile.am touch src/Makefile.am touch src/test/Makefile.am
执行 autoscan 命令,命令如下:
autoscan
重命名文件,具体命令如下:
mv configure.scan configure.ac
编辑配置,具体命令如下:
vim configure.ac
在 AC_INIT 下增加 AM_INIT_AUTOMAKE(threadPool, 1.0):
AC_INIT(ThreadPool, 1.0, haicoder@haicoder.cn) AM_INIT_AUTOMAKE(ThreadPool, 1.0)
执行 aclocal 命令,命令如下:
aclocal
执行 autoconf 命令,命令如下:
autoconf
编辑 Makefile.am,命令如下:
vim Makefile.am
修改如下配置:
SUBDIRS=src etc
编辑 etc/Makefile.am:
vim etc/Makefile.am
修改如下配置:
nac_monitordir=/etc/ nac_monitor_DATA=nac_monitor.conf rules.conf net_acl.conf
编辑 src/Makefile.am:
vim src/Makefile.am
修改如下配置:
SUBDIRS=packet std decode tool test AM_CFLAGS=@CFLAGS@ -D_GNU_SOURCE -D_LGPL_SOURCE bin_PROGRAMS=nac_monitor nac_monitor_DEPENDENCIES=std/libnac_monitor_std.la decode/libnac_monitor_decode.la packet/libnac_monitor_packet.la nac_monitor_INCLUDES= -I${top_srcdir}/src/std -I${top_srcdir}/src/decode -I${top_srcdir}/src/packet nac_monitor_LDADD=std/libnac_monitor_std.la decode/libnac_monitor_decode.la packet/libnac_monitor_packet.la -lconfig -lpthread -lpcap -ldl -lnacstd nac_monitor_SOURCES= nac_monitor.c nac_monitor_LDFLAGS=
编辑 src/test/Makefile.am:
vim src/test/Makefile.am
修改如下配置:
AM_CFLAGS=@CFLAGS@ -D_GNU_SOURCE -D_LGPL_SOURCE INCLUDES= -I${top_srcdir}/src/std -I${top_srcdir}/src/decode noinst_PROGRAMS=test_conf test_rbtree test_conf_DEPENDENCIES=../std/libnac_monitor_std.la ../decode/libnac_monitor_decode.la test_conf_LDADD=../decode/libnac_monitor_decode.la ../std/libnac_monitor_std.la -lconfig -lpthread -ldl test_conf_SOURCES= test_conf.c test_conf_LDFLAGS= test_rbtree_DEPENDENCIES=../std/libnac_monitor_std.la ../decode/libnac_monitor_decode.la test_rbtree_LDADD=../std/libnac_monitor_std.la ../decode/libnac_monitor_decode.la -lconfig -lpthread -ldl test_rbtree_SOURCES= test_rbtree.c test_rbtree_LDFLAGS= noinst_PROGRAMS+= test_ip_tree test_ip_tree_DEPENDENCIES=../std/libnac_monitor_std.la ../decode/libnac_monitor_decode.la test_ip_tree_LDADD=../std/libnac_monitor_std.la ../decode/libnac_monitor_decode.la -lconfig -lpthread -ldl test_ip_tree_SOURCES= test_ip_tree.c noinst_PROGRAMS+= test_nac_acl test_nac_acl_DEPENDENCIES=../std/libnac_monitor_std.la ../decode/libnac_monitor_decode.la test_nac_acl_LDADD=../std/libnac_monitor_std.la test_nac_acl_SOURCES= test_acl.c
执行 autoheader:
autoheader
创建文件:
touch NEWS touch README touch AUTHORS touch ChangeLog
执行 automake:
automake -a
执行 configure:
./configure
执行 make:
make make install make clean