码迷,mamicode.com
首页 > 其他好文 > 详细

automake:从c文件到make

时间:2014-05-07 02:53:24      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:blog   class   code   tar   get   int   

如果你在Linux上从源代码安装过软件,一定记得./configure、make、make install的安装命令。这个神奇的configure和make是什么生成的,下面就将一步一步实现。

首先你有一个C文件,这里将它命名为abc.c。我们将它制作成一个名叫abc的软件包,可以使用./configure、make、make install安装到Linux系统中。

/**
 * abc.c 这是一个简单的程序
 * 用来演示automake是怎么样
 * 一步一步开始工作的
 */
#include <stdio.h>

int main(int argc, char* argv[]){
	printf("hello world!\n");
	return 0
}

我的系统中当前安装的软件有:

sys-devel/autoconf-2.13:2.1
sys-devel/autoconf-2.69:2.5
sys-devel/automake-1.9.6-r3:1.9
sys-devel/automake-1.11.6:1.11
sys-devel/libtool-2.4.2:2

sys-devel/make-3.82-r4
sys-devel/m4-1.4.16
sys-apps/texinfo-4.13-r2
app-arch/tar-1.27.1-r2

mkdir abc
cd abc
have abc.c

$autoscan
$ls
abc.c autoscan-2.69.log configure.scan

$cp configure.scan configure.ac
$aclocal
$ls
abc.c autom4te.cache/ autoscan-2.69.log configure.ac configure.scan

$vim configure.ac
AC_INIT([...
>>AC_INIT([abc], [0.0.1], [lophyxp@163.com])
AM_INIT_AUTOMAKE([foreign])
$aclocal
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log configure.ac configure.scan

$autoheader
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log config.h.in configure.ac configure.scan

$autoconf
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log config.h.in configure* configure.ac 

configure.scan

$automake
configure.ac:6: error: required file ‘./install-sh‘ not found
configure.ac:6:   ‘automake --add-missing‘ can install ‘install-sh‘
configure.ac:6: error: required file ‘./missing‘ not found
configure.ac:6:   ‘automake --add-missing‘ can install ‘missing‘
automake-1.13: error: no ‘Makefile.am‘ found for any configure output
$./configure
configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."

$automake --add-missing
configure.ac:6: installing ‘./install-sh‘
configure.ac:6: installing ‘./missing‘
automake-1.13: error: no ‘Makefile.am‘ found for any configure output

$touch Makefile.am
$automake --add-missing
automake-1.13: error: no ‘Makefile.am‘ found for any configure output
automake-1.13: Did you forget AC_CONFIG_FILES([Makefile]) in configure.ac?

$vim configure.ac
AC_OUTPUT
>>AC_CONFIG_FILES([Makefile])
AC_OUTPUT
$autoconf
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log config.h.in configure* configure.ac 
configure.scan install-sh Makefile.am missing

$automake --add-missing
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log config.h.in config.log configure* configure.ac 
configure.scan install-sh Makefile.am Makefile.in missing

$./configure
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log config.h config.h.in config.log config.status 
configure* configure.ac configure.scan install-sh Makefile.am Makefile.in missing stamp-h1

$make
***
***
***

$make
make  all-am
make[1]: 进入目录“/home/lophyxp/abc”
make[1]: 离开目录“/home/lophyxp/abc”
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log config.h config.h.in config.log config.status 
configure* configure.ac configure.scan install-sh Makefile Makefile.am Makefile.in missing stamp-h1

$echo ************************************************
$echo Now configure ready!
$echo ************************************************

$vim Makefile.am
bin_PROGRAMS=abc
abc_SOURCES=abc.c

$automake
Makefile.am: error: required file ‘./depcomp‘ not found
Makefile.am:   ‘automake --add-missing‘ can install ‘depcomp‘
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log config.h config.h.in config.log config.status 
configure* configure.ac configure.scan install-sh Makefile Makefile.am Makefile.in missing stamp-h1

$automake --add-missing
Makefile.am: installing ‘./depcomp‘
$ls
abc.c aclocal.m4 autom4te.cache/ autoscan-2.69.log config.h config.h.in config.log config.status 
configure* configure.ac configure.scan depcomp install-sh Makefile Makefile.am Makefile.in 
missing stamp-h1

$echo ************************************************
$echo Now Makefile.am ready!
$echo ************************************************

$./configure
$make
make  all-am
make[1]: 进入目录“/home/lophyxp/abc”
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT abc.o -MD -MP -MF .deps/abc.Tpo -c -o abc.o abc.c
mv -f .deps/abc.Tpo .deps/abc.Po
gcc  -g -O2   -o abc abc.o
make[1]: 离开目录“/home/lophyxp/abc”


automake:从c文件到make,布布扣,bubuko.com

automake:从c文件到make

标签:blog   class   code   tar   get   int   

原文地址:http://blog.csdn.net/lophyxp/article/details/24420531

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!