Add convenience libraries to the include path

2014-05-21 Thread
I'm refactoring a small C++ project and in the process I've migrated a 
component to a convenience library.


I would like to add the convenience library's root directory to the 
project's include path, but I haven't found any reference on how to do 
this.  The closest I could find was adding ${srcdir} to the include 
path, but that doesn't sound right.


Does anyone know how to pull this off?



Zé



Set dependencies between convenience libraries

2014-05-21 Thread
Is there a way to specify dependencies between convenience libraries, 
and also set the relevant include paths?



Thanks,
Zé



Re: Add convenience libraries to the include path

2014-05-21 Thread Bob Friesenhahn

On Wed, 21 May 2014, Zé wrote:

I'm refactoring a small C++ project and in the process I've migrated a 
component to a convenience library.


I would like to add the convenience library's root directory to the project's 
include path, but I haven't found any reference on how to do this.  The 
closest I could find was adding ${srcdir} to the include path, but that 
doesn't sound right.


Does anyone know how to pull this off?


You can create/add definitions to AM_CPPFLAGS to specify where the 
C/C++ compiler should search for header files.


For example

AM_CPPFLAGS = -I$(top_srcdir)/my/convenience

Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/

Re: Set dependencies between convenience libraries

2014-05-21 Thread Bob Friesenhahn

On Wed, 21 May 2014, Zé wrote:

Is there a way to specify dependencies between convenience libraries, and 
also set the relevant include paths?


Convenience libraries do not have normal dependencies because they are 
not used as libraries (they are just bundled object files).  However, 
you can use libNAME_la_LIBADD to add them as an linkage dependency for 
another library and Automake will take that into consideration when 
ordering the build within the same directory and also apply the 
objects from the convenience library while linking.  If the 
convenience library is built in some other directory, you have to 
ensure that SUBDIRS in the upper Makefile.am is listed in the correct 
order so that the convenience library is built before it is used.


For example (if convenience library is in some other directory):

libNAME_la_LIBADD = $(top_builddir)/convenience/libconvenience.la

or (if convenience library is in same directory):

libNAME_la_LIBADD = libconvenience.la

In my opinion, convenience libraries are evil (they dramatically slow 
down the build) and it is better to use a non-recursive build, using 
Makefile variables to list the required object files in the link 
rather than using a convenience library.


Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/

Re: Set dependencies between convenience libraries

2014-05-21 Thread Russ Allbery
Bob Friesenhahn  writes:

> In my opinion, convenience libraries are evil (they dramatically slow
> down the build) and it is better to use a non-recursive build, using
> Makefile variables to list the required object files in the link rather
> than using a convenience library.

The only annoyance with this approach is that if you have different
CPPFLAGS or similar variables set for different parts of your build, but
only one set of flags suffices for the convenience library, performing the
transformation that you describe will result in all the source files that
would have been in the convenience library being built multiple times with
meaningless compiler flag variations.  That can reintroduce quite a lot of
build slowness, as well as duplication of warning messages, etc.

-- 
Russ Allbery (ea...@eyrie.org)