configure.ac 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. dnl
  2. dnl "$Id: configure.ac 462 2016-06-11 20:51:49Z msweet $"
  3. dnl
  4. dnl Configuration script for Mini-XML, a small XML-like file parsing library.
  5. dnl
  6. dnl Copyright 2003-2016 by Michael R Sweet.
  7. dnl
  8. dnl These coded instructions, statements, and computer programs are the
  9. dnl property of Michael R Sweet and are protected by Federal copyright
  10. dnl law. Distribution and use rights are outlined in the file "COPYING"
  11. dnl which should have been included with this file. If this file is
  12. dnl missing or damaged, see the license at:
  13. dnl
  14. dnl http://www.msweet.org/projects.php/Mini-XML
  15. dnl
  16. dnl Package name and version...
  17. AC_INIT([Mini-XML], [2.10], [http://www.msweet.org/bugs.php/Mini-XML], [mxml], [http://www.msweet.org/projects.php/Mini-XML])
  18. dnl Set the name of the config header file...
  19. AC_CONFIG_HEADER(config.h)
  20. dnl Version number...
  21. VERSION="AC_PACKAGE_VERSION"
  22. AC_SUBST(VERSION)
  23. AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")
  24. dnl Clear default debugging options and set normal optimization by
  25. dnl default unless the user asks for debugging specifically.
  26. CFLAGS="${CFLAGS:=}"
  27. CXXFLAGS="${CXXFLAGS:=}"
  28. LDFLAGS="${LDFLAGS:=}"
  29. AC_SUBST(LDFLAGS)
  30. OPTIM=""
  31. AC_SUBST(OPTIM)
  32. AC_ARG_WITH(ansi, [ --with-ansi set full ANSI C mode, default=no],
  33. use_ansi="$withval",
  34. use_ansi="no")
  35. AC_ARG_WITH(archflags, [ --with-archflags set additional architecture flags, default=none],
  36. ARCHFLAGS="$withval",
  37. ARCHFLAGS="")
  38. AC_SUBST(ARCHFLAGS)
  39. AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
  40. if eval "test x$enable_debug = xyes"; then
  41. OPTIM="-g"
  42. fi)
  43. AC_ARG_WITH(docdir, [ --with-docdir set directory for documentation, default=${prefix}/share/doc/mxml],
  44. docdir="$withval",
  45. docdir="NONE")
  46. AC_SUBST(docdir)
  47. AC_ARG_WITH(vsnprintf, [ --with-vsnprintf use vsnprintf emulation functions, default=auto],
  48. use_vsnprintf="$withval",
  49. use_vsnprintf="no")
  50. dnl Get the operating system and version number...
  51. uname=`uname`
  52. uversion=`uname -r | sed -e '1,$s/[[^0-9]]//g'`
  53. if test x$uname = xIRIX64; then
  54. uname="IRIX"
  55. fi
  56. dnl Checks for programs...
  57. AC_PROG_CC
  58. AC_PROG_CXX
  59. AC_PROG_INSTALL
  60. if test "$INSTALL" = "$ac_install_sh"; then
  61. # Use full path to install-sh script...
  62. INSTALL="`pwd`/install-sh -c"
  63. fi
  64. AC_PROG_RANLIB
  65. AC_PATH_PROG(AR,ar)
  66. AC_PATH_PROG(CP,cp)
  67. AC_PATH_PROG(LN,ln)
  68. AC_PATH_PROG(MKDIR,mkdir)
  69. AC_PATH_PROG(RM,rm)
  70. dnl Flags for "ar" command...
  71. case "$uname" in
  72. Darwin* | *BSD*)
  73. ARFLAGS="-rcv"
  74. ;;
  75. *)
  76. ARFLAGS="crvs"
  77. ;;
  78. esac
  79. AC_SUBST(ARFLAGS)
  80. dnl Inline functions...
  81. AC_C_INLINE
  82. dnl Checks for string functions.
  83. if test "x$use_ansi" != xyes; then
  84. AC_CHECK_FUNCS(strdup)
  85. fi
  86. if test "x$use_vsnprintf" != xyes; then
  87. AC_CHECK_FUNCS(snprintf vsnprintf)
  88. fi
  89. dnl Check for "long long" support...
  90. AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
  91. [if test "$GCC" = yes; then
  92. ac_cv_c_long_long=yes
  93. else
  94. AC_TRY_COMPILE(,[long long int i;],
  95. ac_cv_c_long_long=yes,
  96. ac_cv_c_long_long=no)
  97. fi])
  98. if test $ac_cv_c_long_long = yes; then
  99. AC_DEFINE(HAVE_LONG_LONG)
  100. fi
  101. dnl Threading support
  102. AC_ARG_ENABLE(threads, [ --enable-threads enable multi-threading support])
  103. have_pthread=no
  104. PTHREAD_FLAGS=""
  105. PTHREAD_LIBS=""
  106. if test "x$enable_threads" != xno; then
  107. AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
  108. if test x$ac_cv_header_pthread_h = xyes; then
  109. dnl Check various threading options for the platforms we support
  110. for flag in -lpthreads -lpthread -pthread; do
  111. AC_MSG_CHECKING([for pthread_create using $flag])
  112. SAVELIBS="$LIBS"
  113. LIBS="$flag $LIBS"
  114. AC_TRY_LINK([#include <pthread.h>],
  115. [pthread_create(0, 0, 0, 0);],
  116. have_pthread=yes)
  117. AC_MSG_RESULT([$have_pthread])
  118. LIBS="$SAVELIBS"
  119. if test $have_pthread = yes; then
  120. PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
  121. PTHREAD_LIBS="$flag"
  122. # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
  123. # be POSIX-compliant... :(
  124. if test $uname = SunOS; then
  125. PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
  126. fi
  127. break
  128. fi
  129. done
  130. fi
  131. fi
  132. AC_SUBST(PTHREAD_FLAGS)
  133. AC_SUBST(PTHREAD_LIBS)
  134. dnl Shared library support...
  135. DSO="${DSO:=:}"
  136. DSOFLAGS="${DSOFLAGS:=}"
  137. AC_ARG_ENABLE(shared, [ --enable-shared turn on shared libraries, default=no])
  138. if test x$enable_shared != xno; then
  139. AC_MSG_CHECKING(for shared library support)
  140. PICFLAG=1
  141. case "$uname" in
  142. SunOS* | UNIX_S*)
  143. AC_MSG_RESULT(yes)
  144. LIBMXML="libmxml.so.1.5"
  145. DSO="\$(CC)"
  146. DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)"
  147. LDFLAGS="$LDFLAGS -R\$(libdir)"
  148. ;;
  149. HP-UX*)
  150. AC_MSG_RESULT(yes)
  151. LIBMXML="libmxml.sl.1"
  152. DSO="ld"
  153. DSOFLAGS="$DSOFLAGS -b -z +h libmxml.sl.1 +s +b \$(libdir)"
  154. LDFLAGS="$LDFLAGS -Wl,+s,+b,\$(libdir)"
  155. ;;
  156. IRIX)
  157. AC_MSG_RESULT(yes)
  158. LIBMXML="libmxml.so.1.5"
  159. DSO="\$(CC)"
  160. DSOFLAGS="$DSOFLAGS -Wl,-rpath,\$(libdir),-set_version,sgi1.0,-soname,libmxml.so.1 -shared \$(OPTIM)"
  161. ;;
  162. OSF1* | Linux | GNU)
  163. AC_MSG_RESULT(yes)
  164. LIBMXML="libmxml.so.1.5"
  165. DSO="\$(CC)"
  166. DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)"
  167. LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)"
  168. ;;
  169. *BSD*)
  170. AC_MSG_RESULT(yes)
  171. LIBMXML="libmxml.so.1.5"
  172. DSO="\$(CC)"
  173. DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)"
  174. LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)"
  175. ;;
  176. Darwin*)
  177. AC_MSG_RESULT(yes)
  178. LIBMXML="libmxml.1.dylib"
  179. DSO="\$(CC)"
  180. DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -lc"
  181. ;;
  182. *)
  183. AC_MSG_RESULT(no)
  184. AC_MSG_WARN(shared libraries not supported on this platform.)
  185. PICFLAG=0
  186. LIBMXML="libmxml.a"
  187. ;;
  188. esac
  189. else
  190. PICFLAG=0
  191. LIBMXML="libmxml.a"
  192. fi
  193. AC_SUBST(DSO)
  194. AC_SUBST(DSOFLAGS)
  195. AC_SUBST(LIBMXML)
  196. AC_SUBST(PICFLAG)
  197. dnl Add -Wall for GCC...
  198. if test -n "$GCC"; then
  199. CFLAGS="-Wall $CFLAGS"
  200. if test "x$OPTIM" = x; then
  201. OPTIM="-Os -g"
  202. fi
  203. if test "x$use_ansi" = xyes; then
  204. CFLAGS="-ansi -pedantic $CFLAGS"
  205. fi
  206. if test $PICFLAG = 1 -a $uname != AIX; then
  207. OPTIM="-fPIC $OPTIM"
  208. fi
  209. else
  210. case $uname in
  211. HP-UX*)
  212. CFLAGS="-Ae $CFLAGS"
  213. if test "x$OPTIM" = x; then
  214. OPTIM="-O"
  215. fi
  216. OPTIM="+DAportable $OPTIM"
  217. if test $PICFLAG = 1; then
  218. OPTIM="+z $OPTIM"
  219. fi
  220. ;;
  221. UNIX_SVR* | SunOS*)
  222. if test "x$OPTIM" = x; then
  223. OPTIM="-O"
  224. fi
  225. if test $PICFLAG = 1; then
  226. OPTIM="-KPIC $OPTIM"
  227. fi
  228. ;;
  229. *)
  230. if test "x$OPTIM" = x; then
  231. OPTIM="-O"
  232. fi
  233. ;;
  234. esac
  235. fi
  236. dnl Fix "prefix" variable if it hasn't been specified...
  237. if test "$prefix" = "NONE"; then
  238. prefix="/usr/local"
  239. fi
  240. dnl Fix "exec_prefix" variable if it hasn't been specified...
  241. if test "$exec_prefix" = "NONE"; then
  242. exec_prefix="$prefix"
  243. fi
  244. dnl Fix "docdir" variable if it hasn't been specified...
  245. if test "$docdir" = "NONE"; then
  246. docdir="$datadir/doc/mxml"
  247. fi
  248. dnl Fix "mandir" variable if it hasn't been specified...
  249. if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"; then
  250. case "$uname" in
  251. *BSD* | Darwin* | Linux*)
  252. # BSD, Darwin (MacOS X), and Linux
  253. mandir="/usr/share/man"
  254. ;;
  255. IRIX*)
  256. # SGI IRIX
  257. mandir="/usr/share/catman/u_man"
  258. ;;
  259. *)
  260. # All others
  261. mandir="/usr/man"
  262. ;;
  263. esac
  264. fi
  265. dnl pkg-config stuff...
  266. if test "$includedir" != /usr/include; then
  267. PC_CFLAGS="-I$includedir"
  268. else
  269. PC_CFLAGS=""
  270. fi
  271. if test "$libdir" != /usr/lib; then
  272. PC_LIBS="-L$libdir -lmxml"
  273. else
  274. PC_LIBS="-lmxml"
  275. fi
  276. AC_SUBST(PC_CFLAGS)
  277. AC_SUBST(PC_LIBS)
  278. dnl Output the makefile, etc...
  279. AC_OUTPUT(Makefile mxml.list mxml.pc)
  280. dnl
  281. dnl End of "$Id: configure.ac 462 2016-06-11 20:51:49Z msweet $".
  282. dnl