automake 实例 helloworld
时间:2010-06-18 来源:coldwinter011
automake 实例 helloworld
[dev@centos-252 tmp]$ uname -a //环境
Linux centos-252 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux
[dev@centos-252 tmp]$ mkdir helloworld && cd helloworld
[dev@centos-252 helloworld]$ vi helloworld.c [dev@centos-252 helloworld]$ cat helloworld.c
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
printf("Hello, world\n");
exit(0);
} [dev@centos-252 helloworld]$ autoscan //生成autoscan.log与configure.scan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[dev@centos-252 helloworld]$ ls
autoscan.log configure.scan helloworld.c
[dev@centos-252 helloworld]$ cp configure.scan configure.ac //生成configure.ac [dev@centos-252 helloworld]$ vi configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script. AC_PREREQ(2.59)
AC_INIT(hellworld, 1.0, [email protected]) //修改
AM_INIT_AUTOMAKE(hello,1.0) //增加
AC_CONFIG_SRCDIR([helloworld.c])
AC_CONFIG_HEADER([config.h]) # Checks for programs.
AC_PROG_CC # Checks for libraries. # Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h]) # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions.
AC_CONFIG_FILES([Makefile]) //增加
AC_OUTPUT [dev@centos-252 helloworld]$ aclocal //生成aclocal.m4与autom4te.cache文件
[dev@centos-252 helloworld]$ ls
aclocal.m4 autom4te.cache autoscan.log configure.ac configure.scan helloworld.c
[dev@centos-252 helloworld]$ autoheader //生成config.h.in文件
[dev@centos-252 helloworld]$ ls
aclocal.m4 autom4te.cache autoscan.log config.h.in configure.ac configure.scan helloworld.c
[dev@centos-252 helloworld]$ vi Makefile.am //创建文件Makefile.am 1 AUTOMAKE_OPTIONS= foreign
2 bin_PROGRAMS = helloworld
3 hello_SOURCES = helloworld.c [dev@centos-252 helloworld]$ automake --add-missing //生成install-sh, missing, depcomp文件
configure.ac: installing `./install-sh'
configure.ac: installing `./missing'
Makefile.am: installing `./depcomp'
Makefile.am:3: variable `hello_SOURCES' is defined but no program or
Makefile.am:3: library has `hello' as canonic name (possible typo) [dev@centos-252 helloworld]$ autoconf //生成configure脚本
[dev@centos-252 helloworld]$ ./configure //执行configure脚本生成Makefile
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
.... 省略 ....
[dev@centos-252 helloworld]$ make
make all-am
make[1]: Entering directory `/home/dev/tmp/helloworld'
if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT helloworld.o -MD -MP -MF ".deps/helloworld.Tpo" -c -o helloworld.o helloworld.c; \
then mv -f ".deps/helloworld.Tpo" ".deps/helloworld.Po"; else rm -f ".deps/helloworld.Tpo"; exit 1; fi
gcc -g -O2 -o helloworld helloworld.o
make[1]: Leaving directory `/home/dev/tmp/helloworld'
[dev@centos-252 helloworld]$ ./helloworld
Hello, world
Linux centos-252 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux
[dev@centos-252 tmp]$ mkdir helloworld && cd helloworld
[dev@centos-252 helloworld]$ vi helloworld.c [dev@centos-252 helloworld]$ cat helloworld.c
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
printf("Hello, world\n");
exit(0);
} [dev@centos-252 helloworld]$ autoscan //生成autoscan.log与configure.scan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[dev@centos-252 helloworld]$ ls
autoscan.log configure.scan helloworld.c
[dev@centos-252 helloworld]$ cp configure.scan configure.ac //生成configure.ac [dev@centos-252 helloworld]$ vi configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script. AC_PREREQ(2.59)
AC_INIT(hellworld, 1.0, [email protected]) //修改
AM_INIT_AUTOMAKE(hello,1.0) //增加
AC_CONFIG_SRCDIR([helloworld.c])
AC_CONFIG_HEADER([config.h]) # Checks for programs.
AC_PROG_CC # Checks for libraries. # Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h]) # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions.
AC_CONFIG_FILES([Makefile]) //增加
AC_OUTPUT [dev@centos-252 helloworld]$ aclocal //生成aclocal.m4与autom4te.cache文件
[dev@centos-252 helloworld]$ ls
aclocal.m4 autom4te.cache autoscan.log configure.ac configure.scan helloworld.c
[dev@centos-252 helloworld]$ autoheader //生成config.h.in文件
[dev@centos-252 helloworld]$ ls
aclocal.m4 autom4te.cache autoscan.log config.h.in configure.ac configure.scan helloworld.c
[dev@centos-252 helloworld]$ vi Makefile.am //创建文件Makefile.am 1 AUTOMAKE_OPTIONS= foreign
2 bin_PROGRAMS = helloworld
3 hello_SOURCES = helloworld.c [dev@centos-252 helloworld]$ automake --add-missing //生成install-sh, missing, depcomp文件
configure.ac: installing `./install-sh'
configure.ac: installing `./missing'
Makefile.am: installing `./depcomp'
Makefile.am:3: variable `hello_SOURCES' is defined but no program or
Makefile.am:3: library has `hello' as canonic name (possible typo) [dev@centos-252 helloworld]$ autoconf //生成configure脚本
[dev@centos-252 helloworld]$ ./configure //执行configure脚本生成Makefile
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
.... 省略 ....
[dev@centos-252 helloworld]$ make
make all-am
make[1]: Entering directory `/home/dev/tmp/helloworld'
if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT helloworld.o -MD -MP -MF ".deps/helloworld.Tpo" -c -o helloworld.o helloworld.c; \
then mv -f ".deps/helloworld.Tpo" ".deps/helloworld.Po"; else rm -f ".deps/helloworld.Tpo"; exit 1; fi
gcc -g -O2 -o helloworld helloworld.o
make[1]: Leaving directory `/home/dev/tmp/helloworld'
[dev@centos-252 helloworld]$ ./helloworld
Hello, world
相关阅读 更多 +