Rob Latham
Rob Latham

Reputation: 5223

automake: distcheck with CPPFLAGS

I am looking for something like DISTCHECK_CONFIGURE_FLAGS but more flexible.

I am using an external package in my program. Let's say foo and on my laptop it's installed to ${HOME}/soft/foo.

configuring with the autotools is simple:

./configure CPPFLAGS=-I${HOME}/soft/foo/include LDFLAGS=-L${HOME}/soft/foo/lib

but distcheck is giving me headaches. When distcheck unpacks and configures, how do I tell it to use my CPPFLAGS and LDFLAGS?

DISTCHECK_CONFIGURE_FLAGS is close, but incorrect: other maintainers might have the foo library installed under /opt/ or /software/random/whatever or /usr/local/foo-master and I don't want to impose my environment on other maintainers.

Upvotes: 0

Views: 363

Answers (1)

Rob Latham
Rob Latham

Reputation: 5223

The answer is to not hard-code anything in the Makefile.am. Automake will inherit several environment variables from autoconf.

All one needs to do is pass the CPPFLAGS and LDFLAGS used to configure the package:

DISTCHECK_CONFIGURE_FLAGS = CPPFLAGS=${CPPFLAGS} CFLAGS=${CFLAGS}\
     ${CXXFLAGS}=${CXXFLAGS} LDFLAGS=${LDFLAGS} 

and now 'make distcheck' will use the requested flags and find the headers and libraries for the desired package.

Upvotes: 1

Related Questions