在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 自動生成 Makefile 的全過程詳解

            自動生成 Makefile 的全過程詳解

            作者: 時間:2016-10-10 來源:網(wǎng)絡(luò) 收藏

            4 、新建Makefile.am

            新建Makefile.am 文件,命令:

            $ vi Makefile.am

            內(nèi)容如下:

            AUTOMAKE_OPTIONS=foreign

            bin_PROGRAMS=helloworld

            helloworld_SOURCES=helloworld.c

            automake 會根據(jù)你寫的Makefile.am 來自動生成Makefile.in 。

            Makefile.am 中定義的宏和目標(biāo), 會指導(dǎo)automake 生成指定的代碼。例如,宏bin_PROGRAMS 將導(dǎo)致編譯和連接的目標(biāo)被生成。

            5 、運行automake

            命令:

            $ automake --add-missing

            configure.in: installing `./install-sh'

            configure.in: installing `./mkinstalldirs'

            configure.in: installing `./missing'

            Makefile.am: installing `./depcomp'

            automake 會根據(jù)Makefile.am 文件產(chǎn)生一些文件,包含最重要的Makefile.in 。

            6 、執(zhí)行configure 生成Makefile

            $ ./configure

            checking for a BSD-compatible install... /usr/bin/install -c

            checking whether build environment is sane... yes

            checking for gawk... gawk

            checking whether make sets $(MAKE)... yes

            checking for gcc... gcc

            checking for C compiler default output... 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 ANSI C... 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

            $ ls -l Makefile

            -rw-rw-r-- 1 yutao yutao 15035 Oct 15 10:40 Makefile

            你可以看到,此時Makefile 已經(jīng)產(chǎn)生出來了。

            7 、使用Makefile 編譯代碼

            $ make

            if gcc -DPACKAGE_NAME= -DPACKAGE_TARNAME= -DPACKAGE_VERSION= -

            DPACKAGE_STRING= -DPACKAGE_BUGREPORT= -DPACKAGE=helloworld -DVERSION=1.0

            -I. -I. -g -O2 -MT helloworld.o -MD -MP -MF .deps/helloworld.Tpo

            -c -o helloworld.o `test -f 'helloworld.c' || echo './'`helloworld.c;

            then mv -f .deps/helloworld.Tpo .deps/helloworld.Po;

            else rm -f .deps/helloworld.Tpo; exit 1;

            fi

            gcc -g -O2 -o helloworld helloworld.o

            運行helloworld

            $ ./helloworld

            Hello, Linux World!

            這樣helloworld 就編譯出來了,你如果按上面的步驟來做的話,應(yīng)該也會很容易地編譯出正確的helloworld 文件。你還可以試著使用一些其 他的make 命令,如make clean ,make install ,make dist ,看看它們會給你什么樣的效果。感覺如何?自己也能寫出這么專業(yè)的Makefile ,老板一定會對你刮目相看。

            四、深入淺出

            針對上面提到的各個命令,我們再做些詳細(xì)的介紹。

            1 、 autoscan

            autoscan 是用來掃描源代碼目錄生成configure.scan 文件的。autoscan 可以用目錄名做為參數(shù),但如果你不使用參數(shù)的話,那么 autoscan 將認(rèn)為使用的是當(dāng)前目錄。autoscan 將掃描你所指定目錄中的源文件,并創(chuàng)建configure.scan 文件。

            2 、 configure.scan

            configure.scan 包含了系統(tǒng)配置的基本選項,里面都是一些宏定義。我們需要將它改名為configure.in

            3 、 aclocal

            aclocal 是一個perl 腳本程序。aclocal 根據(jù)configure.in 文件的內(nèi)容,自動生成aclocal.m4 文件。aclocal 的定義是:“aclocal - create aclocal.m4 by scanning configure.ac” 。

            4 、 autoconf

            autoconf 是用來產(chǎn)生configure 文件的。configure 是一個腳本,它能設(shè)置源程序來適應(yīng)各種不同的操作系統(tǒng)平臺,并且根據(jù)不同的系統(tǒng)來產(chǎn)生合適的Makefile ,從而可以使你的源代碼能在不同的操作系統(tǒng)平臺上被編譯出來。

            configure.in 文件的內(nèi)容是一些宏,這些宏經(jīng)過autoconf 處理后會變成檢查系統(tǒng)特性、環(huán)境變量、軟件必須的參數(shù)的shell 腳本。configure.in 文件中的宏的順序并沒有規(guī)定,但是你必須在所有宏的最前 面和最后面分別加上AC_INIT 宏和AC_OUTPUT 宏。

            在configure.ini 中:

            # 號表示注釋,這個宏后面的內(nèi)容將被忽略。

            AC_INIT(FILE)

            這個宏用來檢查源代碼所在的路徑。

            AM_INIT_AUTOMAKE(PACKAGE, VERSION)

            這個宏是必須的,它描述了我們將要生成的軟件包的名字及其版本號:PACKAGE 是軟件包的名字,VERSION 是版本號。當(dāng)你使用make dist 命令時,它會給你生成一個類似helloworld-1.0.tar.gz 的軟件發(fā)行包,其中就有對應(yīng)的軟件包的名字和版本號。

            AC_PROG_CC

            這個宏將檢查系統(tǒng)所用的C 編譯器。

            AC_OUTPUT(FILE)

            這個宏是我們要輸出的Makefile 的名字。

            我們在使用automake 時,實際上還需要用到其他的一些宏,但我們可以用aclocal 來幫我們自動產(chǎn)生。執(zhí)行aclocal后我們會得到aclocal.m4 文件。

            產(chǎn)生了configure.in 和aclocal.m4 兩個宏文件后,我們就可以使用autoconf 來產(chǎn)生configure 文件了。

            5 、 Makefile.am

            Makefile.am 是用來生成Makefile.in 的,需要你手工書寫。Makefile.am 中定義了一些內(nèi)容:

            AUTOMAKE_OPTIONS

            這個是automake 的選項。在執(zhí)行automake 時,它會檢查目錄下是否存在標(biāo)準(zhǔn)GNU 軟件包中應(yīng)具備的各種文件,例如AUTHORS 、ChangeLog 、NEWS 等文件。我們將其設(shè)置成foreign 時,automake 會改用一般軟件包的標(biāo)準(zhǔn)來檢查。



            關(guān)鍵詞: linux

            評論


            相關(guān)推薦

            技術(shù)專區(qū)

            關(guān)閉