1. 程式人生 > >弄懂autoscan, autoconf, automake, Makefile.am

弄懂autoscan, autoconf, automake, Makefile.am

之前一直把所有的h檔案和c檔案都放在同一個目錄下,用的是通用Makefile,現在覺得需要現代化一點,於是進行了一些改造,分多個目錄,多級目錄,因此,學習一下autoscan,aclocal,autoconf,automake這些工具的使用。

本文不是講解這些工具用法的,只是列出網上較好的文章。如果這些連結失效了,請通知我。

autoscan,autoconf,automake講解,首先是這兩篇文章,寫的比較詳細:

然後,一個典型的例項,可以參考:

最後,關於核心的Makefile.am,多級目錄下Makefile.am的寫法,可以參考這兩篇文章:

讀懂這些,應該就足夠了。總結一下,基本步驟如下:
1、autoscan ./
2、修改生成的configure.scan檔案,增加AM_INIT_AUTOMAKE ,AC_CONFIG_FILES([Makefile])
3、aclocal
4、核心步驟:根據情況,編寫Makefile.am
5、autoheader
6、touch NEWS README AUTHORS ChangeLog
7、automake -a
8、autoconf

注:執行autoscan時,會出現以下提示:

[shell]
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[/shell]

這個提示不影響下面的步驟,因為configure.scan檔案已經生成了。