【问题标题】:how to make automake conditionally choose a src package?如何使 automake 有条件地选择一个 src 包?
【发布时间】:2013-08-17 02:23:32
【问题描述】:

在我的项目下,我有 3 个源代码包,比如 package1、package2、package3。其中一个将根据依赖的软件(例如softA)版本进行编译。

如果我输入'./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 文件中定义 Micros?

【问题讨论】:

    标签: autotools autoconf automake


    【解决方案1】:

    您可能应该查看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 包名,而不是使用AM_CONDITIONAL 但这可能会奏效。不过我没试过。

    【讨论】:

      猜你喜欢
      • 2013-11-07
      • 2017-09-04
      • 2020-04-06
      • 1970-01-01
      • 2020-11-12
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多