• <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>

            doing5552

            記錄每日點滴,不枉人生一世

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              73 Posts :: 0 Stories :: 94 Comments :: 0 Trackbacks

            公告

            常用鏈接

            留言簿(24)

            我參與的團隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 454873
            • 排名 - 48

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            自動化生成的例子還可以參照:http://blog.csdn.net/sayigood/archive/2009/12/07/4954772.aspx

            轉載自:http://blog.chinaunix.net/u3/90876/showart_2072884.html

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

            此時狀態如下:
            [root@localhost main]# pwd
            /root/project/main
            [root@localhost main]# ls
            main.c
            [root@localhost main]#

            第二步:
            ----------
            運行 autoscan , 自動創建兩個文件: autoscan.log  configure.scan

            此時狀態如下:
            [root@localhost main]# autoscan
            [root@localhost main]# ls
            autoscan.log  configure.scan   main.c
            [root@localhost main]#

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

            查看configure.in 的內容:
            ------------------------------------------------
            #                                               -*- 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版本。如果用于創建configure的Autoconf的版
            # 本比version 要早,就在標準錯誤輸出打印一條錯誤消息并不會創建configure。
            AC_PREREQ(2.61)

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

            #
            # 用來偵測所指定的源碼文件是否存在,來確定源碼目錄的有效性
            #
            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.

            #
            # 創建輸出文件。在`configure.in'的末尾調用本宏一次。
            #
            AC_OUTPUT
            ------------------------------------------------

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


            修改后的結果:
            ------------------------------------------------
            #                                               -*- 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])
            ------------------------------------------------

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

            此時的狀態是:
            [root@localhost main]# aclocal
            [root@localhost main]# ls
            aclocal.m4  autom4te.cache   autoscan.log  configure.in  configure.in~  main.c
            [root@localhost main]#


            第五步:
            運行 autoconf , 目的是生成 configure

            此時的狀態是:
            [root@localhost main]# autoconf
            [root@localhost main]# ls
            aclocal.m4      autoscan.log  configure.in   main.c
            autom4te.cache  configure      configure.in~
            [root@localhost main]#

            第六步:
            運行 autoheader ,它負責生成config.h.in文件。該工具通常會從“acconfig.h”文件中復制用戶附加的符號定義,因此此處沒有附加符號定義,所以不需要創建“acconfig.h”文件。

            此時的狀態是:
            [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]#

            第七步:
            下面即將運行 automake , 但在此之前應該做一下準備工作!

            首先
            創建一個 Makefile.am .這一步是創建Makefile很重要的一步,automake要用的腳本配置文件是Makefile.am,用戶需要自己創建相應的文件。之后,automake工具轉換成Makefile.in。

            這個Makefile.am的內容如下:
            ------------------------------------------------
            AUTOMAKE_OPTIONS=foreign
            bin_PROGRAMS=main
            main_SOURCES=main.c
            ------------------------------------------------

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

            其次
            使用automake對其生成“configure.in”文件,在這里使用選項“—adding-missing”可以讓automake自動添加有一些必需的腳本文件。
            運行后的狀態是:
            ------------------------------------------------
            [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]#
            ------------------------------------------------

            第八步
            運行configure ,在這一步中,通過運行自動配置設置文件configure,把Makefile.in變成了最終的Makefile。
            運行的結果如下:
            ------------------------------------------------
            [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]#
            ------------------------------------------------

            第九步
            運行 make ,對配置文件Makefile進行測試一下

            此時的狀態如下:
            ------------------------------------------------
            [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]#
            ------------------------------------------------

            第十步
            運行生成的文件 main:
            ------------------------------------------------
            [root@localhost main]# ./main
            Hello, Auto Makefile!
            [root@localhost main]#


            本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/cctt_1/archive/2009/12/04/4937923.aspx

            posted on 2010-07-15 22:59 doing5552 閱讀(533) 評論(0)  編輯 收藏 引用
            国产伊人久久| 久久人人爽人人爽人人AV| 久久香蕉综合色一综合色88| 久久精品www| 久久国产成人午夜aⅴ影院 | 无码人妻久久一区二区三区蜜桃| 久久国产欧美日韩精品免费| 国产成人久久精品激情| 国产99久久九九精品无码| 久久精品国产亚洲AV香蕉| 久久婷婷国产综合精品| 久久久亚洲精品蜜桃臀| 久久久久人妻精品一区二区三区| 国内精品久久久久久久久电影网 | 日韩精品无码久久一区二区三| 午夜精品久久久久9999高清| 久久国产精品无码一区二区三区| 久久99精品免费一区二区| 亚洲中文久久精品无码ww16| 九九99精品久久久久久| 亚洲国产欧美国产综合久久| 久久精品国产亚洲一区二区三区| 97久久综合精品久久久综合| 久久久久久久久久久久久久 | 77777亚洲午夜久久多喷| 99久久精品国产一区二区蜜芽| 精品久久久久久无码专区不卡| 色青青草原桃花久久综合| 精品久久久久久国产免费了| 久久精品成人免费网站| 久久A级毛片免费观看| 久久久久久精品无码人妻| 一级做a爰片久久毛片毛片| 久久久久久一区国产精品| 久久国产午夜精品一区二区三区| 久久99热国产这有精品| 久久国产精品久久久| 99久久精品午夜一区二区| 久久久久久午夜成人影院| 97久久久精品综合88久久| 激情伊人五月天久久综合|