root/configure.in

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

integrate command line docs as usage, refs #21

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