下面我们将试图如何生成这种发行版本,这里面主要使用到了aclocal, automake等工具。
1. 现在假设程序源代码已经编写完成,这里是main.c
xuqiang@ubuntu:~/automake/helloworld$ ls
main.c
xuqiang@ubuntu:~/automake/helloworld$ cat main.c
#include <stdio.h>
int main()
{
printf("hello linux world !");
return 0;
}
2. 运行autoscan,此时将生成autoscan.log,configure.scan两个文件。
xuqiang@ubuntu:~/automake/helloworld$ autoscan
xuqiang@ubuntu:~/automake/helloworld$ ls
autoscan.log configure.scan main.c
3. 我们将 configure.scan作为configure.in文件的模板,以供aclocal来使用。首先将configure.scan改名为configure.in
xuqiang@ubuntu:~/automake/helloworld$ mv configure.scan configure.in
修改configure.in件:
xuqiang@ubuntu:~/automake/helloworld$ vim configure.in
xuqiang@ubuntu:~/automake/helloworld$ cat configure.in
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([helloauto], [1.0], [xuqiang@gmail.com])
AC_CONFIG_SRCDIR([main.c])
# comment this line, no use
# AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
# init automake
AM_INIT_AUTOMAKE(helloauto, 1.0)
# write out the makefile
AC_OUTPUT(Makefile)
4. 执行aclocal命令,生成aclocal.m4 autom4te.cache两个文件
xuqiang@ubuntu:~/automake/helloworld$ aclocal
xuqiang@ubuntu:~/automake/helloworld$ ls
aclocal.m4 autom4te.cache autoscan.log configure.in main.c
5. 运行autoconf命令,将生成configure文件。
xuqiang@ubuntu:~/automake/helloworld$ autoconf
xuqiang@ubuntu:~/automake/helloworld$ ls
aclocal.m4 autom4te.cache autoscan.log configure configure.in main.c
6. 新建Makefile.am文件,该文件是工具automake的依赖文件。
xuqiang@ubuntu:~/automake/helloworld$ vim Makefile.am
xuqiang@ubuntu:~/automake/helloworld$ cat Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=helloauto
helloauto_SOURCES=main.c
7. 运行automake命令,该命令将在该源文件目录中增加所需脚本,例如INSTALL文件等。
xuqiang@ubuntu:~/automake/helloworld$ automake --add-missing
Makefile.am: installing `./INSTALL'
Makefile.am: required file `./NEWS' not found
Makefile.am: required file `./README' not found
Makefile.am: required file `./AUTHORS' not found
Makefile.am: required file `./ChangeLog' not found
Makefile.am: installing `./COPYING' using GNU General Public License v3 file
Makefile.am: Consider adding the COPYING file to the version control system
Makefile.am: for your code, to avoid questions about which license your project uses.
xuqiang@ubuntu:~/automake/helloworld$ ls
aclocal.m4 autoscan.log config.status configure.in INSTALL Makefile.am
autom4te.cache config.log configure COPYING main.c Makefile.in
8. 下面开始测试一下上面生成的文件。
xuqiang@ubuntu:~/automake/helloworld$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
xuqiang@ubuntu:~/automake/helloworld$ make
gcc -DPACKAGE_NAME=\"helloauto\" -DPACKAGE_TARNAME=\"helloauto\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"helloauto\ 1.0\" -DPACKAGE_BUGREPORT=\"xuqiang@gmail.com\" -DPACKAGE=\"helloauto\" -DVERSION=\"1.0\" -I. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc -g -O2 -o helloauto main.o
xuqiang@ubuntu:~/automake/helloworld$ ls
aclocal.m4 config.log configure.in INSTALL Makefile
autom4te.cache config.status COPYING main.c Makefile.am
autoscan.log configure helloauto main.o Makefile.in
xuqiang@ubuntu:~/automake/helloworld$ ./helloauto
hello linux world !xuqiang@ubuntu:~/automake/helloworld$
通过使用这些工具,只要编写简单的几个文件就能生成Makefile,编译源代码。
转载来至:
http://www.cnblogs.com/xuqiang/archive/2011/05/08/2040316.html
0 0
- linux 如何制作:./configure; make; make install
- linux configure make make install
- linux configure,make,make install
- ./configure make make install
- ./configure && make && make install
- configure/make/make install
- make install / make / configure
- configure; make; make install
- configure ,make ,make install
- ./configure,make,make install
- configure && make && make install
- ./configure && make && make install
- ./configure,make,make install
- ./configure,make,make install
- configure-make-make install
- configure,make.make install
- linux configure make make install 相关了解
- Linux中的./configure,make,make install解析
- __weak typeof(self) weakSelf=self; __strong typeof(weakSelf) strongSelf = weakSelf;
- Git笔记
- java.lang.UnsatisfiedLinkError解决方法汇集(转载)
- Java字符串利用正则除去中文快捷方法
- Material Design入门(三)
- linux 如何制作:./configure; make; make install
- opencv imwrite()函数 崩溃 失败
- 转载----支持向量机通俗导论(理解SVM的三层境界)
- Linux 应用编程
- /bin/thttpd: can't load library 'libcrypt.so.0问题解决
- Spring - 控制反转IOC
- C++:‘std::ostream& String::operator<<(std::ostream&, const String&)’ must take exactly one argument
- c3p0源码解析 三 (WrapperConnectionPoolDataSource类)
- 待办模板库拷贝