详解linux下auto工具制作Makefile源码包(制作篇)(autoconf 2.61版本之前) .
来源:互联网 发布:新网怎么解析域名 编辑:程序博客网 时间:2024/05/22 03:02
automake 实例hello.c
平台与工具:
[root@mylinux hello]# uname -a
Linux mylinux.xiaodao.com 2.6.9-5.EL #1 Wed Jan 5 19:22:18 EST 2005 i686 athlon i386 GNU/Linux
autoscan (GNU Autoconf) 2.59
autoconf (GNU Autoconf) 2.59
automake (GNU automake) 1.9.2
==============================================================================
[root@mylinux hello]# uname -a
Linux mylinux.xiaodao.com 2.6.9-5.EL #1 Wed Jan 5 19:22:18 EST 2005 i686 athlon i386 GNU/Linux
autoscan (GNU Autoconf) 2.59
autoconf (GNU Autoconf) 2.59
automake (GNU automake) 1.9.2
==============================================================================
[root@mylinux c]# mkdir hello //新建工程目录hello
[root@mylinux c]# cd hello //进入工程目录hello
[root@mylinux hello]# vi hello.c //创建源文件hello.c
#include <stdio.h>
#include <stdlib.h>
[root@mylinux c]# cd hello //进入工程目录hello
[root@mylinux hello]# vi hello.c //创建源文件hello.c
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
printf("Hello, world\n");
exit(0);
}
[root@mylinux hello]# autoscan //生成autoscan.log与configure.scan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[root@mylinux hello]# cp configure.scan configure.ac //生成configure.ac
[root@mylinux hello]# vi configure.ac //编辑configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
main(void)
{
printf("Hello, world\n");
exit(0);
}
[root@mylinux hello]# autoscan //生成autoscan.log与configure.scan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[root@mylinux hello]# cp configure.scan configure.ac //生成configure.ac
[root@mylinux hello]# vi configure.ac //编辑configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(hello, 1.0, abc@abc.com) //修改
AM_INIT_AUTOMAKE(hello,1.0) //增加
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([config.h])
AC_INIT(hello, 1.0, abc@abc.com) //修改
AM_INIT_AUTOMAKE(hello,1.0) //增加
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h])
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
[root@mylinux hello]# aclocal //生成aclocal.m4与autom4te.cache文件
[root@mylinux hello]# autoheader //生成config.h.in文件
[root@mylinux hello]# vi Makefile.am //创建文件Makefile.am
AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS = hello
hello_SOURCES = hello.c
[root@mylinux hello]# touch README NEWS AUTHORS ChangeLog//创建README NEWS AUTHORS ChangeLog文件
[root@mylinux hello]# automake --add-missing //生成install-sh, missing, depcomp文件
configure.ac: installing `./install-sh'
configure.ac: installing `./missing'
Makefile.am: installing `./depcomp'
[root@mylinux hello]# autoconf //生成configure脚本
[root@mylinux hello]# ./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
.....省略
config.status: executing depfiles commands
[root@mylinux hello]# make //make编译生成hello可执行文件
make all-am
make[1]: Entering directory `/root/c/hello'
if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \
then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f ".deps/hello.Tpo"; exit 1; fi
gcc -g -O2 -o hello hello.o
make[1]: Leaving directory `/root/c/hello'
[root@mylinux hello]# ./hello //执行hello程序
Hello, world
[root@mylinux hello]#
AC_CONFIG_FILES([Makefile]) //增加
AC_OUTPUT
[root@mylinux hello]# aclocal //生成aclocal.m4与autom4te.cache文件
[root@mylinux hello]# autoheader //生成config.h.in文件
[root@mylinux hello]# vi Makefile.am //创建文件Makefile.am
AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS = hello
hello_SOURCES = hello.c
[root@mylinux hello]# touch README NEWS AUTHORS ChangeLog//创建README NEWS AUTHORS ChangeLog文件
[root@mylinux hello]# automake --add-missing //生成install-sh, missing, depcomp文件
configure.ac: installing `./install-sh'
configure.ac: installing `./missing'
Makefile.am: installing `./depcomp'
[root@mylinux hello]# autoconf //生成configure脚本
[root@mylinux hello]# ./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
.....省略
config.status: executing depfiles commands
[root@mylinux hello]# make //make编译生成hello可执行文件
make all-am
make[1]: Entering directory `/root/c/hello'
if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \
then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f ".deps/hello.Tpo"; exit 1; fi
gcc -g -O2 -o hello hello.o
make[1]: Leaving directory `/root/c/hello'
[root@mylinux hello]# ./hello //执行hello程序
Hello, world
[root@mylinux hello]#
- 详解linux下auto工具制作Makefile源码包(制作篇)(autoconf 2.61版本之前) .
- 详解linux下auto工具制作Makefile源码包(制作篇)(autoconf 2.61版本之后)
- 详解Linux下auto工具制作Makefile源码包(制作篇)
- 详解linux下auto工具制作Makefile源码包(制作篇)
- 详解linux下auto工具制作Makefile源码包(制作篇)
- 详解linux下auto工具制作Makefile源码包(制作篇)
- 详解linux下auto工具制作Makefile源码包(工具安装篇)
- 详解linux下auto工具制作Makefile源码包(工具安装篇)
- 详解linux下auto工具制作Makefile源码包(工具安装篇)
- linux下auto工具制作Makefile源码包
- 《Linux内核Makefile分析》之 auto.conf, auto.conf.cmd, autoconf.h(转载)
- linux 源码包的制作
- linux下简单源代码包(.tar.gz)的制作
- linux下简单源代码包(.tar.gz)的制作
- linux下制作deb包
- linux下RPM包制作
- autools工具制作Makefile
- 【Linux技术】autotools制作makefile过程详解
- 不求追上别人的步伐,需要有自己的风格
- 详解linux下auto工具制作Makefile源码包(制作篇)(autoconf 2.61版本之后)
- listview分页加载
- oracle系统表大全
- MySQL存储过程详解
- 详解linux下auto工具制作Makefile源码包(制作篇)(autoconf 2.61版本之前) .
- 一次远程的谈话
- 继承 动态绑定 默认参数
- webkit的js对象扩展(一)——binding方式创建自定义对象(单实例)
- makefile如何指定编译文件
- vector中insert()的用法详解
- 关于Ireport的使用技巧
- Linux在帅工具VI命令收集
- android对话框(非速成)