root/configure.in

Revision 451a0e07f83d6599e8716c96d353c9737726a91b, 12.6 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

better detection and correct use of POSIX.1c getpwnam_r

  • Property mode set to 100755
Line 
1 AC_INIT(src/noitd.c)
2
3 node=`hostname | cut -f1 -d '.' | tr '[A-Z]' '[a-z]'`
4 if test -f ".configure.$node"; then
5         echo "***********************************************************"
6         echo "* Loading node specific configure settings for $node."
7         echo "***********************************************************"
8         . ./.configure.$node
9 fi
10
11 AC_CANONICAL_HOST
12 AC_CONFIG_HEADER(src/noit_config.h)
13 AC_CONFIG_HEADER(src/jlog/jlog_config.h)
14
15 AC_PROG_CC
16 AC_C_INLINE
17 AC_C_BIGENDIAN
18 AC_PROG_CPP
19 AC_PROG_RANLIB
20 AC_PROG_INSTALL
21 AC_PROG_LN_S
22 AC_PATH_PROG(AR, ar)
23 AC_PATH_PROGS(PERL, perl)
24 AC_PATH_PROGS(XSLTPROC, xsltproc)
25 AC_PATH_PROGS(XMLLINT, xmllint)
26 AC_PATH_PROG(NROFF, nroff)
27 AC_SUBST(PERL)
28
29 if test "x$CC" = "xgcc" ; then
30   CFLAGS="$CFLAGS -g -Wall"
31 else
32   CFLAGS="$CFLAGS -g"
33 fi
34
35 CPPFLAGS="$CPPFLAGS "'-I$(top_srcdir)/src'
36
37 case $host in
38 *-*-darwin*)
39         PICFLAGS="-fPIC"
40         MODULELD="$CC -bundle -flat_namespace -undefined suppress"
41         SHLD="$CC -dynamiclib -flat_namespace -undefined suppress"
42         MODULEEXT=bundle
43         RLDFLAG="-Wl,--rpath="
44         ;;
45 *-*-solaris*)
46         AC_MSG_CHECKING([32 or 64 bit Solaris assembly])
47         if test -n "`echo $CFLAGS | grep m64`"; then
48                 AC_MSG_RESULT([64])
49                 ATOMIC_OBJS="noit_atomic_sol_x86_64.o"
50         else
51                 AC_MSG_RESULT([32])
52                 ATOMIC_OBJS="noit_atomic_sol_x86_32.o"
53         fi
54         PICFLAGS="-Kpic"
55         MODULELD="$CC -G"
56         SHLD="$CC -G"
57         MODULEEXT=so
58         RLDFLAG="-R"
59         WHOLE_ARCHIVE="-Wl,-z -Wl,allextract"
60         NOWHOLE_ARCHIVE="-Wl,-z -Wl,defaultextract"
61         ;;
62 *-*-openbsd*)
63         PICFLAGS="-fpic"
64         LDFLAGS="$LDFLAGS -Wl,-E"
65         MODULELD="$CC -shared"
66         SHLD="$CC -shared"
67         MODULEEXT=so
68         LDFLAGS="$LDFLAGS -L/usr/local/lib"
69         CFLAGS="$CFLAGS -I/usr/local/include"
70         RLDFLAG="-Wl,--rpath="
71         WHOLE_ARCHIVE="-Wl,--whole-archive"
72         NOWHOLE_ARCHIVE="-Wl,--no-whole-archive"
73         ;;
74 *-*-linux*)
75         LDFLAGS="$LDFLAGS -Wl,-E"
76         CPPFLAGS="$CPPFLAGS"
77         PICFLAGS="-fpic"
78         MODULELD="$CC -shared"
79         SHLD="$CC -shared"
80         MODULEEXT=so
81         RLDFLAG="-Wl,--rpath="
82         WHOLE_ARCHIVE="-Wl,--whole-archive"
83         NOWHOLE_ARCHIVE="-Wl,--no-whole-archive"
84         ;;
85 *)
86         PICFLAGS="-fpic"
87         MODULELD="$CC -shared"
88         MODULEEXT=so
89         RLDFLAG="-Wl,--rpath="
90         ;;
91 esac
92 AC_SUBST(SHLD)
93 AC_SUBST(RLDFLAG)
94 AC_SUBST(MODULELD)
95 AC_SUBST(MODULEEXT)
96 AC_SUBST(WHOLE_ARCHIVE)
97 AC_SUBST(NOWHOLE_ARCHIVE)
98 AC_SUBST(ATOMIC_OBJS)
99 AC_DEFINE_UNQUOTED(MODULEEXT, "$MODULEEXT", [module extension])
100
101 # Checks for data types
102 AC_CHECK_SIZEOF(char, 1)
103 AC_CHECK_SIZEOF(short int, 2)
104 AC_CHECK_SIZEOF(int, 4)
105 AC_CHECK_SIZEOF(long int, 4)
106 AC_CHECK_SIZEOF(long long int, 8)
107 AC_CHECK_SIZEOF(void *, 1)
108
109 AC_CHECK_LIB(z, compress2, , [AC_MSG_ERROR(*** zlib is required ***)])
110 AC_CHECK_LIB(rt, sem_init, , )
111 AC_CHECK_LIB(posix4, sem_wait, , )
112 AC_CHECK_LIB(pthread, pthread_create, , )
113 AC_CHECK_LIB(uuid, uuid_generate, , [AC_MSG_ERROR(*** uuid is required ***)])
114 # Some libraries provide an unparse_lower command
115 # we use that, so if it isn't present, we'll need
116 # to implement it.
117 AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE(HAVE_UUID_UNPARSE_LOWER)], )
118 AC_CHECK_LIB(util, openpty, , )
119 AC_CHECK_LIB(termcap, tputs, , )
120 AC_CHECK_LIB(curses, clear, , [AC_MSG_ERROR([curses not found, but required])])
121
122 CPPFLAGS="$CPPFLAGS `pcre-config --cflags`"
123 LDFLAGS="$LDFLAGS `pcre-config --libs`"
124 AC_CHECK_LIB(pcre, pcre_compile, ,
125         [
126                 AC_MSG_ERROR([libpcre not found, but required])
127         ]
128 )
129 AC_CHECK_LIB(crypto, ERR_load_CRYPTO_strings, ,
130         [
131                 AC_MSG_ERROR([libcrypto not found, but required])
132         ]
133 )
134 AC_CHECK_LIB(ssl, SSL_library_init, ,
135         [
136                 AC_MSG_ERROR([libssl not found, but required])
137         ]
138 )
139
140 old_LIBS=$LIBS
141 old_CFLAGS=$CFLAGS
142 AC_CHECK_LIB(pq, PQconnectdb,
143         [
144                 LIBS="$LIBS -lpq"
145                 PGLIBS="$LIBS"
146                 AC_SUBST(PGLIBS)
147         ],
148         [
149                 AC_MSG_ERROR([libpq required])
150         ]
151 )
152
153 AC_MSG_CHECKING([libpq includes])
154 PQICFLAGS=`pg_config --includedir`
155 if test -n "$PQICFLAGS" ; then
156   CFLAGS="$CFLAGS -I$PQICFLAGS"
157 fi
158
159 AC_TRY_LINK([
160         #include <libpq-fe.h>
161         ],
162         [ PGconn *dbh = PQconnectdb(""); ],
163         [],
164         [ AC_MSG_ERROR([Cannot compile/link against libpq]) ]
165 )
166 PGCFLAGS=$CFLAGS
167 AC_SUBST(PGCFLAGS)
168
169 LIBS=$old_LIBS
170 CFLAGS=$old_CFLAGS
171
172 ########
173 #
174 # CHECK FOR VARIOUS MODULE CRITERIA
175 # We don't track the libs themselves, as we'll just explictly link
176 # against the in the makefile if we enable them to build (by adding
177 # them to the BUILD_MODULES list).
178 #
179 ########
180
181 # Should we build snmp checks?
182 SAVELIBS="$LIBS"
183 AC_CHECK_LIB(netsnmp, snmp_sess_open,
184         [
185                 BUILD_MODULES="$BUILD_MODULES snmp.$MODULEEXT"
186         ],
187         [
188                 AC_MSG_WARN([No libnetsnmp, skipping snmp module])
189         ]
190 )
191 LIBS="$SAVELIBS"
192
193 # Should we build ssh2 checks?
194 SAVELIBS="$LIBS"
195 AC_CHECK_LIB(ssh2, libssh2_session_init_ex,
196         [
197                 BUILD_MODULES="$BUILD_MODULES ssh2.$MODULEEXT"
198         ],
199         [
200                 AC_MSG_WARN([No libssh2, skipping ssh2 module])
201         ]
202 )
203 LIBS="$SAVELIBS"
204
205 AC_MSG_CHECKING([libxml2 cflags])
206 XML2CFLAGS=`xml2-config --cflags`
207 CFLAGS="$CFLAGS $XML2CFLAGS"
208 AC_MSG_RESULT([$XML2CFLAGS])
209
210 AC_MSG_CHECKING([libxml2 libs])
211 XML2LIBS=`xml2-config --libs`
212 LIBS="$LIBS $XML2LIBS"
213 AC_MSG_RESULT([$XML2LIBS])
214
215 AC_CHECK_FUNC(xmlParseDocument, , [AC_MSG_ERROR(*** libxml2 is required ***)])
216
217 AC_MSG_CHECKING([libxslt cflags])
218 XSLTCFLAGS=`xslt-config --cflags`
219 CFLAGS="$CFLAGS $XSLTCFLAGS"
220 AC_MSG_RESULT([$XSLTCFLAGS])
221
222 AC_MSG_CHECKING([libxslt libs])
223 XSLTLIBS=`xslt-config --libs`
224 LIBS="$LIBS $XSLTLIBS"
225 AC_MSG_RESULT([$XSLTLIBS])
226
227 AC_CHECK_FUNC(xsltParseStylesheetDoc, , [AC_MSG_ERROR(*** libxslt is required ***)])
228
229 APRPREFIX="`apr-1-config --prefix`"
230 AC_MSG_CHECKING([libserf cflags])
231 AC_SUBST(APRPREFIX)
232 AC_MSG_RESULT([$APRPREFIX])
233
234 AC_MSG_CHECKING([libserf cflags])
235 SERFCFLAGS="`apr-1-config --cflags --cppflags`"
236 SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`"
237 AC_SUBST(SERFCFLAGS)
238 AC_MSG_RESULT([$SERFCFLAGS])
239
240 AC_MSG_CHECKING([libserf libs])
241 SERFLIBS="`apu-1-config --link-ld --ldflags --libs` `apr-1-config --link-ld --ldflags --libs`"
242 AC_SUBST(SERFLIBS)
243 AC_MSG_RESULT([$SERFLIBS])
244
245 AC_TRY_LINK([],
246         [ issetugid(); ],
247         [ ac_cv_libc_defines_issetugid="yes" ],
248         [ ac_cv_libc_defines_issetugid="no" ]
249 )
250 if test "x$ac_cv_libc_defines_issetugid" = "xyes" ; then
251         AC_DEFINE(HAVE_ISSETUGID)
252 fi
253
254 AC_MSG_CHECKING([whether sem_init works])
255 AC_TRY_RUN(
256         [
257 #include <semaphore.h>
258 int main(void){sem_t s;return (0 != sem_init(&s,0,0));}
259         ],
260         [
261                 AC_MSG_RESULT(yes)
262                 AC_DEFINE(WORKING_SEM_INIT)
263         ],
264         [
265                 AC_MSG_RESULT(no)
266                 AC_MSG_WARN([****** sem_init() is broken, I'll implement one myself.])
267         ]
268 )
269
270 AC_FUNC_STRFTIME
271 AC_CHECK_FUNCS(ssetugid strlcpy strnstrn openpty inet_pton inet_ntop getopt \
272                poll)
273
274 # Checks for header files.
275 AC_CHECK_HEADERS(sys/file.h sys/types.h dirent.h sys/param.h fcntl.h errno.h limits.h \
276                  sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \
277                  ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \
278                  term.h termio.h termios.h curses.h sys/cdefs.h grp.h netinet/in_systm.h \
279                  sys/ioctl_compat.h sys/filio.h util.h sys/time.h sys/mman.h \
280                  stropts.h sys/stream.h alloca.h sys/wait.h)
281
282 AC_CHECK_FUNCS(getpwnam_r)
283 GETPWNAM_R_POSIX
284 AC_CHECK_FUNCS(getgrnam_r)
285 GETGRNAM_R_POSIX
286
287 AC_MSG_CHECKING(for tputs() function final argument type)
288 AC_EGREP_CPP([tputs.*[(][       ]*char[         ]*[)]],
289                 [#if defined(HAVE_TERM_H)
290                  #include <term.h>
291                  #endif
292                  #if defined(HAVE_CURSES_H)
293                  #include <curses.h>
294                  #endif],
295                 [AC_MSG_RESULT(char)
296                  AC_DEFINE(TPUTS_TAKES_CHAR)],
297                 [AC_MSG_RESULT(not char)])
298
299 AC_CACHE_CHECK([for epoll support], ac_cv_have_epoll, [
300         AC_TRY_LINK(
301                 [ #include <sys/types.h> ],
302                 [ u_int a; a = epoll_create(); ],
303                 [ ac_cv_have_epoll="yes" ],
304                 [ ac_cv_have_epoll="no" ]
305         )
306 ])
307 if test "x$ac_cv_have_epoll" = "xyes" ; then
308         AC_DEFINE(HAVE_EPOLL)
309         EVENTER_OBJS="$EVENTER_OBJS eventer_epoll_impl.o"
310         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "epoll")
311         have_epoll=1
312 fi
313
314 AC_CACHE_CHECK([for kqueue support], ac_cv_have_kqueue, [
315         AC_TRY_LINK(
316                 [ #include <sys/types.h> ],
317                 [ u_int a; a = kqueue(); ],
318                 [ ac_cv_have_kqueue="yes" ],
319                 [ ac_cv_have_kqueue="no" ]
320         )
321 ])
322 if test "x$ac_cv_have_kqueue" = "xyes" ; then
323         AC_DEFINE(HAVE_KQUEUE)
324         EVENTER_OBJS="$EVENTER_OBJS eventer_kqueue_impl.o"
325         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "kqueue")
326         have_kqueue=1
327 fi
328
329 AC_CACHE_CHECK([for Solaris ports support], ac_cv_have_ports, [
330         AC_TRY_LINK(
331                 [ #include <port.h> ],
332                 [ u_int a; a = port_create(); ],
333                 [ ac_cv_have_ports="yes" ],
334                 [ ac_cv_have_ports="no" ]
335         )
336 ])
337 if test "x$ac_cv_have_ports" = "xyes" ; then
338         AC_DEFINE(HAVE_PORTS)
339         EVENTER_OBJS="$EVENTER_OBJS eventer_ports_impl.o"
340         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "ports")
341         have_ports=1
342 fi
343
344 AC_SUBST(EVENTER_OBJS)
345
346 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
347         AC_TRY_COMPILE(
348                 [ #include <sys/types.h> ],
349                 [ u_int a; a = 1;],
350                 [ ac_cv_have_u_int="yes" ],
351                 [ ac_cv_have_u_int="no" ]
352         )
353 ])
354 if test "x$ac_cv_have_u_int" = "xyes" ; then
355         AC_DEFINE(HAVE_U_INT)
356         have_u_int=1
357 fi
358
359 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
360         AC_TRY_COMPILE(
361                 [ #include <sys/types.h> ],
362                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
363                 [ ac_cv_have_intxx_t="yes" ],
364                 [ ac_cv_have_intxx_t="no" ]
365         )
366 ])
367 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
368         AC_DEFINE(HAVE_INTXX_T)
369         have_intxx_t=1
370 fi
371        
372 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
373         AC_TRY_COMPILE(
374                 [ #include <sys/types.h> ],
375                 [ int64_t a; a = 1;],
376                 [ ac_cv_have_int64_t="yes" ],
377                 [ ac_cv_have_int64_t="no" ]
378         )
379 ])
380 if test "x$ac_cv_have_int64_t" = "xyes" ; then
381         AC_DEFINE(HAVE_INT64_T)
382         have_int64_t=1
383 fi
384        
385 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
386         AC_TRY_COMPILE(
387                 [ #include <sys/types.h> ],
388                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
389                 [ ac_cv_have_u_intxx_t="yes" ],
390                 [ ac_cv_have_u_intxx_t="no" ]
391         )
392 ])
393 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
394         AC_DEFINE(HAVE_U_INTXX_T)
395         have_u_intxx_t=1
396 fi
397
398 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
399         AC_TRY_COMPILE(
400                 [ #include <sys/types.h> ],
401                 [ u_int64_t a; a = 1;],
402                 [ ac_cv_have_u_int64_t="yes" ],
403                 [ ac_cv_have_u_int64_t="no" ]
404         )
405 ])
406 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
407         AC_DEFINE(HAVE_U_INT64_T)
408         have_u_int64_t=1
409 fi
410
411 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
412            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
413 then
414         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
415         AC_TRY_COMPILE(
416                 [
417 #include <sys/bitypes.h>
418                 ],
419                 [
420                         int8_t a; int16_t b; int32_t c;
421                         u_int8_t e; u_int16_t f; u_int32_t g;
422                         a = b = c = e = f = g = 1;
423                 ],
424                 [
425                         AC_DEFINE(HAVE_U_INTXX_T)
426                         AC_DEFINE(HAVE_INTXX_T)
427                         AC_MSG_RESULT(yes)
428                 ],
429                 [AC_MSG_RESULT(no)]
430         )
431 fi
432
433 if test -z "$have_u_intxx_t" ; then
434         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
435                 AC_TRY_COMPILE(
436                         [
437 #include <sys/types.h>
438                         ],
439                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
440                         [ ac_cv_have_uintxx_t="yes" ],
441                         [ ac_cv_have_uintxx_t="no" ]
442                 )
443         ])
444         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
445                 AC_DEFINE(HAVE_UINTXX_T)
446         fi
447 fi
448
449 AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
450         AC_TRY_COMPILE(
451                 [
452 #include <sys/types.h>
453 #include <sys/socket.h>
454                 ],
455                 [socklen_t foo; foo = 1235;],
456                 [ ac_cv_have_socklen_t="yes" ],
457                 [ ac_cv_have_socklen_t="no" ]
458         )
459 ])
460 if test "x$ac_cv_have_socklen_t" = "xyes" ; then
461         AC_DEFINE(HAVE_SOCKLEN_T)
462 fi
463
464 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
465         AC_TRY_COMPILE(
466                 [
467 #include <sys/types.h>
468                 ],
469                 [ size_t foo; foo = 1235; ],
470                 [ ac_cv_have_size_t="yes" ],
471                 [ ac_cv_have_size_t="no" ]
472         )
473 ])
474 if test "x$ac_cv_have_size_t" = "xyes" ; then
475         AC_DEFINE(HAVE_SIZE_T)
476 fi
477
478 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
479         AC_TRY_COMPILE(
480                 [
481 #include <sys/types.h>
482                 ],
483                 [ ssize_t foo; foo = 1235; ],
484                 [ ac_cv_have_ssize_t="yes" ],
485                 [ ac_cv_have_ssize_t="no" ]
486         )
487 ])
488 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
489         AC_DEFINE(HAVE_SSIZE_T)
490 fi
491
492 AC_SUBST(BUILD_MODULES)
493
494 docdir="docs"
495 mansubdir="man"
496 AC_SUBST(docdir)
497 AC_SUBST(mansubdir)
498 SHCFLAGS="$PICFLAGS $CFLAGS"
499 AC_SUBST(SHCFLAGS)
500
501 AC_MSG_CHECKING([Resolving libexec path...])
502 fullpath=$libexecdir
503 while test "x$temppath" != "x$fullpath" ; do
504   temppath=$fullpath
505   fullpath=`eval echo ${fullpath}`
506 done
507 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
508 AC_MSG_RESULT([$fullpath/noit])
509 AC_DEFINE_UNQUOTED(MODULES_DIR, "${fullpath}/noit")
510 MODULES_DIR=${fullpath}/noit
511 AC_SUBST(MODULES_DIR)
512
513 AC_MSG_CHECKING([Resolving sysconfdir path...])
514 fullpath=$sysconfdir
515 while test "x$temppath" != "x$fullpath" ; do
516   temppath=$fullpath
517   fullpath=`eval echo ${fullpath}`
518 done
519 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
520 AC_MSG_RESULT([$fullpath])
521 AC_DEFINE_UNQUOTED(ETC_DIR, "${fullpath}")
522 ETC_DIR=${fullpath}
523 AC_SUBST(ETC_DIR)
524
525
526 AC_OUTPUT([
527 Makefile
528 src/Makefile
529 src/eventer/Makefile
530 src/jlog/Makefile
531 src/jlog/perl/Makefile.PL
532 src/udns/Makefile
533 src/man/Makefile
534 src/modules/Makefile
535 src/modules-lua/Makefile
536 src/utils/Makefile
537 src/noitedit/Makefile
538 src/lua/Makefile
539 sql/Makefile
540 test/Makefile
541 ])
Note: See TracBrowser for help on using the browser.