Newer
Older
James David Berry
committed
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
James David Berry
committed
# http://www.apache.org/licenses/LICENSE-2.0
James David Berry
committed
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# $Id$
#
James David Berry
committed
AC_CONFIG_SRCDIR([src/Makefile.am])
Boris Kolpackov
committed
AC_CONFIG_LIBOBJ_DIR([src])
James David Berry
committed
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h src/xercesc/util/Xerces_autoconf_config.hpp])
AC_CONFIG_FILES([Makefile \
src/Makefile \
tests/Makefile \
Boris Kolpackov
committed
samples/Makefile \
James David Berry
committed
# Check the target system
AC_CANONICAL_HOST
# Initialize automake
James David Berry
committed
AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2 tar-ustar])
AM_MAINTAINER_MODE
# Check if rpath is disabled
AC_MSG_CHECKING(whether to use rpath)
AC_ARG_ENABLE(rpath,
[AC_HELP_STRING([--disable-rpath],
[Patches libtool to not use rpath in the libraries produced.])],
[xerces_cv_rpath="$enable_rpath"], [xerces_cv_rpath="yes"])
AC_MSG_RESULT($xerces_cv_rpath)
James David Berry
committed
# Checks for programs.
AC_PROG_CXX
Alberto Massari
committed
# Use the C++ compiler for the compile tests
AC_LANG(C++)
# used by "make check"
AC_PROG_SED
#it would be nice to also check for PERL...
#AC_PROG_PERL
Alberto Massari
committed
Alberto Massari
committed
#skip detection of Fortran
m4_undefine([AC_PROG_F77])
m4_defun([AC_PROG_F77],[])
James David Berry
committed
AC_PROG_LN_S
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AM_PROG_CC_C_O
AS_IF([test x$AR = xfalse],
AC_MSG_ERROR([Cannot find a valid 'ar' tool]))
# Patch libtool to not use rpath if requested.
Boris Kolpackov
committed
#
AC_CONFIG_COMMANDS([libtool-rpath-patch],
[if test "$libtool_patch_use_rpath" = "no"; then
echo config.status: patching libtool to not use rpath
sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/'
mv libtool-2 libtool
chmod 755 libtool
fi],
[libtool_patch_use_rpath=$xerces_cv_rpath])
Boris Kolpackov
committed
# Export information on whether we are building static/shared libraries.
# enable_shared and enable_static are defined by AC_PROG_LIBTOOL.
#
AC_SUBST([BUILD_SHARED], [$enable_shared])
AC_SUBST([BUILD_STATIC], [$enable_static])
James David Berry
committed
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h langinfo.h limits.h locale.h \
Alberto Massari
committed
memory.h netdb.h netinet/in.h nl_types.h stddef.h stdint.h stdlib.h \
string.h strings.h \
sys/param.h sys/socket.h sys/time.h sys/timeb.h \
unistd.h wchar.h wctype.h \
CoreServices/CoreServices.h \
endian.h machine/endian.h arpa/nameser_compat.h \
Alberto Massari
committed
])
James David Berry
committed
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
AC_CHECK_SIZEOF(wchar_t)
AC_CHECK_TYPE(size_t)
AC_CHECK_TYPE(ssize_t)
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
XERCES_INT_TYPES
AC_CXX_HAVE_BOOL
AC_CXX_HAVE_NAMESPACES
AC_CXX_HAVE_STD_NAMESPACE
AC_CXX_HAVE_STD_LIBS
AC_CXX_HAVE_LSTRING
ACX_PTHREAD
# Checks for library functions.
#AC_FUNC_ERROR_AT_LINE
#AC_FUNC_MALLOC
#AC_FUNC_MEMCMP
#AC_FUNC_STRCOLL
#AC_FUNC_STRTOD
Alberto Massari
committed
AC_CHECK_FUNCS([getcwd pathconf realpath \
getaddrinfo gethostbyaddr gethostbyname socket \
clock_gettime ftime gettimeofday \
memmove memset nl_langinfo setlocale localeconv \
strcasecmp strncasecmp stricmp strnicmp strchr strdup \
strrchr strstr strtol strtoul \
Alberto Massari
committed
towupper towlower mblen \
Alberto Massari
committed
wcsupr wcslwr wcsnicmp wcsicmp \
Alberto Massari
committed
])
Alberto Massari
committed
# Some Unix systems, like Gnu Hurd, don't define PATH_MAX
AC_MSG_CHECKING([for PATH_MAX])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <limits.h>]],
[[char dummy[PATH_MAX];]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([HAVE_PATH_MAX], 1, [Define to 1 if you have the PATH_MAX macro.])
],
[
AC_MSG_RESULT([no])
AC_DEFINE_UNQUOTED([HAVE_PATH_MAX], 0, [Define to 1 if you have the PATH_MAX macro.])
]
)
# Check for functional cstdint header
AC_MSG_CHECKING([for cstdint])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <cstdint>]],
[[
uint32_t v1 = 342;
int64_t v2 = -23;
return 0;
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([XERCES_HAVE_CSTDINT], 1, [Define to 1 if cstdint is functional.])
],
[
AC_MSG_RESULT([no])
AC_DEFINE_UNQUOTED([XERCES_HAVE_CSTDINT], 0, [Define to 1 if cstdint is functional.])
]
)
Alberto Massari
committed
# The check for mbrlen, wcsrtombs and mbsrtowcs gives a false
# positive on HP-UX, so we use a different snippet to set the
# corresponding macro
Alberto Massari
committed
# Furthermore, OpenBSD 5.1 doesn't follow the standard that states
# that the "src" pointer must be set to NULL when a \0 has been
# converted in the source data, a behaviour that we rely on
# So we also check for this scenario before using these functions
Alberto Massari
committed
AC_MSG_CHECKING([for mbrlen])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <wchar.h>]],
Alberto Massari
committed
[[mbstate_t st; mbrlen( "t", 5, &st );]])],
[
Alberto Massari
committed
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([HAVE_MBRLEN], 1, [Define to 1 if you have the `mbrlen' function.])
],
[
Alberto Massari
committed
AC_MSG_RESULT([no])
AC_DEFINE_UNQUOTED([HAVE_MBRLEN], 0, [Define to 1 if you have the `mbrlen' function.])
]
)
AC_MSG_CHECKING([for wcsrtombs])
Alberto Massari
committed
AC_RUN_IFELSE( [AC_LANG_PROGRAM([[#include <wchar.h>
#include <string.h>]],
[[
mbstate_t st;
memset(&st, 0, sizeof(st));
char buffer[32];
const wchar_t* src=L"help";
wcsrtombs(buffer, &src, 32, &st);
if(src==0)
return 0;
else
return 1;]])],
[
Alberto Massari
committed
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([HAVE_WCSRTOMBS], 1, [Define to 1 if you have the `wcsrtombs' function.])
],
[
Alberto Massari
committed
AC_MSG_RESULT([no])
AC_DEFINE_UNQUOTED([HAVE_WCSRTOMBS], 0, [Define to 1 if you have the `wcsrtombs' function.])
]
)
AC_MSG_CHECKING([for mbsrtowcs])
Alberto Massari
committed
AC_RUN_IFELSE( [AC_LANG_PROGRAM([[#include <wchar.h>
#include <string.h>]],
[[
mbstate_t st;
memset(&st, 0, sizeof(st));
wchar_t buffer[32];
const char* src="help";
mbsrtowcs(buffer, &src, 32, &st);
if(src==0)
return 0;
else
return 1;]])],
[
Alberto Massari
committed
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([HAVE_MBSRTOWCS], 1, [Define to 1 if you have the `mbsrtowcs' function.])
],
[
Alberto Massari
committed
AC_MSG_RESULT([no])
AC_DEFINE_UNQUOTED([HAVE_MBSRTOWCS], 0, [Define to 1 if you have the `mbsrtowcs' function.])
]
)
Alberto Massari
committed
AC_MSG_CHECKING([if iconv uses const pointers])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <iconv.h>]],
[[
const char *fromPtr=0;
size_t fromLen=0;
Alberto Massari
committed
size_t toLen=0;
iconv_t cv=0;
iconv(cv, &fromPtr, &fromLen, &toPtr, &toLen);
Alberto Massari
committed
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([ICONV_USES_CONST_POINTER], 1, [Define to 1 if you have to use const char* with iconv, to 0 if you must use char*.])
],
[
AC_MSG_RESULT([no])
AC_DEFINE_UNQUOTED([ICONV_USES_CONST_POINTER], 0, [Define to 1 if you have to use const char* with iconv, to 0 if you must use char*.])
]
)
Alberto Massari
committed
AC_SUBST([SHREXT], [$shrext_cmds])
James David Berry
committed
#
# Orchestrate the replacement of missing functions
#
AC_REPLACE_FUNCS([stricmp strnicmp towlower towupper])
James David Berry
committed
Alberto Massari
committed
abs_top_srcdir=`cd $srcdir; pwd`
AC_SUBST(abs_top_srcdir)
abs_top_builddir=`pwd`
AC_SUBST(abs_top_builddir)
James David Berry
committed
######################################################
# Look for availability of available packages
######################################################
XERCES_PATH_DELIMITERS
XERCES_MUTEXMGR_SELECTION
James David Berry
committed
XERCES_NETACCESSOR_SELECTION
XERCES_TRANSCODER_SELECTION
XERCES_MSGLOADER_SELECTION
XERCES_FILEMGR_SELECTION
Boris Kolpackov
committed
# Allow the user to specify the pkgconfig directory.
#
AC_ARG_WITH(pkgconfigdir,
Alberto Massari
committed
AC_HELP_STRING([--with-pkgconfigdir=DIR],[Specify location of pkgconfig dir (default is libdir/pkgconfig)]),
Boris Kolpackov
committed
[pkgconfigdir=${withval}],
[pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir])
Alberto Massari
committed
# Allow the user to disable the SSE2 support
#
Boris Kolpackov
committed
AC_ARG_ENABLE(sse2,
AC_HELP_STRING([--disable-sse2],[disable SSE2 optimizations]),
[have_sse2=${enableval}],
Alberto Massari
committed
[have_sse2=yes])
James David Berry
committed
######################################################
Boris Kolpackov
committed
# Define some namespace-protected macros for use in the
Alberto Massari
committed
# publicly visible Xerces_autoconf_config.h file.
James David Berry
committed
######################################################
Boris Kolpackov
committed
James David Berry
committed
AC_DEFINE([XERCES_AUTOCONF], 1, [Define to true if autoconf is used in this configuration])
AS_IF([test x$ac_cv_header_stdint_h = xyes],
AC_DEFINE([XERCES_HAVE_STDINT_H], 1, [Define to 1 if we have stdint.h]))
James David Berry
committed
AS_IF([test x$ac_cv_header_sys_types_h = xyes],
AC_DEFINE([XERCES_HAVE_SYS_TYPES_H], 1, [Define to 1 if we have sys/types.h]))
AS_IF([test x$ac_cv_header_inttypes_h = xyes],
AC_DEFINE([XERCES_HAVE_INTTYPES_H], 1, [Define to 1 if we have inttypes.h]))
case $host in
*-*-msdos* | *-*-mingw32* | *-*-cygwin* | *-*-windows* )
platform_export="__declspec(dllexport)"
platform_import="__declspec(dllimport)"
;;
James David Berry
committed
* )
Boris Kolpackov
committed
platform_export=""
platform_import=""
;;
James David Berry
committed
esac
Boris Kolpackov
committed
James David Berry
committed
AC_DEFINE_UNQUOTED([XERCES_PLATFORM_EXPORT], [$platform_export], [Define as the platform's export attribute])
AC_DEFINE_UNQUOTED([XERCES_PLATFORM_IMPORT], [$platform_import], [Define as the platform's import attribute])
AS_IF([test ! $ac_cv_cxx_have_bool],
AC_DEFINE([XERCES_NO_NATIVE_BOOL], 1, [Define if there is no native bool support in this environment]))
AS_IF([test $ac_cv_cxx_have_lstring],
AC_DEFINE([XERCES_LSTRSUPPORT], 1, [Define if there is support for L"widestring"]))
# check if the Windows API is defined as using wchar_t or unsigned short; if it's wchar_t, we need to map XMLCh to be wchar_t
# (this is safe because on Windows wchar_t is used to store UTF-16 codepoints, while it is not true on Unix)
AC_MSG_CHECKING([whether the Windows SDK is available and using wchar_t as wide string])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <windows.h>
wchar_t file[] = L"dummy.file";]],
[
xerces_cv_type_xmlch=wchar_t
Alberto Massari
committed
AC_MSG_RESULT([yes])
Alberto Massari
committed
AC_DEFINE_UNQUOTED([XERCES_INCLUDE_WCHAR_H], 1, [Define to have Xerces_autoconf_config.hpp include wchar.h])
Alberto Massari
committed
[
xerces_cv_type_xmlch=$xerces_cv_type_u16bit_int
AC_MSG_RESULT([no])
]
)
AC_DEFINE_UNQUOTED([XERCES_XMLCH_T], [$xerces_cv_type_xmlch], [Define to the 16 bit type used to represent Xerces UTF-16 characters])
Alberto Massari
committed
AC_MSG_CHECKING([whether the compiler chokes on a placement operator delete])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <stdlib.h>
Boris Kolpackov
committed
Alberto Massari
committed
class XMemory
{
public :
void* operator new(size_t s) { return 0; }
void* operator new(size_t s, void* ptr) { return 0; }
void operator delete(void* p) {}
void operator delete(void* p, void* ptr) {}
};]],
[[ ]])],
[
AC_MSG_RESULT([no])
],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([XERCES_NO_MATCHING_DELETE_OPERATOR], 1, [Define to have XMemory.hpp avoid declaring a matching operator delete for the placement operator new])
]
)
Alberto Massari
committed
if test "$have_sse2" = "yes"; then
Boris Kolpackov
committed
no_sse2_CXXFLAGS="$CXXFLAGS"
Alberto Massari
committed
save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -msse2"
AC_MSG_CHECKING([whether we need to add -msse2])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <emmintrin.h>]], [[__m128i one;]])],
[msse2_ok=yes],
[msse2_ok=no]
)
AC_MSG_RESULT($msse2_ok)
if test x"$msse2_ok" = xno; then
CXXFLAGS="$save_CXXFLAGS"
fi
Boris Kolpackov
committed
# Sun CC option test. Currently disabled since it doesn't work. Also note
# that Sun CC will accept -msse2 (i.e., it won't fail) but will keep issuing
# warnings. So if enabled this test needs to be moved before -msse2 and if
# it passes, then -msse2 should be skipped.
#
# save_CXXFLAGS="$CXXFLAGS"
# CXXFLAGS="$CXXFLAGS -xarch=sse2"
# AC_MSG_CHECKING([whether we need to add -xarch=sse2])
# AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <emmintrin.h>]], [[__m128i one;]])],
# [xarchsse2_ok=yes],
# [xarchsse2_ok=no]
# )
# AC_MSG_RESULT($xarchsse2_ok)
# if test x"$xarchsse2_ok" = xno; then
# CXXFLAGS="$save_CXXFLAGS"
# fi
Alberto Massari
committed
Alberto Massari
committed
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
AC_MSG_CHECKING([for intrin.h usability])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <intrin.h>]],
[[]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([XERCES_HAVE_INTRIN_H], 1, [Define to 1 if you have intrin.h])
],
[
AC_MSG_RESULT([no])
]
)
AC_MSG_CHECKING([for emmintrin.h usability])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <emmintrin.h>]],
[[]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([XERCES_HAVE_EMMINTRIN_H], 1, [Define to 1 if you have emmintrin.h])
],
[
AC_MSG_RESULT([no])
]
)
AC_MSG_CHECKING([for cpuid.h usability])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <cpuid.h>]],
[[]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([HAVE_CPUID_H], 1, [Define to 1 if you have cpuid.h])
],
[
AC_MSG_RESULT([no])
]
)
Alberto Massari
committed
AC_MSG_CHECKING([whether the compiler has the CPUID intrinsic])
Alberto Massari
committed
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <intrin.h>]],
Alberto Massari
committed
[[int CPUInfo[4];
__cpuid(CPUInfo, 1);
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([XERCES_HAVE_CPUID_INTRINSIC], 1, [Define to have SSE2 instruction support detected at runtime using __cpuid])
],
[
AC_MSG_RESULT([no])
]
)
AC_MSG_CHECKING([whether the compiler has the _get_cpuid intrinsic])
Alberto Massari
committed
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <cpuid.h>]],
Alberto Massari
committed
[[unsigned int eax, ebx, ecx, edx;
__get_cpuid (1, &eax, &ebx, &ecx, &edx);
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([XERCES_HAVE_GETCPUID], 1, [Define to have SSE2 instruction support detected at runtime using __get_cpuid])
],
[
AC_MSG_RESULT([no])
]
)
AC_MSG_CHECKING([whether the compiler has the SSE2 intrinsic])
Alberto Massari
committed
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <emmintrin.h>]],
Alberto Massari
committed
[[__m128i* one=(__m128i*)_mm_malloc(4, 16);
__m128i* two=(__m128i*)_mm_malloc(4, 16);
__m128i xmm1 = _mm_load_si128(one);
__m128i xmm2 = _mm_load_si128(two);
__m128i xmm3 = _mm_or_si128(xmm1, xmm2);
_mm_store_si128(one, xmm3);
_mm_free(one);
_mm_free(two);
]])],
[
AC_MSG_RESULT([yes])
Boris Kolpackov
committed
sse2_usable=yes
Alberto Massari
committed
AC_DEFINE_UNQUOTED([XERCES_HAVE_SSE2_INTRINSIC], 1, [Define to have SSE2 instruction used at runtime])
],
[
AC_MSG_RESULT([no])
Boris Kolpackov
committed
sse2_usable=no
Alberto Massari
committed
]
Boris Kolpackov
committed
)
# Restore original CXXFLAGS if SSE2 is not usable.
#
if test "$sse2_usable" = "no"; then
CXXFLAGS="$no_sse2_CXXFLAGS"
fi
Alberto Massari
committed
fi
Alberto Massari
committed
James David Berry
committed
AS_IF([test x$ac_cv_type_size_t = xyes],
AC_DEFINE([XERCES_SIZE_T], [size_t], [Define as the appropriate size_t type])
AC_DEFINE([XERCES_SIZE_MAX], [SIZE_MAX], [Define as the appropriate SIZE_MAX macro]),
AC_DEFINE([XERCES_SIZE_T], [unsigned long], [Define as the appropriate size_t type])
AC_DEFINE([XERCES_SIZE_MAX], [ULONG_MAX], [Define as the appropriate SIZE_MAX macro]))
James David Berry
committed
AS_IF([test x$ac_cv_type_ssize_t = xyes],
AC_DEFINE([XERCES_SSIZE_T], [ssize_t], [Define as the appropriate ssize_t type])
AC_DEFINE([XERCES_SSIZE_MAX], [SSIZE_MAX], [Define as the appropriate SSIZE_MAX macro]),
AC_DEFINE([XERCES_SSIZE_T], [long], [Define as the appropriate ssize_t type])
AC_DEFINE([XERCES_SSIZE_MAX], [LONG_MAX], [Define as the appropriate SSIZE_MAX macro]))
James David Berry
committed
AS_IF([test x$ac_cv_cxx_have_namespaces = xyes],
AC_DEFINE([XERCES_HAS_CPP_NAMESPACE], 1, [Define if namespaces is supported by the compiler]))
James David Berry
committed
AS_IF([test x$ac_cv_cxx_have_std_namespace = xyes],
AC_DEFINE([XERCES_STD_NAMESPACE], 1, [Define if the std namespace is supported]))
James David Berry
committed
AS_IF([test x$ac_cv_cxx_have_std_libs = xyes],
AC_DEFINE([XERCES_NEW_IOSTREAMS], 1, [Define if the isstream library can be included as <iostream>]))
AC_OUTPUT
AC_MSG_NOTICE
AC_MSG_NOTICE([Report:])
AC_MSG_NOTICE([ File Manager: $filemgr])
AC_MSG_NOTICE([ Mutex Manager: $mutexmgr])
AC_MSG_NOTICE([ Transcoder: $transcoder])
AC_MSG_NOTICE([ NetAccessor: $netaccessor])
AC_MSG_NOTICE([ Message Loader: $msgloader])