autoconf
[Top][All Lists]
Advanced

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

Re: How to add directory to CFLAGS (or CXXFLAGS) search path?


From: Patrick Doyle
Subject: Re: How to add directory to CFLAGS (or CXXFLAGS) search path?
Date: Mon, 10 Nov 2014 13:17:17 -0500

Hi Mike,
Thanks for the tip.  I received some help this morning on IRC and
settled on something vaguely like:

dnl Search for legacy code trunk directory, allow --with-legacy=/path/to/branch
legacy_shared_include=legacy_include.h
AC_ARG_WITH([legacy],
            [AS_HELP_STRING([--with-legacy=/path/to/branch],
     [specify path to legacy source branch @<:@default=../../../trunk@:>@])],
            [legacy_path=$withval],
            [legacy_path=../../../trunk])
AC_CHECK_FILE([$legacy_path/common/include/$legacy_shared_include],
     [LEGACY_CFLAGS="-I$legacy_path/common/include"],
     [AC_MSG_ERROR([unable to find $legacy_shared_include])])
AC_SUBST([LEGACY_CFLAGS])

Note, I chose LEGACY_CFLAGS over LEGACY_CPPFLAGS in order to mimic the
behavior of PKG_CHECK_MODULES.  That way, the Makefile.am for my new
application looks like:

bin_PROGRAMS = new

new_CXXFLAGS = $(OPENCV_CFLAGS) $(GSTREAMER_CFLAGS) $(ZBAR_CFLAGS)
$(LEGACY_CFLAGS)
new_LDADD    = $(OPENCV_LIBS)   $(GSTREAMER_LIBS)   $(ZBAR_LIBS)
new_SOURCES  =  new.cpp

I could/should still add some code to configure.ac to handle the case
where the end user specifies --with-legacy or --without-legacy
(instead of --with-legacy=/path/to/branch), but since only 5 of us
will ever use this code, and we're all within mumbling distance of
each other, I decided to punt.

This is more or less what I where I was heading when I first asked my
question... thanks very much to help from <berndj> and <va>  on IRC.
But I wanted to ask first if there was an existing macro or method for
doing this.  (I think I also had some whacked out idea about magic
code that would traverse the file system back up the tree from where
my code base was installed until it found
common/include/legacy_include.h, but I decided that would offer far
less usefulness than the trouble of writing it would cost).

--wpd



reply via email to

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