Allow returning something of type void in a function that returns void
[delight/core.git] / phobos2 / configure.in
blobc6c3e85511024516ed7c07bef2566ffe4817416a
1 # GDC -- D front-end for GCC
2 # Copyright (C) 2004 David Friedman
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 dnl Parts taken from libobjc configure.in
20 AC_PREREQ(2.59)
21 AC_INIT(libphobos, version-unused)
22 AC_CONFIG_SRCDIR(gcc/builtins.d)
23 AC_CONFIG_HEADERS(config.h)
25 AC_CANONICAL_SYSTEM
26 target_alias=${target_alias-$target}
27 AC_SUBST(target_alias)
29 AM_INIT_AUTOMAKE([1.9.4 foreign no-dependencies])
31 AM_ENABLE_MULTILIB(,[$d_mlcd])
33 # libphobos is usually a symlink to gcc/d/phobos, so libphobos/..
34 # is not the toplevel GCC directory.  gcc/d may also be a symlink.
35 # Find the correct top-level directory by removing "/libphobos"
36 # from $srcdir.
37 dnl NOTE: This assumes that AM_ENABLE_MULTILIB uses $multi_basedir
38 if test ! -r "$multi_basedir/config-ml.in"; then
39     better_dir=`echo "$srcdir" | sed -e 's|/libphobos||'`
40     if test -r "$better_dir/config-ml.in"; then
41         multi_basedir=$better_dir
42     fi
45 if test "$build" != "$host"; then
46   # We are being configured with some form of cross compiler.
47   #GLIBCXX_IS_NATIVE=false
48   GCC_NO_EXECUTABLES
49   d_cross_comp=yes
50 else
51   d_cross_comp=
54 dnl Copied from libstdc++-v3/acinclude.m4.  Indeed, multilib will not work
55 dnl correctly without this.
56 # We're almost certainly being configured before anything else which uses
57 # C++, so all of our AC_PROG_* discoveries will be cached.  It's vital that
58 # we not cache the value of CXX that we "discover" here, because it's set
59 # to something unique for us and libjava.  Other target libraries need to
60 # find CXX for themselves.  We yank the rug out from under the normal AC_*
61 # process by sneakily renaming the cache variable.  This also lets us debug
62 # the value of "our" CXX in postmortems.
64 # We must also force CXX to /not/ be a precious variable, otherwise the
65 # wrong (non-multilib-adjusted) value will be used in multilibs.  This
66 # little trick also affects CPPFLAGS, CXXFLAGS, and LDFLAGS.  And as a side
67 # effect, CXXFLAGS is no longer automagically subst'd, so we have to do
68 # that ourselves.  Un-preciousing AC_PROG_CC also affects CC and CFLAGS.
70 # -fno-builtin must be present here so that a non-conflicting form of
71 # std::exit can be guessed by AC_PROG_CXX, and used in later tests.
73 m4_define([ac_cv_prog_CXX],[glibcxx_cv_prog_CXX])
74 m4_rename([_AC_ARG_VAR_PRECIOUS],[glibcxx_PRECIOUS])
75 m4_define([_AC_ARG_VAR_PRECIOUS],[])
76 save_CXXFLAGS="$CXXFLAGS"
77 CXXFLAGS="$CXXFLAGS -fno-builtin"
78 # --- Extra hack for Phobos ---
79 # AC_PROG_CC, if not "cross-compiling", tries to run a simple C program.
80 # However, a given multilib variant may not be executable on the current
81 # system.  Example:  Building for x86_64 on IA-32.  This is technically
82 # cross-compiling, but we don't want cross-compiling directory layouts
83 # and we still need link tests.  Solution is to make autoconf think it
84 # is cross compiling only when it tests the compilers.
85 d_save_cross_compiling=$cross_compiling
86 cross_compiling=yes
87 AC_PROG_CC
88 AC_PROG_CXX
89 cross_compiling=$d_save_cross_compiling
90 CXXFLAGS="$save_CXXFLAGS"
91 m4_rename([glibcxx_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
92 AC_SUBST(CFLAGS)
93 AC_SUBST(CXXFLAGS)
94 dnl -- End of copy from libstdc++-v3/acinclude.m4
96 dnl These should be inherited in the recursive make, but ensure they are
97 dnl defined:
98 test "$AR" || AR=ar
99 AC_SUBST(AR)
100 if test "$RANLIB"; then :
101   AC_SUBST(RANLIB)
102 else
103   AC_PROG_RANLIB
105 AC_PROG_INSTALL
106 AC_PROG_MAKE_SET
107 dnl GNU_SOURCE needed for fpclassify on Linux
108 AC_GNU_SOURCE
109 dnl AC_PROG_LIBTOOL
111 AC_ARG_ENABLE(thread-lib,
112   AC_HELP_STRING([--enable-thread-lib=<arg>],
113                  [specify linker option for the system thread library (default: autodetect)]),
114   [d_thread_lib=$enableval],[d_thread_lib=""])
116 AC_ARG_ENABLE(unix,
117   AC_HELP_STRING([--enable-unix],
118                  [enables Unix runtime (default: yes, for Unix targets)]),
119   :,[enable_unix=auto])
121 dnl If Phobos is built as a shared library, the loader module may add a library
122 dnl dependency (-ldl on Linux).  So, make it optional for now.
123 AC_ARG_ENABLE(loader,
124   AC_HELP_STRING([--enable-loader],
125                  [builds the std.loader module (default: yes, if supported on taret)]),
126   :,[enable_loader=yes])
128 AC_ARG_ENABLE(proc-maps,
129   AC_HELP_STRING([--enable-proc-maps],
130                  [use /proc/self/maps to find data segments for garbage collection (default: yes, if supported on target)]),
131 [case "${enableval}" in
132 yes) echo 'TODO: If cross, warn that there is no check that this works'
133      ;;
134 auto|no)
135      ;;
136 *)   AC_MSG_ERROR([--enable-proc-maps argument must be "yes", "no", or "auto"])
137      ;;
138 esac],[enable_proc_maps=auto])
140 AC_ARG_ENABLE(phobos-config-dir,
141   AC_HELP_STRING([--enable-phobos-config-dir=<dir>],
142                  [use source file fragments in <dir>]),
143 [if test -z "${enableval}"; then
144   AC_MSG_ERROR([must specify a value for --enable-phobos-config-dir])
145 fi],
148 if test ${multilib} = yes; then
149   multilib_arg="--enable-multilib"
150 else
151   multilib_arg=
154 d_target_os=`echo $target_os | sed 's/^\([A-Za-z_]+\)/\1/'`
156 # SkyOS uses i386-skyos-pe
157 case "$target" in
158 *-skyos*-pe*) d_target_os=skyos ;;
159 esac
161 dnl if test -z "$GDC"; then
162 dnl   #GDC=gdc
163 dnl   GDC=$CC
164 dnl fi
165 dnl if test -z "$"
166 dnl AC_CHECK_PROG(d_have_dmd,$GDC,yes,no)
167 dnl if test "$d_have_dmd" = "no"; then
168 dnl   AC_MSG_ERROR([can't find the D compiler!])
169 dnl fi
171 GDC=$CC
172 GDC=`echo $CC | sed s/xgcc/gdc/`
174 AC_MSG_CHECKING([If $GDC can compile D sources])
175 echo "int function(int) test;" > actest.d
176 $GDC -c -x d -I "$srcdir" actest.d
177 r=$?
178 rm -f actest.[do]
179 if test $r -eq 0; then
180   AC_MSG_RESULT([yes])
181 else
182   AC_MSG_RESULT([no])
183   AC_MSG_ERROR([can't compile D sources!])
186 AC_SUBST(GDC)
188 AC_MSG_CHECKING([D GCC version])
189 d_gcc_ver=`$GDC -dumpversion`
190 AC_MSG_RESULT($d_gcc_ver)
192 # Need to export this variables for multilib
193 export CC_FOR_BUILD
194 export CFLAGS_FOR_BUILD
195 AC_SUBST(CC_FOR_BUILD)
196 AC_SUBST(CFLAGS_FOR_BUILD)
198 # Find build libiberty which is needed by x3
199 # Should not have to go up too many directories
202 dnl BUILD_LIBIBERTY=../../build-${build_alias}/libiberty/libiberty.a
203 dnl d_count=''
204 dnl while test ! -f "$BUILD_LIBIBERTY" && test "$d_count" != 'xxx'; do
205 dnl     BUILD_LIBIBERTY=../$BUILD_LIBIBERTY
206 dnl     d_count="x$d_count"
207 dnl done
208 dnl 
209 dnl # GCC 3.x does not use the 'build-' dir, so we have so search
210 dnl # for plain 'libiberty' with some kind of check it is not a target dir
211 dnl if test ! -f "$BUILD_LIBIBERTY"; then
212 dnl     BUILD_LIBIBERTY=../../libiberty/libiberty.a
213 dnl     d_count=''
214 dnl     while (test ! -f "$BUILD_LIBIBERTY" ||&& test "$d_count" != 'xxx'; do
215 dnl     BUILD_LIBIBERTY=../$BUILD_LIBIBERTY
216 dnl     d_count="x$d_count"
217 dnl     done
218 dnl fi
220 d_libiberty_dir=../..
221 while test "$d_count" != 'xxx'; do
222     BUILD_LIBIBERTY=$d_libiberty_dir/build-${ac_cv_build}/libiberty/libiberty.a
223     if test -f $BUILD_LIBIBERTY; then
224         break
225     fi
226     # GCC 3.x does not use the 'build-' dir, so we have so search
227     # for plain 'libiberty' with some kind of check it is not a target dir
228     BUILD_LIBIBERTY=$d_libiberty_dir/libiberty/libiberty.a
229     if test -f $BUILD_LIBIBERTY && test -d $d_libiberty_dir/gcc; then
230         break
231     fi
232     
233     d_libiberty_dir=../$d_libiberty_dir
234     d_count="x$d_count"
235 done
237 if test ! -f "$BUILD_LIBIBERTY"; then
238     AC_MSG_ERROR([cannot find libiberty.a for build])
241 LIBIBERTY_H_PATH='$(srcdir)/../include'
243 AC_SUBST(BUILD_LIBIBERTY)
244 AC_SUBST(LIBIBERTY_H_PATH)
247 dnl Eventually need to include everything from libstdc++-v3/acinclude.m4
248 dnl (# Default case for install directory for include files.) and on
250 # include dir .. need to support --enable-version-specific.. but
251 # will have to modify gcc/configure.ac ..
252 gdc_include_dir='${prefix}'/include/d2/${d_gcc_ver}
253 AC_SUBST(gdc_include_dir)
254 AC_ARG_WITH([cross-host],
255   AC_HELP_STRING([--with-cross-host=HOST],
256                [configuring with a cross compiler]))
257 if test -n "$with_cross_host" &&
258    test x"$with_cross_host" != x"no"; then
259   phobos_toolexecdir='${exec_prefix}/${ac_cv_host_alias}'
260   phobos_toolexeclibdir='${toolexecdir}/lib'
261 else
262   phobos_toolexecdir='${libdir}/gcc/${ac_cv_host_alias}'
263   phobos_toolexeclibdir='${libdir}'
265 # The norm would be to use $GDC -print-multi-os-directory, but
266 # that would require modifying config-ml.in
267 multi_os_directory=`$CC -print-multi-os-directory`
268 case $multi_os_directory in
269   .) ;; # Avoid trailing /.
270   *) phobos_toolexeclibdir=$phobos_toolexeclibdir/$multi_os_directory ;;
271 esac
272 AC_SUBST(phobos_toolexecdir)
273 AC_SUBST(phobos_toolexeclibdir)
275 dnl Checks for header files.
276 # Sanity check for the cross-compilation case:
277 AC_CHECK_HEADER(stdio.h,:,
278   [AC_MSG_ERROR([can't find stdio.h.])])
280 dnl AC_HEADER_STDC
281 # TODO...
283 dnl There was some target on sizeof(FILE) didn't work.
284 dnl Also, anything less than 4 bytes is probably a lie.
285 AC_MSG_CHECKING([for sizeof(FILE)])
286 AC_TRY_COMPILE([#include <stdio.h>],[
287 struct Test { int x: sizeof(FILE)>4; };],
288   [AC_MSG_RESULT([yes])
289    AC_DEFINE(HAVE_SIZEOF_FILE,1,[Define to 1 if it is possible to determine the size of the FILE struct])],
290   [AC_MSG_RESULT([no])])
292 AC_MSG_CHECKING([for sizeof(DIR)])
293 AC_TRY_COMPILE([#include <dirent.h>],[
294 struct Test { int x: sizeof(DIR)>4; };],
295   [AC_MSG_RESULT([yes])
296    AC_DEFINE(HAVE_SIZEOF_DIR,1,[Define to 1 if it is possible to determine the size of the DIR struct])],
297   [AC_MSG_RESULT([no])])
299 D_EXTRA_OBJS=
300 AC_SUBST(D_EXTRA_OBJS)
302 D_PREREQ_SRCS='$(config_d_src) $(config_errno_d_src) $(config_libc_d_src) $(config_mathfuncs_d_src)'
303 AC_SUBST(D_PREREQ_SRCS)
305 case "$target_cpu" in
306     i*86|powerpc*|ppc*|x86_64 ) d_use_ieee_fpsb=1 ;;
307     *) d_use_ieee_fpsb=0 ;;
308 esac
310 if test $d_use_ieee_fpsb -gt 0; then
311     D_EXTRA_OBJS="$D_EXTRA_OBJS internal/fpmath.o"
314 DCFG_USE_IEEE_FPSB=$d_use_ieee_fpsb
315 AC_SUBST(DCFG_USE_IEEE_FPSB)
317 if test "$with_newlib" = yes; then
318     # TODO: there is some way to enable long double funcs in newlib so need to support that
319     DCFG_LONG_DOUBLE_FUNCS=config/noldfuncs
320     DCFG_SQRTF=config/sqrtf
321     # TODO: newlib has trunc and exp2, but not log2 -- so configure all separately
322     DCFG_TRUNC=""
323     DCFG_NEARBYINT=""
324     DCFG_ROUND=""
325     DCFG_TGAMMA=""
326     DCFG_NAN=""
327     DCFG_EXP2_LOG2="GNU_Need_exp2_log2"
328     
329     AC_DEFINE(HAVE_FP_CLASSIFY_SIGNBIT,1,[Define to 1 fpclassify and signbit are available])
330     D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/cbridge_math.o"
331     D_PREREQ_SRCS="$D_PREREQ_SRCS "'$(config_fpcls_d_src)'
332     
333     # TODO: exec stuff
334     
335     DCFG_FWIDE=0
336     # Have getdelim, but it may not be unix (need ssize_t)... TODO
337     DCFG_HAVE_GETDELIM=0
338     DCFG_HAVE_FGETLN=0
339     DCFG_HAVE_FGETLINE=0
340     DCFG_HAVE_UNLOCKED_STDIO=0
341     DCFG_HAVE_UNLOCKED_WIDE_STDIO=$DCFG_HAVE_UNLOCKED_STDIO
342     DCFG_STRTOLD="0"
343     # NO HAVE_TM_GMTOFF_AND_ZONE
344     # NO HAVE_TIMEZONE
345     AC_DEFINE(HAVE__TIMEZONE,1,[Another global timezone variable])
346 else
348 AC_CHECK_LIB(m,cos)
350 case "$d_target_os" in
351   aix*) AC_CHECK_LIB(C,sqrtf) ;;
352 esac
354 case "$target_os" in
355   darwin6*) DCFG_LONG_DOUBLE_FUNCS=config/noldfuncs ;;
356   darwin*)  DCFG_LONG_DOUBLE_FUNCS=config/ldfuncs-darwin ;;
357   linux*|k*bsd*-gnu)
358     case "$target_cpu" in
359         powerpc*)
360             DCFG_LONG_DOUBLE_FUNCS=config/ldfuncs-ppclinux
361             # Libc without nldbl not supported...
362             AC_CHECK_FUNC(__nldbl_printf,d_have_nldbl_funcs=1,:)
363             if test "$d_have_nldbl_funcs" = 1; then
364                 :
365             fi
366             ;;
367     esac
368 esac
370 if test -z "$DCFG_LONG_DOUBLE_FUNCS"; then
371     AC_CHECK_FUNC(acosl,have_ldf_a=1,:)
372     AC_CHECK_FUNC(truncl,have_ldf_b=1,:)
373     if test "${have_ldf_a}${have_ldf_b}" = "11"; then
374         DCFG_LONG_DOUBLE_FUNCS=config/ldfuncs
375     else
376         DCFG_LONG_DOUBLE_FUNCS=config/noldfuncs
377     fi
378     DCFG_LONG_DOUBLE_FUNCS="$DCFG_LONG_DOUBLE_FUNCS"
381 # on darwin, we don't seem to have sqrtf, even though it's in math.h
382 AC_CHECK_FUNC(sqrtf,DCFG_SQRTF=config/sqrtf,DCFG_SQRTF=config/nosqrtf)
384 # on freebsd, trunc,exp2,log2 are not provided
385 # This is "need" and not "have" to mesh better with non-GNU.  Othrewise, it
386 # would be version(GNU)version(GNU_Have_trunc)....
387 AC_CHECK_FUNC(trunc,DCFG_TRUNC="",DCFG_TRUNC="GNU_Need_trunc")
388 AC_SUBST(DCFG_TRUNC)
390 AC_CHECK_FUNC(nearbyint,DCFG_NEARBYINT="",DCFG_NEARBYINT="GNU_Need_nearbyint")
391 AC_SUBST(DCFG_NEARBYINT)
393 AC_CHECK_FUNC(round,DCFG_ROUND="",DCFG_ROUND="GNU_Need_round")
394 AC_SUBST(DCFG_ROUND)
396 AC_CHECK_FUNC(tgamma,DCFG_TGAMMA="",[
397         DCFG_TGAMMA="GNU_Need_tgamma"
398         D_EXTRA_OBJS="$D_EXTRA_OBJS etc/gamma.o"        
399         ])
400 AC_SUBST(DCFG_TGAMMA)
402 AC_CHECK_FUNC(nan,DCFG_NAN="",DCFG_NAN="GNU_Need_nan")
403 AC_SUBST(DCFG_NAN)
405 AC_CHECK_FUNCS(exp2 log2,:,:)
406 if test "$ac_cv_func_exp2" = "yes" && test "$ac_cv_func_log2" = "yes"; then
407     DCFG_EXP2_LOG2=""
408 else
409     DCFG_EXP2_LOG2="GNU_Need_exp2_log2"
411 AC_SUBST(DCFG_EXP2_LOG2)
413 AC_MSG_CHECKING([for fpclassify and signbit])
414 AC_TRY_COMPILE([
415     #ifndef fpclassify
416     static void fpclassify(int x, int y) { }
417     #endif
418     #ifndef signbit
419     static void signbit(int x, int y) { }
420     #endif
421     #include <math.h>],
422   [int x = fpclassify(4.2);
423    int y = signbit(1.1);
424    int z = FP_NAN + FP_INFINITE + FP_ZERO + FP_SUBNORMAL + FP_NORMAL;],
425   [AC_MSG_RESULT([yes])
426    d_have_fpsb=1],
427   [AC_MSG_RESULT([no])])
429 # Currently can only have either itnernal/fpmath or gcc/cbridge_math
430 if test $d_use_ieee_fpsb -eq 0; then
431     if test -n "$d_have_fpsb"; then
432         AC_DEFINE(HAVE_FP_CLASSIFY_SIGNBIT,1,[Define to 1 fpclassify and signbit are available])
433         D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/cbridge_math.o"
434         D_PREREQ_SRCS="$D_PREREQ_SRCS "'$(config_fpcls_d_src)'
435     fi
438 # no expm1 on mingw (msvcrt)
439 # AC_CHECK_FUNCS(expm1,DCFG_EXPM1="",DCFG_EXPM1="GNU_Need_expm1")
440 # AC_SUBST(DCFG_EXPM1)
441 # also erf, erfc
443 AC_CHECK_FUNC(execvpe,DCFG_EXECVPE="",DCFG_EXECVPE="GNU_Need_execvpe")
444 AC_SUBST(DCFG_EXECVPE)
446 AC_CHECK_FUNC(spawnvp,DCFG_SPAWNVP="",DCFG_SPAWNVP="GNU_Need_spawnvp")
447 AC_SUBST(DCFG_SPAWNVP)
449 AC_CHECK_FUNC(fwide,[DCFG_FWIDE=1],[DCFG_FWIDE=0])
450 AC_SUBST(DCFG_FWIDE)
452 AC_CHECK_FUNC(getdelim,[DCFG_HAVE_GETDELIM=1],[DCFG_HAVE_GETDELIM=0])
453 AC_SUBST(DCFG_HAVE_GETDELIM)
455 AC_CHECK_FUNC(fgetln,[DCFG_HAVE_FGETLN=1],[DCFG_HAVE_FGETLN=0])
456 AC_SUBST(DCFG_HAVE_FGETLN)
458 AC_CHECK_FUNC(fgetline,[DCFG_HAVE_FGETLINE=1],[DCFG_HAVE_FGETLINE=0])
459 AC_SUBST(DCFG_HAVE_FGETLINE)
461 DCFG_HAVE_UNLOCKED_STDIO=1
462 AC_CHECK_FUNCS([flockfile funlockfile putc_unlocked getc_unlocked],
463         [],[DCFG_HAVE_UNLOCKED_STDIO=0])
464 AC_SUBST(DCFG_HAVE_UNLOCKED_STDIO)
466 DCFG_HAVE_UNLOCKED_WIDE_STDIO=$DCFG_HAVE_UNLOCKED_STDIO
467 AC_CHECK_FUNCS([putwc_unlocked getwc_unlocked], [],[DCFG_HAVE_UNLOCKED_WIDE_STDIO=0])
468 AC_SUBST(DCFG_HAVE_UNLOCKED_WIDE_STDIO)
470 AC_CHECK_FUNC(strtold,DCFG_STRTOLD="1",DCFG_STRTOLD="0")
471 AC_SUBST(DCFG_STRTOLD)
473 save_CFLAGS=$CFLAGS
474 # Check for the glibc version of strerror_r
475 AC_MSG_CHECKING([for glibc strerror_r])
476 CFLAGS="$CFLAGS -D_GNU_SOURCE=1"
477 AC_TRY_COMPILE([#include <string.h>],[
478 char c = * strerror_r(0, NULL, 0);
480   [AC_MSG_RESULT([yes])
481    AC_DEFINE(HAVE_GLIBC_STRERROR_R,1,[Have glibc strerror_r])],
482   [AC_MSG_RESULT([no])])
483 CFLAGS=$save_CFLAGS
485 AC_CHECK_FUNCS([strerror_r],[],[])
487 dnl Check for BSD(?) specific fields in struct tm
488 dnl Maybe test fields separately
489 AC_MSG_CHECKING([for tm_gmtoff])
490 AC_TRY_COMPILE([#include <time.h>],[
491 struct tm t;
492 t.tm_gmtoff = t.tm_gmtoff;
493 t.tm_zone = t.tm_zone;],
494   [AC_MSG_RESULT([yes])
495    AC_DEFINE(HAVE_TM_GMTOFF_AND_ZONE,1,[Extra fields in struct tm])],
496   [AC_MSG_RESULT([no])])
498 dnl The '* 42' is to ensure a type error occurs if timezone is not a
499 dnl number.  Simple assignment will not do this.
500 AC_MSG_CHECKING([for timezone])
501 AC_TRY_COMPILE([#include <time.h>],[
502 time_t t = timezone * 42;],
503   [AC_MSG_RESULT([yes])
504    AC_DEFINE(HAVE_TIMEZONE,1,[Global timezone variable])],
505   [AC_MSG_RESULT([no])])
507 AC_MSG_CHECKING([for _timezone])
508 AC_TRY_COMPILE([#include <time.h>],[
509 time_t t = _timezone * 42;],
510   [AC_MSG_RESULT([yes])
511    AC_DEFINE(HAVE__TIMEZONE,1,[Another global timezone variable])],
512   [AC_MSG_RESULT([no])])
514 AC_CHECK_FUNCS(snprintf _snprintf,break,[AC_MSG_ERROR([No variant of snprintf.])])
515 AC_CHECK_FUNCS(vsnprintf _vsnprintf,break,[AC_MSG_ERROR([No variant of vsnprintf.])])
517 # end of 'if $with_newlib...'
520 DCFG_LONG_DOUBLE_FUNCS="$srcdir/$DCFG_LONG_DOUBLE_FUNCS"
521 AC_SUBST_FILE(DCFG_LONG_DOUBLE_FUNCS)
522 DCFG_SQRTF="$srcdir/$DCFG_SQRTF"
523 AC_SUBST_FILE(DCFG_SQRTF)
525 AC_MSG_CHECKING([for ARM unwinder])
526 AC_TRY_COMPILE([#include <unwind.h>],[
527 #if __ARM_EABI_UNWINDER__
528 #error Yes, it is.
529 #endif
531   [AC_MSG_RESULT([no])
532    DCFG_ARM_EABI_UNWINDER=0
533    D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/unwind_generic.o"],
534   [AC_MSG_RESULT([yes])
535    DCFG_ARM_EABI_UNWINDER=1
536    D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/unwind_arm.o"])
537 AC_SUBST(DCFG_ARM_EABI_UNWINDER)
539 AC_MSG_CHECKING([if std.boxer will work])
540 cat > conftest.d <<END
541 void test(...) { _argptr += 4; }
543 $GDC -c -I . -I $srcdir conftest.d >/dev/null 2>&1
544 if test $? = 0; then
545     AC_MSG_RESULT([yes])
546     D_EXTRA_OBJS="$D_EXTRA_OBJS std/boxer.o"
547 else
548     AC_MSG_RESULT([no])
550 rm -f conftest.d conftest.$ac_objext
552 case "$d_target_os" in
553   aix*|*bsd*|cygwin*|darwin*|linux*|skyos*|solaris*|sysv*) d_have_unix=1 ;;
554 esac
556 DCFG_CBRIDGE_STDIO=
557 AC_SUBST(DCFG_CBRIDGE_STDIO)
559 if test -n "$d_have_unix" && test "$enable_unix" = auto ; then
560   enable_unix=yes
563 case "$d_target_os" in
564     aix*)    d_is_aix=1
565              ;;
566     darwin*) d_module_mach=1
567              d_sem_impl="mach"
568              d_have_loader=1
569              ;;
570     freebsd*|k*bsd*-gnu)
571              d_have_loader=1
572              D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/cbridge_stdio.o"
573              DCFG_CBRIDGE_STDIO=GNU_CBridge_Stdio
574              ;;
575     linux*)  #D_EXTRA_OBJS="$D_EXTRA_OBJS std/c/linux/linux.o"
576              d_sem_impl="posix"
577              d_have_loader=1 # should check for <dlfcn.h>, and use verion(GNU_Have_dlopen)
578              ;;
579     cygwin*) D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/cbridge_stdio.o"
580              DCFG_CBRIDGE_STDIO=GNU_CBridge_Stdio
581              ;;
582     mingw*)  #D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/cbridge_stdio.o"
583              D_EXTRA_OBJS="$D_EXTRA_OBJS \$(WINDOWS_OBJS)"
584              D_EXTRA_OBJS="$D_EXTRA_OBJS \$(OS_OBJS)"
585              #DCFG_CBRIDGE_STDIO=GNU_CBridge_Stdio
586              DCFG_UNIX=Windows
587              d_have_loader=1
588              ;;
589     skyos*)  d_sem_impl="skyos"
590              D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/cbridge_stdio.o"
591              DCFG_CBRIDGE_STDIO=GNU_CBridge_Stdio
592              AC_DEFINE(PTHREAD_MUTEX_ALREADY_RECURSIVE,1,[Define if mutexes are recursive by default])
593              ;;
594     *)       if test "$enable_unix" != "yes"; then
595                  DCFG_UNIX=NoSystem
596                  AC_DEFINE(PHOBOS_NO_SYSTEM,1,[Define if there is no file system, synchronization services, etc.])
597              fi
598              D_EXTRA_OBJS="$D_EXTRA_OBJS gcc/cbridge_stdio.o"
599              DCFG_CBRIDGE_STDIO=GNU_CBridge_Stdio
600              ;;
601 esac
603 # = D_EXTRA_OBJS="$D_EXTRA_OBJS \$(WINDOWS_OBJS)"
604 # for cygw: WINDOWS_DFLAGS=-mno-cygwin
606 # in Make: .win.o maybe... to get a separate rule
608 if test -n "$d_module_mach"; then
609   D_EXTRA_OBJS="$D_EXTRA_OBJS std/c/mach/mach.o"
612 if test "$enable_unix" = "yes"; then
613   D_EXTRA_OBJS="$D_EXTRA_OBJS \$(OS_OBJS)"
614   DPHOBOS_CONFIGURE_UNIX
616 dnl can these be moved to acinclude.m4?
617 AC_SUBST(DCFG_SEMAPHORE_IMPL)
618 AC_SUBST(DCFG_MMAP)
619 AC_SUBST(DCFG_GETPWNAM_R)
622 AC_SUBST(DCFG_UNIX)
623         
624 if test -z "$DFLAGS"; then
625     DFLAGS="-g -frelease -O2"
627 AC_SUBST(DFLAGS)
630 if test -n "$d_have_loader" && test "$enable_loader" = yes; then
631   D_EXTRA_OBJS="$D_EXTRA_OBJS std/loader.o"
634 dnl TODO: change this to using pthreads? if so, define usepthreads
635 dnl and configure semaphore
638 # phobose_use_pthreads was here...
640 d_subdirs=`( cd $srcdir && find . -type d ) | sed -e 's/^.\///'`
641 d_subdirs="$d_subdirs gcc"
642 for i in $d_subdirs; do
643         mkdir -p $i;
644 done
646 AC_SUBST(srcdir)
648 # Cross stuff
649 # if test -n "$d_cross_comp"; then
650 #       
651 # fi
653 # Garbage collection configuration
655 D_GC_MODULES=
656 D_GC_FLAGS=
658 case "$target_os" in
659   mingw*)
660             D_GC_MODULES=internal/gc/win32.o
661             need_to_cfgr_gc=''
662             ;;
663   *)        if test "$with_newlib"; then
664                 dnl Not sure what to do about GC...
665                 D_GC_MODULES=internal/gc/gcgcc.o
666                 D_GC_FLAGS='-fversion=GC_Use_Stack_Guess -fversion=GC_Use_Alloc_Malloc'
667                 D_GC_MODULES="internal/gc/gcgcc.o internal/gc/gc_guess_stack.o"
668             else
669                 need_to_cfgr_gc=yes
670             fi
671             ;;
672 esac
674 if test "$need_to_cfgr_gc" = yes; then
675     DPHOBOS_CONFIGURE_GC
678 AC_SUBST(D_GC_FLAGS)
679 AC_SUBST(D_GC_MODULES)
681 AC_OUTPUT([Makefile frag-ac frag-math phobos-ver-syms])