In an autotools-based project, I currently have the following line in my Makefile.am:
AUTOMAKE_OPTIONS = serial-tests
I would like to make this option apply if and only if my automake version is 1.12 or greater. The reason is the need to support the serial test harness with both 1.11 and 1.13 automake. What is the best way to do this?
I have already tried this:
AM_VER = $(shell $(AUTOMAKE) --version | head -n1 | sed -e 's|[^0-9.]||g')
AM_VER_MAJOR = $(shell echo $(AM_VER) | cut -d. -f1)
AM_VER_MINOR = $(shell echo $(AM_VER) | cut -d. -f2)
AM_VER_PATCH = $(shell echo $(AM_VER) | cut -d. -f3)
$(info $(AM_VER_MAJOR) $(AM_VER_MINOR) $(AM_VER_PATCH))
supports_serial_tests_opt = $(shell if [ "$(AM_VER_MAJOR)" -gt 1 ] || { [ "$(AM_VER_MAJOR)" -eq 1 ] && [ "$(AM_VER_MINOR)" -ge 12 ]; }; then echo true; fi)
$(info $(supports_serial_tests_opt))
$(if $(supports_serial_tests_opt), $(eval AUTOMAKE_OPTIONS=serial-opts))
$(info $(AUTOMAKE_OPTIONS))
and it doesn't work, because AUTOMAKE_OPTIONS need to be set at automake execution time, and the function conditionals are executed at make time. Even if it worked, I would have found it ridiculously verbose and bloated; is there a better way? My gut tells me I should use my configure.ac to set a variable which I will then simply let expand in the Makefile.am, like this:
AUTOMAKE_OPTIONS = $(SERIAL_TESTS)
The philosophy behind autoconfiguration is to check for features -- can I somehow skip the version checking and check for the serial-tests option availability and use it if given?
parallel-testsoption is compatible with the three versions, and your build will benefit from the parallelism. – adl Apr 12 '13 at 9:20