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