root/configure.in

Revision 644a39f2b16d4123980672227c37632008c01012, 13.0 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

MySQL from Dave Gray with some cleanup, refs #10

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