You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

479 lines
18 KiB

  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. #
  5. # Licensed to the Apache Software Foundation (ASF) under one or more
  6. # contributor license agreements. See the NOTICE file distributed with
  7. # this work for additional information regarding copyright ownership.
  8. # The ASF licenses this file to You under the Apache License, Version 2.0
  9. # (the "License"); you may not use this file except in compliance with
  10. # the License. You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. #
  20. #
  21. # $Id: configure.ac 1662881 2015-02-28 02:00:45Z scantor $
  22. #
  23. AC_PREREQ(2.60)
  24. AC_INIT([xerces-c],[3.1.2])
  25. AC_CONFIG_SRCDIR([src/Makefile.am])
  26. AC_CONFIG_LIBOBJ_DIR([src])
  27. AC_CONFIG_AUX_DIR([config])
  28. AC_CONFIG_MACRO_DIR([m4])
  29. AC_CONFIG_HEADERS([config.h src/xercesc/util/Xerces_autoconf_config.hpp])
  30. AC_CONFIG_FILES([Makefile \
  31. src/Makefile \
  32. src/xercesc/util/MsgLoaders/MsgCatalog/Makefile \
  33. tests/Makefile \
  34. samples/Makefile \
  35. xerces-c.pc])
  36. # Check the target system
  37. AC_CANONICAL_HOST
  38. # Initialize automake
  39. AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2 tar-ustar])
  40. AM_MAINTAINER_MODE
  41. # Check if rpath is disabled
  42. AC_MSG_CHECKING(whether to use rpath)
  43. AC_ARG_ENABLE(rpath,
  44. [AC_HELP_STRING([--disable-rpath],
  45. [Patches libtool to not use rpath in the libraries produced.])],
  46. [xerces_cv_rpath="$enable_rpath"], [xerces_cv_rpath="yes"])
  47. AC_MSG_RESULT($xerces_cv_rpath)
  48. # Checks for programs.
  49. AC_PROG_CXX
  50. # Use the C++ compiler for the compile tests
  51. AC_LANG(C++)
  52. # used by "make check"
  53. AC_PROG_SED
  54. #it would be nice to also check for PERL...
  55. #AC_PROG_PERL
  56. #skip detection of Fortran
  57. m4_undefine([AC_PROG_F77])
  58. m4_defun([AC_PROG_F77],[])
  59. AC_PROG_LN_S
  60. AC_LIBTOOL_WIN32_DLL
  61. AC_PROG_LIBTOOL
  62. AM_PROG_CC_C_O
  63. AS_IF([test x$AR = xfalse],
  64. AC_MSG_ERROR([Cannot find a valid 'ar' tool]))
  65. # Patch libtool to not use rpath if requested.
  66. #
  67. AC_CONFIG_COMMANDS([libtool-rpath-patch],
  68. [if test "$libtool_patch_use_rpath" = "no"; then
  69. echo config.status: patching libtool to not use rpath
  70. sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/'
  71. mv libtool-2 libtool
  72. chmod 755 libtool
  73. fi],
  74. [libtool_patch_use_rpath=$xerces_cv_rpath])
  75. # Export information on whether we are building static/shared libraries.
  76. # enable_shared and enable_static are defined by AC_PROG_LIBTOOL.
  77. #
  78. AC_SUBST([BUILD_SHARED], [$enable_shared])
  79. AC_SUBST([BUILD_STATIC], [$enable_static])
  80. # Checks for header files.
  81. AC_HEADER_STDC
  82. AC_HEADER_TIME
  83. AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h langinfo.h limits.h locale.h \
  84. memory.h netdb.h netinet/in.h nl_types.h stddef.h stdint.h stdlib.h \
  85. string.h strings.h \
  86. sys/param.h sys/socket.h sys/time.h sys/timeb.h \
  87. unistd.h wchar.h wctype.h \
  88. CoreServices/CoreServices.h \
  89. endian.h machine/endian.h arpa/nameser_compat.h \
  90. ])
  91. # Checks for typedefs, structures, and compiler characteristics.
  92. AC_HEADER_STDBOOL
  93. AC_C_CONST
  94. AC_C_INLINE
  95. AC_C_VOLATILE
  96. AC_CHECK_SIZEOF(wchar_t)
  97. AC_CHECK_TYPE(size_t)
  98. AC_CHECK_TYPE(ssize_t)
  99. AC_TYPE_OFF_T
  100. AC_TYPE_SIZE_T
  101. XERCES_INT_TYPES
  102. AC_CXX_HAVE_BOOL
  103. AC_CXX_HAVE_NAMESPACES
  104. AC_CXX_HAVE_STD_NAMESPACE
  105. AC_CXX_HAVE_STD_LIBS
  106. AC_CXX_HAVE_LSTRING
  107. ACX_PTHREAD
  108. # Checks for library functions.
  109. #AC_FUNC_ERROR_AT_LINE
  110. #AC_FUNC_MALLOC
  111. #AC_FUNC_MEMCMP
  112. #AC_FUNC_STRCOLL
  113. #AC_FUNC_STRTOD
  114. AC_CHECK_FUNCS([getcwd pathconf realpath \
  115. getaddrinfo gethostbyaddr gethostbyname socket \
  116. clock_gettime ftime gettimeofday \
  117. memmove memset nl_langinfo setlocale localeconv \
  118. strcasecmp strncasecmp stricmp strnicmp strchr strdup \
  119. strrchr strstr strtol strtoul \
  120. towupper towlower mblen \
  121. wcsupr wcslwr wcsnicmp wcsicmp \
  122. ])
  123. # Some Unix systems, like Gnu Hurd, don't define PATH_MAX
  124. AC_MSG_CHECKING([for PATH_MAX])
  125. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <limits.h>]],
  126. [[char dummy[PATH_MAX];]])],
  127. [
  128. AC_MSG_RESULT([yes])
  129. AC_DEFINE_UNQUOTED([HAVE_PATH_MAX], 1, [Define to 1 if you have the PATH_MAX macro.])
  130. ],
  131. [
  132. AC_MSG_RESULT([no])
  133. AC_DEFINE_UNQUOTED([HAVE_PATH_MAX], 0, [Define to 1 if you have the PATH_MAX macro.])
  134. ]
  135. )
  136. # The check for mbrlen, wcsrtombs and mbsrtowcs gives a false
  137. # positive on HP-UX, so we use a different snippet to set the
  138. # corresponding macro
  139. AC_MSG_CHECKING([for mbrlen])
  140. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <wchar.h>]],
  141. [[mbstate_t st; mbrlen( "t", 5, &st );]])],
  142. [
  143. AC_MSG_RESULT([yes])
  144. AC_DEFINE_UNQUOTED([HAVE_MBRLEN], 1, [Define to 1 if you have the `mbrlen' function.])
  145. ],
  146. [
  147. AC_MSG_RESULT([no])
  148. AC_DEFINE_UNQUOTED([HAVE_MBRLEN], 0, [Define to 1 if you have the `mbrlen' function.])
  149. ]
  150. )
  151. AC_MSG_CHECKING([for wcsrtombs])
  152. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <wchar.h>]],
  153. [[mbstate_t st; char buffer[2]; const wchar_t* src=0; wcsrtombs(buffer, &src, 2, &st);]])],
  154. [
  155. AC_MSG_RESULT([yes])
  156. AC_DEFINE_UNQUOTED([HAVE_WCSRTOMBS], 1, [Define to 1 if you have the `wcsrtombs' function.])
  157. ],
  158. [
  159. AC_MSG_RESULT([no])
  160. AC_DEFINE_UNQUOTED([HAVE_WCSRTOMBS], 0, [Define to 1 if you have the `wcsrtombs' function.])
  161. ]
  162. )
  163. AC_MSG_CHECKING([for mbsrtowcs])
  164. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <wchar.h>]],
  165. [[mbstate_t st; wchar_t buffer[2]; const char* src=0; mbsrtowcs(buffer, &src, 2, &st);]])],
  166. [
  167. AC_MSG_RESULT([yes])
  168. AC_DEFINE_UNQUOTED([HAVE_MBSRTOWCS], 1, [Define to 1 if you have the `mbsrtowcs' function.])
  169. ],
  170. [
  171. AC_MSG_RESULT([no])
  172. AC_DEFINE_UNQUOTED([HAVE_MBSRTOWCS], 0, [Define to 1 if you have the `mbsrtowcs' function.])
  173. ]
  174. )
  175. AC_MSG_CHECKING([if iconv uses const pointers])
  176. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <iconv.h>]],
  177. [[
  178. const char *fromPtr=0;
  179. size_t fromLen=0;
  180. char *toPtr=0;
  181. size_t toLen=0;
  182. iconv_t cv=0;
  183. iconv(cv, &fromPtr, &fromLen, &toPtr, &toLen);
  184. ]])],
  185. [
  186. AC_MSG_RESULT([yes])
  187. 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*.])
  188. ],
  189. [
  190. AC_MSG_RESULT([no])
  191. 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*.])
  192. ]
  193. )
  194. AC_SUBST([SHREXT], [$shrext_cmds])
  195. #
  196. # Orchestrate the replacement of missing functions
  197. #
  198. AC_REPLACE_FUNCS([stricmp strnicmp towlower towupper])
  199. abs_top_srcdir=`cd $srcdir; pwd`
  200. AC_SUBST(abs_top_srcdir)
  201. abs_top_builddir=`pwd`
  202. AC_SUBST(abs_top_builddir)
  203. ######################################################
  204. # Look for availability of available packages
  205. ######################################################
  206. XERCES_PRETTY_MAKE
  207. XERCES_PATH_DELIMITERS
  208. XERCES_MUTEXMGR_SELECTION
  209. XERCES_NETACCESSOR_SELECTION
  210. XERCES_TRANSCODER_SELECTION
  211. XERCES_MSGLOADER_SELECTION
  212. XERCES_FILEMGR_SELECTION
  213. # Allow the user to specify the pkgconfig directory.
  214. #
  215. AC_ARG_WITH(pkgconfigdir,
  216. AC_HELP_STRING([--with-pkgconfigdir=DIR],[Specify location of pkgconfig dir (default is libdir/pkgconfig)]),
  217. [pkgconfigdir=${withval}],
  218. [pkgconfigdir='${libdir}/pkgconfig'])
  219. AC_SUBST([pkgconfigdir])
  220. # Allow the user to disable the SSE2 support
  221. #
  222. AC_ARG_ENABLE(sse2,
  223. AC_HELP_STRING([--disable-sse2],[disable SSE2 optimizations]),
  224. [have_sse2=${enableval}],
  225. [have_sse2=yes])
  226. ######################################################
  227. # Define some namespace-protected macros for use in the
  228. # publicly visible Xerces_autoconf_config.h file.
  229. ######################################################
  230. AC_DEFINE([XERCES_AUTOCONF], 1, [Define to true if autoconf is used in this configuration])
  231. AS_IF([test x$ac_cv_header_sys_types_h = xyes],
  232. AC_DEFINE([XERCES_HAVE_SYS_TYPES_H], 1, [Define to 1 if we have sys/types.h]))
  233. AS_IF([test x$ac_cv_header_inttypes_h = xyes],
  234. AC_DEFINE([XERCES_HAVE_INTTYPES_H], 1, [Define to 1 if we have inttypes.h]))
  235. case $host in
  236. *-*-msdos* | *-*-mingw32* | *-*-cygwin* | *-*-windows* )
  237. platform_export="__declspec(dllexport)"
  238. platform_import="__declspec(dllimport)"
  239. ;;
  240. * )
  241. platform_export=""
  242. platform_import=""
  243. ;;
  244. esac
  245. AC_DEFINE_UNQUOTED([XERCES_PLATFORM_EXPORT], [$platform_export], [Define as the platform's export attribute])
  246. AC_DEFINE_UNQUOTED([XERCES_PLATFORM_IMPORT], [$platform_import], [Define as the platform's import attribute])
  247. AS_IF([test ! $ac_cv_cxx_have_bool],
  248. AC_DEFINE([XERCES_NO_NATIVE_BOOL], 1, [Define if there is no native bool support in this environment]))
  249. AS_IF([test $ac_cv_cxx_have_lstring],
  250. AC_DEFINE([XERCES_LSTRSUPPORT], 1, [Define if there is support for L"widestring"]))
  251. # 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
  252. # (this is safe because on Windows wchar_t is used to store UTF-16 codepoints, while it is not true on Unix)
  253. AC_MSG_CHECKING([whether the Windows SDK is available and using wchar_t as wide string])
  254. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <windows.h>
  255. wchar_t file[] = L"dummy.file";]],
  256. [[DeleteFileW(file);]])],
  257. [
  258. xerces_cv_type_xmlch=wchar_t
  259. AC_MSG_RESULT([yes])
  260. AC_DEFINE_UNQUOTED([XERCES_INCLUDE_WCHAR_H], 1, [Define to have Xerces_autoconf_config.hpp include wchar.h])
  261. ],
  262. [
  263. xerces_cv_type_xmlch=$xerces_cv_type_u16bit_int
  264. AC_MSG_RESULT([no])
  265. ]
  266. )
  267. AC_DEFINE_UNQUOTED([XERCES_XMLCH_T], [$xerces_cv_type_xmlch], [Define to the 16 bit type used to represent Xerces UTF-16 characters])
  268. AC_MSG_CHECKING([whether the compiler chokes on a placement operator delete])
  269. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <stdlib.h>
  270. class XMemory
  271. {
  272. public :
  273. void* operator new(size_t s) { return 0; }
  274. void* operator new(size_t s, void* ptr) { return 0; }
  275. void operator delete(void* p) {}
  276. void operator delete(void* p, void* ptr) {}
  277. };]],
  278. [[ ]])],
  279. [
  280. AC_MSG_RESULT([no])
  281. ],
  282. [
  283. AC_MSG_RESULT([yes])
  284. 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])
  285. ]
  286. )
  287. if test "$have_sse2" = "yes"; then
  288. no_sse2_CXXFLAGS="$CXXFLAGS"
  289. save_CXXFLAGS="$CXXFLAGS"
  290. CXXFLAGS="$CXXFLAGS -msse2"
  291. AC_MSG_CHECKING([whether we need to add -msse2])
  292. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <emmintrin.h>]], [[__m128i one;]])],
  293. [msse2_ok=yes],
  294. [msse2_ok=no]
  295. )
  296. AC_MSG_RESULT($msse2_ok)
  297. if test x"$msse2_ok" = xno; then
  298. CXXFLAGS="$save_CXXFLAGS"
  299. fi
  300. # Sun CC option test. Currently disabled since it doesn't work. Also note
  301. # that Sun CC will accept -msse2 (i.e., it won't fail) but will keep issuing
  302. # warnings. So if enabled this test needs to be moved before -msse2 and if
  303. # it passes, then -msse2 should be skipped.
  304. #
  305. # save_CXXFLAGS="$CXXFLAGS"
  306. # CXXFLAGS="$CXXFLAGS -xarch=sse2"
  307. # AC_MSG_CHECKING([whether we need to add -xarch=sse2])
  308. # AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <emmintrin.h>]], [[__m128i one;]])],
  309. # [xarchsse2_ok=yes],
  310. # [xarchsse2_ok=no]
  311. # )
  312. # AC_MSG_RESULT($xarchsse2_ok)
  313. # if test x"$xarchsse2_ok" = xno; then
  314. # CXXFLAGS="$save_CXXFLAGS"
  315. # fi
  316. AC_MSG_CHECKING([for intrin.h usability])
  317. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <intrin.h>]],
  318. [[]])],
  319. [
  320. AC_MSG_RESULT([yes])
  321. AC_DEFINE_UNQUOTED([XERCES_HAVE_INTRIN_H], 1, [Define to 1 if you have intrin.h])
  322. ],
  323. [
  324. AC_MSG_RESULT([no])
  325. ]
  326. )
  327. AC_MSG_CHECKING([for emmintrin.h usability])
  328. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <emmintrin.h>]],
  329. [[]])],
  330. [
  331. AC_MSG_RESULT([yes])
  332. AC_DEFINE_UNQUOTED([XERCES_HAVE_EMMINTRIN_H], 1, [Define to 1 if you have emmintrin.h])
  333. ],
  334. [
  335. AC_MSG_RESULT([no])
  336. ]
  337. )
  338. AC_MSG_CHECKING([for cpuid.h usability])
  339. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <cpuid.h>]],
  340. [[]])],
  341. [
  342. AC_MSG_RESULT([yes])
  343. AC_DEFINE_UNQUOTED([HAVE_CPUID_H], 1, [Define to 1 if you have cpuid.h])
  344. ],
  345. [
  346. AC_MSG_RESULT([no])
  347. ]
  348. )
  349. AC_MSG_CHECKING([whether the compiler has the CPUID intrinsic])
  350. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <intrin.h>]],
  351. [[int CPUInfo[4];
  352. __cpuid(CPUInfo, 1);
  353. ]])],
  354. [
  355. AC_MSG_RESULT([yes])
  356. AC_DEFINE_UNQUOTED([XERCES_HAVE_CPUID_INTRINSIC], 1, [Define to have SSE2 instruction support detected at runtime using __cpuid])
  357. ],
  358. [
  359. AC_MSG_RESULT([no])
  360. ]
  361. )
  362. AC_MSG_CHECKING([whether the compiler has the _get_cpuid intrinsic])
  363. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <cpuid.h>]],
  364. [[unsigned int eax, ebx, ecx, edx;
  365. __get_cpuid (1, &eax, &ebx, &ecx, &edx);
  366. ]])],
  367. [
  368. AC_MSG_RESULT([yes])
  369. AC_DEFINE_UNQUOTED([XERCES_HAVE_GETCPUID], 1, [Define to have SSE2 instruction support detected at runtime using __get_cpuid])
  370. ],
  371. [
  372. AC_MSG_RESULT([no])
  373. ]
  374. )
  375. AC_MSG_CHECKING([whether the compiler has the SSE2 intrinsic])
  376. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <emmintrin.h>]],
  377. [[__m128i* one=(__m128i*)_mm_malloc(4, 16);
  378. __m128i* two=(__m128i*)_mm_malloc(4, 16);
  379. __m128i xmm1 = _mm_load_si128(one);
  380. __m128i xmm2 = _mm_load_si128(two);
  381. __m128i xmm3 = _mm_or_si128(xmm1, xmm2);
  382. _mm_store_si128(one, xmm3);
  383. _mm_free(one);
  384. _mm_free(two);
  385. ]])],
  386. [
  387. AC_MSG_RESULT([yes])
  388. sse2_usable=yes
  389. AC_DEFINE_UNQUOTED([XERCES_HAVE_SSE2_INTRINSIC], 1, [Define to have SSE2 instruction used at runtime])
  390. ],
  391. [
  392. AC_MSG_RESULT([no])
  393. sse2_usable=no
  394. ]
  395. )
  396. # Restore original CXXFLAGS if SSE2 is not usable.
  397. #
  398. if test "$sse2_usable" = "no"; then
  399. CXXFLAGS="$no_sse2_CXXFLAGS"
  400. fi
  401. fi
  402. AS_IF([test x$ac_cv_type_size_t = xyes],
  403. AC_DEFINE([XERCES_SIZE_T], [size_t], [Define as the appropriate size_t type]),
  404. AC_DEFINE([XERCES_SIZE_T], [long], [Define as the appropriate size_t type]))
  405. AS_IF([test x$ac_cv_type_ssize_t = xyes],
  406. AC_DEFINE([XERCES_SSIZE_T], [ssize_t], [Define as the appropriate ssize_t type]),
  407. AC_DEFINE([XERCES_SSIZE_T], [unsigned long], [Define as the appropriate ssize_t type]))
  408. AS_IF([test x$ac_cv_cxx_have_namespaces = xyes],
  409. AC_DEFINE([XERCES_HAS_CPP_NAMESPACE], 1, [Define if namespaces is supported by the compiler]))
  410. AS_IF([test x$ac_cv_cxx_have_std_namespace = xyes],
  411. AC_DEFINE([XERCES_STD_NAMESPACE], 1, [Define if the std namespace is supported]))
  412. AS_IF([test x$ac_cv_cxx_have_std_libs = xyes],
  413. AC_DEFINE([XERCES_NEW_IOSTREAMS], 1, [Define if the isstream library can be included as <iostream>]))
  414. AC_OUTPUT
  415. AC_MSG_NOTICE
  416. AC_MSG_NOTICE([Report:])
  417. AC_MSG_NOTICE([ File Manager: $filemgr])
  418. AC_MSG_NOTICE([ Mutex Manager: $mutexmgr])
  419. AC_MSG_NOTICE([ Transcoder: $transcoder])
  420. AC_MSG_NOTICE([ NetAccessor: $netaccessor])
  421. AC_MSG_NOTICE([ Message Loader: $msgloader])