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.

378 lines
13 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. AC_INIT(csoap, 1.1.0)
  2. AC_CONFIG_SRCDIR([nanohttp/nanohttp-server.c])
  3. AC_CONFIG_SRCDIR([libcsoap/soap-server.c])
  4. AM_INIT_AUTOMAKE
  5. AM_CONFIG_HEADER(config.h)
  6. dnl
  7. dnl checks for programs
  8. dnl
  9. AC_LANG_C
  10. AC_PROG_CC
  11. AC_PROG_AWK
  12. AC_PROG_INSTALL
  13. AC_PROG_LIBTOOL
  14. dnl
  15. dnl release and version information
  16. dnl
  17. csoap_major=`echo $VERSION | $AWK -F. '{print $1}'`
  18. csoap_minor=`echo $VERSION | $AWK -F. '{print $2}'`
  19. csoap_patch=`echo $VERSION | $AWK -F. '{print $3}'`
  20. AC_SUBST(csoap_major)
  21. AC_SUBST(csoap_minor)
  22. AC_SUBST(csoap_patch)
  23. csoap_release="$csoap_major.$csoap_minor"
  24. csoap_version=`expr $csoap_major + $csoap_minor`":$csoap_patch:$csoap_minor"
  25. AC_SUBST(csoap_release)
  26. AC_SUBST(csoap_version)
  27. nanohttp_release=$csoap_release
  28. nanohttp_version=$csoap_version
  29. AC_SUBST(nanohttp_release)
  30. AC_SUBST(nanohttp_version)
  31. dnl
  32. dnl checks for headers
  33. dnl
  34. AC_HEADER_STDC
  35. AC_HEADER_TIME
  36. AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h malloc.h netdb.h netinet/in.h stdint.h stdlib.h signal.h pthread.h string.h sys/socket.h sys/time.h unistd.h io.h stdio.h stdarg.h errno.h ctype.h openssl/rand.h openssl/err.h])
  37. dnl
  38. dnl Checks for typedefs, structures, and compiler characteristics.
  39. dnl
  40. AC_C_CONST
  41. AC_STRUCT_TM
  42. AC_TYPE_SIGNAL
  43. AC_TYPE_SIZE_T
  44. AC_CHECK_TYPE(ssize_t, int)
  45. dnl
  46. dnl check for functions
  47. dnl
  48. AC_FUNC_MALLOC
  49. AC_FUNC_VPRINTF
  50. AC_FUNC_STRFTIME
  51. AC_FUNC_SELECT_ARGTYPES
  52. AC_CHECK_FUNCS([gethostbyname inet_ntoa memmove memset mkdir select socket strchr strdup strncasecmp strpbrk strspn strstr strtol])
  53. dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
  54. dnl
  55. dnl @summary figure out how to build C programs using POSIX threads
  56. dnl
  57. dnl This macro figures out how to build C programs using POSIX threads.
  58. dnl It sets the PTHREAD_LIBS output variable to the threads library and
  59. dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
  60. dnl C compiler flags that are needed. (The user can also force certain
  61. dnl compiler flags/libs to be tested by setting these environment
  62. dnl variables.)
  63. dnl
  64. dnl Also sets PTHREAD_CC to any special C compiler that is needed for
  65. dnl multi-threaded programs (defaults to the value of CC otherwise).
  66. dnl (This is necessary on AIX to use the special cc_r compiler alias.)
  67. dnl
  68. dnl NOTE: You are assumed to not only compile your program with these
  69. dnl flags, but also link it with them as well. e.g. you should link
  70. dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
  71. dnl $LIBS
  72. dnl
  73. dnl If you are only building threads programs, you may wish to use
  74. dnl these variables in your default LIBS, CFLAGS, and CC:
  75. dnl
  76. dnl LIBS="$PTHREAD_LIBS $LIBS"
  77. dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  78. dnl CC="$PTHREAD_CC"
  79. dnl
  80. dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
  81. dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
  82. dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
  83. dnl
  84. dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
  85. dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
  86. dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
  87. dnl default action will define HAVE_PTHREAD.
  88. dnl
  89. dnl Please let the authors know if this macro fails on any platform, or
  90. dnl if you have any other suggestions or comments. This macro was based
  91. dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
  92. dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
  93. dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
  94. dnl We are also grateful for the helpful feedback of numerous users.
  95. dnl
  96. dnl @category InstalledPackages
  97. dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
  98. dnl @version 2006-05-29
  99. dnl @license GPLWithACException
  100. AC_DEFUN([ACX_PTHREAD], [
  101. AC_REQUIRE([AC_CANONICAL_HOST])
  102. AC_LANG_SAVE
  103. AC_LANG_C
  104. acx_pthread_ok=no
  105. # We used to check for pthread.h first, but this fails if pthread.h
  106. # requires special compiler flags (e.g. on True64 or Sequent).
  107. # It gets checked for in the link test anyway.
  108. # First of all, check if the user has set any of the PTHREAD_LIBS,
  109. # etcetera environment variables, and if threads linking works using
  110. # them:
  111. if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
  112. save_CFLAGS="$CFLAGS"
  113. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  114. save_LIBS="$LIBS"
  115. LIBS="$PTHREAD_LIBS $LIBS"
  116. AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
  117. AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
  118. AC_MSG_RESULT($acx_pthread_ok)
  119. if test x"$acx_pthread_ok" = xno; then
  120. PTHREAD_LIBS=""
  121. PTHREAD_CFLAGS=""
  122. fi
  123. LIBS="$save_LIBS"
  124. CFLAGS="$save_CFLAGS"
  125. fi
  126. # We must check for the threads library under a number of different
  127. # names; the ordering is very important because some systems
  128. # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
  129. # libraries is broken (non-POSIX).
  130. # Create a list of thread flags to try. Items starting with a "-" are
  131. # C compiler flags, and other items are library names, except for "none"
  132. # which indicates that we try without any flags at all, and "pthread-config"
  133. # which is a program returning the flags for the Pth emulation library.
  134. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
  135. # The ordering *is* (sometimes) important. Some notes on the
  136. # individual items follow:
  137. # pthreads: AIX (must check this before -lpthread)
  138. # none: in case threads are in libc; should be tried before -Kthread and
  139. # other compiler flags to prevent continual compiler warnings
  140. # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
  141. # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
  142. # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
  143. # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
  144. # -pthreads: Solaris/gcc
  145. # -mthreads: Mingw32/gcc, Lynx/gcc
  146. # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
  147. # doesn't hurt to check since this sometimes defines pthreads too;
  148. # also defines -D_REENTRANT)
  149. # ... -mt is also the pthreads flag for HP/aCC
  150. # pthread: Linux, etcetera
  151. # --thread-safe: KAI C++
  152. # pthread-config: use pthread-config program (for GNU Pth library)
  153. case "${host_cpu}-${host_os}" in
  154. *solaris*)
  155. # On Solaris (at least, for some versions), libc contains stubbed
  156. # (non-functional) versions of the pthreads routines, so link-based
  157. # tests will erroneously succeed. (We need to link with -pthreads/-mt/
  158. # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
  159. # a function called by this macro, so we could check for that, but
  160. # who knows whether they'll stub that too in a future libc.) So,
  161. # we'll just look for -pthreads and -lpthread first:
  162. acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
  163. ;;
  164. esac
  165. if test x"$acx_pthread_ok" = xno; then
  166. for flag in $acx_pthread_flags; do
  167. case $flag in
  168. none)
  169. AC_MSG_CHECKING([whether pthreads work without any flags])
  170. ;;
  171. -*)
  172. AC_MSG_CHECKING([whether pthreads work with $flag])
  173. PTHREAD_CFLAGS="$flag"
  174. ;;
  175. pthread-config)
  176. AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
  177. if test x"$acx_pthread_config" = xno; then continue; fi
  178. PTHREAD_CFLAGS="`pthread-config --cflags`"
  179. PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
  180. ;;
  181. *)
  182. AC_MSG_CHECKING([for the pthreads library -l$flag])
  183. PTHREAD_LIBS="-l$flag"
  184. ;;
  185. esac
  186. save_LIBS="$LIBS"
  187. save_CFLAGS="$CFLAGS"
  188. LIBS="$PTHREAD_LIBS $LIBS"
  189. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  190. # Check for various functions. We must include pthread.h,
  191. # since some functions may be macros. (On the Sequent, we
  192. # need a special flag -Kthread to make this header compile.)
  193. # We check for pthread_join because it is in -lpthread on IRIX
  194. # while pthread_create is in libc. We check for pthread_attr_init
  195. # due to DEC craziness with -lpthreads. We check for
  196. # pthread_cleanup_push because it is one of the few pthread
  197. # functions on Solaris that doesn't have a non-functional libc stub.
  198. # We try pthread_create on general principles.
  199. AC_TRY_LINK([#include <pthread.h>],
  200. [pthread_t th; pthread_join(th, 0);
  201. pthread_attr_init(0); pthread_cleanup_push(0, 0);
  202. pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
  203. [acx_pthread_ok=yes])
  204. LIBS="$save_LIBS"
  205. CFLAGS="$save_CFLAGS"
  206. AC_MSG_RESULT($acx_pthread_ok)
  207. if test "x$acx_pthread_ok" = xyes; then
  208. break;
  209. fi
  210. PTHREAD_LIBS=""
  211. PTHREAD_CFLAGS=""
  212. done
  213. fi
  214. # Various other checks:
  215. if test "x$acx_pthread_ok" = xyes; then
  216. save_LIBS="$LIBS"
  217. LIBS="$PTHREAD_LIBS $LIBS"
  218. save_CFLAGS="$CFLAGS"
  219. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  220. # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
  221. AC_MSG_CHECKING([for joinable pthread attribute])
  222. attr_name=unknown
  223. for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
  224. AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
  225. [attr_name=$attr; break])
  226. done
  227. AC_MSG_RESULT($attr_name)
  228. if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
  229. AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
  230. [Define to necessary symbol if this constant
  231. uses a non-standard name on your system.])
  232. fi
  233. AC_MSG_CHECKING([if more special flags are required for pthreads])
  234. flag=no
  235. case "${host_cpu}-${host_os}" in
  236. *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
  237. *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
  238. esac
  239. AC_MSG_RESULT(${flag})
  240. if test "x$flag" != xno; then
  241. PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
  242. fi
  243. LIBS="$save_LIBS"
  244. CFLAGS="$save_CFLAGS"
  245. # More AIX lossage: must compile with xlc_r or cc_r
  246. if test x"$GCC" != xyes; then
  247. AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
  248. else
  249. PTHREAD_CC=$CC
  250. fi
  251. else
  252. PTHREAD_CC="$CC"
  253. fi
  254. AC_SUBST(PTHREAD_LIBS)
  255. AC_SUBST(PTHREAD_CFLAGS)
  256. AC_SUBST(PTHREAD_CC)
  257. # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
  258. if test x"$acx_pthread_ok" = xyes; then
  259. ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
  260. :
  261. else
  262. acx_pthread_ok=no
  263. $2
  264. fi
  265. AC_LANG_RESTORE
  266. ])dnl ACX_PTHREAD
  267. ACX_PTHREAD(LIBS="$PTHREAD_LIBS $LIBS"; CFLAGS="$PTHREAD_CFLAGS $CFLAGS",)
  268. AC_CHECK_FUNCS([localtime_r strtok_r])
  269. # ------------------------------------------
  270. # Check socket library (for Solaris)
  271. # ------------------------------------------
  272. AC_CHECK_LIB(socket, socket, [LIBSOCKET="-lsocket"])
  273. AC_SUBST(LIBSOCKET)
  274. AC_CHECK_LIB(nsl, inet_ntoa, [LIBNSL="-lnsl"])
  275. AC_CHECK_LIB(nsl, gethostbyname, [LIBNSL="-lnsl"])
  276. AC_SUBST(LIBNSL)
  277. AM_PATH_XML2(2.6.0,CFLAGS="$CFLAGS $XML_CPPFLAGS"; LDFLAGS="$LDFLAGS $XML_LIBS",exit 1)
  278. # ------------------------------------------
  279. # Check ssl library
  280. # Original work at: http://autoconf-archive.cryp.to/check_ssl.html
  281. # ------------------------------------------
  282. AC_DEFUN([CHECK_SSL],
  283. [AC_MSG_CHECKING(if ssl is wanted)
  284. AC_ARG_WITH(ssl,
  285. [ --with-ssl=PFX will check PFX for ssl library
  286. --with-ssl will check /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr for ssl library
  287. ],
  288. [ AC_MSG_RESULT(yes)
  289. for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
  290. ssldir="$dir"
  291. if test -f "$dir/include/openssl/ssl.h"; then
  292. found_ssl="yes";
  293. CFLAGS="$CFLAGS -I$ssldir/include/openssl";
  294. break;
  295. fi
  296. if test -f "$dir/include/ssl.h"; then
  297. found_ssl="yes";
  298. CFLAGS="$CFLAGS -I$ssldir/include";
  299. break
  300. fi
  301. done
  302. if test x_$found_ssl != x_yes; then
  303. AC_MSG_ERROR(Cannot find ssl libraries
  304. Please goto http://www.openssl.org and install OpenSSL or
  305. install it from your os distribution)
  306. else
  307. printf "OpenSSL found in $ssldir\n";
  308. LIBS="$LIBS -lssl -lcrypto";
  309. LDFLAGS="$LDFLAGS -L$ssldir/lib";
  310. AC_DEFINE(HAVE_SSL,1,Define to 1 if you have requested --with-ssl)
  311. fi
  312. ],
  313. [
  314. AC_MSG_RESULT(no)
  315. ])
  316. ])dnl
  317. CHECK_SSL
  318. AC_OUTPUT(Makefile
  319. libcsoap/Makefile
  320. nanohttp/Makefile
  321. examples/Makefile
  322. examples/nanohttp/Makefile
  323. examples/csoap/Makefile
  324. libcsoap.pc
  325. csoap-config)
  326. echo "Configured cSOAP $csoap_major.$csoap_minor.$csoap_patch for installation in $prefix";