目录

流程

一.安装包tar.gz的生成

准备源文件

autoscan

生成configure.scan

aclocal

autoconf

autoheader

Makefile.am

automake

./configure

make dist \ make distclean

生成tar.gz安装包

二.安装测试

解压tar.gz

./configure

make

make install

运行

三.整体过程回顾

四.后续

本文全部代码、资源地址:


流程

一.安装包tar.gz的生成

准备源文件

首先准备好源文件(夹),如下(一下文件可见https://blog.csdn.net/Rong_Toa/article/details/82716420):

$ tree 2048-c/
2048-c/
├── 2048.c
├── 2048.h
└── main.c0 directories, 3 files

autoscan

生成configure.scan

然后进入文件夹,执行autoscan生成configure.scan文件

$ cd 2048-c/
$ ls
2048.c*  2048.h*  main.c*
$ autoscan
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/\${ <-- HERE [^\}]*}/ at /usr/bin/autoscan-2.69 line 361.
$ ls
2048.c*  2048.h*  autoscan-2.69.log  configure.scan  main.c*

将configure.scan文件更名为configure.ac,并进行编辑:

$ mv configure.scan configure.ac
$ vim configure.ac

修改第5行,添加第6行,第9行选填,并保存:

  1 #                                               -*- Autoconf -*-2 # Process this file with autoconf to produce a configure script.34 AC_PREREQ([2.69])5 AC_INIT(2048, 1.0, rongtoa@163.com)6 AM_INIT_AUTOMAKE(2048, 1.0)7 AC_CONFIG_SRCDIR([2048.c])8 AC_CONFIG_HEADERS([config.h])9 AC_CONFIG_FILES([Makefile])10 # Checks for programs.11 AC_PROG_CC1213 # Checks for libraries.1415 # Checks for header files.16 AC_CHECK_HEADERS([stdlib.h string.h termios.h unistd.h])1718 # Checks for typedefs, structures, and compiler characteristics.1920 # Checks for library functions.2122 AC_OUTPUT
~
:wq

aclocal

执行aclocal命令:

$ ls
2048.c*  2048.h*  autoscan-2.69.log  configure.ac  main.c*
$ aclocal
$ ls
2048.c*  aclocal.m4       autoscan-2.69.log  main.c*
2048.h*  autom4te.cache/  configure.ac

autoconf

执行autoconf指令:

$ autoconf
$ ls
2048.c*  aclocal.m4       autoscan-2.69.log  configure.ac
2048.h*  autom4te.cache/  configure*         main.c*

autoheader

执行autoheader命令:

$ autoheader
$ ls
2048.c*  aclocal.m4       autoscan-2.69.log  configure*    main.c*
2048.h*  autom4te.cache/  config.h.in        configure.ac

Makefile.am

接下来创建文件Makefile.am

内容如下(忽略行号):

$ vim Makefile.am1 AUTOMAKE_OPTIONS=foreign2 bin_PROGRAMS=20483 2048_SOURCES=2048.c 2048.h main.c
~
~
~
:wq

automake

然后automake

$ automake --add-missing
configure.ac:6: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
configure.ac:6: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation$ ls
2048.c*     autom4te.cache/    config.log      install-sh@  Makefile.in
2048.exe*   autoscan-2.69.log  config.status*  main.c*      missing@
2048.h*     compile@           configure*      main.o       stamp-h1
2048.o      config.h           configure.ac    Makefile
aclocal.m4  config.h.in        depcomp@        Makefile.am

./configure

接下来进行./configure操作生成Makefile文件,具体命令行此处不作讲解:

$ ./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... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
...$

然后make编译、make distclean删除安装包的无关项,make dist生成安装的压缩包tar.gz:

make dist \ make distclean

$ make dist
make  dist-gzip am__post_remove_distdir='@:'
make[1]: 进入目录“/home/rongtao/2048-c”
if test -d "2048-1.0"; then find "2048-1.0" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "2048-1.0" || { sleep 5 && rm -rf "2048-1.0"; }; else :; fi
test -d "2048-1.0" || mkdir "2048-1.0"
test -n "" \
|| find "2048-1.0" -type d ! -perm -755 \-exec chmod u+rwx,go+rx {} \; -o \! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \! -type d ! -perm -400 -exec chmod a+r {} \; -o \! -type d ! -perm -444 -exec /bin/sh /home/rongtao/2048-c/install-sh -c -m a+r {} {} \; \
|| chmod -R a+r "2048-1.0"
tardir=2048-1.0 && ${TAR-tar} chof - "$tardir" | eval GZIP= gzip --best -c >2048-1.0.tar.gz
make[1]: 离开目录“/home/rongtao/2048-c”
if test -d "2048-1.0"; then find "2048-1.0" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "2048-1.0" || { sleep 5 && rm -rf "2048-1.0"; }; else :; fi
$ make distclean
test -z "2048.exe" || rm -f 2048.exe
rm -f *.o
rm -f *.tab.c
test -z "" || rm -f
test . = "." || test -z "" || rm -f
rm -f config.h stamp-h1
rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
rm -f cscope.out cscope.in.out cscope.po.out cscope.files
rm -f config.status config.cache config.log configure.lineno config.status.lineno
rm -rf ./.deps
rm -f Makefile

