Linux configure檔案產生

來源:互聯網
上載者:User

一. 安裝工具 automake, autoconf,  編寫來源程式:mycc.c

#include <stdio.h>#include "config.h"int main(int argc, char** argv){    if(argv == 1)    {        printf("version: %s\n", PACKAGE_STRING);    }    else    {        printf("name     : %s\n", PACKAGE);        printf("version  : %s\n", VERSION);        printf("bugreport: %s\n", PACKAGE_BUGREPORT);    }    return 0;}

需要說明的是mycc.c中用到的宏來自config.h,  而config.h又是工具產生的(見後文)

二.  運行autoscan , 產生 configure.scan

[root@waf mypkg]# autoscan[root@waf mypkg]# lsautoscan.log  configure.scan  mycc.c[root@waf mypkg]#

重新命名configure.scan 為 configure.in ,並編輯configure.in

#                                               -*- Autoconf -*-# Process this file with autoconf to produce a configure script.AC_PREREQ([2.63])AC_INIT([mycc], [1.0.0], [www.mycc.org])AC_CONFIG_SRCDIR([mycc.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([mycc], [1.0.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 , autoconf

[root@waf mypkg]# aclocal[root@waf mypkg]# lsaclocal.m4  autom4te.cache  autoscan.log  configure.in  mycc.c[root@waf mypkg]# autoconf[root@waf mypkg]# lsaclocal.m4  autom4te.cache  autoscan.log  configure  configure.in  mycc.c

四.  建立 Makefile.am, 內容:

AUTOMAKE_OPTIONS=foreignbin_PROGRAMS=myccmycc_SOURCES=mycc.c

五. 運行 autoheader, 產生config.h.in (automake要用到)

[root@waf mypkg]# lsaclocal.m4  autom4te.cache  autoscan.log  configure  configure.in  mycc.c[root@waf mypkg]# vim Makefile.am[root@waf mypkg]# autoheader[root@waf mypkg]# lsaclocal.m4      autoscan.log  configure     Makefile.amautom4te.cache  config.h.in   configure.in  mycc.c

六. 運行automake ,產生configure

[root@waf mypkg]# automake --add-missingconfigure.in:8: installing `./install-sh'configure.in:8: installing `./missing'Makefile.am: installing `./depcomp'[root@waf mypkg]#

七. 試試configure

./configuremakemake install

參考:

http://www.ibm.com/developerworks/cn/linux/l-makefile/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.