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