Makefile 如何使用自动工具设置有条件的bin程序创建

Makefile 如何使用自动工具设置有条件的bin程序创建,makefile,Makefile,我是使用autotool的初学者,我想在Makefile.am中添加一些shell脚本,当我使用下面的方法时,autotool创建的Makefile不是我所期望的。我如何写才能创建正确的。 谢谢你的回复 附言: 这是我的configure.in和Makefile.am(部件) 配置.in: if test "$sample" = yes;then DEFS="$DEFS -DSAMPLE=1" AC_SUBST(SAMPLE, [yes]) fi Makefile.am: if

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

附言: 这是我的configure.in和Makefile.am(部件)

配置.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
if SAMPLE
noinst_PROGRAMS = test
test_SOURCES = test.c
else
bin_PROGRAMS = release
release_SOURCES = main.c
endif
已创建Makefile自动工具:

 ........
 ........
 .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

自动生成条件不是这样工作的。看

下面是它的外观:

configure.ac:

AM_CONDITIONAL([SAMPLE], [test "$SAMPLE" = yes])
Makefile.am:

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