2013-08-16 14 views
0

在我的項目下,我有3個源代碼包,比如說package1,package2,package3。其中一個將根據依賴軟件(例如softA)版本進行編譯。如何讓automake有條件地選擇一個src包?

如果我輸入'./configure --softA-version = 1.7.2',我希望package3會被選中。

在makefile.am,它可能看起來像

if "softA_version" == "1.5.2"; then 
    SUBDIRS = package1 
else if "softA_version == "1.6.4"; then 
    SUBDIRS = package2 
else if "softA_version" == "1.7.2"; then 
    SUBDIRS = package3 
endif 

我應該如何在configure.ac或* .m4文件中定義萬分之一?

回答

0

你或許應該看看AC_ARG_WITH宏,它的工作原理幾乎一樣你描述:

AC_ARG_WITH([softA-version], [AS_HELP_STRING([--with-softA-version=version], 
[use the softA version (default 1.7.2)])], 
[softA_version="$withval"], 
[softA_version="1.7.2"]) 

AM_CONDITIONAL([BUILD_SOFTA_1_5_2], [test "$softA_version" = "1.5.2"]) 
AM_CONDITIONAL([BUILD_SOFTA_1_6_4], [test "$softA_version" = "1.6.4"]) 
AM_CONDITIONAL([BUILD_SOFTA_1_7_2], [test "$softA_version" = "1.7.2"]) 

... 

Makefile.am

if BUILD_SOFTA_1_5_2 
SUBDIRS = package1 
endif 
if BUILD_SOFTA_1_6_4 
SUBDIRS = package2 
endif 
if BUILD_SOFTA_1_7_2 
SUBDIRS = package3 
endif 

和調用,如:

configure --with-softA-version=1.5.2 

你可能能夠AC_SUBST包名directl y,而不是使用AM_CONDITIONAL 但這可能會起作用。我還沒有嘗試過。

+0

非常感謝!好人! –