【configure】如何用automake、autoconf指令生成configure並建立自己的linux tar.gz安裝包【初級篇:簡單建立-測試】
目錄
流程
一.安裝包tar.gz的生成
準備原始檔
首先準備好原始檔(夾),如下(一下檔案可見https://blog.csdn.net/Rong_Toa/article/details/82716420):
$ tree 2048-c/
2048-c/
├── 2048.c
├── 2048.h
└── main.c
0 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.
3
4 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_CC
12
13 # Checks for libraries.
14
15 # Checks for header files.
16 AC_CHECK_HEADERS([stdlib.h string.h termios.h unistd.h])
17
18 # Checks for typedefs, structures, and compiler characteristics.
19
20 # Checks for library functions.
21
22 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.am
1 AUTOMAKE_OPTIONS=foreign
2 bin_PROGRAMS=2048
3 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.
3
4 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])
10
11 # Checks for programs.
12 AC_PROG_CC
13
14 # Checks for libraries.
15
16 # Checks for header files.
17 AC_CHECK_HEADERS([stdlib.h string.h termios.h unistd.h])
18
19 # Checks for typedefs, structures, and compiler characteristics.
20
21 # Checks for library functions.
22
23 AC_OUTPUT
:wq
$ vim Makefile.am
Makefile.am 內容如下:
1 AUTOMAKE_OPTIONS=foreign
2 bin_PROGRAMS=2048
3 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操作,敬請期待,我也很期待。。。
本文全部程式碼、資源地址:
相關文章
- Linux下autoconf與automakeLinux
- rman configure exclude測試!
- linux下expect環境安裝以及簡單指令碼測試Linux指令碼
- 用jsmooth + inno生成exe並製作簡單安裝包JS
- 第三週作業(一):安裝VS以及建立單元測試
- 如何用Python建立自己的Dino Run?Python
- 升級openssh前安裝zlib報異常configure aborting
- PHP編譯安裝之Configure引數PHP編譯
- 安裝配置xorg [Install and configure xorg](轉)
- 如何用python建立最簡單的伺服器Python伺服器
- Myeclipse建立單元測試Eclipse
- 建立一個簡單的初級SpringMVC專案(非註解版)SpringMVC
- configure ssh service in linux :Linux
- configure vnc server in linuxVNCServerLinux
- 在Ubuntu上建立並測試GRE tunnelUbuntu
- InnoSetup簡單教程一,安裝使用和簡單測試
- 建立併發布自己的nuget包
- 安裝10g rac,關於asm configureASM
- 如何用TypeScript來建立一個簡單的Web應用TypeScriptWeb
- 如何建立自己的Spring Boot Starter併為其編寫單元測試Spring Boot
- Linux下解除安裝MySQL二進位制包(tar.gz)LinuxMySql
- Oracle Linux 7 Configure DNSOracleLinuxDNS
- Flutter應用Windows安裝包建立教程FlutterWindows
- ORACLE EBS 安裝後的簡單基本測試方法Oracle
- vs下建立並呼叫DLL--簡單例子單例
- 使用Dockerfile建立一個tomcat映象,並執行一個簡單war包DockerTomcat
- Linux的OOMkiller簡單測試LinuxOOM
- rman configure
- linux下安裝安裝pcre-8.32 configure: error: You need a C++ compiler for C++ supportLinuxErrorC++Compile
- 安裝cTex並建立第一個tex程式
- Linux NTP configure and Hangcheck-timeLinuxGC
- Configure the DNS Server for SCAN VIP on LinuxDNSServerLinux
- pmcyg 1.0 釋出,Cygwin 安裝包建立工具
- 簡單資料庫及表建立shell指令碼資料庫指令碼
- 最簡單的物件建立物件
- PHP回顧之建立自己的Composer包PHP
- eclipse建立自己的Library存放jar包EclipseJAR
- autotools —— autoconf和automake生成Makefile檔案(原始檔位於多個子資料夾)