跳至內容

Automake

出自Taiwan Tongues 台語維基
這是此頁批准,以及是最近的修訂。

GNU Automake是一種編程工具,會當產生供 make 程式使用的 Makefile,用來編譯程式。伊是自由軟體基金會發起的 GNU 計畫的其中有一項,做為 GNU 構建系統的一部份。automake 所產生的 Makefile 符合 GNU 編程標準。

automake 是由 Perl 語言所寫的,著愛和 GNU autoconf 做伙來使用。automake 包括講以下這个命令:

  • _ aclocal _
  • _ automake _

_ aclocal _ 是一个泛用的程式,對於 autoconf 使用者是誠有路用。來比例來講,GNU Compiler Collection 使用 _ aclocal _,就算 Makefile 是手寫的。

就親像 autoconf,automake 毋是完全向下相容的。來比例來講,使用 automake 一爿四的專案可能是袂當使用 automake 一孵九。

方法

Automake 目標是欲予使用者透過高階語言來寫 makefile,毋是透過純手工的方式來寫規个 makefile。佇簡單的狀況之下,伊會當提供:

  • 源檔案的列表
  • 傳予編譯器的命令列選項列表(譬如講標頭檔置佇佗一个路徑)
  • 傳予連結器的命令列選項列表(程式需要啥物程式庫佮𪜶的路徑)

經過遮的資訊,Automake 產生 makefile 會當予使用者:

  • 編譯程式
  • clean(清除,刪除編譯過程中所產生的檔案)
  • 將程式安裝佇標準路徑
  • 將程式反安裝(對安裝的所在徙掉)
  • create a source distribution archive ( commonly called a tarball )
  • test that this archive is self-sufficient , and in particular that the program can be compiled in a directory other than the one where the sources are deployed

依存性資訊的產生

Automake 自動生做依存性的資訊,所以,做一个原始檔被修改,後過咻叫 make 命令的時就會知影佗一寡原始檔需要重新編譯。若編譯器允准,Automake 會試予依存性系統保持動態:無論當時原始檔被編譯,攏會要求編譯器重新產生依存性列表更新該檔案的依存性。嘛會使講,依存性追蹤是編譯過程的一種邊際效應。

這企圖避免這寡靜態依存性系統的問題,譬如講依存性只會佇咧程式員開始專案的時陣才會予人偵測著。佇這个情形下,若原始檔得著一个新的依存性(比如講,若是程式員加一个新的 ` # include ` 指令佇咧 C 語言的原始檔), 按呢佇真實的依存性佮編譯系統所使用的依存性之間就會產生差異。程式員應該重新產生依存性,猶毋過真有可能袂記得彼做。佇一般情形下,automake 透過隨附的 depcomp 指令碼生成依存性,這會適當的呼叫編譯器抑是轉去到 makedepend。若是 gcc 編譯器的版本有夠新的話,automake 將會 inline 依存性生做碼,直接呼叫 gcc。

Libtool

Automake 猶閣會當用來輔助庫的編譯,伊會當自動生呼叫 Libtool 的 Makefile 檔案,對使程式設計師避免矣直接呼叫 Libtool , 啊若專案嘛會當對遮搬徙的庫生成工具接著益。

參見

  • CMake
  • qmake
  • imake
  • Flowtracer

參考資料

外部連結

  • Automake home page
  • Online version of _ The Goat Book _ aka Autobook
  • Autotoolset home page
  • Article " Using Automake and Autoconf with C + + " by Murray Cumming

教材

  • Tutorial for beginners " Autotools Tutorial " by Sarah George
  • Tutorial " Learning Autoconf and Automake " by Eleftherios Gkioulekas
  • The " Autotools Tutorial " by Alexandre Duret-Lutz introduces Autoconf , Automake , Libtool , and Gettext .
  • Learning the GNU Development tools