On 2013-05-13 14:49 +0200, Cojocaru Alexandru wrote: > Hi, > I would like to compile both a program and a library from the same > source file. This is what I have inside src/Makefile.am: > > lib_LTLIBRARIES = libex.la > libex_la_SOURCES = src/ex.c > include_HEADERS = src/ex.h > > AM_CPPFLAGS += -DSTANDALONE > > bin_PROGRAMS = ex > ex_SOURCES = src/ex.c src/ex.h > > I would like to build first the library and then after defining STANDALONE > the program. > > Is this possible? I even tried ex_SHORTNAME hoping that it would rename > the object, but it didn't work.
Automake supports separate CPPFLAGS for each program or library, see ยง8.4 "Program and Library Variables" of the Automake manual[1]. Essentially, instead of setting -DSTANDALONE in AM_CPPFLAGS, you would set it in the CPPFLAGS for ex, for example: ex_CPPFLAGS = -DSTANDALONE [1] https://gnu.org/software/automake/manual/automake.html#Program-and-Library-Variables Cheers, -- Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)