3 dnl $Id: configure.in,v 1.46 2012/12/28 21:28:18 sjg Exp $
5 dnl Process this file with autoconf to produce a configure script
7 AC_INIT([bmake], [20121212], [sjg@NetBSD.org])
8 AC_CONFIG_HEADER(config.h)
10 dnl make srcdir absolute
13 *) srcdir=`cd $srcdir && pwd`;;
18 [ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
20 yes) AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
22 *) case "$with_defshell" in
23 sh) DEFSHELL_INDEX=DEFSHELL_INDEX_SH;; # it's the default anyway
24 ksh) DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;;
25 csh) DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;; # kidding right?
26 *) defshell_path=$with_defshell;; # better be sh compatible!
33 [ --without-meta dissable use of meta-mode],
35 yes|no) use_meta=${withval};;
36 *) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
40 [ --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode],
41 [ case "/${withval}" in
42 /no|*/filemon.h) filemon_h="${withval}";;
43 */filemon*) filemon_h="${withval}/filemon.h";;
44 *) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
48 for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
52 filemon_h="$d$x/filemon.h"
53 test -s "$filemon_h" && break
55 test -s "$filemon_h" && break
57 test -s "${filemon_h:-/dev/null}" || filemon_h=no
59 dnl echo "Note: use_meta=$use_meta filemon_h=$filemon_h" >&6
63 *.h) echo "Using: filemon=$filemon_h" >&6;;
68 dnl Check for OS problems
69 dnl Solaris's signal.h only privides sigset_t etc if one of
70 dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
71 dnl The later two seem to cause more problems than they solve so if we
72 dnl see _EXTENSIONS_ we use it.
73 AC_USE_SYSTEM_EXTENSIONS
74 dnl Checks for programs.
76 AC_PROG_GCC_TRADITIONAL
78 dnl Executable suffix - normally empty; .exe on os2.
79 AC_SUBST(ac_exe_suffix)dnl
82 dnl Check if /bin/sh will pass .MAKE.LEVEL
83 echo $ECHO_N "checking if sh will pass .MAKE. variables... $ECHO_C" >&6
84 ok=`env .MAKE.LEVEL=1 /bin/sh -c env | grep LEVEL=`
86 "") echo no >&6; CPPFLAGS="${CPPFLAGS} -DNEED_MAKE_LEVEL_SAFE";;
94 dnl Checks for header files.
98 dnl Keep this list sorted
116 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
117 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
118 dnl also if sys/cdefs.h does not have __RCSID we need to use ours
119 dnl but we need to include the host's one too *sigh*
120 AC_CHECK_HEADER(sys/cdefs.h,
121 echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6
123 [#include <sys/cdefs.h>
129 echo no >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"),
130 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
132 dnl Checks for typedefs, structures, and compiler characteristics.
143 dnl Checks for library functions.
148 dnl Keep this list sorted
180 dnl functions which we may need to provide
188 AC_CHECK_LIB([util], [emalloc],
189 [ AC_CHECK_LIB([util], [erealloc],
190 [ AC_CHECK_LIB([util], [estrdup],
191 [ AC_CHECK_LIB([util], [estrndup],
192 [ LIBS="$LIBS -lutil"
193 CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
201 dnl we want this for unit-tests/Makefile
202 echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6
203 if diff -u /dev/null /dev/null > /dev/null 2>&1; then
211 dnl AC_* don't quite cut it.
213 echo "checking for MACHINE & MACHINE_ARCH..." >&6
214 cat > conftest.$ac_ext <<EOF
215 #include "confdefs.h"
216 #include <sys/param.h>
221 machine_arch=MACHINE_ARCH
225 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 |
226 egrep machine= | tr -d ' "'`
228 if test "$default_machine"; then
229 eval "$default_machine"
231 machine=${machine:-`$srcdir/machine.sh`}
232 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
233 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
235 dnl now allow overrides
238 [ --with-machine=MACHINE explicitly set MACHINE],
239 [case "${withval}" in
240 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
242 generic) machine=`$srcdir/machine.sh`;;
243 *) machine=$with_machine;;
246 AC_ARG_WITH(force_machine,
247 [ --with-force-machine=MACHINE set FORCE_MACHINE],
248 [case "${withval}" in
249 yes) force_machine=FORCE_;;
251 *) force_machine=FORCE_; machine=$with_force_machine;;
255 AC_ARG_WITH(force_machine_arch,
256 [ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH],
257 [case "${withval}" in
258 yes) force_machine_arch=FORCE_;;
260 *) force_machine_arch=FORCE_; machine_arch=$with_force_machine;;
263 AC_ARG_WITH(machine_arch,
264 [ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH],
265 [case "${withval}" in
266 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
268 *) machine_arch=$with_machine_arch;;
271 dnl Tell them what we ended up with
273 echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
275 dnl Allow folk to control _PATH_DEFSYSPATH
277 default_sys_path=\${prefix}/share/mk
278 AC_ARG_WITH(default-sys-path,
279 [ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH
280 MAKESYSPATH is a ':' separated list of directories
281 that bmake will search for system .mk files.
282 _PATH_DEFSYSPATH is its default value.],
283 [case "${withval}" in
284 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
286 *) default_sys_path="$with_default_sys_path"
290 dnl Some folk don't like this one
292 AC_ARG_WITH(path-objdirprefix,
293 [ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX],
294 [case "${withval}" in
295 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
296 no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
297 *) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
300 dnl And this can be handy to do with out.
302 AC_ARG_ENABLE(pwd-override,
303 [ --disable-pwd-override disable \$PWD overriding getcwd()],
304 [case "${enableval}" in
306 no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
307 *) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
312 AC_ARG_ENABLE(check-make-chdir,
313 [ --disable-check-make-chdir disable make trying to guess
314 when it should automatically cd \${.CURDIR}],
315 [case "${enableval}" in
317 no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
318 *) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
321 dnl On non-BSD systems, bootstrap won't work without mk
324 [ --with-mksrc=PATH tell makefile.boot where to find mk src],
325 [case "${withval}" in
327 *) test -s $withval/install-mk && mksrc=$withval ||
328 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
333 dnl Now make sure we have a value
335 srcdir=`cd $srcdir && pwd`
336 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
338 test -s $mksrc/install-mk || continue
339 mksrc=`cd $mksrc && pwd`
342 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
343 echo "Using: MKSRC=$mksrc" 1>&6
344 dnl On some systems we want a different default shell by default
345 if test -x /usr/xpg4/bin/sh; then
346 defshell_path=${defshell_path:-/usr/xpg4/bin/sh}
348 if test -n "$defshell_path"; then
349 echo "Using: SHELL=$defshell_path" >&6
350 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
352 if test -n "$DEFSHELL_INDEX"; then
353 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
357 AC_SUBST(force_machine)
358 AC_SUBST(machine_arch)
360 AC_SUBST(default_sys_path)
366 AC_OUTPUT(makefile Makefile.config make-bootstrap.sh unit-tests/Makefile)
372 sh ./make-bootstrap.sh
374 to produce a fully functional bmake.