2003-06-03 19:46:29 +00:00
|
|
|
|
dnl
|
2021-11-06 14:03:11 +00:00
|
|
|
|
dnl Configuration script for Mini-XML, a small XML file parsing library.
|
2003-06-03 19:46:29 +00:00
|
|
|
|
dnl
|
2019-01-05 01:44:51 +00:00
|
|
|
|
dnl https://www.msweet.org/mxml
|
2003-06-03 19:46:29 +00:00
|
|
|
|
dnl
|
2021-10-26 12:25:41 +00:00
|
|
|
|
dnl Copyright © 2003-2021 by Michael R Sweet.
|
2003-06-03 19:46:29 +00:00
|
|
|
|
dnl
|
2019-01-05 01:44:51 +00:00
|
|
|
|
dnl Licensed under Apache License v2.0. See the file "LICENSE" for more
|
|
|
|
|
dnl information.
|
2003-06-03 19:46:29 +00:00
|
|
|
|
dnl
|
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
dnl We need at least autoconf 2.70 for --runstatedir...
|
|
|
|
|
AC_PREREQ([2.70])
|
|
|
|
|
|
|
|
|
|
|
2016-06-11 20:51:49 +00:00
|
|
|
|
dnl Package name and version...
|
2021-10-26 19:43:44 +00:00
|
|
|
|
AC_INIT([Mini-XML], [3.3], [https://github.com/michaelrsweet/mxml/issues], [mxml], [https://www.msweet.org/mxml])
|
2021-10-26 12:25:41 +00:00
|
|
|
|
|
2003-06-15 00:44:34 +00:00
|
|
|
|
|
2018-07-04 06:10:30 +00:00
|
|
|
|
dnl This line is provided to ensure that you don't run the autoheader program
|
|
|
|
|
dnl against this project. Doing so is completely unsupported and WILL cause
|
|
|
|
|
dnl problems!
|
|
|
|
|
AH_TOP([#error "Somebody ran autoheader on this project which is unsupported and WILL cause problems."])
|
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
|
2017-03-29 15:23:29 +00:00
|
|
|
|
dnl Get the build and host platforms and split the host_os value
|
|
|
|
|
AC_CANONICAL_BUILD
|
2017-03-29 15:02:47 +00:00
|
|
|
|
AC_CANONICAL_HOST
|
|
|
|
|
|
|
|
|
|
[host_os_name=`echo $host_os | sed -e '1,$s/[0-9.]*$//g'`]
|
|
|
|
|
[host_os_version=`echo $host_os | sed -e '1,$s/^[^0-9.]*//g'`]
|
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
|
2003-07-20 13:41:17 +00:00
|
|
|
|
dnl Set the name of the config header file...
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AC_CONFIG_HEADERS([config.h])
|
|
|
|
|
|
2003-07-20 13:41:17 +00:00
|
|
|
|
|
2004-05-02 22:02:36 +00:00
|
|
|
|
dnl Version number...
|
2016-06-11 20:51:49 +00:00
|
|
|
|
VERSION="AC_PACKAGE_VERSION"
|
2004-05-02 22:02:36 +00:00
|
|
|
|
AC_SUBST(VERSION)
|
|
|
|
|
AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")
|
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
|
2003-06-15 00:44:34 +00:00
|
|
|
|
dnl Clear default debugging options and set normal optimization by
|
|
|
|
|
dnl default unless the user asks for debugging specifically.
|
|
|
|
|
CFLAGS="${CFLAGS:=}"
|
2021-10-26 12:25:41 +00:00
|
|
|
|
CPPFLAGS="${CPPFLAGS:=}"
|
2003-06-15 00:44:34 +00:00
|
|
|
|
LDFLAGS="${LDFLAGS:=}"
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AC_SUBST([LDFLAGS])
|
|
|
|
|
LIBS="${LIBS:=}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dnl Options...
|
|
|
|
|
AC_ARG_WITH([ansi], AS_HELP_STRING([--with-ansi], [set full ANSI C mode, default=no]), [
|
|
|
|
|
use_ansi="$withval"
|
|
|
|
|
], [
|
|
|
|
|
use_ansi="no"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AC_ARG_WITH([archflags], AS_HELP_STRING([--with-archflags], [set additional architecture flags, default=none]), [
|
|
|
|
|
ARCHFLAGS="$withval"
|
|
|
|
|
], [
|
|
|
|
|
ARCHFLAGS=""
|
|
|
|
|
])
|
|
|
|
|
AC_SUBST([ARCHFLAGS])
|
|
|
|
|
|
|
|
|
|
AC_ARG_WITH([optim], AS_HELP_STRING([--with-optim], [set additional optimization flags, default=none]), [
|
|
|
|
|
OPTIM="$withval"
|
|
|
|
|
], [
|
|
|
|
|
OPTIM=""
|
|
|
|
|
])
|
|
|
|
|
AC_SUBST([OPTIM])
|
|
|
|
|
|
|
|
|
|
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [turn on debugging, default=no]))
|
|
|
|
|
AC_ARG_ENABLE([maintainer], AS_HELP_STRING([--enable-maintainer], [turn on maintainer mode, default=no]))
|
|
|
|
|
AC_ARG_ENABLE([sanitizer], AS_HELP_STRING([--enable-sanitizer], [build with AddressSanitizer, default=no]))
|
|
|
|
|
|
|
|
|
|
AC_ARG_WITH([docdir], AS_HELP_STRING([--with-docdir], [set directory for documentation, default=${prefix}/share/doc/mxml]), [
|
|
|
|
|
docdir="$withval"
|
|
|
|
|
], [
|
|
|
|
|
docdir="NONE"
|
|
|
|
|
])
|
2003-06-15 00:44:34 +00:00
|
|
|
|
AC_SUBST(docdir)
|
2003-06-03 19:46:29 +00:00
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AC_ARG_WITH([vsnprintf], AS_HELP_STRING([--with-vsnprintf], [use vsnprintf emulation functions, default=auto]), [
|
|
|
|
|
use_vsnprintf="$withval"
|
|
|
|
|
], [
|
|
|
|
|
use_vsnprintf="no"
|
|
|
|
|
])
|
|
|
|
|
|
2003-09-28 12:44:39 +00:00
|
|
|
|
|
2003-06-03 19:46:29 +00:00
|
|
|
|
dnl Checks for programs...
|
|
|
|
|
AC_PROG_CC
|
|
|
|
|
AC_PROG_CXX
|
2005-04-24 23:23:59 +00:00
|
|
|
|
AC_PROG_INSTALL
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AS_IF([test "$INSTALL" = "$ac_install_sh"], [
|
|
|
|
|
# Use full path to install-sh script...
|
|
|
|
|
INSTALL="`pwd`/install-sh -c"
|
|
|
|
|
])
|
2003-06-03 19:46:29 +00:00
|
|
|
|
AC_PROG_RANLIB
|
2017-03-29 19:53:52 +00:00
|
|
|
|
AC_CHECK_TOOL(AR,ar)
|
2003-06-15 00:44:34 +00:00
|
|
|
|
AC_PATH_PROG(CP,cp)
|
2019-07-03 15:30:38 +00:00
|
|
|
|
AC_PATH_PROGS(LDCONFIG,ldconfig false)
|
2005-02-26 03:10:23 +00:00
|
|
|
|
AC_PATH_PROG(LN,ln)
|
2003-06-15 00:44:34 +00:00
|
|
|
|
AC_PATH_PROG(MKDIR,mkdir)
|
|
|
|
|
AC_PATH_PROG(RM,rm)
|
2003-06-03 19:46:29 +00:00
|
|
|
|
|
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
dnl Flags for "ar" command...
|
|
|
|
|
AS_CASE(["$host_os_name"], [darwin* | *bsd], [
|
|
|
|
|
ARFLAGS="-rcv"
|
|
|
|
|
], [*], [
|
|
|
|
|
ARFLAGS="crvs"
|
|
|
|
|
])
|
2003-06-03 19:46:29 +00:00
|
|
|
|
AC_SUBST(ARFLAGS)
|
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
|
2007-09-09 07:27:08 +00:00
|
|
|
|
dnl Inline functions...
|
|
|
|
|
AC_C_INLINE
|
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
|
2003-07-20 13:41:17 +00:00
|
|
|
|
dnl Checks for string functions.
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AS_IF([test "x$use_ansi" != xyes], [
|
|
|
|
|
AC_CHECK_FUNCS([strdup strlcat strlcpy])
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test "x$use_vsnprintf" != xyes], [
|
|
|
|
|
AC_CHECK_FUNCS([snprintf vasprintf vsnprintf])
|
|
|
|
|
])
|
2003-07-20 13:41:17 +00:00
|
|
|
|
|
2003-09-28 12:44:39 +00:00
|
|
|
|
|
2009-04-18 17:05:52 +00:00
|
|
|
|
dnl Check for "long long" support...
|
2021-10-27 12:38:49 +00:00
|
|
|
|
AC_TYPE_LONG_LONG_INT
|
2021-10-26 12:25:41 +00:00
|
|
|
|
|
2009-04-18 17:05:52 +00:00
|
|
|
|
|
2007-09-22 21:00:56 +00:00
|
|
|
|
dnl Threading support
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AC_ARG_ENABLE([threads], AS_HELP_STRING([--disable-threads], [disable multi-threading support, default=no]))
|
2007-09-22 21:00:56 +00:00
|
|
|
|
|
|
|
|
|
have_pthread=no
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AS_IF([test "x$enable_threads" != xno], [
|
|
|
|
|
AC_CHECK_HEADER([pthread.h], [
|
|
|
|
|
AC_DEFINE([HAVE_PTHREAD_H], [Have <pthread.h>?])
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test x$ac_cv_header_pthread_h = xyes], [
|
|
|
|
|
dnl Check various threading options for the platforms we support
|
|
|
|
|
for flag in -lpthreads -lpthread -pthread; do
|
|
|
|
|
AC_MSG_CHECKING([for pthread_create using $flag])
|
|
|
|
|
SAVELIBS="$LIBS"
|
|
|
|
|
LIBS="$flag $LIBS"
|
|
|
|
|
AC_LANG([C])
|
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],[pthread_create(0, 0, 0, 0);])], [
|
|
|
|
|
have_pthread=yes
|
|
|
|
|
], [
|
|
|
|
|
LIBS="$SAVELIBS"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test x$have_pthread = xyes], [
|
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
|
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -D_REENTRANT"
|
|
|
|
|
break
|
|
|
|
|
], [
|
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
|
])
|
|
|
|
|
done
|
|
|
|
|
])
|
|
|
|
|
])
|
|
|
|
|
|
2007-09-22 21:00:56 +00:00
|
|
|
|
|
2005-02-26 03:10:23 +00:00
|
|
|
|
dnl Shared library support...
|
|
|
|
|
DSO="${DSO:=:}"
|
|
|
|
|
DSOFLAGS="${DSOFLAGS:=}"
|
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AC_ARG_ENABLE([shared], AS_HELP_STRING([--disable-shared], [turn off shared libraries, default=no]))
|
|
|
|
|
|
|
|
|
|
AS_IF([test x$enable_shared != xno], [
|
|
|
|
|
AC_MSG_CHECKING([for shared library support])
|
|
|
|
|
PICFLAG=1
|
|
|
|
|
|
|
|
|
|
AS_CASE(["$host_os_name"], [sunos | unix_s], [
|
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
|
LIBMXML="libmxml.so.1.6"
|
|
|
|
|
DSO="\$(CC)"
|
|
|
|
|
DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)"
|
|
|
|
|
LDFLAGS="$LDFLAGS -R\$(libdir)"
|
|
|
|
|
], [linux*], [
|
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
|
LIBMXML="libmxml.so.1.6"
|
|
|
|
|
DSO="\$(CC)"
|
|
|
|
|
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1 -shared \$(OPTIM)"
|
|
|
|
|
], [osf | gnu], [
|
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
|
LIBMXML="libmxml.so.1.6"
|
|
|
|
|
DSO="\$(CC)"
|
|
|
|
|
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)"
|
|
|
|
|
LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)"
|
|
|
|
|
], [*bsd | haiku*], [
|
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
|
LIBMXML="libmxml.so.1.6"
|
|
|
|
|
DSO="\$(CC)"
|
|
|
|
|
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)"
|
|
|
|
|
LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)"
|
|
|
|
|
], [darwin], [
|
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
|
LIBMXML="libmxml.1.dylib"
|
|
|
|
|
DSO="\$(CC)"
|
|
|
|
|
DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -lc"
|
|
|
|
|
], [mingw], [
|
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
|
LIBMXML="mxml1.dll"
|
|
|
|
|
DSO="\$(CC)"
|
|
|
|
|
DSOFLAGS="$DSOFLAGS -shared -Wl,--out-implib,libmxml1.a,--no-undefined,--enable-runtime-pseudo-reloc"
|
|
|
|
|
], [*], [
|
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
|
AC_MSG_WARN([shared libraries not supported on this platform.])
|
2005-02-26 03:10:23 +00:00
|
|
|
|
PICFLAG=0
|
|
|
|
|
LIBMXML="libmxml.a"
|
2021-10-26 12:25:41 +00:00
|
|
|
|
])
|
|
|
|
|
], [
|
|
|
|
|
PICFLAG=0
|
|
|
|
|
LIBMXML="libmxml.a"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AC_SUBST([DSO])
|
|
|
|
|
AC_SUBST([DSOFLAGS])
|
|
|
|
|
AC_SUBST([LIBMXML])
|
|
|
|
|
AC_SUBST([PICFLAG])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dnl Compiler options...
|
|
|
|
|
WARNINGS=""
|
|
|
|
|
AC_SUBST([WARNINGS])
|
|
|
|
|
|
|
|
|
|
AS_IF([test -n "$GCC"], [
|
|
|
|
|
CFLAGS="-D_GNU_SOURCE $CFLAGS"
|
|
|
|
|
|
|
|
|
|
AS_IF([test "x$OPTIM" = x], [
|
|
|
|
|
AS_IF([test x$enable_debug = xyes], [
|
|
|
|
|
OPTIM="-g"
|
|
|
|
|
], [
|
|
|
|
|
OPTIM="-g -Os"
|
|
|
|
|
])
|
|
|
|
|
], [test x$enable_debug = xyes], [
|
|
|
|
|
OPTIM="$OPTIM -g"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test x$enable_sanitizer = xyes], [
|
|
|
|
|
# Use -fsanitize=address with debugging...
|
|
|
|
|
OPTIM="$OPTIM -fsanitize=address"
|
|
|
|
|
], [
|
|
|
|
|
# Otherwise use the Fortify enhancements to catch any unbounded
|
|
|
|
|
# string operations...
|
|
|
|
|
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test "x$use_ansi" = xyes], [
|
|
|
|
|
CFLAGS="-ansi -pedantic $CFLAGS"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
dnl Show all standard warnings + unused variables when compiling...
|
|
|
|
|
WARNINGS="-Wall -Wunused"
|
|
|
|
|
|
|
|
|
|
dnl Drop some not-useful/unreliable warnings...
|
|
|
|
|
for warning in char-subscripts format-truncation format-y2k switch unused-result; do
|
|
|
|
|
AC_MSG_CHECKING([whether compiler supports -Wno-$warning])
|
|
|
|
|
|
|
|
|
|
OLDCFLAGS="$CFLAGS"
|
|
|
|
|
CFLAGS="$CFLAGS -Wno-$warning -Werror"
|
|
|
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
|
|
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
|
WARNINGS="$WARNINGS -Wno-$warning"
|
|
|
|
|
], [
|
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
CFLAGS="$OLDCFLAGS"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
dnl Maintainer mode enables -Werror...
|
|
|
|
|
AS_IF([test x$enable_maintainer = xyes], [
|
|
|
|
|
WARNINGS="$WARNINGS -Werror"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test $PICFLAG = 1 -a "$host_os_name" != aix], [
|
|
|
|
|
OPTIM="-fPIC $OPTIM"
|
|
|
|
|
])
|
|
|
|
|
], [
|
|
|
|
|
AS_IF([test "x$OPTIM" = x], [
|
|
|
|
|
AS_IF([test x$enable_debug = xyes], [
|
|
|
|
|
OPTIM="-g"
|
|
|
|
|
], [
|
|
|
|
|
OPTIM="-O"
|
|
|
|
|
])
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_CASE(["$host_os_name"], [hp-ux], [
|
|
|
|
|
CFLAGS="-Ae $CFLAGS"
|
|
|
|
|
|
|
|
|
|
OPTIM="+DAportable $OPTIM"
|
|
|
|
|
|
|
|
|
|
AS_IF([test $PICFLAG = 1], [
|
|
|
|
|
OPTIM="+z $OPTIM"
|
|
|
|
|
])
|
|
|
|
|
], [unix_svr | sunos], [
|
|
|
|
|
AS_IF([test $PICFLAG = 1], [
|
|
|
|
|
OPTIM="-KPIC $OPTIM"
|
|
|
|
|
])
|
|
|
|
|
])
|
|
|
|
|
])
|
|
|
|
|
|
2003-06-04 00:30:04 +00:00
|
|
|
|
|
2017-03-29 15:23:29 +00:00
|
|
|
|
dnl Determine whether we are cross-compiling...
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AS_IF([test "$build" = "$host"], [
|
|
|
|
|
TARGETS="ALLTARGETS"
|
|
|
|
|
], [
|
|
|
|
|
TARGETS="CROSSTARGETS"
|
|
|
|
|
])
|
|
|
|
|
AC_SUBST([TARGETS])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dnl Fix installation directories...
|
|
|
|
|
AS_IF([test "$prefix" = "NONE"], [
|
|
|
|
|
prefix="/usr/local"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test "$exec_prefix" = "NONE"], [
|
|
|
|
|
exec_prefix="$prefix"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test "$docdir" = "NONE"], [
|
|
|
|
|
docdir="$datadir/doc/mxml"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
AS_IF([test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"], [
|
|
|
|
|
mandir="/usr/share/man"
|
|
|
|
|
])
|
|
|
|
|
|
2003-06-15 00:44:34 +00:00
|
|
|
|
|
2004-05-02 22:02:36 +00:00
|
|
|
|
dnl pkg-config stuff...
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AS_IF([test "$includedir" != /usr/include], [
|
|
|
|
|
PC_CFLAGS="-I$includedir"
|
|
|
|
|
], [
|
|
|
|
|
PC_CFLAGS=""
|
|
|
|
|
])
|
|
|
|
|
AC_SUBST([PC_CFLAGS])
|
2004-05-02 22:02:36 +00:00
|
|
|
|
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AS_IF([test "$libdir" != /usr/lib], [
|
|
|
|
|
PC_LIBS="-L$libdir -lmxml"
|
|
|
|
|
], [
|
|
|
|
|
PC_LIBS="-lmxml"
|
|
|
|
|
])
|
|
|
|
|
AC_SUBST([PC_LIBS])
|
2004-05-02 22:02:36 +00:00
|
|
|
|
|
|
|
|
|
|
2003-06-15 00:44:34 +00:00
|
|
|
|
dnl Output the makefile, etc...
|
2021-10-26 12:25:41 +00:00
|
|
|
|
AC_CONFIG_FILES([Makefile mxml.pc])
|
|
|
|
|
AC_OUTPUT
|