生成tar.gz安装包

生成了一个:

$ ls -l
-rw-r--r--  1 rongtao None  82991 10月 20 09:03 2048-1.0.tar.gz

二.安装测试

对生成的tar.gz进行安装

将2018-1.0.tar.gz拷贝至“下载”目录,假装他是下载得到的:

$ pwd
/home/rongtao/下载
$ ls
2048-1.0.tar.gz

解压tar.gz

$ tar -xzvf 2048-1.0.tar.gz
2048-1.0/
2048-1.0/2048.c
2048-1.0/2048.h
2048-1.0/aclocal.m4
2048-1.0/compile
2048-1.0/config.h.in
2048-1.0/configure
2048-1.0/configure.ac
2048-1.0/depcomp
2048-1.0/install-sh
2048-1.0/main.c
2048-1.0/Makefile.am
2048-1.0/Makefile.in
2048-1.0/missing$ ls
2048-1.0/  2048-1.0.tar.gz

./configure

进入文件夹进行configure

$ cd 2048-1.0$ ls
2048.c*     compile*     configure.ac  main.c*      missing*
2048.h*     config.h.in  depcomp*      Makefile.am
aclocal.m4  configure*   install-sh*   Makefile.in$ ./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... /usr/bin/mkdir -p
checking for gawk... gawk
...$ 

make

进行编译make:

$ make
make  all-am
make[1]: 进入目录“/home/rongtao/下载/2048-1.0”
gcc -DHAVE_CONFIG_H -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 -DHAVE_CONFIG_H -I.     -g -O2 -MT 2048.o -MD -MP -MF .deps/2048.Tpo -c -o 2048.o 2048.c
mv -f .deps/2048.Tpo .deps/2048.Po
gcc  -g -O2   -o 2048.exe main.o 2048.o
make[1]: 离开目录“/home/rongtao/下载/2048-1.0”

make install

进行安装make install

$ make install
make[1]: 进入目录“/home/rongtao/下载/2048-1.0”/usr/bin/mkdir -p '/usr/local/bin'/usr/bin/install -c 2048.exe '/usr/local/bin'
make[1]: 对“install-data-am”无需做任何事。
make[1]: 离开目录“/home/rongtao/下载/2048-1.0”

运行

检查是否安装,在终端输入20,然后按Tab直接跳出可执行文件,是不是很nice:

$ 2048.exe

三.整体过程回顾

