root/configure.in

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

Patch from Sean Coates to make uuid detection terminal

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