Try using POSIX::getcwd to find the working directory wherever it exists.
[make.git] / configure.in
blobb1f52c5165d6855f6ad43356ff9daafbbfccde42
1 # Process this file with autoconf to produce a configure script.
3 AC_INIT([GNU make],[3.81beta3],[bug-make@gnu.org])
5 AC_PREREQ(2.59)
6 AC_REVISION([[$Id: configure.in,v 1.137 2005/07/12 04:35:13 psmith Exp $]])
8 # Autoconf setup
9 AC_CONFIG_AUX_DIR(config)
10 AC_CONFIG_SRCDIR(vpath.c)
11 AC_CONFIG_HEADERS(config.h)
13 # Automake setup
14 AM_INIT_AUTOMAKE([1.8.2])
16 # Checks for programs.
17 AC_PROG_CC
18 AC_PROG_INSTALL
19 AC_PROG_RANLIB
20 AC_PROG_CPP
21 AC_CHECK_PROG(AR, ar, ar, ar)
22 # Perl is needed for the test suite (only)
23 AC_CHECK_PROG(PERL, perl, perl, perl)
25 # Specialized system macros
26 AC_CANONICAL_HOST
27 AC_AIX
28 AC_ISC_POSIX
29 AC_MINIX
31 # Needed for ansi2knr
32 AM_C_PROTOTYPES
34 # Enable gettext, in "external" mode.
36 AM_GNU_GETTEXT_VERSION(0.14.1)
37 AM_GNU_GETTEXT([external])
39 # This test must come as early as possible after the compiler configuration
40 # tests, because the choice of the file model can (in principle) affect
41 # whether functions and headers are available, whether they work, etc.
42 AC_SYS_LARGEFILE
44 # Checks for libraries.
45 AC_SEARCH_LIBS(getpwnam, [sun])
47 # Checks for header files.
48 AC_HEADER_STDC
49 AC_HEADER_DIRENT
50 AC_HEADER_STAT
51 AC_HEADER_TIME
52 AC_CHECK_HEADERS(stdlib.h locale.h unistd.h limits.h fcntl.h string.h \
53                  memory.h sys/param.h sys/resource.h sys/time.h sys/timeb.h)
55 # Set a flag if we have an ANSI C compiler
56 if test "$ac_cv_prog_cc_stdc" != no; then
57   AC_DEFINE(HAVE_ANSI_COMPILER, 1,
58               [Define if your compiler conforms to the ANSI C standard.])
62 # Determine what kind of variadic function calls we support
63 AC_CHECK_HEADERS(stdarg.h varargs.h, break)
65 AM_PROG_CC_C_O
66 AC_C_CONST
67 AC_TYPE_SIGNAL
68 AC_TYPE_UID_T
69 AC_TYPE_PID_T
71 # Find some definition for uintmax_t
73 AC_CHECK_TYPE(uintmax_t,,[
74   uintmax_t="unsigned long"
75   AC_CHECK_TYPE(unsigned long long,[uintmax_t="unsigned long long"])
76   AC_DEFINE_UNQUOTED(uintmax_t,$uintmax_t,
77     [Define uintmax_t if not defined in <stdint.h> or <inttypes.h>.])])
79 # Find out whether our struct stat returns nanosecond resolution timestamps.
81 AC_STRUCT_ST_MTIM_NSEC
82 AC_MSG_CHECKING([whether to use high resolution file timestamps])
83 AC_CACHE_VAL(make_cv_file_timestamp_hi_res, [
84   make_cv_file_timestamp_hi_res=no
85   if test "$ac_cv_struct_st_mtim_nsec" != no; then
86     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
87 #       if HAVE_INTTYPES_H
88 #        include <inttypes.h>
89 #       endif]],
90                       [[char a[0x7fffffff < (uintmax_t)-1 >> 30 ? 1 : -1];]])],
91       [make_cv_file_timestamp_hi_res=yes],
92       [])
93   fi])
94 AC_MSG_RESULT($make_cv_file_timestamp_hi_res)
95 if test "$make_cv_file_timestamp_hi_res" = yes; then
96   val=1
97 else
98   val=0
100 AC_DEFINE_UNQUOTED(FILE_TIMESTAMP_HI_RES, $val,
101                    [Use high resolution file timestamps if nonzero.])
103 if test "$make_cv_file_timestamp_hi_res" = yes; then
104   # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
105   # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
106   AC_SEARCH_LIBS(clock_gettime, [rt posix4])
107   if test "$ac_cv_search_clock_gettime" != no; then
108     AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
109               [Define if you have the clock_gettime function.])
110   fi
113 # Check for DOS-style pathnames.
114 pds_AC_DOS_PATHS
116 # See if we have a standard version of gettimeofday().  Since actual
117 # implementations can differ, just make sure we have the most common
118 # one.
119 AC_CACHE_CHECK([for standard gettimeofday], ac_cv_func_gettimeofday,
120   [ac_cv_func_gettimeofday=no
121    AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/time.h>
122                   int main ()
123                   {
124                     struct timeval t; t.tv_sec = -1; t.tv_usec = -1;
125                     exit (gettimeofday (&t, 0) != 0
126                           || t.tv_sec < 0 || t.tv_usec < 0);
127                   }]])],
128                   [ac_cv_func_gettimeofday=yes],
129                   [ac_cv_func_gettimeofday=no],
130                   [ac_cv_func_gettimeofday="no (cross-compiling)"])])
131 if test "$ac_cv_func_gettimeofday" = yes; then
132   AC_DEFINE(HAVE_GETTIMEOFDAY, 1,
133             [Define if you have a standard gettimeofday function])
136 AC_CHECK_FUNCS( memcpy memmove strchr strdup mkstemp mktemp fdopen \
137                 bsd_signal dup2 getcwd realpath sigsetmask sigaction \
138                 getgroups seteuid setegid setlinebuf setreuid setregid \
139                 getrlimit setrlimit setvbuf pipe strerror strsignal \
140                 lstat readlink atexit)
142 AC_FUNC_SETVBUF_REVERSED
144 # strcoll() is used by the GNU glob library
145 AC_FUNC_STRCOLL
147 AC_FUNC_ALLOCA
148 AC_FUNC_FORK([])
149 AC_FUNC_VPRINTF
150 AC_FUNC_CLOSEDIR_VOID
152 AC_FUNC_GETLOADAVG
154 # AC_FUNC_GETLOADAVG is documented to set the NLIST_STRUCT value, but it
155 # doesn't.  So, we will.
157 if test "$ac_cv_header_nlist_h" = yes; then
158   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
159         [[struct nlist nl;
160           nl.n_name = "string";
161           return 0;]])],
162         [make_cv_nlist_struct=yes],
163         [make_cv_nlist_struct=no])
164   if test "$make_cv_nlist_struct" = yes; then
165     AC_DEFINE(NLIST_STRUCT, 1,
166        [Define if struct nlist.n_name is a pointer rather than an array.])
167   fi
170 AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], , ,
171   [AC_INCLUDES_DEFAULT
172 #include <signal.h>
173 /* NetBSD declares sys_siglist in unistd.h.  */
174 #if HAVE_UNISTD_H
175 # include <unistd.h>
176 #endif
180 # Check out the wait reality.
181 AC_CHECK_HEADERS(sys/wait.h)
182 AC_CHECK_FUNCS(waitpid wait3)
183 AC_MSG_CHECKING(for union wait)
184 AC_CACHE_VAL(make_cv_union_wait, [dnl
185     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
186 #include <sys/wait.h>]],
187      [[union wait status; int pid; pid = wait (&status);
188 #ifdef WEXITSTATUS
189 /* Some POSIXoid systems have both the new-style macros and the old
190    union wait type, and they do not work together.  If union wait
191    conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
192         if (WEXITSTATUS (status) != 0) pid = -1;
193 #ifdef WTERMSIG
194         /* If we have WEXITSTATUS and WTERMSIG, just use them on ints.  */
195         -- blow chunks here --
196 #endif
197 #endif
198 #ifdef HAVE_WAITPID
199         /* Make sure union wait works with waitpid.  */
200         pid = waitpid (-1, &status, 0);
201 #endif
202       ]])],
203     [make_cv_union_wait=yes],
204     [make_cv_union_wait=no])])
205 if test "$make_cv_union_wait" = yes; then
206   AC_DEFINE(HAVE_UNION_WAIT, 1,
207             [Define this if you have the \`union wait' type in <sys/wait.h>.])
209 AC_MSG_RESULT($make_cv_union_wait)
212 # If we're building on Windows/DOS/OS/2, add some support for DOS drive specs.
213 if test "$PATH_SEPARATOR" = ';'; then
214   AC_DEFINE(HAVE_DOS_PATHS, 1,
215             [Define this if your system requires backslashes or drive specs in pathnames.])
219 # See if the user wants to use pmake's "customs" distributed build capability
221 AC_SUBST(REMOTE) REMOTE=stub
222 use_customs=false
223 AC_ARG_WITH(customs,
224   AC_HELP_STRING([--with-customs=DIR],
225                  [enable remote jobs via Customs--see README.customs]),
226   [case $withval in
227     n|no) : ;;
228     *) make_cppflags="$CPPFLAGS"
229        case $withval in
230          y|ye|yes) : ;;
231          *) CPPFLAGS="$CPPFLAGS -I$with_customs/include/customs"
232             make_ldflags="$LDFLAGS -L$with_customs/lib" ;;
233        esac
234        CF_NETLIBS
235        AC_CHECK_HEADER(customs.h,
236                        [use_customs=true
237                          REMOTE=cstms
238                          LIBS="$LIBS -lcustoms" LDFLAGS="$make_ldflags"],
239                        [with_customs=no
240                          CPPFLAGS="$make_cppflags" make_badcust=yes])
241        ;;
242   esac])
243 # Tell automake about this, so it can include the right .c files.
244 AM_CONDITIONAL(USE_CUSTOMS, test "$use_customs" = true)
246 # See if the user asked to handle case insensitive file systems.
248 AH_TEMPLATE(HAVE_CASE_INSENSITIVE_FS, [Use case insensitive file names])
249 AC_ARG_ENABLE(case-insensitive-file-system,
250   AC_HELP_STRING([--enable-case-insensitive-file-system],
251                  [enable case insensitive file system support]),
252   case_insensitive_fs="yes" AC_DEFINE(HAVE_CASE_INSENSITIVE_FS),
253   case_insensitive_fs="no")
255 # See if we can handle the job server feature, and if the user wants it.
257 AC_ARG_ENABLE(job-server,
258   AC_HELP_STRING([--disable-job-server],
259                  [disallow recursive make communication during -jN]),
260   [make_cv_job_server="$enableval" user_job_server="$enableval"],
261   [make_cv_job_server="yes"])
263 has_wait_nohang=yes
264 case "$ac_cv_func_waitpid/$ac_cv_func_wait3" in
265   no/no) has_wait_nohang=no ;;
266 esac
268 AC_CACHE_CHECK(for SA_RESTART, make_cv_sa_restart, [
269   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]],
270       [[return SA_RESTART;]])],
271     [make_cv_sa_restart=yes],
272     [make_cv_sa_restart=no])])
274 if test "$make_cv_sa_restart" != no; then
275   AC_DEFINE(HAVE_SA_RESTART, 1,
276      [Define if <signal.h> defines the SA_RESTART constant.])
279 # enable make_cv_sa_restart for OS/2 so that the jobserver will be enabled,
280 # but do it after HAVE_SA_RESTART has been defined.
281 case "$host_os" in
282   os2*) make_cv_sa_restart=yes ;;
283 esac
285 case "$ac_cv_func_pipe/$ac_cv_func_sigaction/$make_cv_sa_restart/$has_wait_nohang/$make_cv_job_server" in
286   yes/yes/yes/yes/yes)
287     AC_DEFINE(MAKE_JOBSERVER, 1,
288               [Define this to enable job server support in GNU make.]);;
289 esac
291 # if we have both lstat() and readlink() then we can support symlink
292 # timechecks.
293 case "$ac_cv_func_lstat/$ac_cv_func_readlink" in
294   yes/yes)
295     AC_DEFINE(MAKE_SYMLINKS, 1,
296               [Define this to enable symbolic link timestamp checking.]);;
297 esac
299 # Find the SCCS commands, so we can include them in our default rules.
301 AC_CACHE_CHECK(for location of SCCS get command, make_cv_path_sccs_get, [
302 if test -f /usr/sccs/get; then
303   make_cv_path_sccs_get=/usr/sccs/get
304 else
305   make_cv_path_sccs_get=get
306 fi])
307 AC_DEFINE_UNQUOTED(SCCS_GET, ["$make_cv_path_sccs_get"],
308                    [Define to the name of the SCCS 'get' command.])
310 ac_clean_files="$ac_clean_files s.conftest conftoast" # Remove these later.
311 if ( /usr/sccs/admin -n s.conftest || admin -n s.conftest ) >/dev/null 2>&1 &&
312    test -f s.conftest; then
313   # We successfully created an SCCS file.
314   AC_CACHE_CHECK(if SCCS get command understands -G, make_cv_sys_get_minus_G, [
315     if $make_cv_path_sccs_get -Gconftoast s.conftest >/dev/null 2>&1 &&
316        test -f conftoast; then
317        make_cv_sys_get_minus_G=yes
318     else
319        make_cv_sys_get_minus_G=no
320     fi])
321   case "$make_cv_sys_get_minus_G" in
322     yes) AC_DEFINE(SCCS_GET_MINUS_G, 1,
323            [Define this if the SCCS 'get' command understands the '-G<file>' option.]);;
324   esac
326 rm -f s.conftest conftoast
328 # Check the system to see if it provides GNU glob.  If not, use our
329 # local version.
331 AC_MSG_CHECKING(if system libc has GNU glob)
332 AC_CACHE_VAL(make_cv_sys_gnu_glob, [
333  AC_EGREP_CPP(gnu glob,[
334 #include <features.h>
335 #include <glob.h>
336 #include <fnmatch.h>
338 #define GLOB_INTERFACE_VERSION 1
339 #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
340 # include <gnu-versions.h>
341 # if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
342    gnu glob
343 # endif
344 #endif
345  ], [AC_MSG_RESULT(yes)
346 make_cv_sys_gnu_glob=yes], [AC_MSG_RESULT([no; using local copy])
347 AC_SUBST(GLOBINC) GLOBINC='-I$(srcdir)/glob'
348 AC_SUBST(GLOBLIB) GLOBLIB=glob/libglob.a
349 make_cv_sys_gnu_glob=no])])
350 # Tell automake about this, so it can build the right .c files.
351 AM_CONDITIONAL(USE_LOCAL_GLOB, test "$make_cv_sys_gnu_glob" = no)
353 # Let the makefile know what our build host is
355 AC_DEFINE_UNQUOTED(MAKE_HOST,"$host",[Build host information.])
356 MAKE_HOST="$host"
357 AC_SUBST(MAKE_HOST)
359 w32_target_env=no
360 AM_CONDITIONAL([WINDOWSENV], false)
362 case "$host" in
363   *-*-mingw32)
364     AM_CONDITIONAL(WINDOWSENV, true)
365     w32_target_env=yes
366     AC_DEFINE([WINDOWS32], [1], [Use platform specific coding])
367     AC_DEFINE([HAVE_DOS_PATHS], [1], [Use platform specific coding])
368     ;;
369 esac
371 # Include the Maintainer's Makefile section, if it's here.
373 MAINT_MAKEFILE=/dev/null
374 if test -r "$srcdir/maintMakefile"; then
375   MAINT_MAKEFILE="$srcdir/maintMakefile"
377 AC_SUBST_FILE(MAINT_MAKEFILE)
379 # Allow building with dmalloc
380 AM_WITH_DMALLOC
382 # Forcibly disable SET_MAKE.  If it's set it breaks things like the test
383 # scripts, etc.
384 SET_MAKE=
386 # Sanity check and inform the user of what we found
388 case "$make_badcust" in
389   yes) echo
390        echo "WARNING: --with-customs specified but no customs.h could be found;"
391        echo "         disabling Customs support."
392        echo ;;
393 esac
395 case "$with_customs" in
396   ""|n|no|y|ye|yes) ;;
397   *) if test -f "$with_customs/lib/libcustoms.a"; then
398        :
399      else
400        echo
401        echo "WARNING: '$with_customs/lib' does not appear to contain the"
402        echo "         Customs library.  You must build and install Customs"
403        echo "         before compiling GNU make."
404        echo
405      fi ;;
406 esac
408 case "$has_wait_nohang" in
409   no) echo
410       echo "WARNING: Your system has neither waitpid() nor wait3()."
411       echo "         Without one of these, signal handling is unreliable."
412       echo "         You should be aware that running GNU make with -j"
413       echo "         could result in erratic behavior."
414       echo ;;
415 esac
417 case "$make_cv_job_server/$user_job_server" in
418   no/yes) echo
419           echo "WARNING: Make job server requires a POSIX-ish system that"
420           echo "         supports the pipe(), sigaction(), and either"
421           echo "         waitpid() or wait3() functions.  Your system doesn't"
422           echo "         appear to provide one or more of those."
423           echo "         Disabling job server support."
424           echo ;;
425 esac
428 # Specify what files are to be created.
429 AC_CONFIG_FILES(Makefile glob/Makefile po/Makefile.in config/Makefile doc/Makefile w32/Makefile)
431 # OK, do it!
433 AC_OUTPUT
435 # We only generate the build.sh if we have a build.sh.in; we won't have
436 # one before we've created a distribution.
437 if test -f build.sh.in; then
438   ./config.status --file build.sh
439   chmod +x build.sh
442 dnl Local Variables:
443 dnl comment-start: "dnl "
444 dnl comment-end: ""
445 dnl comment-start-skip: "\\bdnl\\b\\s *"
446 dnl compile-command: "make configure config.h.in"
447 dnl End: