]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/configure.in
Update to Zstandard 1.4.5
[FreeBSD/FreeBSD.git] / contrib / bmake / configure.in
1 dnl
2 dnl RCSid:
3 dnl     $Id: configure.in,v 1.63 2020/04/19 05:17:57 sjg Exp $
4 dnl
5 dnl Process this file with autoconf to produce a configure script
6 dnl
7 AC_PREREQ(2.50)
8 AC_INIT([bmake], [20200418], [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
22 AC_ARG_WITH(defshell,
23 [  --with-defshell=SHELL  use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
24 [case "${withval}" in
25 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
26 no)    ;;
27 *)     case "$with_defshell" in
28        sh)  DEFSHELL_INDEX=DEFSHELL_INDEX_SH;;  # it's the default anyway
29        ksh) DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;;
30        csh) DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;; # kidding right?
31        *)   defshell_path=$with_defshell;;      # better be sh compatible!
32        esac
33        ;;
34        esac])
35 dnl
36 case "$OS" in
37 CYGWIN*|MINGW*) use_makefile=no;;
38 *) use_makefile=yes;;
39 esac
40 AC_ARG_WITH(makefile,
41 [ --without-makefile dissable use of generated makefile],
42 [case "${withval}" in
43 yes|no) use_makefile=${withval};;
44 *) AC_MSG_ERROR(bad value ${withval} given for makefile) ;;
45 esac])
46 dnl
47 use_meta=yes
48 AC_ARG_WITH(meta,
49 [ --without-meta dissable use of meta-mode],
50 [case "${withval}" in
51 yes|no) use_meta=${withval};;
52 *) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
53 esac])
54 dnl
55 AC_ARG_WITH(filemon,
56 [ --with-filemon={no,dev,ktrace,path/filemon.h} indicate filemon method for meta-mode. Path to filemon.h implies dev],
57 [ case "/${withval}" in
58 /no) use_filemon=no;;
59 /*trace) filemon_h=no use_filemon="${withval}";;
60 */filemon.h) filemon_h="${withval}";;
61 */filemon*) filemon_h="${withval}/filemon.h";;
62 *) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
63 esac],
64 [
65 case "$OS" in
66 NetBSD) filemon_h=no use_filemon=ktrace;;
67 *)
68     for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/../../sys/dev/filemon"
69     do  
70         for x in "/$OS" ""
71         do
72             filemon_h="$d$x/filemon.h"
73             test -s "$filemon_h" && break
74         done
75         test -s "$filemon_h" && { use_filemon=dev; break; }
76     done
77     ;;
78 esac
79 use_filemon=${use_filemon:-no}
80 case "$use_filemon" in
81 dev) ;;
82 *) filemon_h=no;;
83 esac
84 ])
85 dnl echo "Note: use_meta=$use_meta use_filemon=$use_filemon filemon_h=$filemon_h" >&6
86 case "$use_meta" in
87 yes)
88         case "$use_filemon" in
89         no) ;;
90         *) echo "Using: filemon_${use_filemon}.c" >&6;;
91         esac
92         ;;
93 esac
94 dnl
95 dnl Check for OS problems
96 dnl Solaris's signal.h only privides sigset_t etc if one of
97 dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
98 dnl The later two seem to cause more problems than they solve so if we
99 dnl see _EXTENSIONS_ we use it.
100 AC_USE_SYSTEM_EXTENSIONS
101 dnl Checks for programs.
102 AC_PROG_CC
103 AC_PROG_GCC_TRADITIONAL
104 AC_PROG_INSTALL
105 dnl Executable suffix - normally empty; .exe on os2.
106 AC_SUBST(ac_exe_suffix)dnl
107 dnl
108 dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
109 if test -x /usr/bin/getconf; then
110    bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
111    # only a numeric response is useful
112    test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
113 fi
114 bmake_path_max=${bmake_path_max:-1024}
115 if test $bmake_path_max -gt 1024; then
116    # this is all we expect
117    bmake_path_max=1024
118 fi
119 echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6
120 AC_SUBST(bmake_path_max)dnl
121 dnl
122 dnl AC_C_CROSS
123 dnl
124
125 dnl Checks for header files.
126 AC_HEADER_STDC
127 AC_HEADER_SYS_WAIT
128 AC_HEADER_DIRENT
129 dnl Keep this list sorted
130 AC_CHECK_HEADERS(sys/param.h)
131 dnl On BSDi at least we really need sys/param.h for sys/sysctl.h
132 AC_CHECK_HEADERS([sys/sysctl.h], [], [],
133 [#ifdef HAVE_SYS_PARAM_H
134 # include <sys/param.h>
135 # endif
136 ])
137
138 AC_CHECK_HEADERS( \
139         ar.h \
140         err.h \
141         fcntl.h \
142         libgen.h \
143         limits.h \
144         paths.h \
145         poll.h \
146         ranlib.h \
147         string.h \
148         sys/mman.h \
149         sys/select.h \
150         sys/socket.h \
151         sys/time.h \
152         sys/uio.h \
153         unistd.h \
154         utime.h \
155         )
156
157 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
158 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
159 dnl also if sys/cdefs.h does not have __RCSID we need to use ours
160 dnl but we need to include the host's one too *sigh*
161 AC_CHECK_HEADER(sys/cdefs.h,
162 echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6
163 AC_EGREP_CPP(yes,
164 [#include <sys/cdefs.h>
165 #ifdef __RCSID
166 yes
167 #endif
168 ],
169 echo yes  >&6,
170 echo no  >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"),
171 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
172
173 dnl Checks for typedefs, structures, and compiler characteristics.
174 AC_C___ATTRIBUTE__
175 AC_C_BIGENDIAN
176 AC_C_CONST
177 AC_TYPE_MODE_T
178 AC_TYPE_OFF_T
179 AC_TYPE_PID_T
180 AC_TYPE_SIZE_T
181 AC_TYPE_UINT32_T
182 AC_DECL_SYS_SIGLIST
183 AC_HEADER_TIME
184 AC_STRUCT_TM
185
186 dnl Checks for library functions.
187 AC_TYPE_SIGNAL
188 AC_FUNC_VFORK
189 AC_FUNC_VPRINTF
190 AC_FUNC_WAIT3
191 dnl Keep this list sorted
192 AC_CHECK_FUNCS( \
193         err \
194         errx \
195         getcwd \
196         getenv \
197         getopt \
198         getwd \
199         killpg \
200         mmap \
201         putenv \
202         select \
203         setenv \
204         setpgid \
205         setsid \
206         sigaction \
207         sigvec \
208         snprintf \
209         strerror \
210         strftime \
211         strsep \
212         strtod \
213         strtol \
214         sysctl \
215         unsetenv \
216         vsnprintf \
217         wait3 \
218         wait4 \
219         waitpid \
220         warn \
221         warnx \
222         )
223
224 dnl functions which we may need to provide
225 AC_REPLACE_FUNCS( \
226         realpath \
227         dirname \
228         stresep \
229         strlcpy \
230         )
231
232 AC_CHECK_LIB([util], [emalloc],
233     [ AC_CHECK_LIB([util], [erealloc],
234       [ AC_CHECK_LIB([util], [estrdup],
235         [ AC_CHECK_LIB([util], [estrndup],
236           [ LIBS="$LIBS -lutil"
237             CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
238
239 dnl
240 dnl Structures
241 dnl
242 AC_HEADER_STAT
243 AC_STRUCT_ST_RDEV
244 dnl
245 echo "checking if compiler supports __func__" >&6
246 AC_LANG(C)
247 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],,
248         AC_DEFINE(__func__, __FUNCTION__, C99 function name))
249 dnl
250 dnl we want this for unit-tests/Makefile
251 echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6
252 if diff -u /dev/null /dev/null > /dev/null 2>&1; then
253    diff_u=-u
254    echo yes >&6
255 else
256    diff_u=
257    echo no >&6
258 fi
259 dnl
260 dnl AC_* don't quite cut it.
261 dnl 
262 echo "checking for MACHINE & MACHINE_ARCH..." >&6
263 cat > conftest.$ac_ext <<EOF
264 #include "confdefs.h"
265 #include <sys/param.h>
266 #ifdef MACHINE
267 machine=MACHINE
268 #endif
269 #ifdef MACHINE_ARCH
270 machine_arch=MACHINE_ARCH
271 #endif
272 EOF
273
274 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | 
275         egrep machine= | tr -d ' "'`
276 rm -rf conftest*
277 if test "$default_machine"; then
278         eval "$default_machine"
279 fi
280 machine=${machine:-`$srcdir/machine.sh`}
281 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
282 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
283 dnl
284 dnl now allow overrides
285 dnl
286 AC_ARG_WITH(machine,
287 [  --with-machine=MACHINE  explicitly set MACHINE],
288 [case "${withval}" in
289 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
290 no)    ;;
291 generic) machine=`$srcdir/machine.sh`;;
292 *)     machine=$with_machine;;
293 esac])
294 force_machine=
295 AC_ARG_WITH(force_machine,
296 [  --with-force-machine=MACHINE  set FORCE_MACHINE],
297 [case "${withval}" in
298 yes)   force_machine=FORCE_;;
299 no)    ;;
300 *)     force_machine=FORCE_; machine=$with_force_machine;;
301 esac])
302 dnl
303 force_machine_arch=
304 AC_ARG_WITH(force_machine_arch,
305 [  --with-force-machine-arch=MACHINE  set FORCE_MACHINE_ARCH],
306 [case "${withval}" in
307 yes)   force_machine_arch=FORCE_;;
308 no)    ;;
309 *)     force_machine_arch=FORCE_; machine_arch=$with_force_machine;;
310 esac])
311 dnl
312 AC_ARG_WITH(machine_arch,
313 [  --with-machine_arch=MACHINE_ARCH  explicitly set MACHINE_ARCH],
314 [case "${withval}" in
315 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
316 no)    ;;
317 *)     machine_arch=$with_machine_arch;;
318 esac])
319 dnl
320 dnl Tell them what we ended up with
321 dnl
322 echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
323 dnl
324 dnl Allow folk to control _PATH_DEFSYSPATH
325 dnl
326 default_sys_path=\${prefix}/share/mk
327 AC_ARG_WITH(default-sys-path,
328 [  --with-default-sys-path=PATH:DIR:LIST  use an explicit _PATH_DEFSYSPATH
329         MAKESYSPATH is a ':' separated list of directories 
330         that bmake will search for system .mk files. 
331         _PATH_DEFSYSPATH is its default value.],
332 [case "${withval}" in
333 yes)    AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
334 no)     ;;
335 *)      default_sys_path="$with_default_sys_path"
336         ;;
337 esac])
338 dnl
339 dnl Some folk don't like this one
340 dnl
341 AC_ARG_WITH(path-objdirprefix,
342 [  --with-path-objdirprefix=PATH  override _PATH_OBJDIRPREFIX],
343 [case "${withval}" in
344 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
345 no)    CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
346 *)     CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
347 esac])
348 dnl
349 dnl And this can be handy to do with out.
350 dnl
351 AC_ARG_ENABLE(pwd-override,
352 [  --disable-pwd-override  disable \$PWD overriding getcwd()],
353 [case "${enableval}" in
354 yes)   ;;
355 no)    CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
356 *)     AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
357 esac])
358 dnl
359 dnl Just for grins
360 dnl
361 AC_ARG_ENABLE(check-make-chdir,
362 [  --disable-check-make-chdir disable make trying to guess 
363         when it should automatically cd \${.CURDIR}],
364 [case "${enableval}" in
365 yes)   ;;
366 no)    CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
367 *)     AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
368 esac])
369 dnl
370 dnl On non-BSD systems, bootstrap won't work without mk
371 dnl
372 AC_ARG_WITH(mksrc,
373 [  --with-mksrc=PATH tell makefile.boot where to find mk src],
374 [case "${withval}" in
375 ""|yes|no) ;;
376 *) test -s $withval/install-mk && mksrc=$withval ||
377 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
378 ;;
379 esac
380 ])
381 dnl
382 dnl Now make sure we have a value
383 dnl
384 srcdir=`cd $srcdir && pwd`
385 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
386 do
387         test -s $mksrc/install-mk || continue
388         mksrc=`cd $mksrc && pwd`
389         break
390 done
391 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
392 echo "Using: MKSRC=$mksrc" 1>&6
393 dnl On some systems we want a different default shell by default
394 if test -x /usr/xpg4/bin/sh; then
395         defshell_path=${defshell_path:-/usr/xpg4/bin/sh}
396 fi
397 if test -n "$defshell_path"; then
398         echo "Using: SHELL=$defshell_path"  >&6
399         AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
400 fi
401 if test -n "$DEFSHELL_INDEX"; then
402        AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
403 fi        
404 dnl
405 AC_SUBST(machine)
406 AC_SUBST(force_machine)
407 AC_SUBST(machine_arch)
408 AC_SUBST(mksrc)
409 AC_SUBST(default_sys_path)
410 AC_SUBST(INSTALL)
411 AC_SUBST(GCC)
412 AC_SUBST(diff_u)
413 AC_SUBST(use_meta)
414 AC_SUBST(use_filemon)
415 AC_SUBST(filemon_h)
416 AC_SUBST(_MAKE_VERSION)
417 bm_outfiles="Makefile.config unit-tests/Makefile.config make-bootstrap.sh"
418 if test $use_makefile = yes; then
419    bm_outfiles="makefile $bm_outfiles"
420 fi
421 AC_OUTPUT($bm_outfiles)
422 cat <<EOF
423
424 You can now run
425
426         sh ./make-bootstrap.sh
427
428 to produce a fully functional bmake.
429
430 EOF