root/configure.in

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

This is needed on OpenBSD too, refs #29

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