D compiler sanity checks in configure; check D2 by default if no D1 compiler can be found.

For both D1 and D2, if the compiler has not been specified explicitly via a command line option, the configure script tries to compile a minimal program stub. Only if this succeeds, the respective compiler is enabled.

If neither a working D1 nor a working D2 compiler has been found, D is skipped completely as usual.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12334 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
David Nadlinger 2010-12-08 16:57:55 +00:00
commit e120dfcc70
2 changed files with 55 additions and 7 deletions

View file

@ -1219,6 +1219,10 @@ go_clean:
DLIBPREFIX = @DLIBPREFIX@
ifeq (,$(D_VERSION))
D_VERSION = @DDEFAULTVERSION@
endif
ifeq (2,$(D_VERSION))
SWIGD = $(SWIG) -d -d2
DCOMPILER = @D2COMPILER@
@ -1229,7 +1233,7 @@ endif
ifeq (dmd,$(DCOMPILER))
# DMD is 32bit only by now
CFLAGS += -m32
DCFLAGS = -m32
endif
# ----------------------------------------------------------------
@ -1238,8 +1242,8 @@ endif
d: $(SRCS)
$(SWIGD) $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
$(LDSHARED) $(CFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
$(CC) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
$(LDSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
# ----------------------------------------------------------------
# Build a dynamically loadable D wrapper for a C++ module
@ -1247,8 +1251,8 @@ d: $(SRCS)
d_cpp: $(SRCS)
$(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
# ----------------------------------------------------------------
# Compile D files

View file

@ -2028,25 +2028,68 @@ AC_SUBST(GO)
#----------------------------------------------------------------
AC_ARG_WITH(d, AS_HELP_STRING([--without-d], [Disable D]), [with_d="$withval"], [with_d=yes])
AC_ARG_WITH(d1-compiler, [ --with-d1-compiler=path Set location of D1 compiler (DMD compatible)],[D1COMPILERBIN="$withval"], [D1COMPILERBIN=])
AC_ARG_WITH(d1-compiler, [ --with-d1-compiler=path Set location of D1/Tango compiler (DMD compatible)],[D1COMPILERBIN="$withval"], [D1COMPILERBIN=])
AC_ARG_WITH(d2-compiler, [ --with-d2-compiler=path Set location of D2 compiler (DMD compatible)],[D2COMPILERBIN="$withval"], [D2COMPILERBIN=])
# First, check for "--without-d" or "--with-d=no".
if test x"${with_d}" = xno -o x"${with_alllang}" = xno ; then
AC_MSG_NOTICE([Disabling D])
D1COMPILER=
D2COMPILER=
else
old_ac_ext=$ac_ext
ac_ext=d
if test -z "$D1COMPILERBIN" ; then
AC_CHECK_PROGS(D1COMPILER, dmd ldmd gdmd)
AC_MSG_CHECKING(whether the D1/Tango compiler works)
cat > conftest.$ac_ext <<_ACEOF
import tango.io.Stdout;
void main() {
}
_ACEOF
rm -f conftest.$ac_objext
AS_IF(
[_AC_DO_STDERR($D1COMPILER conftest.$ac_ext) && test ! -s conftest.err && test -s conftest.$ac_objext],
[AC_MSG_RESULT([yes])],
[_AC_MSG_LOG_CONFTEST AC_MSG_RESULT([no])
D1COMPILER=]
)
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
else
D1COMPILER="$D1COMPILERBIN"
fi
if test -z "$D2COMPILERBIN" ; then
AC_CHECK_PROGS(D2COMPILER, dmd gdmd)
AC_MSG_CHECKING(whether the D2 compiler works)
cat > conftest.$ac_ext <<_ACEOF
import std.algorithm;
void main() {
}
_ACEOF
rm -f conftest.$ac_objext
AS_IF(
[_AC_DO_STDERR($D2COMPILER conftest.$ac_ext) && test ! -s conftest.err && test -s conftest.$ac_objext],
[AC_MSG_RESULT([yes])],
[_AC_MSG_LOG_CONFTEST AC_MSG_RESULT([no])
D2COMPILER=]
)
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
else
D2COMPILER="$D2COMPILERBIN"
fi
ac_ext=$old_ac_ext
fi
if test -n "$D1COMPILER"; then
DDEFAULTVERSION=1
elif test -n "$D2COMPILER"; then
DDEFAULTVERSION=2
fi
# Do not prefix library file names with "lib" on Windows.
@ -2057,6 +2100,7 @@ esac
AC_SUBST(D1COMPILER)
AC_SUBST(D2COMPILER)
AC_SUBST(DDEFAULTVERSION)
AC_SUBST(DLIBPREFIX)
#----------------------------------------------------------------
@ -2216,7 +2260,7 @@ fi
AC_SUBST(SKIP_GO)
SKIP_D=
if test -z "$D1COMPILER" && test -z "$D2COMPILER" ; then
if test -z "$DDEFAULTVERSION" ; then
SKIP_D="1"
fi
AC_SUBST(SKIP_D)