$ cd 2048-c/
$ ls
2048.c*  2048.h*  main.c*$ ls
2048.c*  2048.h*  main.c*$ autoscan
输出略...$ ls
2048.c*  2048.h*  autoscan-2.69.log  configure.scan  main.c*$ mv configure.scan configure.ac$ ls
2048.c*  2048.h*  autoscan-2.69.log  configure.ac  main.c*$ vim configure.ac
configure.ac 内容如下:1 #                                               -*- Autoconf -*-2 # Process this file with autoconf to produce a configure script.34 AC_PREREQ([2.69])5 AC_INIT(2048, 1.0.0, rongtoa@163.com)6 AM_INIT_AUTOMAKE(2048, 1.0.0)7 AC_CONFIG_SRCDIR([2048.c])8 AC_CONFIG_HEADERS([config.h])9 AC_CONFIG_FILES([Makefile])1011 # Checks for programs.12 AC_PROG_CC1314 # Checks for libraries.1516 # Checks for header files.17 AC_CHECK_HEADERS([stdlib.h string.h termios.h unistd.h])1819 # Checks for typedefs, structures, and compiler characteristics.2021 # Checks for library functions.2223 AC_OUTPUT
:wq$ vim Makefile.am
Makefile.am 内容如下:1 AUTOMAKE_OPTIONS=foreign2 bin_PROGRAMS=20483 2048_SOURCES=main.c 2048.c 2048.h
~
~
:wq$ aclocal$ autoconf$ autoheader$ automake --add-missing
configure.ac:6: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
configure.ac:6: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.ac:12: installing './compile'
configure.ac:6: installing './install-sh'
configure.ac:6: installing './missing'
Makefile.am: installing './depcomp'$ ./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... /usr/bin/mkdir -p
checking for gawk... gawk
略去部分中间输出...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands$ make
make  all-am
make[1]: 进入目录“/home/rongtao/2048-c”
gcc -DHAVE_CONFIG_H -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 -DHAVE_CONFIG_H -I.     -g -O2 -MT 2048.o -MD -MP -MF .deps/2048.Tpo -c -o 2048.o 2048.c
mv -f .deps/2048.Tpo .deps/2048.Po
gcc  -g -O2   -o 2048.exe main.o 2048.o
make[1]: 离开目录“/home/rongtao/2048-c”$ make dist
make  dist-gzip am__post_remove_distdir='@:'
make[1]: 进入目录“/home/rongtao/2048-c”
if test -d "2048-1.0.0"; then find "2048-1.0.0" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "2048-1.0.0" || { sleep 5 && rm -rf "2048-1.0.0"; }; else :; fi
test -d "2048-1.0.0" || mkdir "2048-1.0.0"
test -n "" \
|| find "2048-1.0.0" -type d ! -perm -755 \-exec chmod u+rwx,go+rx {} \; -o \! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \! -type d ! -perm -400 -exec chmod a+r {} \; -o \! -type d ! -perm -444 -exec /bin/sh /home/rongtao/2048-c/install-sh -c -m a+r {} {} \; \
|| chmod -R a+r "2048-1.0.0"
tardir=2048-1.0.0 && ${TAR-tar} chof - "$tardir" | eval GZIP= gzip --best -c >2048-1.0.0.tar.gz
make[1]: 离开目录“/home/rongtao/2048-c”
if test -d "2048-1.0.0"; then find "2048-1.0.0" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "2048-1.0.0" || { sleep 5 && rm -rf "2048-1.0.0"; }; else :; fi$ make clean
test -z "2048.exe" || rm -f 2048.exe
rm -f *.o$ make distclean
test -z "2048.exe" || rm -f 2048.exe
rm -f *.o
rm -f *.tab.c
test -z "" || rm -f
test . = "." || test -z "" || rm -f
rm -f config.h stamp-h1
rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
rm -f cscope.out cscope.in.out cscope.po.out cscope.files
rm -f config.status config.cache config.log configure.lineno config.status.lineno
rm -rf ./.deps
rm -f Makefile$ ls
2048.c*            autom4te.cache/    configure*    main.c*
2048.h*            autoscan-2.69.log  configure.ac  Makefile.am
2048-1.0.0.tar.gz  compile@           depcomp@      Makefile.in
aclocal.m4         config.h.in        install-sh@   missing@$ tar -xzvf 2048-1.0.0.tar.gz
2048-1.0.0/
2048-1.0.0/2048.c
2048-1.0.0/2048.h
2048-1.0.0/aclocal.m4
2048-1.0.0/compile
2048-1.0.0/config.h.in
2048-1.0.0/configure
2048-1.0.0/configure.ac
2048-1.0.0/depcomp
2048-1.0.0/install-sh
2048-1.0.0/main.c
2048-1.0.0/Makefile.am
2048-1.0.0/Makefile.in
2048-1.0.0/missing$ cd 2048-1.0.0$ ./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... /usr/bin/mkdir -p
checking for gawk... gawk
省略中间输出...
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands$ make
make  all-am
make[1]: 进入目录“/home/rongtao/2048-c/2048-1.0.0”
gcc -DHAVE_CONFIG_H -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 -DHAVE_CONFIG_H -I.     -g -O2 -MT 2048.o -MD -MP -MF .deps/2048.Tpo -c -o 2048.o 2048.c
mv -f .deps/2048.Tpo .deps/2048.Po
gcc  -g -O2   -o 2048.exe main.o 2048.o
make[1]: 离开目录“/home/rongtao/2048-c/2048-1.0.0”$ make install
make[1]: 进入目录“/home/rongtao/2048-c/2048-1.0.0”/usr/bin/mkdir -p '/usr/local/bin'/usr/bin/install -c 2048.exe '/usr/local/bin'
make[1]: 对“install-data-am”无需做任何事。
make[1]: 离开目录“/home/rongtao/2048-c/2048-1.0.0”

四.后续

到此结束,以后会继续更新对一个项目的configure操作,敬请期待,我也很期待。。。

本文全部代码、资源地址:

https://download.csdn.net/download/rong_toa/10733319

