autoconf
[Top][All Lists]
Advanced

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

Re: usage of ac_check_header


From: Joao Miguel Ferreira
Subject: Re: usage of ac_check_header
Date: Tue, 24 Jul 2007 10:44:28 +0100

Hi Keith,

On Mon, 2007-07-23 at 20:55 +0100, Keith Marshall wrote:
> Are you sure that your compiler is searching /usr/include, as the 
> default include path?
> 
>   # mkdir -p /usr/include/libxml2/libxml
>   # touch /usr/include/libxml2/libxml/xpath.h
> 
>   $ cat > configure.ac
>   AC_INIT
>   AC_PROG_CC
>   AC_CHECK_HEADER([libxml2/libxml/xpath.h],,
>     [AC_MSG_ERROR([cannot find xml headers])])
> 
>   $ autoconf
>   $ ./configure
>   checking for gcc... gcc
>   checking for C compiler default output file name... a.out
...
..
>   checking for stdint.h... yes
>   checking for unistd.h... yes
>   checking libxml2/libxml/xpath.h usability... yes
>   checking libxml2/libxml/xpath.h presence... yes
>   checking for libxml2/libxml/xpath.h... yes

Well... I'm unable to get my system to work as yours... it seems to me
your system is not refusing to look into /usr/include/libxml2/..... mine
is...

In order to get this to work I had to explicitlly 'ask' ./configure dig
into the libxml2 dir.... check this out (configure.ac)

----------------------------------------------
XTRAINCPATHS="-I/usr/include/libxml2/"
CFLAGS="$CFLAGS $XTRAINCPATHS"
CPPFLAGS="$CPPFLAGS $XTRAINCPATHS"
#now that we got the include paths right lets check

AC_CHECK_HEADERS([libxml/xmlreader.h
libxml/xpath.h],,AC_MSG_ERROR([cannot find headers for libxml2]))

AC_CHECK_HEADER([libxslt/xslt.h],,[AC_MSG_ERROR([cannot find headers for
libxslt])])
------------------------------

it seems to me that, on my system, I need to tell both to configure and
to make some extra include path.... notice that I did not have to tell
it the path to libxslt.... but I did have to tell it the path to libxml
(my guess is it's because libxml does not reside directllu
in /usr/include(, which makes some sense)...

bellow is my whole configure.ac :)

cheers

jmf


> 
> HTH,
> Keith.

---------------------------------------------------------------
AC_INIT([libbabel],[0.4])

#path to some source file just for Autoconf to double-check what it's
doing
AC_CONFIG_SRCDIR([langs.c])

#generate and include a header file to deal with != functions and
headers in != systems
#config.h is generated by autoheader, from things like: AC_HEADER_STDC,
AC_CHECK_FUNCS, AC_CHECK_HEADERS
#autoheader: a) reads configure.ac, b) looks into the system and c)
generates config.h accordinglly
AC_CONFIG_HEADER([config.h])

#initializa Automake
AM_INIT_AUTOMAKE

#AC_LANG([C])

#we need a C compiler, a standard install program and 
AC_PROG_CC
AC_PROG_INSTALL

#we need libtool; we need shared libraries;
AM_PROG_LIBTOOL
AC_PROG_LIBTOOL
AC_ENABLE_SHARED

#check for STDC headers in the system
AC_HEADER_STDC

AC_CHECK_HEADERS(unistd.h sys/socket.h)
AC_CHECK_FUNCS(socket htons)

#these extra pathS could also (maybe they really should) be later at
(after) the "./configure ..."
#this is because in some systems these includes could reside somewhere
else... WTF !!!
XTRAINCPATHS="-I/usr/include/libxml2/"
CFLAGS="$CFLAGS $XTRAINCPATHS"
CPPFLAGS="$CPPFLAGS $XTRAINCPATHS"
#in fact these settings will end up in the Makefile
#but they first allow for ./configure to find the libxml/xpath header
#If libmxl/*.h were located at /usr/include/ none of this would be
needed, would it ?! No. jmf.

#now that we got the include paths right lets check if the system has
the needed headers
AC_CHECK_HEADERS([libxml/xmlreader.h
libxml/xpath.h],,AC_MSG_ERROR([cannot find headers for libxml2]))
AC_CHECK_HEADER([libxslt/xslt.h],,[AC_MSG_ERROR([cannot find headers for
libxslt])])

#and the needed libs for linking
#checks for existance of lib, the specified function and adds it to
$(LIBS) in link phase of make
AC_CHECK_LIB(xml2,xmlParseDoc,,AC_MSG_ERROR([cannot link to libxml2]))
AC_CHECK_LIB(xslt,xsltInit,,AC_MSG_ERROR([cannot link to libxslt]))

#set some sanity flags... well... some compilers don't know them... "gcc
sweet gcc"
# additionally -Werror would be too optimistic, wouldn't it ?!...
CFLAGS="$CFLAGS -Wshadow -Wunused -Wall -Werror"

#now we ask Autoconf to output just the top-level Makefile (we have no
more levels... do we ?)
AC_CONFIG_FILES([Makefile])
#mandatory AC_OUTPUT
AC_OUTPUT
---------------------------------------------------------------






reply via email to

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