I’ve got a program that’s written in C, built using automake/autoconf, and has two test suites. One is a unit test suite also written in C; the other is end-to-end and is (currently) written in Python. I want “make check” to run the unit tests always, and the end-to-end tests only if Python is installed. This is what I have now:
TESTS = unittests
if HAVE_PYTHON
TESTS += tester.py
tester_py_SOURCES = src/test/tester.py.in
tester.py: src/test/tester.py.in Makefile
$(SED) -e 's,[@]PYTHON[@],$(PYTHON),' < $< > $@
chmod +x $@
endif
HAVE_PYTHON is set by the configure script with
AM_PATH_PYTHON([2.6],, [:])
AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != ":"])
This works correctly on Unix, but blows up with “no rule to make tester.py.exe” on Windows. Also, the copy-and-substitute technique for getting the #! line right means I can’t break up the test suite into multiple modules.
Is there a better way to do this?
You must use
_SOURCESfor compiled things only, so that’s why it’a adding$(EXEEXT). Try this:Is there any reason you don’t just do the substitution via
configure.ac?This will remake the script using
config.statusand autogenerate rebuild rules.EDIT 1:
If what you really want to do is run the python tester script as part of
make check, I’d do this:(I put the
check-localoutside theif HAVE_PYTHONso that you can define other commands to run as part ofcheck-local, if needed.)You might prefer writing this, instead:
See extending in the automake manual.