I have a C application I'm converting from a set of hand coded Makefiles to GNU AutoMake. It has a subdirectory that contains an interface header and several platform-dependent implementations. Currently an implementation is selected and built to an object file with a fixed name in that directory. The code that uses the driver interface then links against that object file and automagically gets the right driver.
What's the best way to convert this system to use AutoTools? I already have AutoConf creating a substitution for the correct driver implementation file. I just can't figure out how to get an AutoMake target whose EXTRA_*_SOURCES
and *_LDADD
variables I can put the implementation files in. Do I just need to give up on the intermediate object file and put them in the list for the program target that uses them?
EDIT: Solved thanks to ptomato.
Because of Automake's dependency resolution all possible sources must be named in *_SOURCES
and EXTRA_*_SOURCES
, as explained in the Conditional Sources section of the manual. Therefore, the library stanza is actually:
noinst_LIBRARIES = libdriver.a
libdriver_a_SOURCES = driver.h
EXTRA_libdriver_a_SOURCES = driver-linux.c driver-windows.c driver-osx.c
libdriver_a_LIBADD = @DRIVERIMPL@