root/configure.in

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

fixes #31

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