• <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>
            posts - 297,  comments - 15,  trackbacks - 0
              

            1.autoscan (autoconf): 掃描源代碼以搜尋普通的可移植性問題,比如檢查編譯器,庫(kù),頭文件等,生成文件configure.scan,它是configure.ac的一個(gè)雛形。

                your source files --> [autoscan*] --> [configure.scan] --> configure.ac

            2.aclocal (automake):根據(jù)已經(jīng)安裝的宏,用戶定義宏和acinclude.m4文件中的宏將configure.ac文件所需要的宏集中定義到文件 aclocal.m4中。aclocal是一個(gè)perl 腳本程序,它的定義是:“aclocal - create aclocal.m4 by scanning configure.ac”
            user input files   optional input     process          output files
            ================ ============== ======= ============

            acinclude.m4 - - - - -.
            V
            .-------,
            configure.ac ------------------------>|aclocal|
            {user macro files} ->| |------> aclocal.m4
            `-------'
            3.autoheader(autoconf): 根據(jù)configure.ac中的某些宏,比如cpp宏定義,運(yùn)行m4,聲稱config.h.in

            user input files optional input process output files
            ================ ============== ======= ============

            aclocal.m4 - - - - - - - .
            |
            V
            .----------,
            configure.ac ----------------------->|autoheader|----> autoconfig.h.in
            `----------'

            4.automake: automake將Makefile.am中定義的結(jié)構(gòu)建立Makefile.in,然后configure腳本將生成的Makefile.in文件轉(zhuǎn)換 為Makefile。如果在configure.ac中定義了一些特殊的宏,比如AC_PROG_LIBTOOL,它會(huì)調(diào)用libtoolize,否則它 會(huì)自己產(chǎn)生config.guess和config.sub

            user input files   optional input   processes          output files
            ================ ============== ========= ============

            .--------,
            | | - - -> COPYING
            | | - - -> INSTALL
            | |------> install-sh
            | |------> missing
            |automake|------> mkinstalldirs
            configure.ac ----------------------->| |
            Makefile.am ----------------------->| |------> Makefile.in
            | |------> stamp-h.in
            .---+ | - - -> config.guess
            | | | - - -> config.sub
            | `------+-'
            | | - - - -> config.guess
            |libtoolize| - - - -> config.sub
            | |--------> ltmain.sh
            | |--------> ltconfig
            `----------'

            5.autoconf:將configure.ac中的宏展開,生成configure腳本。這個(gè)過(guò)程可能要用到aclocal.m4中定義的宏。

            user input files   optional input   processes          output files
            ================ ============== ========= ============

            aclocal.m4 ,autoconfig.h.in - - - - - - -.
            V
            .--------,
            configure.ac ----------------------->|autoconf|------> configure
             
            6. ./configure的過(guò)程

            .-------------> [config.cache]
            configure* --------------------------+-------------> config.log
            |
            [config.h.in] -. v .--> [autoconfig.h]
            +-------> config.status* -+
            Makefile.in ---' `--> Makefile
             
            7. make過(guò)程
             
            [autoconfig.h] -.
            +--> make* ---> 程序
            Makefile ---'
             
            .---------,
            config.site - - ->| |
            config.cache - - ->|configure| - - -> config.cache
            | +-,
            `-+-------' |
            | |----> config.status
            config.h.in ------->|config- |----> config.h
            Makefile.in ------->| .status|----> Makefile
            | |----> stamp-h
            | +--,
            .-+ | |
            | `------+--' |
            ltmain.sh ------->|ltconfig|-------> libtool
            | | |
            `-+------' |
            |config.guess|
            | config.sub |
            `------------'

            .--------,
            Makefile ------>| |
            config.h ------>| make |
            {project sources} ---------------->| |--------> {project targets}
            .-+ +--,
            | `--------' |
            | libtool |
            | missing |
            | install-sh |
            |mkinstalldirs|
            `-------------'
            實(shí)例
            在/hello/目錄下創(chuàng)建一個(gè)hello.c文件,并編譯運(yùn)行它:

            #cd /hello/

            (1) 編寫源文件hello.c:

            #include<stdio.h> 
            int main(int argc, char** argv)
            {
            printf("Hello, GNU!n");
            return 0;
            }

            [litao@vm0000131 hello]$ ll
            total 4
            -rw-rw-r-- 1 litao litao 68 Aug 12 12:02 hello.c

            一、autoscan

            [litao@vm0000131 hello]$ autoscan
            autom4te: configure.ac: no such file or directory
            autoscan: /usr/bin/autom4te failed with exit status: 1
            [litao@vm0000131 hello]$ ll
            total 8
            -rw-rw-r-- 1 litao litao   0 Aug 12 12:03 autoscan.log
            -rw-rw-r-- 1 litao litao 457 Aug 12 12:03 configure.scan
            -rw-rw-r-- 1 litao litao  68 Aug 12 12:02 hello.c

            已經(jīng)生成了configure.scan,autoscan.log文件

            將configure.scan 修改為 configure.in,最后修改的內(nèi)容如下:

            [litao@vm0000131 hello]$ mv configure.scan configure.in    
            [litao@vm0000131 hello]$ vim configure.in 

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

            AC_PREREQ(2.59)
            AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
            AC_CONFIG_SRCDIR([hello.c])
            #AC_CONFIG_HEADER([config.h])
            AM_INIT_AUTOMAKE(hello, 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)

            二、acloacl

            [litao@vm0000131 hello]$ aclocal 

            生成 aclocal.m4 和 autom4te.cache (生成aclocal.m4的過(guò)程中涉及到configure.in)

            [litao@vm0000131 hello]$ ll
            total 44
            -rw-rw-r-- 1 litao litao 31120 Aug 12 12:08 aclocal.m4
            drwxr-xr-x 2 litao litao  4096 Aug 12 12:08 autom4te.cache
            -rw-rw-r-- 1 litao litao     0 Aug 12 12:03 autoscan.log
            -rw-rw-r-- 1 litao litao   496 Aug 12 12:08 configure.in
            -rw-rw-r-- 1 litao litao    68 Aug 12 12:02 hello.c

            三、antoconf

            [litao@vm0000131 hello]$ autoconf
            生成 configure (根據(jù) configure.in, 和 aclocal.m4)

            [litao@vm0000131 hello]$ ll
            total 168
            -rw-rw-r-- 1 litao litao  31120 Aug 12 12:08 aclocal.m4
            drwxr-xr-x 2 litao litao   4096 Aug 12 12:11 autom4te.cache
            -rw-rw-r-- 1 litao litao      0 Aug 12 12:03 autoscan.log
            -rwxrwxr-x 1 litao litao 122297 Aug 12 12:11 configure
            -rw-rw-r-- 1 litao litao    496 Aug 12 12:08 configure.in
            -rw-rw-r-- 1 litao litao     68 Aug 12 12:02 hello.c

            四、編寫Makefile.am:

            AUTOMAKE_OPTIONS= foreign
            bin_PROGRAMS= hello
            hello_SOURCES= hello.c

            五、automake

            生成 Makefile.in, depcomp, install-sh, 和 missing (根據(jù) Makefile.am, 和 aclocal.m4)

            [litao@vm0000131 hello]$ automake
            configure.in: required file `./install-sh' not found
            configure.in: required file `./missing' not found
            Makefile.am: required file `./depcomp' not found
            [litao@vm0000131 hello]$ automake --add-missing
            configure.in: installing `./install-sh'
            configure.in: installing `./missing'
            Makefile.am: installing `./depcomp'
            [litao@vm0000131 hello]$ ll
            total 192
            -rw-rw-r-- 1 litao litao  31120 Aug 12 12:08 aclocal.m4
            drwxr-xr-x 2 litao litao   4096 Aug 12 12:14 autom4te.cache
            -rw-rw-r-- 1 litao litao      0 Aug 12 12:03 autoscan.log
            -rwxrwxr-x 1 litao litao 122297 Aug 12 12:11 configure
            -rw-rw-r-- 1 litao litao    496 Aug 12 12:08 configure.in
            lrwxrwxrwx 1 litao litao     31 Aug 12 12:16 depcomp -> /usr/share/automake-1.9/depcomp
            -rw-rw-r-- 1 litao litao     68 Aug 12 12:02 hello.c
            lrwxrwxrwx 1 litao litao     34 Aug 12 12:16 install-sh -> /usr/share/automake-1.9/install-sh
            -rw-rw-r-- 1 litao litao     69 Aug 12 12:15 Makefile.am
            -rw-rw-r-- 1 litao litao  16561 Aug 12 12:16 Makefile.in
            lrwxrwxrwx 1 litao litao     31 Aug 12 12:16 missing -> /usr/share/automake-1.9/missing

            六、configure
            生成 Makefile, config.log, 和 config.status

            生成makefile整個(gè)過(guò)程

            configure.in :
            configure.in文件內(nèi)容是一系列GNU m4 的宏,這些宏經(jīng)autoconf處理后會(huì)變成檢查系統(tǒng)特性的shell scripts。 configure.in 內(nèi)宏的順序并沒有特別的規(guī)定,但是每一個(gè)configure.in 文件必須在所有宏前加入 AC_INIT 宏,然后在所有宏的最后加上 AC_OUTPUT宏。可先用 autoscan 掃描原始文件以產(chǎn)生一個(gè) configure.scan 文件,再對(duì) configure.scan 做些修改成 configure.in 文件。在范例中所用到的宏如下:

            dnl 
            這個(gè)宏后面的字不會(huì)被處理,可以視為注釋 
            AC_INIT(FILE) 
            該宏用來(lái)檢查源代碼所在路徑,autoscan 會(huì)自動(dòng)產(chǎn)生,一般無(wú)須修改它。 
            AM_INIT_AUTOMAKE(PACKAGE,VERSION) 
            這個(gè)是使用 Automake 所
            必備的宏,PACKAGE 是所要產(chǎn)生軟件套件的名稱,VERSION 是版本編號(hào)。 
            AC_PROG_CC 
            檢查系統(tǒng)可用的C編譯器,若源代碼是用C寫的就需要這個(gè)宏。 
            AC_OUTPUT(FILE) 
            設(shè)置 configure 所要產(chǎn)生的文件,若是
            Makefile ,configure 便會(huì)把它檢查出來(lái)的結(jié)果帶入  Makefile.in 文件后產(chǎn)生合適的 Makefile。 
            實(shí)際上,這里使用 Automake 時(shí),還需要一些其他的宏,這些額外的宏我們用 aclocal來(lái)幫助產(chǎn)生。執(zhí)行 aclocal會(huì)產(chǎn)生aclocal.m4 文件,如果無(wú)特別的用途,可以不需要修改它,用 aclocal 所產(chǎn)生的宏會(huì)告訴 Automake如何動(dòng)作。 

            有了 configure.in 及 aclocal.m4兩個(gè)文件以后,便可以執(zhí)行 autoconf來(lái)產(chǎn)生 configure 文件了。

            Makefile.am
                     Automake 會(huì)根據(jù) configure.in 中的宏把Makefile.am 轉(zhuǎn)成 Makefile.in 文件。 Makefile.am 文件定義所要產(chǎn)生的目標(biāo): 

            AUTOMAKE_OPTIONS 
            設(shè)置 automake 的選項(xiàng)。
            Automake 主要是幫助開發(fā) GNU 軟件的人員來(lái)維護(hù)軟件,所以在執(zhí)行 automake 時(shí),會(huì)檢查目錄下是否存在標(biāo)準(zhǔn) GNU 軟件中應(yīng)具備的文件,例如 'NEWS'、'AUTHOR'、'ChangeLog' 等文件。
            設(shè)置 foreign 時(shí),automake 會(huì)改用一般軟件的標(biāo)準(zhǔn)來(lái)檢查。 
            bin_PROGRAMS 
            定義要產(chǎn)生的執(zhí)行文件名。如果要產(chǎn)生多個(gè)執(zhí)行文件,每個(gè)文件名用空白符隔開。 
            hello_SOURCES 
            定義 
            'hello' 這個(gè)執(zhí)行程序所需要的原始文件。如果 'hello'這個(gè)程序是由多個(gè)原始文件所產(chǎn)生,必須把它所用到的所有原始文件都列出來(lái),以空白符隔開。假設(shè) 'hello' 還需要 'hello.c'、'main.c'、'hello.h' 三個(gè)文件的話,則定義 
            hello_SOURCES= hello.c main.c hello.h 
            如果定義多個(gè)執(zhí)行文件,則對(duì)每個(gè)執(zhí)行程序都要定義相對(duì)的filename_SOURCES。 

            編輯好 Makefile.am 文件,就可以用
             automake --add-missing來(lái)產(chǎn)生 Makefile.in。加上 --add-missing 選項(xiàng)來(lái)告訴 automake順便假如包裝一個(gè)軟件所必須的文件。Automake產(chǎn)生生出來(lái)的 Makefile.in 文件是完全符合 GNU Makefile 的慣例,只要執(zhí)行 configure這個(gè)shell script 便可以產(chǎn)生合適的 Makefile 文件了。 


            轉(zhuǎn)自:
            http://blog.chinaunix.net/u2/76292/showart.php?id=2099939

            posted on 2009-11-21 18:33 chatler 閱讀(1617) 評(píng)論(0)  編輯 收藏 引用 所屬分類: makefile
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(10)

            隨筆分類(307)

            隨筆檔案(297)

            algorithm

            Books_Free_Online

            C++

            database

            Linux

            Linux shell

            linux socket

            misce

            • cloudward
            • 感覺這個(gè)博客還是不錯(cuò),雖然做的東西和我不大相關(guān),覺得看看還是有好處的

            network

            OSS

            • Google Android
            • Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
            • os161 file list

            overall

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            伊人色综合久久天天人手人婷| 久久国产精品99精品国产| 一本久道久久综合狠狠躁AV| 国产精品久久久香蕉| 午夜人妻久久久久久久久| 99久久久精品免费观看国产| 久久久久免费视频| 久久精品卫校国产小美女| 国产欧美久久久精品| 亚洲国产成人久久笫一页| 精品久久无码中文字幕| 久久久无码精品午夜| 久久亚洲私人国产精品vA| 久久久久99精品成人片| 色欲综合久久躁天天躁蜜桃| 久久www免费人成精品香蕉| 伊人久久久AV老熟妇色| 久久91这里精品国产2020| 国产亚洲精品久久久久秋霞| 99久久婷婷国产综合精品草原 | 色综合久久天天综线观看| 久久精品a亚洲国产v高清不卡| 久久e热在这里只有国产中文精品99| 久久中文骚妇内射| 一级A毛片免费观看久久精品| 久久777国产线看观看精品| 久久久久久精品久久久久| 国产2021久久精品| 久久综合给久久狠狠97色| 日韩美女18网站久久精品| 国产亚洲婷婷香蕉久久精品| 婷婷久久香蕉五月综合加勒比| 久久一区二区免费播放| 嫩草影院久久99| 久久精品aⅴ无码中文字字幕重口| 思思久久99热只有频精品66| 国产A级毛片久久久精品毛片| 久久99精品久久久久久久不卡| 久久精品国产亚洲AV香蕉| 久久久久亚洲AV无码去区首| 精品一区二区久久|