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