1. autoscan扫描当前目录生成configure.scan
1 ~/work/test/mypro1 2 > autoscan 3 Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE [^\}]*}/ at /usr/bin/autoscan line 361. 4 5 ~/work/test/mypro1 6 > ls 7 autoscan.log configure.scan main.c
2. 将configure.scan改名为configure.ac
1 ~/work/test/mypro1 2 > mv configure.scan configure.ac
3. 编辑configure.ac
1 # -*- Autoconf -*- 2 # Process this file with autoconf to produce a configure script. 3 4 AC_PREREQ([2.69]) 5 6 AC_INIT([mypro1], [0.1]) 7 AC_CONFIG_SRCDIR([main.c]) 8 AM_INIT_AUTOMAKE 9 10 11 # Checks for programs. 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 21 # Checks for library functions. 22 23 AC_OUTPUT(Makefile)
4. aclocal生成aclocal.m4
1 ~/work/test/mypro1 2 > aclocal 3 4 ~/work/test/mypro1 5 > ls 6 aclocal.m4 autom4te.cache autoscan.log configure.ac main.c
5. autoconf生成configure
1 ~/work/test/mypro1 2 > autoconf 3 4 ~/work/test/mypro1 5 > ls 6 aclocal.m4 autom4te.cache autoscan.log configure configure.ac main.c
6. autoheader生成config.h.in
1 ~/work/test/mypro1 2 > autoheader 3 4 ~/work/test/mypro1 5 > ls 6 aclocal.m4 autom4te.cache autoscan.log config.h.in configure configure.ac main.c
7. 编辑Makefile.am
1 AUTOMAKE_OPTIONS=foreign 2 bin_PROGRAMS=mypro1 3 mypro1_SOURCES=main.c
8. automake --add-missing生成Makefile.in
1 ~/work/test/mypro1 2 > automake --add-missing 3 4 ~/work/test/mypro1 5 > ls 6 aclocal.m4 autom4te.cache autoscan.log compile config.h.in configure configure.ac depcomp install-sh main.c Makefile.am Makefile.in missing
9. ./configure生成Makefile
1 ~/work/test/mypro1 2 > ./configure 3 checking for a BSD-compatible install... /usr/bin/install -c 4 checking whether build environment is sane... yes 5 checking for a thread-safe mkdir -p... /bin/mkdir -p 6 checking for gawk... no 7 checking for mawk... mawk 8 checking whether make sets $(MAKE)... yes 9 checking whether make supports nested variables... yes 10 checking for gcc... gcc 11 checking whether the C compiler works... yes 12 checking for C compiler default output file name... a.out 13 checking for suffix of executables... 14 checking whether we are cross compiling... no 15 checking for suffix of object files... o 16 checking whether we are using the GNU C compiler... yes 17 checking whether gcc accepts -g... yes 18 checking for gcc option to accept ISO C89... none needed 19 checking whether gcc understands -c and -o together... yes 20 checking for style of include used by make... GNU 21 checking dependency style of gcc... gcc3 22 checking how to run the C preprocessor... gcc -E 23 checking for grep that handles long lines and -e... /bin/grep 24 checking for egrep... /bin/grep -E 25 checking for ANSI C header files... yes 26 checking for sys/types.h... yes 27 checking for sys/stat.h... yes 28 checking for stdlib.h... yes 29 checking for string.h... yes 30 checking for memory.h... yes 31 checking for strings.h... yes 32 checking for inttypes.h... yes 33 checking for stdint.h... yes 34 checking for unistd.h... yes 35 checking for unistd.h... (cached) yes 36 checking that generated files are newer than configure... done 37 configure: creating ./config.status 38 config.status: creating Makefile 39 config.status: creating config.h 40 config.status: executing depfiles commands 41 42 ~/work/test/mypro1 43 > ls 44 aclocal.m4 autom4te.cache autoscan.log compile config.h config.h.in config.log config.status configure configure.ac depcomp install-sh main.c Makefile Makefile.am Makefile.in missing stamp-h1
10. make编译即可