【configure】如何用automake、autoconf指令生成configure并创建自己的linux tar.gz安装包【初级篇:简单建立-测试】相关推荐

  1. Linux - 如何生成configure文件

    Linux - 如何生成configure文件 简介 本文简单地介绍一下如何生成configure文件,主要目的是把握整体的流程,以后如果要用到再仔细阅读对应文档. 整体的过程 在Linux下面手动编 ...

  2. linux下使用automake、autoconf生成configure文件

    一.生成configure过程中各文件之间的关系图 二.详细介绍 autoscan: 扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是con ...

  3. Sphinx/Coreseek 4.1 跑 buildconf.sh 一个错误,无法生成configure档

    安装前 coorseek 什么时候,遇到一些错误.该官方网站无法看到的解决方案,终于 google 在大牛的博客评论区找到一个解决方案.突然跑到他的膝盖介绍~~ 这里整理是为了方便一些人发现,墙毕竟让 ...

  4. AUTOMAKE\AUTOCONF

    Makefile的作用:自动编译和链接 使用Automake和Autoconf工具生成Makefile 生成符合GNU规范的Makefile 可以使用./configure;make;make ins ...

  5. 大型项目使用Automake/Autoconf完成编译配置

    使用过开源C/C++项目的同学们都知道,标准的编译过程已经变成了简单的三部曲:configure/make/make install, 使用起来很方便,不像平时自己写代码,要手写一堆复杂的Makefi ...

  6. automake,autoconf使用详解

    Home PHP源码分析 PHP应用 JS/CSS 随笔 留言 博客声明 风雪之隅 PHP语言, PHP扩展, Zend引擎相关的研究,技术,新闻分享 – 左手代码 右手诗 18 Nov 09 aut ...

  7. 我的世界4个实用指令生成网站:自定义物品/名称,自定义药水,自定义实体,数据包编写

    1.https://www.gamergeeks.net/apps/minecraft/give-command-generator [点击进入] 这个网站可以制作自定义物品,还可以切换版本,自定义物 ...

  8. 如何用excel表格批量生成文件夹,并命名?

    如何用excel表格批量生成文件夹,并命名?假设一个excel表格里面整理了500个名称,现在需要利用这些名称生成对应名称的文件夹,你会如何处理呢?我想很多人会挨个复制名称然后再新建文件名,再对文件夹 ...

  9. 如何用通过Unity 3D生成真实地形

    如何用通过Unity 3D生成真实地形 发布时间:2018-06-27 版权: 相关教程: 1.建筑物轮廓三维立体图生成 其他三维制作视频教程:Bigemap视频教程-支持200多种格式互转kml\s ...

最新文章

  1. bzoj1691 [Usaco2007 Dec]挑剔的美食家
  2. java jtextfield设置不可见_java – JPanel设置为不可见,除默认值之外的组合框选择将其设置为可见,但组件丢失...
  3. php lmpl,tjx-cold: 用于根据配置模板,快速生成controller,service,serviceimpl 代码
  4. linux系统时间修改及同步
  5. SAP UI5故障排查 - why I cannot get my select control via byId
  6. 方形物体绕中心旋转的扭力_三维旋转
  7. 谷歌为何会选用TypeScript?
  8. java blockqueue_[Java基础] Java多线程-工具篇-BlockingQueue
  9. Web应用工作原理、动态网页技术
  10. 分享:从功能增强说起
  11. JSONObject put,accumulate,element的区别
  12. oracle中的函数
  13. python编写个人信息_Python爬取个人微信朋友信息操作示例
  14. Matlab中的magic函数、vander函数、hilb函数、compan函数、pascal函数、zeros函数、ones函数、eye函数、rand函数、randn函数
  15. Android开发工程师已难找工作
  16. 【游戏】金融帝国2:金融帝国实验室(Capitalism Lab)3.0.19安装包下载
  17. 上海市住房公积金销户提取的步骤
  18. 网站建设之需要改进的地方
  19. 【SpringBoot】 日志框架冲突
  20. linux系统盘锁着,用Linux启动盘解决硬盘逻辑锁

热门文章

  1. NumberUtils的 isParsable(String)和isCreatable(String)方法
  2. phpstorm设置方法头信息备注
  3. Java标识符和关键字(static,final,abstract,interface)
  4. 关于代码控制管理的一些想法
  5. T-SQL 视图 事物 备份还原 分离附加
  6. sql 批量插入数据到Sqlserver中 效率较高的方法
  7. 我眼中BA(业务需求分析师)的技能广度和深度
  8. C++编译器与链接器工作原理
  9. SDUT 1291数据结构上机测试4.1:二叉树的遍历与应用1
  10. css 30 常用选择选择器