root/configure.in

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

refactor shared code, add module dependency detection and start splitting out libs in configure

  • Property mode set to 100755
Line 
1 AC_INIT(src/noitd.c)
2 AC_CANONICAL_HOST
3 AC_CONFIG_HEADER(src/noit_config.h)
4 AC_CONFIG_HEADER(src/jlog/jlog_config.h)
5
6 AC_PROG_CC
7 AC_C_INLINE
8 AC_C_BIGENDIAN
9 AC_PROG_CPP
10 AC_PROG_RANLIB
11 AC_PROG_INSTALL
12 AC_PROG_LN_S
13 AC_PATH_PROG(AR, ar)
14 AC_PATH_PROGS(PERL, perl)
15 AC_SUBST(PERL)
16
17 if test "x$CC" = "xgcc" ; then
18   CFLAGS="$CFLAGS -g -Wall"
19 fi
20
21 case $host in
22 *-*-darwin*)
23         PICFLAGS="-fPIC"
24         MODULELD="$CC -bundle -flat_namespace -undefined suppress"
25         MODULEEXT=bundle
26         ;;
27 *-*-solaris*)
28         PICFLAGS="-Kpic"
29         MODULELD="$CC -G"
30         MODULEEXT=so
31         ;;
32 *-*-openbsd*)
33         PICFLAGS="-fpic"
34         LDFLAGS="$LDFLAGS -Wl,-E"
35         MODULELD="$CC -shared"
36         MODULEEXT=so
37         ;;
38 *)
39         PICFLAGS="-fpic"
40         MODULELD="$CC -shared"
41         MODULEEXT=so
42         ;;
43 esac
44 AC_SUBST(MODULELD)
45 AC_SUBST(MODULEEXT)
46 AC_DEFINE_UNQUOTED(MODULEEXT, "$MODULEEXT", [module extension])
47
48 # Checks for data types
49 AC_CHECK_SIZEOF(char, 1)
50 AC_CHECK_SIZEOF(short int, 2)
51 AC_CHECK_SIZEOF(int, 4)
52 AC_CHECK_SIZEOF(long int, 4)
53 AC_CHECK_SIZEOF(long long int, 8)
54 AC_CHECK_SIZEOF(void *, 1)
55
56 AC_CHECK_LIB(rt, sem_init, , )
57 AC_CHECK_LIB(posix4, sem_wait, , )
58 AC_CHECK_LIB(pthread, pthread_create, , )
59 AC_CHECK_LIB(uuid, uuid_generate, , )
60 AC_CHECK_LIB(util, openpty, , )
61 AC_CHECK_LIB(termcap, tputs, , )
62 AC_CHECK_LIB(curses, clear, , )
63 AC_CHECK_LIB(ssl, SSL_library_init, ,
64         [
65                 AC_MSG_ERROR([libssl not found, but required])
66         ]
67 )
68 AC_CHECK_LIB(crypto, ERR_load_CRYPTO_strings, ,
69         [
70                 AC_MSG_ERROR([libssl not found, but required])
71         ]
72 )
73
74 SAVELIBS="$LIBS"
75 AC_CHECK_LIB(pq, PQconnectdb,
76         [
77                 LIBS="$LIBS -lpq"
78                 PGLIBS="$LIBS"
79                 AC_SUBST(PGLIBS)
80         ],
81         [
82                 AC_MSG_ERROR([libpq required])
83         ]
84 )
85 AC_TRY_LINK([#include <libpq-fe.h>],
86         [ PGconn *dbh = PQconnectdb(""); ],
87         [],
88         [ AC_MSG_ERROR([Cannot compile/link against libpq]) ]
89 )
90 LIBS="$SAVELIBS"
91
92 ########
93 #
94 # CHECK FOR VARIOUS MODULE CRITERIA
95 # We don't track the libs themselves, as we'll just explictly link
96 # against the in the makefile if we enable them to build (by adding
97 # them to the BUILD_MODULES list).
98 #
99 ########
100
101 # Should we build snmp checks?
102 SAVELIBS="$LIBS"
103 AC_CHECK_LIB(netsnmp, snmp_sess_open,
104         [
105                 BUILD_MODULES="$BUILD_MODULES snmp.$MODULEEXT"
106         ],
107         [
108                 AC_MSG_ERROR([No libnetsnmp, skipping snmp module])
109         ]
110 )
111 LIBS="$SAVELIBS"
112
113 AC_MSG_CHECKING([libxml2 cflags])
114 XML2CFLAGS=`xml2-config --cflags`
115 CFLAGS="$CFLAGS $XML2CFLAGS"
116 AC_MSG_RESULT([$XML2CFLAGS])
117
118 AC_MSG_CHECKING([libxml2 libs])
119 XML2LIBS=`xml2-config --libs`
120 LIBS="$LIBS $XML2LIBS"
121 AC_MSG_RESULT([$XML2LIBS])
122
123 AC_MSG_CHECKING([libserf cflags])
124 SERFCFLAGS="`apr-1-config --cflags --cppflags`"
125 SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`"
126 AC_SUBST(SERFCFLAGS)
127 AC_MSG_RESULT([$SERFCFLAGS])
128
129 AC_MSG_CHECKING([libserf libs])
130 SERFLIBS="`apu-1-config --link-ld --ldflags --libs` `apr-1-config --link-ld --ldflags --libs`"
131 AC_SUBST(SERFLIBS)
132 AC_MSG_RESULT([$SERFLIBS])
133
134 AC_TRY_LINK([],
135         [ issetugid(); ],
136         [ ac_cv_libc_defines_issetugid="yes" ],
137         [ ac_cv_libc_defines_issetugid="no" ]
138 )
139 if test "x$ac_cv_libc_defines_issetugid" = "xyes" ; then
140         AC_DEFINE(HAVE_ISSETUGID)
141 fi
142
143 AC_MSG_CHECKING([whether sem_init works])
144 AC_TRY_RUN(
145         [
146 #include <semaphore.h>
147 int main(void){sem_t s;return (0 != sem_init(&s,0,0));}
148         ],
149         [AC_MSG_RESULT(yes)],
150         [
151                 AC_MSG_RESULT(no)
152                 AC_DEFINE(BROKEN_SEM_INIT)
153                 AC_MSG_WARN([****** sem_init() is broken, I'll implement one myself.])
154         ]
155 )
156
157 AC_FUNC_STRFTIME
158 AC_CHECK_FUNC(ssetugid strlcpy)
159
160 # Checks for header files.
161 AC_CHECK_HEADERS(sys/file.h sys/types.h dirent.h sys/param.h fcntl.h errno.h limits.h \
162                  sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \
163                  ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \
164                  term.h termio.h termios.h curses.h sys/cdefs.h pwd.h netinet/in_systm.h \
165                  util.h sys/time.h sys/mman.h)
166
167 AC_CACHE_CHECK([for kqueue support], ac_cv_have_kqueue, [
168         AC_TRY_LINK(
169                 [ #include <sys/types.h> ],
170                 [ u_int a; a = kqueue(); ],
171                 [ ac_cv_have_kqueue="yes" ],
172                 [ ac_cv_have_kqueue="no" ]
173         )
174 ])
175 if test "x$ac_cv_have_kqueue" = "xyes" ; then
176         AC_DEFINE(HAVE_KQUEUE)
177         have_kqueue=1
178 fi
179
180
181 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
182         AC_TRY_COMPILE(
183                 [ #include <sys/types.h> ],
184                 [ u_int a; a = 1;],
185                 [ ac_cv_have_u_int="yes" ],
186                 [ ac_cv_have_u_int="no" ]
187         )
188 ])
189 if test "x$ac_cv_have_u_int" = "xyes" ; then
190         AC_DEFINE(HAVE_U_INT)
191         have_u_int=1
192 fi
193
194 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
195         AC_TRY_COMPILE(
196                 [ #include <sys/types.h> ],
197                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
198                 [ ac_cv_have_intxx_t="yes" ],
199                 [ ac_cv_have_intxx_t="no" ]
200         )
201 ])
202 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
203         AC_DEFINE(HAVE_INTXX_T)
204         have_intxx_t=1
205 fi
206        
207 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
208         AC_TRY_COMPILE(
209                 [ #include <sys/types.h> ],
210                 [ int64_t a; a = 1;],
211                 [ ac_cv_have_int64_t="yes" ],
212                 [ ac_cv_have_int64_t="no" ]
213         )
214 ])
215 if test "x$ac_cv_have_int64_t" = "xyes" ; then
216         AC_DEFINE(HAVE_INT64_T)
217         have_int64_t=1
218 fi
219        
220 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
221         AC_TRY_COMPILE(
222                 [ #include <sys/types.h> ],
223                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
224                 [ ac_cv_have_u_intxx_t="yes" ],
225                 [ ac_cv_have_u_intxx_t="no" ]
226         )
227 ])
228 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
229         AC_DEFINE(HAVE_U_INTXX_T)
230         have_u_intxx_t=1
231 fi
232
233 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
234         AC_TRY_COMPILE(
235                 [ #include <sys/types.h> ],
236                 [ u_int64_t a; a = 1;],
237                 [ ac_cv_have_u_int64_t="yes" ],
238                 [ ac_cv_have_u_int64_t="no" ]
239         )
240 ])
241 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
242         AC_DEFINE(HAVE_U_INT64_T)
243         have_u_int64_t=1
244 fi
245
246 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
247            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
248 then
249         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
250         AC_TRY_COMPILE(
251                 [
252 #include <sys/bitypes.h>
253                 ],
254                 [
255                         int8_t a; int16_t b; int32_t c;
256                         u_int8_t e; u_int16_t f; u_int32_t g;
257                         a = b = c = e = f = g = 1;
258                 ],
259                 [
260                         AC_DEFINE(HAVE_U_INTXX_T)
261                         AC_DEFINE(HAVE_INTXX_T)
262                         AC_MSG_RESULT(yes)
263                 ],
264                 [AC_MSG_RESULT(no)]
265         )
266 fi
267
268 if test -z "$have_u_intxx_t" ; then
269         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
270                 AC_TRY_COMPILE(
271                         [
272 #include <sys/types.h>
273                         ],
274                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
275                         [ ac_cv_have_uintxx_t="yes" ],
276                         [ ac_cv_have_uintxx_t="no" ]
277                 )
278         ])
279         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
280                 AC_DEFINE(HAVE_UINTXX_T)
281         fi
282 fi
283
284 AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
285         AC_TRY_COMPILE(
286                 [
287 #include <sys/types.h>
288 #include <sys/socket.h>
289                 ],
290                 [socklen_t foo; foo = 1235;],
291                 [ ac_cv_have_socklen_t="yes" ],
292                 [ ac_cv_have_socklen_t="no" ]
293         )
294 ])
295 if test "x$ac_cv_have_socklen_t" = "xyes" ; then
296         AC_DEFINE(HAVE_SOCKLEN_T)
297 fi
298
299 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
300         AC_TRY_COMPILE(
301                 [
302 #include <sys/types.h>
303                 ],
304                 [ size_t foo; foo = 1235; ],
305                 [ ac_cv_have_size_t="yes" ],
306                 [ ac_cv_have_size_t="no" ]
307         )
308 ])
309 if test "x$ac_cv_have_size_t" = "xyes" ; then
310         AC_DEFINE(HAVE_SIZE_T)
311 fi
312
313 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
314         AC_TRY_COMPILE(
315                 [
316 #include <sys/types.h>
317                 ],
318                 [ ssize_t foo; foo = 1235; ],
319                 [ ac_cv_have_ssize_t="yes" ],
320                 [ ac_cv_have_ssize_t="no" ]
321         )
322 ])
323 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
324         AC_DEFINE(HAVE_SSIZE_T)
325 fi
326
327 AC_SUBST(BUILD_MODULES)
328
329 docdir="docs"
330 mansubdir="man"
331 AC_SUBST(docdir)
332 AC_SUBST(mansubdir)
333
334 CPPFLAGS='-I$(top_srcdir)/src'
335 SHCFLAGS="$PICFLAGS $CFLAGS"
336 AC_SUBST(SHCFLAGS)
337
338 AC_MSG_CHECKING([Resolving libexec path...])
339 fullpath=$libexecdir
340 while test "x$temppath" != "x$fullpath" ; do
341   temppath=$fullpath
342   fullpath=`eval echo ${fullpath}`
343 done
344 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
345 AC_MSG_RESULT([$fullpath])
346 AC_DEFINE_UNQUOTED(MODULES_DIR, "${fullpath}")
347 MODULES_DIR=${fullpath}
348 AC_SUBST(MODULES_DIR)
349
350 AC_MSG_CHECKING([Resolving sysconfdir path...])
351 fullpath=$sysconfdir
352 while test "x$temppath" != "x$fullpath" ; do
353   temppath=$fullpath
354   fullpath=`eval echo ${fullpath}`
355 done
356 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
357 AC_MSG_RESULT([$fullpath])
358 AC_DEFINE_UNQUOTED(ETC_DIR, "${fullpath}")
359 ETC_DIR=${fullpath}
360 AC_SUBST(ETC_DIR)
361
362
363 AC_OUTPUT([
364 Makefile
365 src/Makefile
366 src/eventer/Makefile
367 src/jlog/Makefile
368 src/modules/Makefile
369 src/utils/Makefile
370 src/noitedit/Makefile
371 ])
Note: See TracBrowser for help on using the browser.