3 dnl $Id: configure.in,v 1.54 2015/10/10 04:17:10 sjg Exp $
5 dnl Process this file with autoconf to produce a configure script
8 AC_INIT([bmake], [20151009], [sjg@NetBSD.org])
9 AC_CONFIG_HEADERS(config.h)
11 dnl make srcdir absolute
14 *) srcdir=`cd $srcdir && pwd`;;
19 [ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
21 yes) AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
23 *) case "$with_defshell" in
24 sh) DEFSHELL_INDEX=DEFSHELL_INDEX_SH;; # it's the default anyway
25 ksh) DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;;
26 csh) DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;; # kidding right?
27 *) defshell_path=$with_defshell;; # better be sh compatible!
34 [ --without-meta dissable use of meta-mode],
36 yes|no) use_meta=${withval};;
37 *) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
41 [ --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode],
42 [ case "/${withval}" in
43 /no|*/filemon.h) filemon_h="${withval}";;
44 */filemon*) filemon_h="${withval}/filemon.h";;
45 *) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
49 for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
53 filemon_h="$d$x/filemon.h"
54 test -s "$filemon_h" && break
56 test -s "$filemon_h" && break
58 test -s "${filemon_h:-/dev/null}" || filemon_h=no
60 dnl echo "Note: use_meta=$use_meta filemon_h=$filemon_h" >&6
64 *.h) echo "Using: filemon=$filemon_h" >&6;;
69 dnl Check for OS problems
70 dnl Solaris's signal.h only privides sigset_t etc if one of
71 dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
72 dnl The later two seem to cause more problems than they solve so if we
73 dnl see _EXTENSIONS_ we use it.
74 AC_USE_SYSTEM_EXTENSIONS
75 dnl Checks for programs.
77 AC_PROG_GCC_TRADITIONAL
79 dnl Executable suffix - normally empty; .exe on os2.
80 AC_SUBST(ac_exe_suffix)dnl
82 dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
83 if test -x /usr/bin/getconf; then
84 bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
85 # only a numeric response is useful
86 test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
88 bmake_path_max=${bmake_path_max:-1024}
89 if test $bmake_path_max -gt 1024; then
90 # this is all we expect
93 echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6
94 AC_SUBST(bmake_path_max)dnl
99 dnl Checks for header files.
103 dnl Keep this list sorted
123 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
124 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
125 dnl also if sys/cdefs.h does not have __RCSID we need to use ours
126 dnl but we need to include the host's one too *sigh*
127 AC_CHECK_HEADER(sys/cdefs.h,
128 echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6
130 [#include <sys/cdefs.h>
136 echo no >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"),
137 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
139 dnl Checks for typedefs, structures, and compiler characteristics.
150 dnl Checks for library functions.
155 dnl Keep this list sorted
188 dnl functions which we may need to provide
196 AC_CHECK_LIB([util], [emalloc],
197 [ AC_CHECK_LIB([util], [erealloc],
198 [ AC_CHECK_LIB([util], [estrdup],
199 [ AC_CHECK_LIB([util], [estrndup],
200 [ LIBS="$LIBS -lutil"
201 CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
209 echo "checking if compiler supports __func__" >&6
211 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],,
212 AC_DEFINE(__func__, __FUNCTION__, C99 function name))
214 dnl we want this for unit-tests/Makefile
215 echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6
216 if diff -u /dev/null /dev/null > /dev/null 2>&1; then
224 dnl AC_* don't quite cut it.
226 echo "checking for MACHINE & MACHINE_ARCH..." >&6
227 cat > conftest.$ac_ext <<EOF
228 #include "confdefs.h"
229 #include <sys/param.h>
234 machine_arch=MACHINE_ARCH
238 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 |
239 egrep machine= | tr -d ' "'`
241 if test "$default_machine"; then
242 eval "$default_machine"
244 machine=${machine:-`$srcdir/machine.sh`}
245 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
246 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
248 dnl now allow overrides
251 [ --with-machine=MACHINE explicitly set MACHINE],
252 [case "${withval}" in
253 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
255 generic) machine=`$srcdir/machine.sh`;;
256 *) machine=$with_machine;;
259 AC_ARG_WITH(force_machine,
260 [ --with-force-machine=MACHINE set FORCE_MACHINE],
261 [case "${withval}" in
262 yes) force_machine=FORCE_;;
264 *) force_machine=FORCE_; machine=$with_force_machine;;
268 AC_ARG_WITH(force_machine_arch,
269 [ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH],
270 [case "${withval}" in
271 yes) force_machine_arch=FORCE_;;
273 *) force_machine_arch=FORCE_; machine_arch=$with_force_machine;;
276 AC_ARG_WITH(machine_arch,
277 [ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH],
278 [case "${withval}" in
279 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
281 *) machine_arch=$with_machine_arch;;
284 dnl Tell them what we ended up with
286 echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
288 dnl Allow folk to control _PATH_DEFSYSPATH
290 default_sys_path=\${prefix}/share/mk
291 AC_ARG_WITH(default-sys-path,
292 [ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH
293 MAKESYSPATH is a ':' separated list of directories
294 that bmake will search for system .mk files.
295 _PATH_DEFSYSPATH is its default value.],
296 [case "${withval}" in
297 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
299 *) default_sys_path="$with_default_sys_path"
303 dnl Some folk don't like this one
305 AC_ARG_WITH(path-objdirprefix,
306 [ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX],
307 [case "${withval}" in
308 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
309 no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
310 *) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
313 dnl And this can be handy to do with out.
315 AC_ARG_ENABLE(pwd-override,
316 [ --disable-pwd-override disable \$PWD overriding getcwd()],
317 [case "${enableval}" in
319 no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
320 *) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
325 AC_ARG_ENABLE(check-make-chdir,
326 [ --disable-check-make-chdir disable make trying to guess
327 when it should automatically cd \${.CURDIR}],
328 [case "${enableval}" in
330 no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
331 *) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
334 dnl On non-BSD systems, bootstrap won't work without mk
337 [ --with-mksrc=PATH tell makefile.boot where to find mk src],
338 [case "${withval}" in
340 *) test -s $withval/install-mk && mksrc=$withval ||
341 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
346 dnl Now make sure we have a value
348 srcdir=`cd $srcdir && pwd`
349 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
351 test -s $mksrc/install-mk || continue
352 mksrc=`cd $mksrc && pwd`
355 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
356 echo "Using: MKSRC=$mksrc" 1>&6
357 dnl On some systems we want a different default shell by default
358 if test -x /usr/xpg4/bin/sh; then
359 defshell_path=${defshell_path:-/usr/xpg4/bin/sh}
361 if test -n "$defshell_path"; then
362 echo "Using: SHELL=$defshell_path" >&6
363 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
365 if test -n "$DEFSHELL_INDEX"; then
366 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
370 AC_SUBST(force_machine)
371 AC_SUBST(machine_arch)
373 AC_SUBST(default_sys_path)
379 AC_OUTPUT(makefile Makefile.config make-bootstrap.sh unit-tests/Makefile)
385 sh ./make-bootstrap.sh
387 to produce a fully functional bmake.