]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/configure.in
zfs: merge openzfs/zfs@57cfae4a2 (master)
[FreeBSD/FreeBSD.git] / contrib / bmake / configure.in
1 dnl
2 dnl RCSid:
3 dnl     $Id: configure.in,v 1.87 2022/09/09 20:00:53 sjg Exp $
4 dnl
5 dnl Process this file with autoconf to produce a configure script
6 dnl
7 AC_PREREQ([2.71])
8 AC_INIT([bmake],[20220909],[sjg@NetBSD.org])
9 AC_CONFIG_HEADERS(config.h)
10
11 dnl make srcdir absolute
12 case "$srcdir" in
13 /*) ;;
14 *) srcdir=`cd $srcdir && 'pwd'`;;
15 esac
16
17 dnl get _MAKE_VERSION
18 . $srcdir/VERSION
19 OS=`uname -s`
20
21 dnl function to set DEFSHELL_INDEX
22 use_defshell() {
23         case "$defshell_path$DEFSHELL_INDEX" in
24         "") ;;
25         *) return 0;;
26         esac
27         case "$1" in
28         *csh) # we must be desperate
29                 DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;;
30         *ksh)
31                 DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;;
32         sh|/bin/sh)
33                 DEFSHELL_INDEX=DEFSHELL_INDEX_SH;;
34         *)      DEFSHELL_INDEX=DEFSHELL_INDEX_CUSTOM
35                 defshell_path=$1
36                 ;;
37         esac
38         case "$1" in
39         /bin/*) ;;
40         */*) defshell_path=$1;;
41         esac
42 }
43 dnl
44 AC_ARG_WITH(defshell,
45 [  --with-defshell=SHELL  use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
46 [case "${withval}" in
47 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
48 no)    ;;
49 *)     use_defshell $with_defshell;;
50 esac])
51 dnl
52 case "$OS" in
53 CYGWIN*|MINGW*) use_makefile=no;;
54 *) use_makefile=yes;;
55 esac
56 AC_ARG_WITH(makefile,
57 [  --without-makefile disable use of generated makefile],
58 [case "${withval}" in
59 yes|no) use_makefile=${withval};;
60 *) AC_MSG_ERROR(bad value ${withval} given for makefile) ;;
61 esac])
62 dnl
63 use_meta=yes
64 AC_ARG_WITH(meta,
65 [  --without-meta disable use of meta-mode],
66 [case "${withval}" in
67 yes|no) use_meta=${withval};;
68 *) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
69 esac])
70 dnl
71 AC_ARG_WITH(filemon,
72 [  --with-filemon={no,dev,ktrace,path/filemon.h} indicate filemon method for meta-mode. Path to filemon.h implies dev],
73 [ case "/${withval}" in
74 /no) use_filemon=no;;
75 /*trace) filemon_h=no use_filemon="${withval}";;
76 */filemon.h) filemon_h="${withval}";;
77 */filemon*) filemon_h="${withval}/filemon.h";;
78 *) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
79 esac
80 case "$use_filemon,$filemon_h" in
81 ,*.h) use_filemon=dev;;
82 esac
83 ],
84 [
85 case "$OS" in
86 NetBSD) filemon_h=no use_filemon=ktrace;;
87 *)
88     for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/../../sys/dev/filemon"
89     do  
90         for x in "/$OS" ""
91         do
92             filemon_h="$d$x/filemon.h"
93             test -s "$filemon_h" && break
94         done
95         test -s "$filemon_h" && { use_filemon=dev; break; }
96     done
97     ;;
98 esac
99 use_filemon=${use_filemon:-no}
100 case "$use_filemon" in
101 dev) ;;
102 *) filemon_h=no;;
103 esac
104 ])
105 dnl echo "Note: use_meta=$use_meta use_filemon=$use_filemon filemon_h=$filemon_h" >&6
106 case "$use_meta" in
107 yes)
108         case "$use_filemon" in
109         no) ;;
110         *) echo "Using: filemon_${use_filemon}.c" >&6;;
111         esac
112         ;;
113 esac
114 dnl
115 dnl Check for OS problems
116 dnl
117 dnl Minix 3 at least has bugs in headers where _NETBSD_SOURCE
118 dnl is needed for compilation
119 case "$OS" in
120 Minix)  CPPFLAGS="${CPPFLAGS} -D_NETBSD_SOURCE"
121         test -x /usr/pkg/bin/clang && CC=${CC:-clang}
122         ;;
123 SCO_SV) # /bin/sh is not usable
124         ALT_DEF_SHELLS="/bin/lsh /usr/bin/bash /bin/ksh"
125         CPPFLAGS="${CPPFLAGS} -DFORCE_USE_SHELL"
126         ;;
127 esac
128 dnl
129 dnl Not everyone groks TZ=Europe/Berlin
130 dnl which is used by the localtime tests
131 echo $ECHO_N "checking whether system has timezone Europe/Berlin... $ECHO_C" >&6
132 if test -f /usr/share/zoneinfo/Europe/Berlin; then
133         echo yes  >&6
134         # seems a safe bet
135         UTC_1=Europe/Berlin
136 else
137         utcH=`TZ=UTC date +%H 2> /dev/null`
138         utc_1H=`TZ=UTC-1 date +%H 2> /dev/null`
139         if test ${utcH-0} -lt ${utc_1H-0}; then
140                 UTC_1=UTC-1
141                 echo no, using UTC-1 >&6
142         else
143                 echo no >&6
144         fi
145 fi
146 dnl
147 dnl Add some places to look for compilers
148 oldPATH=$PATH
149 for d in /usr/gnu/bin
150 do
151         test -d $d || continue
152         PATH=$PATH:$d
153 done
154 export PATH     
155 dnl Solaris's signal.h only privides sigset_t etc if one of
156 dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
157 dnl The later two seem to cause more problems than they solve so if we
158 dnl see _EXTENSIONS_ we use it.
159 AC_USE_SYSTEM_EXTENSIONS
160 dnl Checks for programs.
161 AC_PROG_CC
162 AC_PROG_INSTALL
163 dnl Executable suffix - normally empty; .exe on os2.
164 AC_SUBST(ac_exe_suffix)dnl
165 dnl
166 dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
167 if test -x /usr/bin/getconf; then
168    bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
169    # only a numeric response is useful
170    test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
171 fi
172 bmake_path_max=${bmake_path_max:-1024}
173 if test $bmake_path_max -gt 1024; then
174    # this is all we expect
175    bmake_path_max=1024
176 fi
177 echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6
178 AC_SUBST(bmake_path_max)dnl
179 dnl
180 dnl if type does not work which(1) had better!
181 dnl note we cannot rely on type returning non-zero on failure
182 if (type cat) > /dev/null 2>&1; then
183 : which
184 which() {
185         type "$@" | sed 's,[[()]],,g;s,^[[^/]][[^/]]*,,;q'
186 }
187 fi
188 dnl if CC is somewhere that was not in PATH we need its full path
189 dnl watch out for included flags!
190 case "$CC" in
191 /*) ;;
192 *)
193     for x in $CC
194     do
195         _cc=`which $x`
196         break
197     done
198     if test -x ${_cc:-/dev/null}; then
199         _cc_dir=`dirname $_cc`
200         case ":$oldPATH:" in
201         *:$_cc_dir:*) ;;
202         *) CC=$_cc_dir/$CC;;
203         esac
204     fi
205     ;;
206 esac
207 dnl Checks for header files.
208 AC_HEADER_SYS_WAIT
209 AC_HEADER_DIRENT
210 dnl Keep this list sorted
211 AC_CHECK_HEADERS(sys/param.h)
212 dnl On BSDi at least we really need sys/param.h for sys/sysctl.h
213 AC_CHECK_HEADERS([sys/sysctl.h], [], [],
214 [#ifdef HAVE_SYS_PARAM_H
215 # include <sys/param.h>
216 # endif
217 ])
218
219 AC_CHECK_HEADERS( \
220         ar.h \
221         err.h \
222         fcntl.h \
223         libgen.h \
224         limits.h \
225         paths.h \
226         poll.h \
227         ranlib.h \
228         sys/mman.h \
229         sys/select.h \
230         sys/socket.h \
231         sys/time.h \
232         sys/uio.h \
233         utime.h \
234         )
235
236 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
237 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
238 AC_CHECK_HEADER(sys/cdefs.h,,
239 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
240
241 dnl Checks for typedefs, structures, and compiler characteristics.
242 AC_C___ATTRIBUTE__
243 AC_C_BIGENDIAN
244 AC_C_CONST
245 AC_C_INLINE
246 AC_TYPE_INT64_T
247 AC_TYPE_LONG_LONG_INT
248 AC_TYPE_MODE_T
249 AC_TYPE_OFF_T
250 AC_TYPE_PID_T
251 AC_TYPE_SIZE_T
252 AC_TYPE_UINT32_T
253 AC_CHECK_DECLS([sys_siglist],[],[],[#include <signal.h>
254 /* NetBSD declares sys_siglist in unistd.h.  */
255 #ifdef HAVE_UNISTD_H
256 # include <unistd.h>
257 #endif
258 ])
259
260 AC_CHECK_HEADERS_ONCE([sys/time.h])
261
262 AC_STRUCT_TM
263
264 dnl we need sig_atomic_t
265 AH_TEMPLATE([sig_atomic_t],[type that signal handlers can safely frob])
266 AC_CHECK_TYPES([sig_atomic_t],[],[],
267 [
268 #ifdef HAVE_SYS_TYPES_H
269 #include <sys/types.h>
270 #endif
271 #include <signal.h>
272 ])
273
274 dnl Checks for library functions.
275 AC_FUNC_FORK
276 AC_FUNC_VPRINTF
277 AC_FUNC_WAIT3
278 dnl Keep this list sorted
279 AC_CHECK_FUNCS( \
280         err \
281         errx \
282         getcwd \
283         getenv \
284         getwd \
285         killpg \
286         mmap \
287         putenv \
288         select \
289         setenv \
290         setpgid \
291         setrlimit \
292         setsid \
293         sigaddset \
294         sigpending \
295         sigprocmask \
296         sigsetmask \
297         sigsuspend \
298         sigvec \
299         snprintf \
300         strerror \
301         stresep \
302         strftime \
303         strsep \
304         strtod \
305         strtol \
306         strtoll \
307         strtoul \
308         sysctl \
309         unsetenv \
310         vsnprintf \
311         wait3 \
312         wait4 \
313         waitpid \
314         warn \
315         warnx \
316         )
317
318 dnl functions which we may need to provide
319 AC_REPLACE_FUNCS( \
320         getopt \
321         realpath \
322         dirname \
323         sigaction \
324         stresep \
325         strlcpy \
326         )
327
328 AC_CHECK_LIB([util], [emalloc],
329     [ AC_CHECK_LIB([util], [erealloc],
330       [ AC_CHECK_LIB([util], [estrdup],
331         [ AC_CHECK_LIB([util], [estrndup],
332           [ LIBS="$LIBS -lutil"
333             CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
334
335 dnl
336 dnl Structures
337 dnl
338 AC_HEADER_STAT
339 dnl
340 echo "checking if compiler supports __func__" >&6
341 AC_LANG(C)
342 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],,
343         AC_DEFINE(__func__, __FUNCTION__, C99 function name))
344 dnl
345 dnl we want this for unit-tests/Makefile
346 dnl GNU diff is known to support -u
347 if test -x /usr/gnu/bin/diff; then
348         diff=/usr/gnu/bin/diff
349         diff_u=-u
350 else
351         diff=${diff:-diff}
352         echo $ECHO_N "checking if $diff -u works... $ECHO_C" >&6
353         if $diff -u /dev/null /dev/null > /dev/null 2>&1; then
354                 diff_u=-u
355                 echo yes >&6
356         else
357                 diff_u=
358                 echo no >&6
359         fi
360 fi
361 dnl
362 dnl AC_* don't quite cut it.
363 dnl 
364 echo "checking for MACHINE & MACHINE_ARCH..." >&6
365 cat > conftest.$ac_ext <<EOF
366 #include "confdefs.h"
367 #include <sys/param.h>
368 #ifdef MACHINE
369 machine=MACHINE
370 #endif
371 #ifdef MACHINE_ARCH
372 machine_arch=MACHINE_ARCH
373 #endif
374 EOF
375
376 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | 
377         grep machine= | tr -d ' "'`
378 rm -rf conftest*
379 if test "$default_machine"; then
380         eval "$default_machine"
381 fi
382 machine=${machine:-`$srcdir/machine.sh`}
383 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
384 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
385 dnl
386 dnl now allow overrides
387 dnl
388 AC_ARG_WITH(machine,
389 [  --with-machine=MACHINE  explicitly set MACHINE],
390 [case "${withval}" in
391 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
392 no)    ;;
393 generic) machine=`$srcdir/machine.sh`;;
394 *)     machine=$with_machine;;
395 esac])
396 force_machine=
397 AC_ARG_WITH(force_machine,
398 [  --with-force-machine=MACHINE  set FORCE_MACHINE],
399 [case "${withval}" in
400 yes)   force_machine=FORCE_;;
401 no)    ;;
402 *)     force_machine=FORCE_; machine=$with_force_machine;;
403 esac])
404 dnl
405 force_machine_arch=
406 AC_ARG_WITH(force_machine_arch,
407 [  --with-force-machine-arch=MACHINE  set FORCE_MACHINE_ARCH],
408 [case "${withval}" in
409 yes)   force_machine_arch=FORCE_;;
410 no)    ;;
411 *)     force_machine_arch=FORCE_; machine_arch=$with_force_machine_arch;;
412 esac])
413 dnl
414 AC_ARG_WITH(machine_arch,
415 [  --with-machine_arch=MACHINE_ARCH  explicitly set MACHINE_ARCH],
416 [case "${withval}" in
417 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
418 no)    ;;
419 *)     machine_arch=$with_machine_arch;;
420 esac])
421 dnl
422 dnl Tell them what we ended up with
423 dnl
424 echo "Using: ${force_machine}MACHINE=$machine, ${force_machine_arch}MACHINE_ARCH=$machine_arch" 1>&6
425 dnl
426 dnl Allow folk to control _PATH_DEFSYSPATH
427 dnl
428 default_sys_path=\${prefix}/share/mk
429 AC_ARG_WITH(default-sys-path,
430 [  --with-default-sys-path=PATH:DIR:LIST  use an explicit _PATH_DEFSYSPATH
431         MAKESYSPATH is a ':' separated list of directories 
432         that bmake will search for system .mk files. 
433         _PATH_DEFSYSPATH is its default value.],
434 [case "${withval}" in
435 yes)    AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
436 no)     ;;
437 *)      default_sys_path="$with_default_sys_path"
438         ;;
439 esac])
440 dnl
441 dnl Some folk don't like this one
442 dnl
443 AC_ARG_WITH(path-objdirprefix,
444 [  --with-path-objdirprefix=PATH  override _PATH_OBJDIRPREFIX],
445 [case "${withval}" in
446 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
447 no)    CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
448 *)     CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
449 esac])
450 dnl
451 dnl And this can be handy to do with out.
452 dnl
453 AC_ARG_ENABLE(pwd-override,
454 [  --disable-pwd-override  disable $PWD overriding getcwd()],
455 [case "${enableval}" in
456 yes)   ;;
457 no)    CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
458 *)     AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
459 esac])
460 dnl
461 dnl Just for grins
462 dnl
463 AC_ARG_ENABLE(check-make-chdir,
464 [  --disable-check-make-chdir disable make trying to guess 
465         when it should automatically cd ${.CURDIR}],
466 [case "${enableval}" in
467 yes)   ;;
468 no)    CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
469 *)     AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
470 esac])
471 dnl
472 dnl On non-BSD systems, bootstrap won't work without mk
473 dnl
474 AC_ARG_WITH(mksrc,
475 [  --with-mksrc=PATH tell makefile.boot where to find mk src],
476 [case "${withval}" in
477 ""|yes|no) ;;
478 *) test -s $withval/install-mk && mksrc=$withval ||
479 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
480 ;;
481 esac
482 ])
483 dnl
484 dnl Now make sure we have a value
485 dnl
486 srcdir=`cd $srcdir && pwd`
487 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
488 do
489         test -s $mksrc/install-mk || continue
490         mksrc=`cd $mksrc && pwd`
491         break
492 done
493 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
494 echo "Using: MKSRC=$mksrc" 1>&6
495 dnl On some systems we want a different default shell by default
496 for sh in /usr/xpg4/bin/sh $ALT_DEF_SHELLS
497 do
498         test -x $sh || continue
499         use_defshell $sh
500         break
501 done
502 case "$defshell_path$DEFSHELL_INDEX" in
503 "")     ;;
504 *DEFSHELL_INDEX_CUSTOM)
505         echo "Using: SHELL=$defshell_path"  >&6
506         AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
507         ;;
508 /*INDEX*)
509         echo "Using: SHELL=$DEFSHELL_INDEX ($defshell_path)" | sed 's,DEFSHELL_INDEX_,,' >&6
510         AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
511 AC_DEFINE_UNQUOTED(DEFSHELL_PATH, "$defshell_path", Path of default shell)
512         ;;
513 *)
514         echo "Using: SHELL=$DEFSHELL_INDEX" | sed 's,DEFSHELL_INDEX_,,' >&6
515         AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
516         ;;
517 esac
518 dnl
519 dnl Some systems have deprecated egrep in favor of grep -E
520 case "`echo bmake | egrep 'a|b' 2>&1`" in
521 bmake) egrep=egrep;;
522 *) egrep='grep -E';;
523 esac
524 dnl
525 AC_SUBST(egrep)
526 AC_SUBST(machine)
527 AC_SUBST(force_machine)
528 AC_SUBST(machine_arch)
529 AC_SUBST(force_machine_arch)
530 AC_SUBST(mksrc)
531 AC_SUBST(default_sys_path)
532 AC_SUBST(INSTALL)
533 AC_SUBST(GCC)
534 AC_SUBST(diff)
535 AC_SUBST(diff_u)
536 AC_SUBST(use_meta)
537 AC_SUBST(use_filemon)
538 AC_SUBST(filemon_h)
539 AC_SUBST(_MAKE_VERSION)
540 AC_SUBST(UTC_1)
541 bm_outfiles="Makefile.config unit-tests/Makefile.config make-bootstrap.sh"
542 if test $use_makefile = yes; then
543    bm_outfiles="makefile $bm_outfiles"
544 fi
545
546 here=`'pwd'`
547 : srcdir=$srcdir
548 : here=  $here
549 case "$here" in
550 $srcdir/obj*) # make sure we put unit-tests/Makefile.config in the right place
551         obj=`basename $here`
552         mkdir -p $srcdir/unit-tests/$obj
553         test -d unit-tests || ln -s ../unit-tests/$obj unit-tests
554         ;;
555 esac
556
557 AC_CONFIG_FILES([$bm_outfiles])
558 AC_OUTPUT
559 cat <<EOF
560
561 You can now run
562
563         sh ./make-bootstrap.sh
564
565 to produce a fully functional bmake.
566
567 EOF