2012-04-25 12 views
0

我是使用autotool的初學者,我想在Makefile.am中添加一些shell腳本,當我使用下面的方法時,由autotool創建的Makefile不是我期望的。我怎樣才能寫出來創建正確的。 感謝您的回覆!如何使用autotools設置條件bin程序

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 

回答

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 
相關問題