root/configure.in

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

addresses a lot of warnings. gcc still complains about stuff in xpath stuff, doesn't look like our code though, refs #34

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