root/configure.ac

Revision 19caec1835b1b48503b1338723fcf956d80c81d2, 6.5 kB (checked in by Hans Petter Jansson <hpj@kzerza.amok>, 11 years ago)

Clean up build system.

  • Property mode set to 100644
Line 
1 AC_INIT(configure.ac)
2
3 dnl -------------------------------------
4 dnl Automake/autoconf input file for Flux
5 dnl -------------------------------------
6
7 GLIB_REQUIRED=2.0.0
8 GMP_REQUIRED=3.0.1
9
10
11 dnl --- Package configuration ---
12
13 AM_CONFIG_HEADER(flux/config.h)
14 AM_INIT_AUTOMAKE(flux, 0.10.0)
15 AC_SUBST(VERSION)
16 AC_SUBST(PACKAGE)
17
18 AC_SUBST(GLIB_REQUIRED)
19 AC_SUBST(GMP_REQUIRED)
20
21 AC_CANONICAL_HOST
22
23 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
24 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package name])
25 AC_DEFINE_UNQUOTED(CPU, "$host_cpu", [Build host CPU])
26 AC_DEFINE_UNQUOTED(HOSTNAME, "`hostname`", [Build host name])
27
28 FLUX_CFLAGS='-DG_LOG_DOMAIN=\"Flux\" -I$(top_srcdir)'
29
30 AM_ACLOCAL_INCLUDE(macros)
31
32
33 dnl --- Checks for programs and libraries ---
34
35 AC_ISC_POSIX
36 AC_PROG_CC
37 AM_PROG_LIBTOOL
38
39 AC_DEFINE_UNQUOTED(PRINTABLE_CC_NAME, "unknown", [Build compiler name])
40
41 AC_CACHE_CHECK([for getaddrinfo], flux_cv_hasgetaddrinfo,[
42         AC_COMPILE_IFELSE([
43         #include <sys/types.h>
44         #include <sys/socket.h>
45         #include <netdb.h>
46         int main () {
47         struct addrinfo  hints;
48         struct addrinfo *res = NULL;
49         const char *name = "test";
50         hints.ai_socktype = SOCK_STREAM;
51         getaddrinfo (name, NULL, &hints, &res);
52         if (res) freeaddrinfo (res); }
53         ],
54         flux_cv_hasgetaddrinfo=yes,
55         flux_cv_hasgetaddrinfo=no,)
56 ])
57
58 case x$flux_cv_hasgetaddrinfo in
59 xyes) AC_DEFINE(HAVE_GETADDRINFO,1,[Have getaddrinfo])
60 esac
61
62 PKG_CHECK_MODULES(ALL, \
63   glib-2.0 >= $GLIB_REQUIRED \
64   gobject-2.0 >= $GLIB_REQUIRED \
65   gthread-2.0 >= $GLIB_REQUIRED)
66
67 GTK_DOC_CHECK([1.0])
68
69
70 dnl --- Determine build target ---
71
72 case "${target}" in
73     i386--mingw32)
74         # Special stuff for Win NT
75         cross_compiling=yes
76         CC="i386--mingw32-gcc"
77         CPP="i386--mingw32-gcc -E"
78         RANLIB="i386--mingw32-ranlib"
79         ac_cv_have_dev_random=no
80         AC_DEFINE(USE_RAND_FAKED, 1, [Using faked randomness])
81         ;;
82     *-*-hpux*)
83         if test -z "$GCC" ; then
84             FLUX_CFLAGS="$FLUX_CFLAGS -Ae -D_HPUX_SOURCE"
85         fi
86         AC_DEFINE(USE_RAND_UNIX, 1, [Using kernel randomness])
87         ;;
88     *cygwin*)
89         ac_cv_have_dev_random=no
90         AC_DEFINE(USE_RAND_FAKED, 1, [Using faked randomness])
91         ;;
92     *)
93         AC_DEFINE(USE_RAND_UNIX, 1, [Using kernel randomness])
94         ;;
95 esac
96
97 case "${target}" in
98     i386--mingw32)
99         PRINTABLE_OS_NAME="MingW32"
100         ;;
101     *-linux*)
102         PRINTABLE_OS_NAME="GNU/Linux"
103         ;;
104     *CYGWIN*)
105         PRINTABLE_OS_NAME="GNU/Win32"
106         ;;
107     *)
108         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
109         ;;
110 esac
111 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME", [Printable build OS name])
112
113 dnl Are these the best flags for OpenBSD?
114 case "${target}" in
115     *-openbsd*)
116         NAME_OF_DEV_RANDOM="/dev/srandom"
117         NAME_OF_DEV_URANDOM="/dev/urandom"
118         ;;
119     *)
120         NAME_OF_DEV_RANDOM="/dev/random"
121         NAME_OF_DEV_URANDOM="/dev/urandom"
122         ;;
123 esac
124
125 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM", [Path to strong randomness device])
126 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM", [Path to secondary randomness device])
127
128
129 dnl --- Check for passed options ---
130
131 AC_MSG_CHECKING([whether use of /dev/random is requested])
132 AC_ARG_ENABLE(dev-random,
133 [  --disable-dev-random    disable the use of dev random],
134    try_dev_random=$enableval, try_dev_random=yes)
135 AC_MSG_RESULT($try_dev_random)
136
137
138 dnl --- Set compiler flags ---
139
140 FLUX_CFLAGS="$FLUX_CFLAGS -Wall"
141
142
143 dnl --- Checks for libraries ---
144
145 AC_CHECK_LIB(socket, socket)
146 AC_CHECK_LIB(nsl, gethostbyname)
147
148 FLUX_LIBS=$LIBS
149
150 AM_PATH_GMP($GMP_REQUIRED,
151   [FLUX_LIBS="$FLUX_LIBS $GMP_LIBS" FLUX_CFLAGS="$FLUX_CFLAGS $GMP_CFLAGS"],
152   AC_MSG_ERROR(Cannot find GNU MP))
153
154 FLUX_LIBS="$FLUX_LIBS -lm -lz `pkg-config --libs glib-2.0 gobject-2.0 gthread-2.0`"
155 FLUX_CFLAGS="$FLUX_CFLAGS `pkg-config --cflags glib-2.0 gobject-2.0 gthread-2.0`"
156
157
158 dnl --- Checks for header files ---
159
160 AC_HEADER_STDC
161 AC_CHECK_HEADERS(sys/time.h sys/ioctl.h sys/filio.h sys/types.h unistd.h gnuregex.h)
162
163 AC_MSG_CHECKING(for mpz_init in gmp.h)
164 AC_EGREP_CPP(yes,
165 [#include <gmp.h>
166 #ifdef mpz_init
167   yes
168 #endif
169 ], AC_MSG_RESULT(yes)
170 AC_DEFINE(HAVE_GMP, 1, [Whether we have GMP]), AC_MSG_RESULT(no))
171
172
173 dnl --- Check whether we have a random device ---
174
175 if test "$try_dev_random" = yes ; then
176 AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
177 [if test -c "$NAME_OF_DEV_RANDOM" && test -c "$NAME_OF_DEV_URANDOM" ; then
178   ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
179 if test "$ac_cv_have_dev_random" = yes; then
180     AC_DEFINE(HAVE_DEV_RANDOM, 1, [Whether we have a randomness generating device])
181 fi
182 else
183     AC_MSG_CHECKING(for random device)
184     ac_cv_have_dev_random=no
185     AC_MSG_RESULT(disabled)
186 fi
187
188
189 dnl --- Checks for library functions ---
190
191 AC_PROG_GCC_TRADITIONAL
192
193 dnl --- Disable rebuild of glib-mkenum -generated source code ---
194
195 AC_ARG_ENABLE(rebuilds, [  --disable-rebuilds      disable all source autogeneration rules],,enable_rebuilds=yes)
196
197 # Define a MAINT-like variable REBUILD which is set if Perl
198 # is found, so autogenerated sources can be rebuilt.
199 AC_CHECK_PROGS(PERL, perl5 perl)
200
201 REBUILD=\#
202 if test "x$enable_rebuilds" = "xyes" && \
203      test -n "$PERL" && \
204      $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 ; then
205   REBUILD=
206 fi
207 AC_SUBST(REBUILD)
208
209 dnl --- Output ---
210
211 AC_SUBST(FLUX_LIBS)
212 AC_SUBST(FLUX_CFLAGS)
213
214 AC_OUTPUT(flux/Makefile             \
215           flux/win32/Makefile       \
216           flux/flux.pc              \
217           test/Makefile             \
218           doc/Makefile              \
219           doc/reference/Makefile    \
220           doc/reference/version.xml \
221           flux-redhat.spec          \
222           flux-suse.spec            \
223           Makefile)
224
225
226 dnl --- Print configuration summary ---
227
228 printable_libdir=$(eval echo $(eval echo $libdir))
229 dnl printable_htmldir=$(eval echo $(eval echo $datadir))/flux/html
230 printable_htmldir=$(eval echo $(eval echo $HTML_DIR))
231
232 if test x$ac_cv_have_dev_random = xyes; then random_space="";   else random_space=" ";   fi
233 if test x$enable_gtk_doc        = xyes; then gtk_doc_space="";  else gtk_doc_space=" ";  fi
234
235 echo
236 echo "Configuration Summary"
237 echo "---------------------"
238 echo
239 echo "Installation Paths"
240 echo "  - Library:             $printable_libdir"
241 echo "  - HTML documentation:  $printable_htmldir"
242 echo
243 echo "Functionality"
244 echo "  - Use kernel entropy:  $ac_cv_have_dev_random $random_space (detected | --disable-dev-random)"
245 echo
246 echo "Extras"
247 echo "  - Build documentation: $enable_gtk_doc $gtk_doc_space (--enable-gtk-doc)"
248 echo
Note: See TracBrowser for help on using the browser.