如何使用autotools设置条件bin程序创建

时间:2012-04-25 16:13:53

标签: makefile

我是使用autotool的初学者,我想在Makefile.am中添加一些shell脚本,当我使用下面的方法时,autotool创建的Makefile不是我所期待的。如何编写以创建正确的。 谢谢你的回复!

PS: 这是我的configure.in和Makefile.am(部分)

configure.in:

if test "$sample" = yes;then
    DEFS="$DEFS -DSAMPLE=1"
    AC_SUBST(SAMPLE, [yes])
fi

Makefile.am:

if test "$SAMPLE" = yes;then
    noinst_PROGRAMS = test
    test_SOURCES = test.c
else
    bin_PROGRAMS = release
    release_SOURCES = main.c
fi

创建了Makefile autotool:

 ........
 ........
 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
 clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS ctags \
 distclean distclean-compile distclean-generic \
 distclean-libtool distclean-tags distdir dvi dvi-am html \
 html-am info info-am install install-am install-data \
 install-data-am install-dvi install-dvi-am install-exec \
 install-exec-am install-html install-html-am \
 install-includeHEADERS install-info install-info-am \
 install-libLTLIBRARIES install-man install-pdf install-pdf-am \
 install-ps install-ps-am install-strip installcheck \
 installcheck-am installdirs maintainer-clean \
 maintainer-clean-generic mostlyclean mostlyclean-compile \
 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 tags uninstall uninstall-am uninstall-includeHEADERS \
 uninstall-libLTLIBRARIES

if test "yes" = yes;then
fi

1 个答案:

答案 0 :(得分:0)

Automake条件不能那样工作。请参阅manual

以下是它的外观:

configure.ac:

AM_CONDITIONAL([SAMPLE], [test "$SAMPLE" = yes])

Makefile.am:

if SAMPLE
noinst_PROGRAMS = test
test_SOURCES = test.c
else
bin_PROGRAMS = release
release_SOURCES = main.c
endif