官网说得很详细了,一开始没照着做,出现的问题是:
[shidongxue@centossvr hello]$ automake
configure.ac:8: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
configure.ac:8: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.ac:8: error: required file ‘./install-sh’ not found
configure.ac:8: ‘automake –add-missing’ can install ‘install-sh’
configure.ac:8: error: required file ‘./missing’ not found
configure.ac:8: ‘automake –add-missing’ can install ‘missing’
Makefile.am: error: required file ‘./INSTALL’ not found
Makefile.am: ‘automake –add-missing’ can install ‘INSTALL’
Makefile.am: error: required file ‘./NEWS’ not found
Makefile.am: error: required file ‘./README’ not found
Makefile.am: error: required file ‘./AUTHORS’ not found
Makefile.am: error: required file ‘./ChangeLog’ not found
Makefile.am: error: required file ‘./COPYING’ not found
Makefile.am: ‘automake –add-missing’ can install ‘COPYING’
Makefile.am: error: required file ‘./depcomp’ not found
Makefile.am: ‘automake –add-missing’ can install ‘depcomp’
好,现在照着例子重新做一遍:
1、目录结构是
hello/hello.c
仅一个文件
2、运行autoscan生成一个模板configure.in
3、重命名这个模板为configure.ac
4、修改这个文件为:
cat configure.ac
-- Autoconf --
Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT(hello,1.0,billyshi@126.com)
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT
一定要保证AM_INIT_AUTOMAKE([-Wall -Werror foreign])
和AC_CONFIG_FILES([
Makefile
])
添加进来,默认是没的。
5、准备一个Makefile.am
cat Makefile.am
bin_PROGRAMS=hello
hello_SOURCES=hello.c
6、OK,现在,有了这3个文件,hello.c configure.ac Makefile.am
7、autoreconf执行,带–install
[shidongxue@centossvr hello]$ autoreconf –install
configure.ac:8: installing ‘./install-sh’
configure.ac:8: installing ‘./missing’
Makefile.am: installing ‘./depcomp’
8、现在,软件包完成
9、以后就可以执行./configure和make了
./configure
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /usr/bin/mkdir -p
checking for gawk… gawk
checking whether make sets
(MAKE)…yescheckingwhethermakesupportsnestedvariables…yescheckingforgcc…gcccheckingwhethertheCcompilerworks…yescheckingforCcompilerdefaultoutputfilename…a.outcheckingforsuffixofexecutables…checkingwhetherwearecrosscompiling…nocheckingforsuffixofobjectfiles…ocheckingwhetherweareusingtheGNUCcompiler…yescheckingwhethergccaccepts−g…yescheckingforgccoptiontoacceptISOC89…noneneededcheckingforstyleofincludeusedbymake…GNUcheckingdependencystyleofgcc…gcc3checkingthatgeneratedfilesarenewerthanconfigure…doneconfigure:creating./config.statusconfig.status:creatingMakefileconfig.status:creatingconfig.hconfig.status:executingdepfilescommands[shidongxue@centossvrhello]
make
(CDPATH=”{ZSH_VERSION+.}:” && cd . && /bin/sh /home/shidongxue/work/router/hello/missing autoheader)
rm -f stamp-h1
touch config.h.in
cd . && /bin/sh ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
make all-am
make[1]: 进入目录“/home/shidongxue/work/router/hello”
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
gcc -g -O2 -o hello hello.o
make[1]: 离开目录“/home/shidongxue/work/router/hello”
[shidongxue@centossvr hello] ./hello
hello,world![shidongxue@centossvr hello]$