📄 00000002.htm
字号:
生一个configure.scan 的档案,我们可以用它做为 configure.in <BR> <BR> 档的蓝本。 <BR> <BR> <BR> % autoscan <BR> <BR> % ls <BR> <BR> configure.scan hello.c <BR> <BR> <BR> 2. 编辑 configure.scan 档,如下所示,并且把它的档名改成 <BR> <BR> configure.in <BR> <BR> <BR> dnl Process this file with autoconf to produce a con <BR>figure script. <BR> <BR> <BR> AC_INIT(hello.c) <BR> <BR> <BR> AM_INIT_AUTOMAKE(hello, 1.0) <BR> <BR> <BR> dnl Checks for programs. <BR> <BR> <BR> AC_PROG_CC <BR> <BR> <BR> dnl Checks for libraries. <BR> <BR> <BR> dnl Checks for header files. <BR> <BR> <BR> dnl Checks for typedefs, structures, and compiler ch <BR>aracteristics. <BR> <BR> <BR> dnl Checks for library functions. <BR> <BR> <BR> AC_OUTPUT(Makefile) <BR> <BR> <BR> 3. 执行 aclocal 和 autoconf ,分别会产生 aclocal.m4 及 configure 两 <BR> <BR> 个档案 <BR> <BR> <BR> % aclocal <BR> <BR> <BR> % autoconf <BR> <BR> <BR> % ls <BR> <BR> <BR> aclocal.m4 configure configure.in hello.c <BR> <BR> <BR> 4. 编辑 Makefile.am 档,内容如下 <BR> <BR> <BR> AUTOMAKE_OPTIONS= foreign <BR> <BR> <BR> bin_PROGRAMS= hello <BR> <BR> <BR> hello_SOURCES= hello.c <BR> <BR> <BR> 5. 执行 automake --add-missing ,Automake 会根据 Makefile.am 档产生 <BR> <BR> 一些档案,包含最重要的 Makefile.in <BR> <BR> <BR> % automake --add-missing <BR> <BR> <BR> automake: configure.in: installing `./install-sh' <BR> <BR> <BR> automake: configure.in: installing `./mkinstalldirs' <BR> <BR> <BR> <BR> automake: configure.in: installing `./missing' <BR> <BR> <BR> 6. 最後执行 ./configure , <BR> <BR> <BR> % ./configure <BR> <BR> <BR> creating cache ./config.cache <BR> <BR> checking for a BSD compatible install... /usr/bin/in <BR>stall -c <BR> <BR> checking whether build environment is sane... yes <BR> <BR> checking whether make sets ${MAKE}... yes <BR> <BR> checking for working aclocal... found <BR> <BR> checking for working autoconf... found <BR> <BR> checking for working automake... found <BR> <BR> checking for working autoheader... found <BR> <BR> checking for working makeinfo... found <BR> <BR> checking for gcc... gcc <BR> <BR> checking whether the C compiler (gcc ) works... yes <BR> <BR> <BR> checking whether the C compiler (gcc ) is a cross-co <BR>mpiler... no <BR> <BR> checking whether we are using GNU C... yes <BR> <BR> checking whether gcc accepts -g... yes <BR> <BR> updating cache ./config.cache <BR> <BR> creating ./config.status <BR> <BR> creating Makefile <BR> <BR> <BR> 现在你的目录下已经产生了一个 Makefile 档,下个 ``make'' 指令就可 <BR> <BR> 以开始编译 hello.c 成执行档,执行 ./hello 和 GNU 打声招呼吧! <BR> <BR> <BR> % make <BR> <BR> <BR> gcc -DPACKAGE=\"hello\" -DVERSION=\"1.0\" -I. -I. -g -O2 -c he <BR>llo.c <BR> <BR> <BR> gcc -g -O2 -o hello hello.o <BR> <BR> <BR> % ./hello <BR> <BR> <BR> Hello! GNU! <BR> <BR> <BR> 你还可以试试 ``make clean'',''make install'',''make dist'' 看看 <BR> <BR> 会有什麽结果。你也可以把产生出来的 Makefile 秀给你的老板,让他从 <BR> <BR> 此对你刮目相看 :-) <BR> <BR> <BR> 4. 一探究竟 <BR> <BR> <BR> 上述产生 Makefile 的过程和以往自行编写的方式非常不一样,舍弃传统 <BR> <BR> 自行定义 make 的规则,使用 Automake 只需用到一些已经定义好的巨集 <BR> <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -