在构建大量类似的可执行文件(测试)时,使Makefile.am重复性降低

时间:2015-04-02 18:23:50

标签: automake

我最近在C项目中添加了一堆测试,每次测试都有一个可执行文件。将它们添加到make check非常简单,但它开始使Makefile.am变得巨大:

TESTS = tests/check_bitreader tests/check_cets_ecm tests/check_descriptors tests/check_mpd tests/check_psi
noinst_PROGRAMS = $(TESTS)

tests_check_bitreader_SOURCES = tests/bitreader.c tests/main.c
tests_check_bitreader_CFLAGS = $(CFLAGS) $(CHECK_CFLAGS)
tests_check_bitreader_LDADD = tslib/libts.a $(LDFLAGS) $(CHECK_LIBS)

tests_check_cets_ecm_SOURCES = tests/cets_ecm.c tests/main.c
tests_check_cets_ecm_CFLAGS = $(CFLAGS) $(CHECK_CFLAGS)
tests_check_cets_ecm_LDADD = tslib/libts.a $(LDFLAGS) $(CHECK_LIBS)

tests_check_descriptors_SOURCES = tests/descriptors.c tests/main.c
tests_check_descriptors_CFLAGS = $(CFLAGS) $(CHECK_CFLAGS)
tests_check_descriptors_LDADD = tslib/libts.a $(LDFLAGS) $(CHECK_LIBS)

tests_check_mpd_SOURCES = tests/mpd.c tests/main.c
tests_check_mpd_CFLAGS = $(CFLAGS) $(CHECK_CFLAGS)
tests_check_mpd_LDADD = tslib/libts.a $(LDFLAGS) $(CHECK_LIBS)

tests_check_psi_SOURCES = tests/psi.c tests/main.c
tests_check_psi_CFLAGS = $(CFLAGS) $(CHECK_CFLAGS)
tests_check_psi_LDADD = tslib/libts.a $(LDFLAGS) $(CHECK_LIBS)

我能够避免使用TESTSnoinst_PROGRAMS重复自己,但有没有办法避免所有这些重复tests_check_*_SOURCESCFLAGS,{{1}等等?在普通的Makefile中,我可以执行LDADD(或其他)之类的规则,但我不知道Makefile.am中的选项。

0 个答案:

没有答案