autoconf
[Top][All Lists]
Advanced

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

Howto: run the C preprocessor and capture its output


From: Zack Weinberg
Subject: Howto: run the C preprocessor and capture its output
Date: Thu, 18 Oct 2007 16:11:14 -0700

As far as I can tell, Autoconf provides no documented macro that
allows me to run the preprocessor and capture (selected portions of)
its output in shell variables.  What is the most reliable way to do
this with released versions of Autoconf?  (Ideally something that
would work over the entire 2.5x series.)

A concrete example of what I am trying to do: The program whose
configure script I am hacking embeds a copy of a library, libpcre.
That library  exposes its version number as a pair of #defines in its
primary header file, pcre.h.  It would be nice to allow the program to
be linked against a system-provided copy of libpcre when possible;
however, each version of the program needs to be linked with one and
only one version of libpcre, because successive releases of libpcre
add features which translate directly into user-visible features of
the program.  (It is a regular expression library.) So what I want to
do is compare the system's pcre.h's definition of the version number
macros with the bundled copy's.  I had thought to do something like
this:

AC_PREPROC_IFELSE(
address@hidden:@include <pcre.h>
xxpcre_major="PCRE_MAJOR"
xxpcre_minor="PCRE_MINOR"],
[eval `egrep '^xxpcre_(major|minor)='  conftest.out`
 ac_cv_lib_pcre_version="$xxpcre_major.$xxpcre_minor"]
[ac_cv_lib_pcre_version=unknown])

repeat for the bundled "pcre/pcre.h" with a different result variable,
and then compare them.  But AC_PREPROC_IFELSE sends the preprocessor
output to /dev/null rather than conftest.out. :-(

TIA
zw




reply via email to

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