1 AC_INIT([kamid], [0.2], [kamid@omarpolo.com], [],
2 [https://kamid.omarpolo.com])
4 AC_CONFIG_LIBOBJ_DIR(compat)
5 AM_INIT_AUTOMAKE([foreign subdir-objects])
9 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
11 AC_SUBST(KAMID_RELEASE)
15 # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
16 # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
20 # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
21 # AC_CHECK_HEADER doesn't give us any other way to update the include
22 # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
23 SAVED_CFLAGS="$CFLAGS"
24 SAVED_CPPFLAGS="$CPPFLAGS"
25 SAVED_LDFLAGS="$LDFLAGS"
27 # Checks for programs.
36 AC_USE_SYSTEM_EXTENSIONS
38 # Some functions can be in libbsd. Thanks to lldpb for the inspiration :)
40 AS_HELP_STRING([--with-libbsd], [Use libbsd @<:@default=auto@:>@]),
43 if test x"$with_libbsd" != x"no"; then
44 PKG_CHECK_MODULES([libbsd], [libbsd-overlay libbsd-ctor], [
45 AM_CFLAGS="$AM_CFLAGS $libbsd_CFLAGS"
46 LIBS="$LIBS $libbsd_LIBS"
48 if test x"$with_libbsd" = x"yes"; then
49 AC_MSG_FAILURE([*** no libbsd support found])
74 AC_MSG_CHECKING([for sys/queue.h with TAILQ_FOREACH_SAFE and STAILQ_ENTRY])
75 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
76 #include <sys/queue.h>
79 TAILQ_HEAD(tailhead, entry) head;
81 TAILQ_ENTRY(entry) entries;
84 TAILQ_FOREACH_SAFE(np, &head, entries, nt) {
88 STAILQ_HEAD(listhead, qentry) qhead = STAILQ_HEAD_INITIALIZER(qhead);
90 STAILQ_ENTRY(qentry) entries;
96 AC_DEFINE([HAVE_QUEUE_H], 1, [QUEUE_H])
99 AC_MSG_CHECKING([for usable sys/tree.h])
100 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
101 #include <sys/tree.h>
106 SPLAY_ENTRY(client) sp_entry;
108 SPLAY_HEAD(clients_tree_id, client) clients;
111 clients_tree_cmp(struct client *a, struct client *b)
115 else if (a->id < b->id)
121 SPLAY_PROTOTYPE(clients_tree_id, client, sp_entry, clients_tree_cmp);
122 SPLAY_GENERATE(clients_tree_id, client, sp_entry, clients_tree_cmp);
127 AC_DEFINE([HAVE_SYS_TREE_H], 1, [TREE_H])
128 ], AC_MSG_RESULT(no))
130 AC_CHECK_HEADER([endian.h], [AC_DEFINE(HAVE_ENDIAN_H, 1, [have endian.h])], [
131 AC_CHECK_HEADER([sys/endian.h],
132 [AC_DEFINE(HAVE_SYS_ENDIAN_H, 1, [have sys/endian.h])], [
133 AC_CHECK_HEADERS([libkern/OSByteOrder.h],
134 [AC_DEFINE(HAVE_LIBKERN_OSBYTEORDER_H, 1, [have OSByteOrder.h])],
135 [AC_MSG_ERROR([can't find compatible endian.h header])],
136 [#include <machine/endian.h>])
140 AC_CHECK_DECL(PR_SET_NAME, AC_DEFINE([HAVE_PR_SET_NAME], 1, [pr_set_name]), [],
141 [[#include <sys/prctl.h>]])
143 AC_CHECK_LIB([crypto], [RAND_add], [], [
144 AC_MSG_ERROR([requires openssl])
147 AC_CHECK_LIB(tls, tls_init, [], [
148 AC_MSG_ERROR([requires libtls])
152 [*openbsd*], [AC_CHECK_LIB([event], [event_init], [],
153 [AC_MSG_ERROR([requires libevent])])],
154 [PKG_CHECK_MODULES([libevent2], [libevent_core >= 2],
156 AC_DEFINE([HAVE_EVENT2], 1, [1 if using event2])
157 AM_CFLAGS="$libevent2_CFLAGS $AM_CFLAGS"
158 LIBS="$libevent2_LIBS $LIBS"
159 ], [AC_MSG_ERROR([requires libevent])])])
161 AC_CHECK_LIB(util, imsg_init, [], [
162 AC_LIBOBJ(fmt_scaled)
164 AC_LIBOBJ(imsg-buffer)
171 AC_DEFINE([HAVE_READLINE], 1, [1 if readline found])
173 READLINE_LIBS='-lreadline'
175 PKG_CHECK_MODULES([READLINE], [readline], [
176 AC_DEFINE([HAVE_READLINE], 1, [])
178 AC_DEFINE([HAVE_READLINE], 0, [])
182 AC_SUBST(READLINE_CFLAGS)
183 AC_SUBST(READLINE_LIBS)
185 # check compiler flags
186 AC_DEFUN([CC_ADD_CHECK_FLAGS], [
187 AC_MSG_CHECKING([if $CC supports $1 flag])
188 old_AM_CFLAGS="$AM_CFLAGS"
189 AM_CFLAGS="$AM_CFLAGS $1"
190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
191 AC_MSG_RESULT(yes), [
193 AM_CFLAGS="$old_AM_CFLAGS"
196 CC_ADD_CHECK_FLAGS([-Wall])
197 CC_ADD_CHECK_FLAGS([-Wextra])
198 CC_ADD_CHECK_FLAGS([-Wmissing-declarations])
199 CC_ADD_CHECK_FLAGS([-Wmissing-prototypes])
200 CC_ADD_CHECK_FLAGS([-Wstrict-prototypes])
201 CC_ADD_CHECK_FLAGS([-Wwrite-strings])
202 CC_ADD_CHECK_FLAGS([-Wno-unused-parameter])
203 CC_ADD_CHECK_FLAGS([-Wpointer-arith])
204 CC_ADD_CHECK_FLAGS([-Wsign-compare])
205 CC_ADD_CHECK_FLAGS([-Wcast-align])
206 CC_ADD_CHECK_FLAGS([-Wno-pointer-sign])
208 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
210 AC_SUBST(AM_CPPFLAGS)
211 CPPFLAGS="$SAVED_CPPFLAGS"
213 CFLAGS="$SAVED_CFLAGS"
215 LDFLAGS="$SAVED_LDFLAGS"
217 AC_CONFIG_HEADERS([config.h])
229 regress/lisp/Makefile
230 regress/ninepscript/Makefile