root/configure.in

Revision ad852cb8546e10444c22e82377d8821d24cfec15, 13.1 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 5 years ago)

does this work? refs #60

  • 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_FUNC(uuid_generate, , [
114   AC_MSG_WARN([uuid_generate not available])
115   AC_CHECK_LIB(uuid, uuid_generate, , [AC_MSG_ERROR(*** uuid is required ***)])])
116
117 # Some libraries provide an unparse_lower command
118 # we use that, so if it isn't present, we'll need
119 # to implement it.
120 AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE(HAVE_UUID_UNPARSE_LOWER)], )
121 AC_CHECK_LIB(util, openpty, , )
122 AC_CHECK_LIB(termcap, tputs, , )
123 AC_CHECK_LIB(curses, clear, , [AC_MSG_ERROR([curses not found, but required])])
124
125 CPPFLAGS="$CPPFLAGS `pcre-config --cflags`"
126 LDFLAGS="$LDFLAGS `pcre-config --libs`"
127 AC_CHECK_LIB(pcre, pcre_compile, ,
128         [
129                 AC_MSG_ERROR([libpcre not found, but required])
130         ]
131 )
132 AC_CHECK_LIB(crypto, ERR_load_CRYPTO_strings, ,
133         [
134                 AC_MSG_ERROR([libcrypto not found, but required])
135         ]
136 )
137 AC_CHECK_LIB(ssl, SSL_library_init, ,
138         [
139                 AC_MSG_ERROR([libssl not found, but required])
140         ]
141 )
142
143 old_LIBS=$LIBS
144 old_CFLAGS=$CFLAGS
145 AC_CHECK_LIB(pq, PQconnectdb,
146         [
147                 LIBS="$LIBS -lpq"
148                 PGLIBS="$LIBS"
149                 AC_SUBST(PGLIBS)
150         ],
151         [
152                 AC_MSG_ERROR([libpq required])
153         ]
154 )
155
156 AC_MSG_CHECKING([libpq includes])
157 PQICFLAGS=`pg_config --includedir`
158 if test -n "$PQICFLAGS" ; then
159   CFLAGS="$CFLAGS -I$PQICFLAGS"
160 fi
161
162 AC_TRY_LINK([
163         #include <libpq-fe.h>
164         ],
165         [ PGconn *dbh = PQconnectdb(""); ],
166         [],
167         [ AC_MSG_ERROR([Cannot compile/link against libpq]) ]
168 )
169 PGCFLAGS=$CFLAGS
170 AC_SUBST(PGCFLAGS)
171
172 LIBS=$old_LIBS
173 CFLAGS=$old_CFLAGS
174
175 old_CFLAGS=$CFLAGS
176 old_LIBS=$LIBS
177 CFLAGS="$CFLAGS $MYCFLAGS"
178 LIBS="$MYLIBS"
179
180 AC_CHECK_FUNC(mysql_real_connect,
181         [
182                 BUILD_MODULES="$BUILD_MODULES mysql.$MODULEEXT"
183                 MYCFLAGS="$CFLAGS"
184                 MYLIBS="$LIBS"
185                 AC_SUBST(MYCFLAGS)
186                 AC_SUBST(MYLIBS)
187         ],
188         [
189                 AC_MSG_WARN([No libmysqlclient, skipping mysql module])
190         ]
191 )
192
193
194 LIBS=$old_LIBS
195 CFLAGS=$old_CFLAGS
196
197 ########
198 #
199 # CHECK FOR VARIOUS MODULE CRITERIA
200 # We don't track the libs themselves, as we'll just explictly link
201 # against the in the makefile if we enable them to build (by adding
202 # them to the BUILD_MODULES list).
203 #
204 ########
205
206 # Should we build snmp checks?
207 SAVELIBS="$LIBS"
208 AC_CHECK_LIB(netsnmp, snmp_sess_open,
209         [
210                 BUILD_MODULES="$BUILD_MODULES snmp.$MODULEEXT"
211         ],
212         [
213                 AC_MSG_WARN([No libnetsnmp, skipping snmp module])
214         ]
215 )
216 LIBS="$SAVELIBS"
217
218 # Should we build ssh2 checks?
219 SAVELIBS="$LIBS"
220 AC_CHECK_LIB(ssh2, libssh2_session_init_ex,
221         [
222                 BUILD_MODULES="$BUILD_MODULES ssh2.$MODULEEXT"
223         ],
224         [
225                 AC_MSG_WARN([No libssh2, skipping ssh2 module])
226         ]
227 )
228 LIBS="$SAVELIBS"
229
230 AC_MSG_CHECKING([libxml2 cflags])
231 XML2CFLAGS=`xml2-config --cflags`
232 CFLAGS="$CFLAGS $XML2CFLAGS"
233 AC_MSG_RESULT([$XML2CFLAGS])
234
235 AC_MSG_CHECKING([libxml2 libs])
236 XML2LIBS=`xml2-config --libs`
237 LIBS="$LIBS $XML2LIBS"
238 AC_MSG_RESULT([$XML2LIBS])
239
240 AC_CHECK_FUNC(xmlParseDocument, , [AC_MSG_ERROR(*** libxml2 is required ***)])
241
242 AC_MSG_CHECKING([libxslt cflags])
243 XSLTCFLAGS=`xslt-config --cflags`
244 CFLAGS="$CFLAGS $XSLTCFLAGS"
245 AC_MSG_RESULT([$XSLTCFLAGS])
246
247 AC_MSG_CHECKING([libxslt libs])
248 XSLTLIBS=`xslt-config --libs`
249 LIBS="$LIBS $XSLTLIBS"
250 AC_MSG_RESULT([$XSLTLIBS])
251
252 AC_CHECK_FUNC(xsltParseStylesheetDoc, , [AC_MSG_ERROR(*** libxslt is required ***)])
253
254 APRPREFIX="`apr-1-config --prefix`"
255 AC_MSG_CHECKING([libserf cflags])
256 AC_SUBST(APRPREFIX)
257 AC_MSG_RESULT([$APRPREFIX])
258
259 AC_MSG_CHECKING([libserf cflags])
260 SERFCFLAGS="`apr-1-config --cflags --cppflags`"
261 SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`"
262 AC_SUBST(SERFCFLAGS)
263 AC_MSG_RESULT([$SERFCFLAGS])
264
265 AC_MSG_CHECKING([libserf libs])
266 SERFLIBS="`apu-1-config --link-ld --ldflags --libs` `apr-1-config --link-ld --ldflags --libs`"
267 AC_SUBST(SERFLIBS)
268 AC_MSG_RESULT([$SERFLIBS])
269
270 AC_TRY_LINK([],
271         [ issetugid(); ],
272         [ ac_cv_libc_defines_issetugid="yes" ],
273         [ ac_cv_libc_defines_issetugid="no" ]
274 )
275 if test "x$ac_cv_libc_defines_issetugid" = "xyes" ; then
276         AC_DEFINE(HAVE_ISSETUGID)
277 fi
278
279 AC_MSG_CHECKING([whether sem_init works])
280 AC_TRY_RUN(
281         [
282 #include <semaphore.h>
283 int main(void){sem_t s;return (0 != sem_init(&s,0,0));}
284         ],
285         [
286                 AC_MSG_RESULT(yes)
287                 AC_DEFINE(WORKING_SEM_INIT)
288         ],
289         [
290                 AC_MSG_RESULT(no)
291                 AC_MSG_WARN([****** sem_init() is broken, I'll implement one myself.])
292         ]
293 )
294
295 AC_FUNC_STRFTIME
296 AC_CHECK_FUNCS(ssetugid strlcpy strnstrn openpty inet_pton inet_ntop getopt \
297                poll)
298
299 # Checks for header files.
300 AC_CHECK_HEADERS(sys/file.h sys/types.h dirent.h sys/param.h fcntl.h errno.h limits.h \
301                  sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \
302                  ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \
303                  term.h termio.h termios.h curses.h sys/cdefs.h grp.h netinet/in_systm.h \
304                  sys/ioctl_compat.h sys/filio.h util.h sys/time.h sys/mman.h \
305                  stropts.h sys/stream.h alloca.h sys/wait.h)
306
307 AC_CHECK_FUNCS(getpwnam_r)
308 GETPWNAM_R_POSIX
309 AC_CHECK_FUNCS(getgrnam_r)
310 GETGRNAM_R_POSIX
311
312 AC_MSG_CHECKING(for tputs() function final argument type)
313 AC_EGREP_CPP([tputs.*[(][       ]*char[         ]*[)]],
314                 [#if defined(HAVE_TERM_H)
315                  #include <term.h>
316                  #endif
317                  #if defined(HAVE_CURSES_H)
318                  #include <curses.h>
319                  #endif],
320                 [AC_MSG_RESULT(char)
321                  AC_DEFINE(TPUTS_TAKES_CHAR)],
322                 [AC_MSG_RESULT(not char)])
323
324 AC_CACHE_CHECK([for epoll support], ac_cv_have_epoll, [
325         AC_TRY_LINK(
326                 [ #include <sys/types.h> ],
327                 [ u_int a; a = epoll_create(); ],
328                 [ ac_cv_have_epoll="yes" ],
329                 [ ac_cv_have_epoll="no" ]
330         )
331 ])
332 if test "x$ac_cv_have_epoll" = "xyes" ; then
333         AC_DEFINE(HAVE_EPOLL)
334         EVENTER_OBJS="$EVENTER_OBJS eventer_epoll_impl.o"
335         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "epoll")
336         have_epoll=1
337 fi
338
339 AC_CACHE_CHECK([for kqueue support], ac_cv_have_kqueue, [
340         AC_TRY_LINK(
341                 [ #include <sys/types.h> ],
342                 [ u_int a; a = kqueue(); ],
343                 [ ac_cv_have_kqueue="yes" ],
344                 [ ac_cv_have_kqueue="no" ]
345         )
346 ])
347 if test "x$ac_cv_have_kqueue" = "xyes" ; then
348         AC_DEFINE(HAVE_KQUEUE)
349         EVENTER_OBJS="$EVENTER_OBJS eventer_kqueue_impl.o"
350         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "kqueue")
351         have_kqueue=1
352 fi
353
354 AC_CACHE_CHECK([for Solaris ports support], ac_cv_have_ports, [
355         AC_TRY_LINK(
356                 [ #include <port.h> ],
357                 [ u_int a; a = port_create(); ],
358                 [ ac_cv_have_ports="yes" ],
359                 [ ac_cv_have_ports="no" ]
360         )
361 ])
362 if test "x$ac_cv_have_ports" = "xyes" ; then
363         AC_DEFINE(HAVE_PORTS)
364         EVENTER_OBJS="$EVENTER_OBJS eventer_ports_impl.o"
365         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "ports")
366         have_ports=1
367 fi
368
369 AC_SUBST(EVENTER_OBJS)
370
371 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
372         AC_TRY_COMPILE(
373                 [ #include <sys/types.h> ],
374                 [ u_int a; a = 1;],
375                 [ ac_cv_have_u_int="yes" ],
376                 [ ac_cv_have_u_int="no" ]
377         )
378 ])
379 if test "x$ac_cv_have_u_int" = "xyes" ; then
380         AC_DEFINE(HAVE_U_INT)
381         have_u_int=1
382 fi
383
384 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
385         AC_TRY_COMPILE(
386                 [ #include <sys/types.h> ],
387                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
388                 [ ac_cv_have_intxx_t="yes" ],
389                 [ ac_cv_have_intxx_t="no" ]
390         )
391 ])
392 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
393         AC_DEFINE(HAVE_INTXX_T)
394         have_intxx_t=1
395 fi
396        
397 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
398         AC_TRY_COMPILE(
399                 [ #include <sys/types.h> ],
400                 [ int64_t a; a = 1;],
401                 [ ac_cv_have_int64_t="yes" ],
402                 [ ac_cv_have_int64_t="no" ]
403         )
404 ])
405 if test "x$ac_cv_have_int64_t" = "xyes" ; then
406         AC_DEFINE(HAVE_INT64_T)
407         have_int64_t=1
408 fi
409        
410 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
411         AC_TRY_COMPILE(
412                 [ #include <sys/types.h> ],
413                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
414                 [ ac_cv_have_u_intxx_t="yes" ],
415                 [ ac_cv_have_u_intxx_t="no" ]
416         )
417 ])
418 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
419         AC_DEFINE(HAVE_U_INTXX_T)
420         have_u_intxx_t=1
421 fi
422
423 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
424         AC_TRY_COMPILE(
425                 [ #include <sys/types.h> ],
426                 [ u_int64_t a; a = 1;],
427                 [ ac_cv_have_u_int64_t="yes" ],
428                 [ ac_cv_have_u_int64_t="no" ]
429         )
430 ])
431 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
432         AC_DEFINE(HAVE_U_INT64_T)
433         have_u_int64_t=1
434 fi
435
436 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
437            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
438 then
439         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
440         AC_TRY_COMPILE(
441                 [
442 #include <sys/bitypes.h>
443                 ],
444                 [
445                         int8_t a; int16_t b; int32_t c;
446                         u_int8_t e; u_int16_t f; u_int32_t g;
447                         a = b = c = e = f = g = 1;
448                 ],
449                 [
450                         AC_DEFINE(HAVE_U_INTXX_T)
451                         AC_DEFINE(HAVE_INTXX_T)
452                         AC_MSG_RESULT(yes)
453                 ],
454                 [AC_MSG_RESULT(no)]
455         )
456 fi
457
458 if test -z "$have_u_intxx_t" ; then
459         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
460                 AC_TRY_COMPILE(
461                         [
462 #include <sys/types.h>
463                         ],
464                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
465                         [ ac_cv_have_uintxx_t="yes" ],
466                         [ ac_cv_have_uintxx_t="no" ]
467                 )
468         ])
469         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
470                 AC_DEFINE(HAVE_UINTXX_T)
471         fi
472 fi
473
474 AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
475         AC_TRY_COMPILE(
476                 [
477 #include <sys/types.h>
478 #include <sys/socket.h>
479                 ],
480                 [socklen_t foo; foo = 1235;],
481                 [ ac_cv_have_socklen_t="yes" ],
482                 [ ac_cv_have_socklen_t="no" ]
483         )
484 ])
485 if test "x$ac_cv_have_socklen_t" = "xyes" ; then
486         AC_DEFINE(HAVE_SOCKLEN_T)
487 fi
488
489 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
490         AC_TRY_COMPILE(
491                 [
492 #include <sys/types.h>
493                 ],
494                 [ size_t foo; foo = 1235; ],
495                 [ ac_cv_have_size_t="yes" ],
496                 [ ac_cv_have_size_t="no" ]
497         )
498 ])
499 if test "x$ac_cv_have_size_t" = "xyes" ; then
500         AC_DEFINE(HAVE_SIZE_T)
501 fi
502
503 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
504         AC_TRY_COMPILE(
505                 [
506 #include <sys/types.h>
507                 ],
508                 [ ssize_t foo; foo = 1235; ],
509                 [ ac_cv_have_ssize_t="yes" ],
510                 [ ac_cv_have_ssize_t="no" ]
511         )
512 ])
513 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
514         AC_DEFINE(HAVE_SSIZE_T)
515 fi
516
517 AC_SUBST(BUILD_MODULES)
518
519 docdir="docs"
520 mansubdir="man"
521 AC_SUBST(docdir)
522 AC_SUBST(mansubdir)
523 SHCFLAGS="$PICFLAGS $CFLAGS"
524 AC_SUBST(SHCFLAGS)
525
526 AC_MSG_CHECKING([Resolving libexec path...])
527 fullpath=$libexecdir
528 while test "x$temppath" != "x$fullpath" ; do
529   temppath=$fullpath
530   fullpath=`eval echo ${fullpath}`
531 done
532 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
533 AC_MSG_RESULT([$fullpath/noit])
534 AC_DEFINE_UNQUOTED(MODULES_DIR, "${fullpath}/noit")
535 MODULES_DIR=${fullpath}/noit
536 AC_SUBST(MODULES_DIR)
537
538 AC_MSG_CHECKING([Resolving sysconfdir path...])
539 fullpath=$sysconfdir
540 while test "x$temppath" != "x$fullpath" ; do
541   temppath=$fullpath
542   fullpath=`eval echo ${fullpath}`
543 done
544 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
545 AC_MSG_RESULT([$fullpath])
546 AC_DEFINE_UNQUOTED(ETC_DIR, "${fullpath}")
547 ETC_DIR=${fullpath}
548 AC_SUBST(ETC_DIR)
549
550
551 AC_OUTPUT([
552 Makefile
553 src/Makefile
554 src/eventer/Makefile
555 src/jlog/Makefile
556 src/jlog/perl/Makefile.PL
557 src/udns/Makefile
558 src/man/Makefile
559 src/modules/Makefile
560 src/modules-lua/Makefile
561 src/utils/Makefile
562 src/noitedit/Makefile
563 src/lua/Makefile
564 sql/Makefile
565 test/Makefile
566 ])
Note: See TracBrowser for help on using the browser.