configure.in 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. dnl
  2. dnl autoconf script for UNP 3/e Volume 1 source code.
  3. dnl Process this file with autoconf to produce a configure script.
  4. dnl
  5. dnl The end result of running configure is the "config.h" file and the
  6. dnl "Make.defines" file in the current directory. These two files are
  7. dnl created from the "config.h.in" and "Make.defines.in" files in the
  8. dnl current directory.
  9. dnl
  10. dnl The header "unp.h" that is in every source directory then does a
  11. dnl #include "../config.h" and the Makefile in each source directory
  12. dnl then does a include of ../Make.defines.
  13. dnl
  14. AC_REVISION($Revision: 1.13 $)
  15. AC_INIT(lib/unp.h)
  16. AC_CANONICAL_HOST
  17. AC_CONFIG_HEADER(config.h)
  18. dnl The following cpu_vendor_os string goes into config.h.
  19. dnl
  20. AC_DEFINE_UNQUOTED(CPU_VENDOR_OS, "$host", [CPU, vendor, and operating system])
  21. dnl ##################################################################
  22. dnl Checks for programs.
  23. dnl
  24. dnl Some system-specific stuff ...
  25. dnl Some operating systems require additional flags in order to get all
  26. dnl the definitions that we're looking for in some system headers.
  27. dnl The configure script uses both CFLAGS and CPPFLAGS when compiling.
  28. case "$host_os" in
  29. *aix*) CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE" ;;
  30. *osf*) CPPFLAGS="$CPPFLAGS -D_SOCKADDR_LEN" ;;
  31. esac
  32. AC_PROG_CC
  33. AC_PROG_RANLIB
  34. dnl ##################################################################
  35. dnl Checks for libraries.
  36. dnl The order of these tests is the *reverse* order of the libraries in
  37. dnl the LIBS variable that is constructed: each new one gets prepended,
  38. dnl not appended.
  39. dnl
  40. dnl We are building three strings here; something like:
  41. dnl LIBS="-lresolv -lsocket -lnsl -lpthread"
  42. dnl LIBS_XTI="-lxti -lresolv -lnsl -lpthread"
  43. dnl LIBUNP="./libunp.a"
  44. dnl LIBUNPXTI="./libunpxti.a"
  45. dnl
  46. dnl If a threads library is found, need to update CFLAGS too.
  47. dnl
  48. AC_CHECK_LIB(pthread, pthread_create)
  49. if test "$ac_cv_lib_pthread_pthread_create" = yes ; then
  50. CFLAGS="$CFLAGS -D_REENTRANT"
  51. else
  52. AC_CHECK_LIB(pthreads, pthread_create)
  53. if test "$ac_cv_lib_pthreads_pthread_create" = yes ; then
  54. CFLAGS="$CFLAGS -D_REENTRANT"
  55. fi
  56. fi
  57. AC_CHECK_LIB(nsl, t_open)
  58. AC_SEARCH_LIBS(socket, socket)
  59. dnl Bind 8.1.1 places its library in /usr/local/bind/lib/libbind.a; we check
  60. dnl for it first. Also check for libbind.a in user's home directory.
  61. dnl If there is a libresolv.a in the user's HOME directory, we will use
  62. dnl that instead of -lresolv. Need this for people interested in building
  63. dnl an IPv6-knowledgable resolver, instead of using the system provided
  64. dnl resolver (which is often way out of date).
  65. dnl
  66. AC_MSG_CHECKING(for /usr/local/bind/lib/libbind.a)
  67. if test -f /usr/local/bind/lib/libbind.a ; then
  68. AC_MSG_RESULT(yes)
  69. LIBS="/usr/local/bind/lib/libbind.a $LIBS"
  70. else
  71. AC_MSG_RESULT(no)
  72. AC_MSG_CHECKING(for $HOME/libbind.a)
  73. if test -f $HOME/libbind.a ; then
  74. AC_MSG_RESULT(yes)
  75. LIBS="$HOME/libbind.a $LIBS"
  76. else
  77. AC_MSG_RESULT(no)
  78. AC_MSG_CHECKING(for $HOME/libresolv.a)
  79. if test -f $HOME/libresolv.a ; then
  80. AC_MSG_RESULT(yes)
  81. LIBS="$HOME/libresolv.a $LIBS"
  82. else
  83. AC_MSG_RESULT(no)
  84. AC_CHECK_LIB(resolv, res_init)
  85. fi
  86. fi
  87. fi
  88. dnl Now check for XTI library.
  89. dnl
  90. AC_CHECK_LIB(xti, t_open)
  91. dnl We now need to check for our own libraries, but we cannot prepend
  92. dnl them to the LIBS variable, as that variable is used when compiling
  93. dnl programs later in this script, and that would mess things up.
  94. dnl
  95. dnl If the user has a file named $HOME/libunp.a, then use it.
  96. dnl Else store our library in current directory.
  97. dnl I use this because my source directory is NFS mounted from my various
  98. dnl systems, but I have a unique home directory on each system.
  99. dnl
  100. AC_MSG_CHECKING(for $HOME/libunp.a)
  101. if test -f $HOME/libunp.a ; then
  102. AC_MSG_RESULT(yes)
  103. LIBUNP="$HOME/libunp.a"
  104. LIBUNP_NAME=$HOME/libunp.a
  105. else
  106. AC_MSG_RESULT(no, using ./libunp.a)
  107. LIBUNP="../libunp.a"
  108. LIBUNP_NAME=../libunp.a
  109. fi
  110. dnl If the user has a file named $HOME/libunpxti.a, then use it.
  111. dnl Else store our library in current directory.
  112. dnl Same reasoning as above.
  113. dnl
  114. AC_MSG_CHECKING(for $HOME/libunpxti.a)
  115. if test -f $HOME/libunpxti.a ; then
  116. AC_MSG_RESULT(yes)
  117. LIBUNPXTI="$HOME/libunpxti.a"
  118. LIBUNPXTI_NAME=$HOME/libunpxti.a
  119. else
  120. AC_MSG_RESULT(no, using ./libunpxti.a)
  121. LIBUNPXTI="../libunpxti.a"
  122. LIBUNPXTI_NAME=../libunpxti.a
  123. fi
  124. dnl ##################################################################
  125. dnl Checks for header files.
  126. dnl
  127. dnl The list of headers in the AC_CHECK_HEADERS macro is the same as in
  128. dnl our "unp.h" header, followed by our "unpxti.h" header.
  129. dnl
  130. AC_HEADER_STDC
  131. dnl
  132. dnl The includes (the 4th argument to AC_CHECK_HEADERS) here are
  133. dnl the defeault set ($ac_includes_default) plus <sys/param.h>
  134. dnl for <sys/sysctl.h> on NetBSD and OpenBSD.
  135. AC_CHECK_HEADERS(sys/types.h sys/socket.h sys/time.h time.h netinet/in.h arpa/inet.h errno.h fcntl.h netdb.h signal.h stdio.h stdlib.h string.h sys/stat.h sys/uio.h unistd.h sys/wait.h sys/un.h sys/param.h sys/select.h sys/sysctl.h poll.h sys/event.h strings.h sys/ioctl.h sys/filio.h sys/sockio.h pthread.h net/if_dl.h xti.h xti_inet.h netconfig.h netdir.h stropts.h, [], [], [
  136. #include <stdio.h>
  137. #if HAVE_SYS_TYPES_H
  138. # include <sys/types.h>
  139. #endif
  140. #if HAVE_SYS_STAT_H
  141. # include <sys/stat.h>
  142. #endif
  143. #if STDC_HEADERS
  144. # include <stdlib.h>
  145. # include <stddef.h>
  146. #else
  147. # if HAVE_STDLIB_H
  148. # include <stdlib.h>
  149. # endif
  150. #endif
  151. #if HAVE_STRING_H
  152. # if !STDC_HEADERS && HAVE_MEMORY_H
  153. # include <memory.h>
  154. # endif
  155. # include <string.h>
  156. #endif
  157. #if HAVE_STRINGS_H
  158. # include <strings.h>
  159. #endif
  160. #if HAVE_INTTYPES_H
  161. # include <inttypes.h>
  162. #else
  163. # if HAVE_STDINT_H
  164. # include <stdint.h>
  165. # endif
  166. #endif
  167. #if HAVE_UNISTD_H
  168. # include <unistd.h>
  169. #endif
  170. #if HAVE_SYS_PARAM_H
  171. # include <sys/param.h>
  172. #endif])
  173. dnl ##################################################################
  174. dnl Checks for typedefs.
  175. dnl
  176. dnl We use our own AC_UNP_CHECK_TYPE macro, instead of AC_CHECK_TYPE,
  177. dnl to #include more headers. Our macro is defined in "aclocal.m4".
  178. dnl
  179. AC_HEADER_TIME
  180. AC_UNP_CHECK_TYPE(uint8_t, unsigned char, 8-bit unsigned type)
  181. AC_UNP_CHECK_TYPE(int16_t, short, 16 bit signed type)
  182. AC_UNP_CHECK_TYPE(uint16_t, unsigned short, 16 bit unsigned type)
  183. AC_UNP_CHECK_TYPE(int32_t, int, 32 bit signed type)
  184. AC_UNP_CHECK_TYPE(uint32_t, unsigned int, 32 bit unsigned type)
  185. AC_UNP_CHECK_TYPE(size_t, unsigned int, unsigned integer type of the result of the sizeof operator)
  186. AC_UNP_CHECK_TYPE(ssize_t, int, a signed type appropriate for a count of bytes or an error indication)
  187. AC_UNP_CHECK_TYPE(socklen_t, unsigned int, a type appropriate for address, hostname, buffer, etc. lengths)
  188. dnl
  189. dnl The SA_FAMILY_T in the following is #defined later, as its definition
  190. dnl depends on whether socket address structures have a length field or not.
  191. dnl
  192. AC_UNP_CHECK_TYPE(sa_family_t, SA_FAMILY_T, the type of the sa_family struct member)
  193. dnl We also have our own macro to check for XTI definitions, that can
  194. dnl be defined after #include of our "unpxti.h" header.
  195. dnl
  196. AC_UNPXTI_CHECK_TYPE(t_scalar_t, int32_t, scalar type)
  197. AC_UNPXTI_CHECK_TYPE(t_uscalar_t, uint32_t, unsigned scalar type)
  198. dnl ##################################################################
  199. dnl Check if sockaddr{} has sa_len member.
  200. dnl
  201. AC_CHECK_MEMBER([struct sockaddr.sa_len],
  202. AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, define if socket address structures have length fields),,[
  203. #include <sys/types.h>
  204. #include <sys/socket.h>])
  205. dnl Now we can complete the definition for sa_family_t, if needed.
  206. dnl The size of this datatype depends whether socket address structures
  207. dnl have a length field or not.
  208. dnl
  209. if test $ac_cv_type_sa_family_t = no ; then
  210. if test $ac_cv_member_struct_sockaddr_sa_len = yes ; then
  211. AC_DEFINE(SA_FAMILY_T, uint8_t, the size of the sa_family field in a socket address structure)
  212. else
  213. AC_DEFINE(SA_FAMILY_T, uint16_t)
  214. fi
  215. fi
  216. dnl
  217. dnl Check for sockaddr_storage.
  218. dnl If it's present, check for ss_family.
  219. dnl If ss_family isn't there, check for __ss_family and
  220. dnl #define ss_family __ss_family if so.
  221. dnl If neither is there, I don't know what to do.
  222. dnl
  223. AC_CHECK_TYPES([struct sockaddr_storage],
  224. AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],,
  225. AC_CHECK_MEMBER([struct sockaddr_storage.__ss_family],
  226. AC_DEFINE([ss_family],[__ss_family],[define to __ss_family if sockaddr_storage has that instead of ss_family]),
  227. AC_MSG_ERROR([cannot find ss_family in sockaddr_storage]),[
  228. #include <sys/types.h>
  229. #include <sys/socket.h>]),[
  230. #include <sys/types.h>
  231. #include <sys/socket.h>]),,[
  232. #include <sys/types.h>
  233. #include <sys/socket.h>])
  234. dnl Check if msghdr{} has msg_control member.
  235. dnl
  236. AC_CHECK_MEMBER([struct msghdr.msg_control],
  237. AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL, 1, define if struct msghdr contains the msg_control member),,[
  238. #include <sys/types.h>
  239. #include <sys/socket.h>])
  240. dnl
  241. dnl Check for ifr_mtu in ifreq - some systems have SIOCGIFMTU
  242. dnl but don't have ifr_mtu!!
  243. AC_CHECK_MEMBERS([struct ifreq.ifr_mtu],,,
  244. [#include <sys/types.h>
  245. #include <sys/socket.h>
  246. #include <net/if.h>])
  247. dnl ##################################################################
  248. dnl Check for function prototypes in headers.
  249. dnl AC_CHECK_FUNC_PROTO is our own macro in "aclocal.m4".
  250. dnl
  251. AC_CHECK_FUNC_PROTO(getaddrinfo, netdb.h)
  252. AC_CHECK_FUNC_PROTO(getnameinfo, netdb.h)
  253. AC_CHECK_FUNC_PROTO(gethostname, unistd.h)
  254. AC_CHECK_FUNC_PROTO(getrusage, sys/resource.h)
  255. AC_CHECK_FUNC_PROTO(hstrerror, netdb.h)
  256. AC_CHECK_FUNC_PROTO(if_nametoindex, net/if.h)
  257. AC_CHECK_FUNC_PROTO(inet_aton, arpa/inet.h)
  258. AC_CHECK_FUNC_PROTO(inet_pton, arpa/inet.h)
  259. AC_CHECK_FUNC_PROTO(pselect, sys/select.h)
  260. AC_CHECK_FUNC_PROTO(snprintf, stdio.h)
  261. AC_CHECK_FUNC_PROTO(sockatmark, sys/socket.h)
  262. dnl
  263. dnl autoheader doesn't know how to handle the above, so we have
  264. dnl to help it out.
  265. AH_TEMPLATE(HAVE_GETADDRINFO_PROTO, define if getaddrinfo prototype is in <netdb.h>)
  266. AH_TEMPLATE(HAVE_GETNAMEINFO_PROTO, define if getnameinfo prototype is in <netdb.h>)
  267. AH_TEMPLATE(HAVE_GETHOSTNAME_PROTO, define if gethostname prototype is in <unistd.h>)
  268. AH_TEMPLATE(HAVE_GETRUSAGE_PROTO, define if getrusage prototype is in <sys/resource.h>)
  269. AH_TEMPLATE(HAVE_HSTRERROR_PROTO, define if hstrerror prototype is in <netdb.h>)
  270. AH_TEMPLATE(HAVE_IF_NAMETOINDEX_PROTO, define if if_nametoindex prototype is in <net/if.h>)
  271. AH_TEMPLATE(HAVE_INET_ATON_PROTO, define if inet_aton prototype is in <arpa/inet.h>)
  272. AH_TEMPLATE(HAVE_INET_PTON_PROTO, define if inet_pton prototype is in <arpa/inet.h>)
  273. AH_TEMPLATE(HAVE_PSELECT_PROTO, define if pselect prototype is in <sys/stat.h>)
  274. AH_TEMPLATE(HAVE_SNPRINTF_PROTO, define if snprintf prototype is in <stdio.h>)
  275. AH_TEMPLATE(HAVE_SOCKATMARK_PROTO, define if sockatmark prototype is in <sys/socket.h>)
  276. dnl ##################################################################
  277. dnl Check for structure definitions.
  278. dnl
  279. AC_CHECK_TYPE(struct addrinfo,
  280. AC_DEFINE(HAVE_ADDRINFO_STRUCT, 1, Define to 1 if <netdb.h> defines struct addrinfo),,[
  281. #include <netdb.h>])
  282. dnl
  283. AC_CHECK_TYPE(struct if_nameindex,
  284. AC_DEFINE(HAVE_IF_NAMEINDEX_STRUCT, 1, Define to 1 if <net/if.h> defines struct if_nameindex),,[
  285. #include <sys/types.h>
  286. #include <sys/socket.h>
  287. #include <net/if.h>])
  288. dnl
  289. AC_CHECK_TYPE([struct sockaddr_dl],
  290. AC_DEFINE(HAVE_SOCKADDR_DL_STRUCT, 1, Define to 1 if <net/if_dl.h> defines struct sockaddr_dl),,[
  291. #include <sys/types.h>
  292. #include <sys/socket.h>
  293. #include <net/if_dl.h>])
  294. dnl OpenBSD puts struct timespec in <sys/time.h> instead of <time.h>,
  295. dnl thus this complex test.
  296. AC_CHECK_TYPE([struct timespec],
  297. AC_DEFINE(HAVE_TIMESPEC_STRUCT, 1, Define to 1 if <time.h> or <sys/time.h> defines struct timespec),,[
  298. #if TIME_WITH_SYS_TIME
  299. #include <sys/time.h>
  300. #include <time.h>
  301. #else
  302. #if HAVE_SYS_TIME_H
  303. #include <sys/time.h>
  304. #else
  305. #include <time.h>
  306. #endif
  307. #endif
  308. ])
  309. dnl ##################################################################
  310. dnl Check for XTI devices.
  311. dnl
  312. AC_MSG_CHECKING(for /dev/tcp)
  313. if test -r /dev/tcp ; then
  314. AC_DEFINE(HAVE_DEV_TCP, 1, Define to 1 if the /dev/tcp device exists)
  315. AC_MSG_RESULT(yes)
  316. else
  317. AC_MSG_RESULT(no)
  318. AC_MSG_CHECKING(for /dev/xti/tcp)
  319. if test -r /dev/xti/tcp ; then
  320. AC_DEFINE(HAVE_DEV_XTI_TCP, 1, Define to 1 if the /dev/xti/tcp device exists)
  321. AC_MSG_RESULT(yes)
  322. else
  323. AC_MSG_RESULT(no)
  324. AC_MSG_CHECKING(for /dev/streams/xtiso/tcp)
  325. if test -r /dev/streams/xtiso/tcp ; then
  326. AC_DEFINE(HAVE_DEV_STREAMS_XTISO_TCP, 1, Define to 1 if the /dev/streams/xtiso/tcp device exists)
  327. AC_MSG_RESULT(yes)
  328. else
  329. AC_MSG_RESULT(no)
  330. fi
  331. fi
  332. fi
  333. dnl ##################################################################
  334. dnl Checks for library functions.
  335. dnl
  336. AC_CHECK_FUNCS(bzero)
  337. AC_CHECK_FUNCS(getaddrinfo)
  338. AC_CHECK_FUNCS(gethostname)
  339. AC_CHECK_FUNCS(gethostbyname2)
  340. AC_CHECK_FUNCS(gethostbyname_r)
  341. AC_CHECK_FUNCS(getnameinfo)
  342. AC_CHECK_FUNCS(hstrerror)
  343. AC_CHECK_FUNCS(if_nametoindex)
  344. AC_CHECK_FUNCS(inet_aton)
  345. AC_CHECK_FUNCS(inet_pton)
  346. AC_CHECK_FUNCS(inet6_rth_init)
  347. AC_CHECK_FUNCS(kqueue kevent)
  348. AC_CHECK_FUNCS(mkstemp)
  349. AC_CHECK_FUNCS(poll)
  350. AC_CHECK_FUNCS(pselect)
  351. AC_CHECK_FUNCS(snprintf)
  352. AC_CHECK_FUNCS(sockatmark)
  353. AC_CHECK_FUNCS(vsnprintf)
  354. dnl ##################################################################
  355. dnl Check for system services.
  356. dnl Let's see if the system really supports IPv4.
  357. dnl
  358. AC_MSG_CHECKING(for IPv4 support)
  359. AC_CACHE_VAL(ac_cv_ipv4,
  360. AC_TRY_RUN([
  361. # include <sys/types.h>
  362. # include <sys/socket.h>
  363. # include <netinet/in.h>
  364. /* Make sure the definitions for AF_INET and struct sockaddr_in
  365. * are defined, and that we can actually create an IPv4 TCP socket.
  366. */
  367. main()
  368. {
  369. int fd;
  370. struct sockaddr_in foo;
  371. fd = socket(AF_INET, SOCK_STREAM, 0);
  372. exit(fd >= 0 ? 0 : 1);
  373. }],
  374. ac_cv_ipv4=yes,
  375. ac_cv_ipv4=no,
  376. ac_cv_ipv4=no))
  377. AC_MSG_RESULT($ac_cv_ipv4)
  378. if test $ac_cv_ipv4 = yes ; then
  379. AC_DEFINE(IPV4, 1, Define to 1 if the system supports IPv4)
  380. AC_DEFINE(IPv4, 1, Define to 1 if the system supports IPv4)
  381. fi
  382. dnl Let's see if the system really supports IPv6.
  383. dnl
  384. AC_MSG_CHECKING(for IPv6 support)
  385. AC_CACHE_VAL(ac_cv_ipv6,
  386. AC_TRY_RUN([
  387. # include <sys/types.h>
  388. # include <sys/socket.h>
  389. # include <netinet/in.h>
  390. /* Make sure the definitions for AF_INET6 and struct sockaddr_in6
  391. * are defined, and that we can actually create an IPv6 TCP socket.
  392. */
  393. main()
  394. {
  395. int fd;
  396. struct sockaddr_in6 foo;
  397. fd = socket(AF_INET6, SOCK_STREAM, 0);
  398. exit(fd >= 0 ? 0 : 1);
  399. }],
  400. ac_cv_ipv6=yes,
  401. ac_cv_ipv6=no,
  402. ac_cv_ipv6=no))
  403. AC_MSG_RESULT($ac_cv_ipv6)
  404. if test $ac_cv_ipv6 = yes ; then
  405. AC_DEFINE(IPV6, 1, Define to 1 if the system supports IPv6)
  406. AC_DEFINE(IPv6, 1, Define to 1 if the system supports IPv6)
  407. fi
  408. dnl Let's see if the system really supports Unix domain sockets.
  409. dnl
  410. AC_MSG_CHECKING(for Unix domain sockets)
  411. AC_CACHE_VAL(ac_cv_unixdomain,
  412. AC_TRY_RUN([
  413. # include <sys/types.h>
  414. # include <sys/socket.h>
  415. # include <sys/un.h>
  416. /* Make sure the definitions for AF_UNIX and struct sockaddr_un
  417. * are defined, and that we can actually create an IPv4 TCP socket.
  418. */
  419. main()
  420. {
  421. int fd;
  422. struct sockaddr_un foo;
  423. fd = socket(AF_UNIX, SOCK_STREAM, 0);
  424. exit(fd >= 0 ? 0 : 1);
  425. }],
  426. ac_cv_unixdomain=yes,
  427. ac_cv_unixdomain=no,
  428. ac_cv_unixdomain=no))
  429. AC_MSG_RESULT($ac_cv_unixdomain)
  430. if test $ac_cv_unixdomain = yes ; then
  431. AC_DEFINE(UNIXDOMAIN, 1, Define to 1 if the system supports UNIX domain sockets)
  432. AC_DEFINE(UNIXdomain, 1, Define to 1 if the system supports UNIX domain sockets)
  433. fi
  434. dnl Let's see if the system really supports multicasting.
  435. dnl
  436. AC_MSG_CHECKING(for multicast support)
  437. AC_CACHE_VAL(ac_cv_multicast,
  438. AC_TRY_RUN([
  439. # include <sys/types.h>
  440. # include <sys/socket.h>
  441. # include <netinet/in.h>
  442. main()
  443. {
  444. int fd;
  445. unsigned char flag = 1;
  446. struct sockaddr_in foo;
  447. struct ip_mreq mreq;
  448. fd = socket(AF_INET, SOCK_DGRAM, 0);
  449. if (fd < 0) exit(1);
  450. if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
  451. (void*)&flag, sizeof(flag)) < 0)
  452. exit(1);
  453. exit(0);
  454. }],
  455. ac_cv_multicast=yes,
  456. ac_cv_multicast=no,
  457. ac_cv_multicast=no))
  458. AC_MSG_RESULT($ac_cv_multicast)
  459. if test $ac_cv_multicast = yes ; then
  460. AC_DEFINE(MCAST, 1, Define to 1 if the system supports IP Multicast)
  461. fi
  462. dnl ##################################################################
  463. dnl Build the list of object files to build from the source files in
  464. dnl the lib/ directory.
  465. dnl
  466. LIB_OBJS=
  467. LIB_OBJS="$LIB_OBJS connect_nonb.o"
  468. LIB_OBJS="$LIB_OBJS connect_timeo.o"
  469. LIB_OBJS="$LIB_OBJS daemon_inetd.o"
  470. LIB_OBJS="$LIB_OBJS daemon_init.o"
  471. LIB_OBJS="$LIB_OBJS dg_cli.o"
  472. LIB_OBJS="$LIB_OBJS dg_echo.o"
  473. LIB_OBJS="$LIB_OBJS error.o"
  474. LIB_OBJS="$LIB_OBJS get_ifi_info.o"
  475. LIB_OBJS="$LIB_OBJS gf_time.o"
  476. LIB_OBJS="$LIB_OBJS host_serv.o"
  477. if test "$ac_cv_func_hstrerror" = no ; then
  478. LIBFREE_OBJS="$LIBFREE_OBJS hstrerror.o"
  479. fi
  480. if test "$ac_cv_func_if_nametoindex" = no ; then
  481. LIB_OBJS="$LIB_OBJS if_nametoindex.o if_indextoname.o if_nameindex.o"
  482. fi
  483. if test "$ac_cv_multicast" = yes ; then
  484. LIB_OBJS="$LIB_OBJS family_to_level.o"
  485. LIB_OBJS="$LIB_OBJS mcast_leave.o mcast_join.o"
  486. LIB_OBJS="$LIB_OBJS mcast_get_if.o mcast_get_loop.o mcast_get_ttl.o"
  487. LIB_OBJS="$LIB_OBJS mcast_set_if.o mcast_set_loop.o mcast_set_ttl.o"
  488. fi
  489. LIB_OBJS="$LIB_OBJS my_addrs.o"
  490. if test "$ac_cv_func_pselect" = no ; then
  491. LIB_OBJS="$LIB_OBJS pselect.o"
  492. fi
  493. LIB_OBJS="$LIB_OBJS read_fd.o"
  494. LIB_OBJS="$LIB_OBJS readline.o"
  495. LIB_OBJS="$LIB_OBJS readn.o"
  496. LIB_OBJS="$LIB_OBJS readable_timeo.o"
  497. LIB_OBJS="$LIB_OBJS rtt.o"
  498. LIB_OBJS="$LIB_OBJS signal.o"
  499. LIB_OBJS="$LIB_OBJS signal_intr.o"
  500. if test "$ac_cv_func_snprintf" = no ; then
  501. LIB_OBJS="$LIB_OBJS snprintf.o"
  502. fi
  503. if test "$ac_cv_func_sockatmark" = no ; then
  504. LIB_OBJS="$LIB_OBJS sockatmark.o"
  505. fi
  506. LIB_OBJS="$LIB_OBJS sock_bind_wild.o"
  507. LIB_OBJS="$LIB_OBJS sock_cmp_addr.o"
  508. LIB_OBJS="$LIB_OBJS sock_cmp_port.o"
  509. LIB_OBJS="$LIB_OBJS sock_ntop.o"
  510. LIB_OBJS="$LIB_OBJS sock_ntop_host.o"
  511. LIB_OBJS="$LIB_OBJS sock_get_port.o"
  512. LIB_OBJS="$LIB_OBJS sock_set_addr.o"
  513. LIB_OBJS="$LIB_OBJS sock_set_port.o"
  514. LIB_OBJS="$LIB_OBJS sock_set_wild.o"
  515. LIB_OBJS="$LIB_OBJS sockfd_to_family.o"
  516. LIB_OBJS="$LIB_OBJS str_cli.o"
  517. LIB_OBJS="$LIB_OBJS str_echo.o"
  518. LIB_OBJS="$LIB_OBJS tcp_connect.o"
  519. LIB_OBJS="$LIB_OBJS tcp_listen.o"
  520. LIB_OBJS="$LIB_OBJS tv_sub.o"
  521. LIB_OBJS="$LIB_OBJS udp_client.o"
  522. LIB_OBJS="$LIB_OBJS udp_connect.o"
  523. LIB_OBJS="$LIB_OBJS udp_server.o"
  524. LIB_OBJS="$LIB_OBJS wraplib.o"
  525. LIB_OBJS="$LIB_OBJS wrapsock.o"
  526. LIB_OBJS="$LIB_OBJS wrapstdio.o"
  527. if test "$ac_cv_header_pthread_h" = yes ; then
  528. LIB_OBJS="$LIB_OBJS wrappthread.o"
  529. fi
  530. LIB_OBJS="$LIB_OBJS wrapunix.o"
  531. LIB_OBJS="$LIB_OBJS write_fd.o"
  532. LIB_OBJS="$LIB_OBJS writen.o"
  533. LIB_OBJS="$LIB_OBJS writable_timeo.o"
  534. dnl ##################################################################
  535. dnl Build the list of object files to build from the source files in
  536. dnl the libfree/ directory.
  537. dnl
  538. LIBFREE_OBJS=
  539. LIBFREE_OBJS="$LIBFREE_OBJS in_cksum.o"
  540. if test "$ac_cv_func_inet_aton" = no ; then
  541. LIBFREE_OBJS="$LIBFREE_OBJS inet_aton.o"
  542. fi
  543. dnl We always include both inet_ntop() and inet_pton() because some
  544. dnl vendor's implementations are from the Internet Drafts leading to
  545. dnl RFC 1323, and are wrong.
  546. LIBFREE_OBJS="$LIBFREE_OBJS inet_ntop.o inet_pton.o"
  547. dnl if test "$ac_cv_func_inet_pton" = no ; then
  548. dnl LIBFREE_OBJS="$LIBFREE_OBJS inet_pton.o"
  549. dnl fi
  550. dnl ##################################################################
  551. dnl Build the list of object files to build from the source files in
  552. dnl the libgai/ directory (getaddrinfo() and friends).
  553. dnl
  554. dnl If the system has a getaddrinfo implementation, then
  555. dnl there should be nothing here.
  556. if test "$ac_cv_func_getaddrinfo" = no ; then
  557. LIBGAI_OBJS="getaddrinfo.o getnameinfo.o freeaddrinfo.o gai_strerror.o"
  558. LIBGAI_OBJS="$LIBGAI_OBJS ga_aistruct.o ga_clone.o ga_echeck.o ga_nsearch.o"
  559. LIBGAI_OBJS="$LIBGAI_OBJS ga_port.o ga_serv.o ga_unix.o gn_ipv46.o"
  560. else
  561. LIBGAI_OBJS=""
  562. fi
  563. dnl ##################################################################
  564. dnl Build the list of object files to build from the source files in
  565. dnl the libroute/ directory (routing socket functions).
  566. dnl
  567. LIBROUTE_OBJS="get_rtaddrs.o"
  568. LIBROUTE_OBJS="$LIBROUTE_OBJS if_indextoname.o if_nameindex.o if_nametoindex.o"
  569. LIBROUTE_OBJS="$LIBROUTE_OBJS net_rt_iflist.o net_rt_dump.o"
  570. LIBROUTE_OBJS="$LIBROUTE_OBJS sock_masktop.o"
  571. dnl ##################################################################
  572. dnl Build the list of object files to build from the source files in
  573. dnl the libxti/ directory.
  574. dnl Systems that do not provide <netdir.h> and <netconfig.h> do not
  575. dnl support our tcp_XXX and udp_XXX functions.
  576. dnl
  577. LIBXTI_OBJS=
  578. if test "$ac_cv_header_netdir_h" = yes ; then
  579. LIBXTI_OBJS="$LIBXTI_OBJS tcp_connect.o"
  580. LIBXTI_OBJS="$LIBXTI_OBJS tcp_listen.o"
  581. LIBXTI_OBJS="$LIBXTI_OBJS udp_server.o"
  582. LIBXTI_OBJS="$LIBXTI_OBJS udp_client.o"
  583. fi
  584. LIBXTI_OBJS="$LIBXTI_OBJS wrapxti.o"
  585. LIBXTI_OBJS="$LIBXTI_OBJS xti_accept.o"
  586. LIBXTI_OBJS="$LIBXTI_OBJS xti_flags_str.o"
  587. LIBXTI_OBJS="$LIBXTI_OBJS xti_getopt.o"
  588. LIBXTI_OBJS="$LIBXTI_OBJS xti_ntop.o"
  589. LIBXTI_OBJS="$LIBXTI_OBJS xti_ntop_host.o"
  590. LIBXTI_OBJS="$LIBXTI_OBJS xti_rdwr.o"
  591. LIBXTI_OBJS="$LIBXTI_OBJS xti_setopt.o"
  592. LIBXTI_OBJS="$LIBXTI_OBJS xti_str_opts.o"
  593. LIBXTI_OBJS="$LIBXTI_OBJS xti_tlook_str.o"
  594. dnl Now make certain that when configure is run, AC_OUTPUT replaces these
  595. dnl strings that we built in shell variables in the output files that
  596. dnl it generates.
  597. dnl
  598. AC_SUBST(LIB_OBJS)
  599. AC_SUBST(LIBFREE_OBJS)
  600. AC_SUBST(LIBGAI_OBJS)
  601. AC_SUBST(LIBROUTE_OBJS)
  602. AC_SUBST(LIBXTI_OBJS)
  603. dnl We need our own variable LIBS_XTI for linking XTI programs,
  604. dnl but do not want -lsocket in there.
  605. dnl Ditto for -lxti in LIBS.
  606. dnl
  607. LIBS_XTI=`echo $LIBS | sed 's/-lsocket//'`
  608. LIBS=`echo $LIBS | sed 's/-lxti//'`
  609. AC_SUBST(LIBS_XTI)
  610. AC_SUBST(LIBUNP)
  611. AC_SUBST(LIBUNPXTI)
  612. AC_SUBST(LIBUNP_NAME)
  613. AC_SUBST(LIBUNPXTI_NAME)
  614. dnl ##################################################################
  615. dnl Now that we're doing compiling, modify CFLAGS.
  616. dnl
  617. dnl If the directory $HOME/doc/unp2ev1/src/include exists, the user can
  618. dnl place modified copies of the system's headers in there, with the
  619. dnl function prototypes corrected, as per Posix and X/Open. Lots of
  620. dnl system headers today are missing const qualifiers, they have char*
  621. dnl instead of void*, and so on.
  622. dnl
  623. AC_MSG_CHECKING(for -I$HOME/doc/unp2ev1/src/include)
  624. if test -d $HOME/doc/unp2ev1/src/include ; then
  625. CFLAGS="$CFLAGS -I$HOME/doc/unp2ev1/src/include"
  626. AC_MSG_RESULT(yes)
  627. else
  628. AC_MSG_RESULT(no)
  629. fi
  630. dnl If the compiler is gcc, enable all warnings. Main purpose is to
  631. dnl catch any function call where the function has not been prototyped.
  632. dnl
  633. if test "$ac_cv_prog_gcc" = yes; then
  634. CFLAGS="$CFLAGS -Wall"
  635. dnl
  636. dnl These warnings are useful during development, but not to deploy.
  637. dnl CFLAGS="$CFLAGS -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wno-format-extra-args"
  638. fi
  639. dnl Some system-specific stuff ...
  640. dnl Some operating systems require additional flags in order to get all
  641. dnl the definitions that we're looking for in some system headers.
  642. case "$host_os" in
  643. *aix*) CFLAGS="$CFLAGS -D_ALL_SOURCE" ;;
  644. *osf*) CFLAGS="$CFLAGS -D_SOCKADDR_LEN" ;;
  645. *solaris*) if test "$ac_cv_prog_gcc" = yes; then
  646. CFLAGS="$CFLAGS -D__EXTENSIONS__"
  647. else
  648. CFLAGS="$CFLAGS -D__STDC__"
  649. fi ;;
  650. esac
  651. dnl ##################################################################
  652. dnl We also create a "Makefile" but it is not used for much.
  653. dnl
  654. AC_OUTPUT(Makefile Make.defines)
  655. dnl
  656. dnl If a directory exists whose name equals the host
  657. dnl (e.g., sparc-sun-solaris2.5.1), then save the five files that we
  658. dnl create in that directory also.
  659. dnl Quick and dirty to be able to NFS mount this directory on different
  660. dnl systems and move quickly between the systems, without having to
  661. dnl rerun configure each time.
  662. dnl The "myconfig" script in this directory does the move.
  663. dnl
  664. if test -d "$host" ; then
  665. cp -p config.h config.cache config.status Makefile Make.defines $host
  666. echo "saving copies in $host/"
  667. fi