root/configure.in

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

make sure mysql doesn't build when the libs aren't here

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