root/configure.in

Revision 4330e3d7e1aa02f7bfd1892c3294b652c79ce3a5, 8.4 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 11 years ago)

fixes #7

  • 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 # Should we build ssh2 checks?
114 SAVELIBS="$LIBS"
115 AC_CHECK_LIB(ssh2, libssh2_session_init_ex,
116         [
117                 BUILD_MODULES="$BUILD_MODULES ssh2.$MODULEEXT"
118         ],
119         [
120                 AC_MSG_ERROR([No libssh2, skipping ssh2 module])
121         ]
122 )
123 LIBS="$SAVELIBS"
124
125 AC_MSG_CHECKING([libxml2 cflags])
126 XML2CFLAGS=`xml2-config --cflags`
127 CFLAGS="$CFLAGS $XML2CFLAGS"
128 AC_MSG_RESULT([$XML2CFLAGS])
129
130 AC_MSG_CHECKING([libxml2 libs])
131 XML2LIBS=`xml2-config --libs`
132 LIBS="$LIBS $XML2LIBS"
133 AC_MSG_RESULT([$XML2LIBS])
134
135 AC_MSG_CHECKING([libserf cflags])
136 SERFCFLAGS="`apr-1-config --cflags --cppflags`"
137 SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`"
138 AC_SUBST(SERFCFLAGS)
139 AC_MSG_RESULT([$SERFCFLAGS])
140
141 AC_MSG_CHECKING([libserf libs])
142 SERFLIBS="`apu-1-config --link-ld --ldflags --libs` `apr-1-config --link-ld --ldflags --libs`"
143 AC_SUBST(SERFLIBS)
144 AC_MSG_RESULT([$SERFLIBS])
145
146 AC_TRY_LINK([],
147         [ issetugid(); ],
148         [ ac_cv_libc_defines_issetugid="yes" ],
149         [ ac_cv_libc_defines_issetugid="no" ]
150 )
151 if test "x$ac_cv_libc_defines_issetugid" = "xyes" ; then
152         AC_DEFINE(HAVE_ISSETUGID)
153 fi
154
155 AC_MSG_CHECKING([whether sem_init works])
156 AC_TRY_RUN(
157         [
158 #include <semaphore.h>
159 int main(void){sem_t s;return (0 != sem_init(&s,0,0));}
160         ],
161         [AC_MSG_RESULT(yes)],
162         [
163                 AC_MSG_RESULT(no)
164                 AC_DEFINE(BROKEN_SEM_INIT)
165                 AC_MSG_WARN([****** sem_init() is broken, I'll implement one myself.])
166         ]
167 )
168
169 AC_FUNC_STRFTIME
170 AC_CHECK_FUNC(ssetugid strlcpy)
171
172 # Checks for header files.
173 AC_CHECK_HEADERS(sys/file.h sys/types.h dirent.h sys/param.h fcntl.h errno.h limits.h \
174                  sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \
175                  ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \
176                  term.h termio.h termios.h curses.h sys/cdefs.h pwd.h netinet/in_systm.h \
177                  util.h sys/time.h sys/mman.h)
178
179 AC_CACHE_CHECK([for kqueue support], ac_cv_have_kqueue, [
180         AC_TRY_LINK(
181                 [ #include <sys/types.h> ],
182                 [ u_int a; a = kqueue(); ],
183                 [ ac_cv_have_kqueue="yes" ],
184                 [ ac_cv_have_kqueue="no" ]
185         )
186 ])
187 if test "x$ac_cv_have_kqueue" = "xyes" ; then
188         AC_DEFINE(HAVE_KQUEUE)
189         have_kqueue=1
190 fi
191
192
193 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
194         AC_TRY_COMPILE(
195                 [ #include <sys/types.h> ],
196                 [ u_int a; a = 1;],
197                 [ ac_cv_have_u_int="yes" ],
198                 [ ac_cv_have_u_int="no" ]
199         )
200 ])
201 if test "x$ac_cv_have_u_int" = "xyes" ; then
202         AC_DEFINE(HAVE_U_INT)
203         have_u_int=1
204 fi
205
206 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
207         AC_TRY_COMPILE(
208                 [ #include <sys/types.h> ],
209                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
210                 [ ac_cv_have_intxx_t="yes" ],
211                 [ ac_cv_have_intxx_t="no" ]
212         )
213 ])
214 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
215         AC_DEFINE(HAVE_INTXX_T)
216         have_intxx_t=1
217 fi
218        
219 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
220         AC_TRY_COMPILE(
221                 [ #include <sys/types.h> ],
222                 [ int64_t a; a = 1;],
223                 [ ac_cv_have_int64_t="yes" ],
224                 [ ac_cv_have_int64_t="no" ]
225         )
226 ])
227 if test "x$ac_cv_have_int64_t" = "xyes" ; then
228         AC_DEFINE(HAVE_INT64_T)
229         have_int64_t=1
230 fi
231        
232 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
233         AC_TRY_COMPILE(
234                 [ #include <sys/types.h> ],
235                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
236                 [ ac_cv_have_u_intxx_t="yes" ],
237                 [ ac_cv_have_u_intxx_t="no" ]
238         )
239 ])
240 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
241         AC_DEFINE(HAVE_U_INTXX_T)
242         have_u_intxx_t=1
243 fi
244
245 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
246         AC_TRY_COMPILE(
247                 [ #include <sys/types.h> ],
248                 [ u_int64_t a; a = 1;],
249                 [ ac_cv_have_u_int64_t="yes" ],
250                 [ ac_cv_have_u_int64_t="no" ]
251         )
252 ])
253 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
254         AC_DEFINE(HAVE_U_INT64_T)
255         have_u_int64_t=1
256 fi
257
258 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
259            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
260 then
261         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
262         AC_TRY_COMPILE(
263                 [
264 #include <sys/bitypes.h>
265                 ],
266                 [
267                         int8_t a; int16_t b; int32_t c;
268                         u_int8_t e; u_int16_t f; u_int32_t g;
269                         a = b = c = e = f = g = 1;
270                 ],
271                 [
272                         AC_DEFINE(HAVE_U_INTXX_T)
273                         AC_DEFINE(HAVE_INTXX_T)
274                         AC_MSG_RESULT(yes)
275                 ],
276                 [AC_MSG_RESULT(no)]
277         )
278 fi
279
280 if test -z "$have_u_intxx_t" ; then
281         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
282                 AC_TRY_COMPILE(
283                         [
284 #include <sys/types.h>
285                         ],
286                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
287                         [ ac_cv_have_uintxx_t="yes" ],
288                         [ ac_cv_have_uintxx_t="no" ]
289                 )
290         ])
291         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
292                 AC_DEFINE(HAVE_UINTXX_T)
293         fi
294 fi
295
296 AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
297         AC_TRY_COMPILE(
298                 [
299 #include <sys/types.h>
300 #include <sys/socket.h>
301                 ],
302                 [socklen_t foo; foo = 1235;],
303                 [ ac_cv_have_socklen_t="yes" ],
304                 [ ac_cv_have_socklen_t="no" ]
305         )
306 ])
307 if test "x$ac_cv_have_socklen_t" = "xyes" ; then
308         AC_DEFINE(HAVE_SOCKLEN_T)
309 fi
310
311 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
312         AC_TRY_COMPILE(
313                 [
314 #include <sys/types.h>
315                 ],
316                 [ size_t foo; foo = 1235; ],
317                 [ ac_cv_have_size_t="yes" ],
318                 [ ac_cv_have_size_t="no" ]
319         )
320 ])
321 if test "x$ac_cv_have_size_t" = "xyes" ; then
322         AC_DEFINE(HAVE_SIZE_T)
323 fi
324
325 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
326         AC_TRY_COMPILE(
327                 [
328 #include <sys/types.h>
329                 ],
330                 [ ssize_t foo; foo = 1235; ],
331                 [ ac_cv_have_ssize_t="yes" ],
332                 [ ac_cv_have_ssize_t="no" ]
333         )
334 ])
335 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
336         AC_DEFINE(HAVE_SSIZE_T)
337 fi
338
339 AC_SUBST(BUILD_MODULES)
340
341 docdir="docs"
342 mansubdir="man"
343 AC_SUBST(docdir)
344 AC_SUBST(mansubdir)
345
346 CPPFLAGS='-I$(top_srcdir)/src'
347 SHCFLAGS="$PICFLAGS $CFLAGS"
348 AC_SUBST(SHCFLAGS)
349
350 AC_MSG_CHECKING([Resolving libexec path...])
351 fullpath=$libexecdir
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(MODULES_DIR, "${fullpath}")
359 MODULES_DIR=${fullpath}
360 AC_SUBST(MODULES_DIR)
361
362 AC_MSG_CHECKING([Resolving sysconfdir path...])
363 fullpath=$sysconfdir
364 while test "x$temppath" != "x$fullpath" ; do
365   temppath=$fullpath
366   fullpath=`eval echo ${fullpath}`
367 done
368 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
369 AC_MSG_RESULT([$fullpath])
370 AC_DEFINE_UNQUOTED(ETC_DIR, "${fullpath}")
371 ETC_DIR=${fullpath}
372 AC_SUBST(ETC_DIR)
373
374
375 AC_OUTPUT([
376 Makefile
377 src/Makefile
378 src/eventer/Makefile
379 src/jlog/Makefile
380 src/modules/Makefile
381 src/utils/Makefile
382 src/noitedit/Makefile
383 ])
Note: See TracBrowser for help on using the browser.