1 #! /bin/sh
2 set -x
3 now_dir=`pwd`
4 Build_main_dir=$now_dir/autotools
5 Build_src_dir=$Build_main_dir/src
6
7 #clear
8 if [ -e $Build_main_dir ]; then
9 rm -fr $Build_main_dir;
10 fi
11
12 # create code1.c code1.h code2.c code2.h
13 mkdir -p $Build_src_dir
14 cat <> $Build_src_dir/code1.c
15 #include "code1.h"
16 void foo_a()
17 {
18 printf("This is code1.\n");
19 }
20 eof
21
22 cat <> $Build_src_dir/code2.c
23 #include "code1.h"
24 #include "code2.h"
25 void foo_b()
26 {
27 printf("This is code2.\n");
28 }
29
30 int main()
31 {
32 foo_a();
33 foo_b();
34 }
35 eof
36
37 cat <> $Build_src_dir/code1.h
38 #include
39 #include
40 void foo_a();
41 eof
42
43 cat <> $Build_src_dir/code2.h
44 #include
45 #include
46 void foo_b();
47 eof
48
49 #create Makefile.am in src dir
50 cat <> $Build_src_dir/Makefile.am
51 bin_PROGRAMS=prog1
52 prog1_SOURCES=code1.c code2.c
53 eof
54
55 #create confingure.scan modify
56 cd $Build_main_dir
57 autoscan
58 sed -e 's&AC_OUTPUT&AC_OUTPUT\(Makefile src\/Makefile\)&g' \
59 -e 's&AC_CONFIG_HEADER&\#AC_CONFIG_HEADER&g' \
60 -e 's&AC_CONFIG_FILES&\#AC_CONFIG_FILES&g' \
61 -e 's&\(AC_INIT.*\)&\1\nAM_INIT_AUTOMAKE&g' ./configure.scan >configure.in
62
63 cat << eof >>$Build_main_dir/Makefile.am
64 SUBDIRS=src
65 eof
66
67 #然后执行命令aclocal和autoconf,分别会产生aclocal.m4及configure两个文件
68 touch NEWS README AUTHORS ChangeLog
69 aclocal
70 automake --add-missing
71 autoconf
72
73 ./configure && make
74 exit
阅读(1198) | 评论(0) | 转发(0) |