青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 8, comments - 12, trackbacks - 0, articles - 0
  C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

makefile自動(dòng)生成(轉(zhuǎn))

Posted on 2008-07-09 18:07 eyesmart 閱讀(1069) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Basic Knowledge
為了編譯一個(gè)簡(jiǎn)單的源文件main.c,需要自動(dòng)生成一個(gè)makefile,以下是步驟:

第一步:
----------
在/root/project/main目錄下創(chuàng)建一個(gè)文件main.c,其內(nèi)容如下:
------------------------------------------------
#include <stdio.h>
int main(int argc, char** argv)
{
    printf("Hello, Auto Makefile!\n");
    return 0;
}
------------------------------------------------

此時(shí)狀態(tài)如下:
[root@localhost main]# pwd
/root/project/main
[root@localhost main]# ls
main.c
[root@localhost main]#

第二步:
----------
運(yùn)行 autoscan , 自動(dòng)創(chuàng)建兩個(gè)文件: autoscan.log  configure.scan

此時(shí)狀態(tài)如下:
[root@localhost main]# autoscan
[root@localhost main]# ls
autoscan.log  configure.scan  main.c
[root@localhost main]#

第三步:
----------
修改configure.scan的文件名為configure.in

查看configure.in的內(nèi)容:
------------------------------------------------
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADER([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.

AC_OUTPUT
------------------------------------------------

解讀以上的文件:

------------------------------------------------
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

# AC_PREREQ:
# 確保使用的是足夠新的Autoconf版本。如果用于創(chuàng)建configure的Autoconf的版
# 本比version 要早,就在標(biāo)準(zhǔn)錯(cuò)誤輸出打印一條錯(cuò)誤消息并不會(huì)創(chuàng)建configure。
AC_PREREQ(2.61)

#
# 初始化,定義軟件的基本信息,包括設(shè)置包的全稱,版本號(hào)以及報(bào)告BUG時(shí)需要用的郵箱地址
#
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)

#
# 用來(lái)偵測(cè)所指定的源碼文件是否存在,來(lái)確定源碼目錄的有效性
#
AC_CONFIG_SRCDIR([main.c])

#
# 用于生成config.h文件,以便autoheader使用
#
AC_CONFIG_HEADER([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.

#
# 創(chuàng)建輸出文件。在`configure.in'的末尾調(diào)用本宏一次。
#
AC_OUTPUT
------------------------------------------------

修改動(dòng)作:
    1.修改AC_INIT里面的參數(shù): AC_INIT(main,1.0, pgpxc@163.com)
    2.添加宏AM_INIT_AUTOMAKE, 它是automake所必備的宏,也同前面一樣,PACKAGE是所要產(chǎn)生軟件套件的名稱,VERSION是版本編號(hào)。
    3.在AC_OUTPUT后添加輸出文件Makefile


修改后的結(jié)果:
------------------------------------------------
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(main, 1.0, pgpxc@163.com)
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE(main,1.0)

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT([Makefile])
------------------------------------------------

第四步:
運(yùn)行 aclocal, 生成一個(gè)“aclocal.m4”文件和一個(gè)緩沖文件夾autom4te.cache,該文件主要處理本地的宏定義。

此時(shí)的狀態(tài)是:
[root@localhost main]# aclocal
[root@localhost main]# ls
aclocal.m4  autom4te.cache  autoscan.log  configure.in  configure.in~  main.c
[root@localhost main]#


第五步:
運(yùn)行 autoconf, 目的是生成 configure

此時(shí)的狀態(tài)是:
[root@localhost main]# autoconf
[root@localhost main]# ls
aclocal.m4      autoscan.log  configure.in   main.c
autom4te.cache  configure     configure.in~
[root@localhost main]#

第六步:
運(yùn)行 autoheader,它負(fù)責(zé)生成config.h.in文件。該工具通常會(huì)從“acconfig.h”文件中復(fù)制用戶附加的符號(hào)定義,因此此處沒(méi)有附加符號(hào)定義,所以不需要?jiǎng)?chuàng)建“acconfig.h”文件。

此時(shí)的狀態(tài)是:
[root@localhost main]# autoheader
[root@localhost main]# ls
aclocal.m4      autoscan.log  configure     configure.in~
autom4te.cache  config.h.in   configure.in  main.c
[root@localhost main]#

第七步:
下面即將運(yùn)行 automake, 但在此之前應(yīng)該做一下準(zhǔn)備工作!

首先
創(chuàng)建一個(gè) Makefile.am.這一步是創(chuàng)建Makefile很重要的一步,automake要用的腳本配置文件是Makefile.am,用戶需要自己創(chuàng)建相應(yīng)的文件。之后,automake工具轉(zhuǎn)換成Makefile.in。

這個(gè)Makefile.am的內(nèi)容如下:
------------------------------------------------
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main
main_SOURCES=main.c
------------------------------------------------

下面對(duì)該腳本文件的對(duì)應(yīng)項(xiàng)進(jìn)行解釋。
    其中的AUTOMAKE_OPTIONS為設(shè)置automake的選項(xiàng)。由于GNU(在第1章中已經(jīng)有所介紹)對(duì)自己發(fā)布的軟件有嚴(yán)格的規(guī)范,比如必須附帶許可證聲明文件COPYING等,否則automake執(zhí)行時(shí)會(huì)報(bào)錯(cuò)。automake提供了三種軟件等級(jí):foreign、gnu和gnits,讓用戶選擇采用,默認(rèn)等級(jí)為gnu。在本例使用foreign等級(jí),它只檢測(cè)必須的文件。
    bin_PROGRAMS定義要產(chǎn)生的執(zhí)行文件名。如果要產(chǎn)生多個(gè)執(zhí)行文件,每個(gè)文件名用空格隔開(kāi)。
    main_SOURCES定義“main”這個(gè)執(zhí)行程序所需要的原始文件。如果”main”這個(gè)程序是由多個(gè)原始文件所產(chǎn)生的,則必須把它所用到的所有原始文件都列出來(lái),并用空格隔開(kāi)。例如:若目標(biāo)體“main”需要“main.c”、“sunq.c”、“main.h”三個(gè)依賴文件,則定義main_SOURCES=main.c sunq.c main.h。要注意的是,如果要定義多個(gè)執(zhí)行文件,則對(duì)每個(gè)執(zhí)行程序都要定義相應(yīng)的file_SOURCES。

其次
使用automake對(duì)其生成“configure.in”文件,在這里使用選項(xiàng)“—adding-missing”可以讓automake自動(dòng)添加有一些必需的腳本文件。
運(yùn)行后的狀態(tài)是:
------------------------------------------------
[root@localhost main]# automake --add-missing
configure.in:8: installing `./missing'
configure.in:8: installing `./install-sh'
Makefile.am: installing `./depcomp'
[root@localhost main]# ls
aclocal.m4      config.h.in   configure.in~  main.c        Makefile.in
autom4te.cache  configure     depcomp        Makefile.am   missing
autoscan.log    configure.in  install-sh     Makefile.am~
[root@localhost main]#
------------------------------------------------

第八步
運(yùn)行configure,在這一步中,通過(guò)運(yùn)行自動(dòng)配置設(shè)置文件configure,把Makefile.in變成了最終的Makefile。
運(yùn)行的結(jié)果如下:
------------------------------------------------
[root@localhost main]# ./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... gawk
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: creating config.h
config.status: executing depfiles commands
[root@localhost main]# ls
aclocal.m4      config.h.in    configure.in   main.c        Makefile.in
autom4te.cache  config.log     configure.in~  Makefile      missing
autoscan.log    config.status  depcomp        Makefile.am   stamp-h1
config.h        configure      install-sh     Makefile.am~
[root@localhost main]#
------------------------------------------------

第九步
運(yùn)行 make,對(duì)配置文件Makefile進(jìn)行測(cè)試一下

此時(shí)的狀態(tài)如下:
------------------------------------------------
[root@localhost main]# make
cd . && /bin/sh /root/project/main/missing --run aclocal-1.10
cd . && /bin/sh /root/project/main/missing --run automake-1.10 --foreign
cd . && /bin/sh /root/project/main/missing --run autoconf
/bin/sh ./config.status --recheck
running CONFIG_SHELL=/bin/sh /bin/sh ./configure   --no-create --no-recursion
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... gawk
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
/bin/sh ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
cd . && /bin/sh /root/project/main/missing --run autoheader
rm -f stamp-h1
touch config.h.in
make  all-am
make[1]: Entering directory `/root/project/main'
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  -g -O2   -o main main.o 
cd . && /bin/sh ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
make[1]: Leaving directory `/root/project/main'
[root@localhost main]# ls
aclocal.m4      autoscan.log  config.h.in  config.status  configure.in   depcomp     main    main.o    Makefile.am   Makefile.in  stamp-h1
autom4te.cache  config.h      config.log   configure      configure.in~  install-sh  main.c  Makefile  Makefile.am~  missing
[root@localhost main]#
------------------------------------------------

第十步
運(yùn)行生成的文件 main:
------------------------------------------------
[root@localhost main]# ./main
Hello, Auto Makefile!
[root@localhost main]#
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲人成在线影院| 欧美伊人久久久久久午夜久久久久| 99亚洲一区二区| 亚洲高清毛片| 欧美日韩一区二区三区视频| 亚洲一二三四区| 久久久国产91| 一区二区三区高清视频在线观看| 日韩一级免费观看| 国产亚洲精品aa午夜观看| 久久亚洲精选| 欧美国产日韩二区| 亚欧成人精品| 久久最新视频| 久久久久免费视频| 国产精品久久久久一区| 亚洲激情电影在线| 含羞草久久爱69一区| 亚洲一区3d动漫同人无遮挡| 在线国产日韩| 性视频1819p久久| 亚洲调教视频在线观看| 久久一区二区精品| 久久婷婷国产综合精品青草| 国产精品免费区二区三区观看| 亚洲国产另类久久久精品极度| 国产有码一区二区| 欧美制服第一页| 久久精品夜色噜噜亚洲aⅴ| 久热精品视频| 影音先锋另类| 久久亚洲精选| 亚洲国产电影| 99精品国产一区二区青青牛奶| 免费影视亚洲| 99v久久综合狠狠综合久久| 一区二区三区日韩在线观看| 欧美亚洲第一区| 亚洲男人第一av网站| 久久成人精品视频| 韩国一区二区在线观看| 老司机久久99久久精品播放免费| 久久久一区二区| 91久久精品一区二区三区| 欧美国产高清| 亚洲午夜性刺激影院| 久久精品盗摄| 一区二区欧美激情| 国产一区二区欧美| 欧美日韩1区| 久久高清免费观看| 最新成人av网站| 久久久99国产精品免费| 亚洲人成7777| 国内成人在线| 欧美性开放视频| 久久久夜色精品亚洲| 亚洲美女视频网| 久久综合色婷婷| 亚洲永久精品大片| 日韩午夜激情| 亚洲国产成人精品女人久久久| 欧美视频中文一区二区三区在线观看| 欧美影院成人| 亚洲欧美成人网| 亚洲线精品一区二区三区八戒| 亚洲国产高清aⅴ视频| 久久久亚洲欧洲日产国码αv| 久久久999成人| 亚洲综合视频一区| 亚洲一区影音先锋| 宅男噜噜噜66国产日韩在线观看| 亚洲第一福利在线观看| 欧美华人在线视频| 亚洲韩国精品一区| 亚洲日本中文字幕| 亚洲乱码国产乱码精品精98午夜| 欧美激情成人在线视频| 亚洲电影网站| 一本一本久久a久久精品综合妖精| 亚洲美女视频在线观看| 夜夜夜精品看看| 午夜伦理片一区| 久久成人资源| 麻豆精品传媒视频| 欧美日韩另类字幕中文| 国产精品久久久久久久久久三级| 国产精品久久二区二区| 国产一区二区剧情av在线| 亚洲国产影院| 欧美一级久久久久久久大片| 久久久久久久久久码影片| 亚洲国产二区| 欧美一区二区高清在线观看| 欧美成年人视频网站| 国产精品一区免费视频| 激情综合网址| 午夜精品久久久久久99热软件| 老司机精品视频一区二区三区| 亚洲黄一区二区| 久久狠狠亚洲综合| 国产精品高潮呻吟久久av黑人| 好吊妞这里只有精品| 翔田千里一区二区| 99精品国产99久久久久久福利| 久久www免费人成看片高清| 欧美日韩国产首页| 亚洲精品一二三区| 欧美激情视频网站| 久久久久久黄| 亚洲国产精品v| 性亚洲最疯狂xxxx高清| 欧美亚洲不卡| 一区二区三区四区蜜桃| 亚洲电影免费观看高清完整版在线观看 | 国产一区二区三区精品久久久| 亚洲国产一区二区视频| 久久久久亚洲综合| 亚洲欧美日韩精品| 国产精品久久久爽爽爽麻豆色哟哟| 亚洲国产成人不卡| 亚洲国产精品嫩草影院| 久久亚洲电影| 在线观看日韩av电影| 蜜臀av性久久久久蜜臀aⅴ| 欧美一区亚洲| 亚洲片在线观看| 欧美激情片在线观看| 欧美黄色日本| 在线视频一区二区| 亚洲午夜国产一区99re久久| 国产精品日韩电影| 美女网站久久| 欧美日韩一区二区视频在线观看 | 欧美成人蜜桃| 一本一道久久综合狠狠老精东影业| 亚洲国产日韩欧美| 国产精品热久久久久夜色精品三区| 久久精品国产99国产精品澳门| 你懂的成人av| 欧美一级欧美一级在线播放| 美女网站久久| 欧美影院在线播放| 一区二区三区成人| 久久婷婷蜜乳一本欲蜜臀| 久久婷婷一区| 午夜精品久久久| 欧美大片一区二区三区| 午夜日韩av| 欧美视频一区在线观看| 欧美黄色影院| 亚洲国产精品99久久久久久久久| 日韩午夜视频在线观看| 在线免费观看视频一区| 欧美一区二区免费| 一区二区日韩精品| 欧美日韩三级一区二区| 欧美黄在线观看| 亚洲经典三级| 欧美国产成人精品| 亚洲国产精品女人久久久| 亚洲福利视频一区| 老牛国产精品一区的观看方式| 久久久水蜜桃| 亚洲国产精品一区二区尤物区| 欧美在线观看视频一区二区| 欧美一区二区三区免费观看| 国产麻豆视频精品| 亚洲欧美不卡| 欧美成人精品h版在线观看| 一区在线播放视频| 欧美顶级艳妇交换群宴| 一本一道久久综合狠狠老精东影业 | 亚洲女同同性videoxma| 久久久无码精品亚洲日韩按摩| 亚洲国产一二三| 欧美日韩亚洲一区在线观看| 欧美国产日本在线| 亚洲一区二区欧美日韩| 一区二区亚洲精品国产| 国产精品v欧美精品v日韩| 新片速递亚洲合集欧美合集| 欧美r片在线| 久久国产精品色婷婷| 在线综合亚洲欧美在线视频| 狠狠噜噜久久| 国产色爱av资源综合区| 欧美日韩综合在线免费观看| 一本色道久久99精品综合| 国产亚洲午夜| 欧美视频一区二| 欧美第一黄色网| 另类尿喷潮videofree| 欧美一区二区三区婷婷月色| 亚洲乱码国产乱码精品精可以看| 奶水喷射视频一区| 老司机久久99久久精品播放免费 | 欧美中文字幕视频在线观看| 一区二区三区精品| 一区二区三区福利|