[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Macro writing
From: |
Mattias Brändström |
Subject: |
Macro writing |
Date: |
Wed, 4 Jun 2003 16:19:41 +0200 (CEST) |
Hello!
I just starting out to use autoconf and automake. Now I have written a
small macro that checks for the existance of xerces-c on my system. I
was someone on this list could give me some feedback on it. =)
This is the macro:
AC_DEFUN([RKC_XERCES], [
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([for Xerces-C])
RKC_TMP=$CXXFLAGS
CXXFLAGS=-lxerces-c
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <iostream>
XERCES_CPP_NAMESPACE_USE
],
[
XercesDOMParser* parser = new XercesDOMParser();
])],
[AC_MSG_RESULT([yes])],
[AC_MSG_FAILURE([missing])])
CXXFLAGS=$RKC_TMP
AC_LANG_POP
])
The first thing I am unhappy about is my use of the variable RKC_TMP
to store the value of CXXFLAGS in order to restore that value at the
end of the macro. Is there a better way to do this or should I just be
happy that it works and leave it at that?
This macro will fail if Xerces-C isn't intalled in in a standard
location like /usr or /usr/local, to get around this I supppose that I
could use something like AC_ARG_WITH and let the user specify the
location with ./configure --with-xerces-prefix=/opt?
Maybe like this:
AC_ARG_WITH(xerces-prefix, [some help],
xerces-prefix="$withval", xerces-prefix="")
Now if xerces-prefix != "" I could set CXXFLAGS to something like this:
CXXFLAGS=-I$xerces-prefix/include -L$xerces-prefix/lib -lxerces-c
Am I on the right track so far? =)
The last thing I'm a bit puzzled with is if I should add the include
and library paths to my project globaly or if I should set some
Xerces-C specific variables and use them in my Makefile.am's where
necessary? If I should add them globaly then how do I do that?
I understand if you think I'm rambling, even I think that. =) I'm just
curious if there are any best prectices for things like this. Any
suggestions would be helpful!
Regards,
Mattias
- Macro writing,
Mattias Brändström <=