automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building both a program and a library from the same sources


From: Nick Bowler
Subject: Re: Building both a program and a library from the same sources
Date: Mon, 13 May 2013 13:40:37 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

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/)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]