add -framework gecode if necessary

This commit is contained in:
Denys Duchier 2011-12-02 14:30:55 +01:00
parent 7c78f52a89
commit 9ebcae23ea
3 changed files with 75 additions and 5 deletions

54
configure vendored
View File

@ -705,6 +705,7 @@ LN_S
DefTrailSpace
DefStackSpace
DefHeapSpace
GECODE_EXTRALIBS
GECODE_VERSION
EGREP
GREP
@ -4336,10 +4337,12 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
GECODE_VERSION=unknown-gecode-version
GECODE_EXTRALIBS=
if test "$use_gecode" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking determining gecode version" >&5
$as_echo_n "checking determining gecode version... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking gecode version" >&5
$as_echo_n "checking gecode version... " >&6; }
if test "$cross_compiling" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@ -4376,6 +4379,53 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
case "$target_os" in
*darwin*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -framework gecode is required" >&5
$as_echo_n "checking if -framework gecode is required... " >&6; }
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -framework gecode"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include "gecode/int.hh"
int
main ()
{
Gecode::Exception e("","");
return 0;
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
GECODE_EXTRALIBS="-framework gecode"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
CXXFLAGS="$saved_CXXFLAGS"
;;
esac
fi
# Check whether --enable-tabling was given.

View File

@ -98,9 +98,11 @@ AC_COMPILE_IFELSE([
AC_MSG_RESULT([no])
])
GECODE_VERSION=unknown-gecode-version
GECODE_EXTRALIBS=
AC_SUBST(GECODE_VERSION)
AC_SUBST(GECODE_EXTRALIBS)
if test "$use_gecode" = yes; then
AC_MSG_CHECKING([determining gecode version])
AC_MSG_CHECKING([gecode version])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include "gecode/support/config.hpp"
#include <stdio.h>
@ -112,6 +114,24 @@ if test "$use_gecode" = yes; then
]])],[GECODE_VERSION=$(cat conftest.out)
AC_MSG_RESULT([$GECODE_VERSION])],
[AC_MSG_ERROR([cannot determine gecode version])])
case "$target_os" in
*darwin*)
AC_MSG_CHECKING([if -framework gecode is required])
AC_LANG_PUSH([C++])
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -framework gecode"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "gecode/int.hh"
]],[[
Gecode::Exception e("","");
return 0;
]])],[GECODE_EXTRALIBS="-framework gecode"
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
AC_LANG_POP()
CXXFLAGS="$saved_CXXFLAGS"
;;
esac
fi
AC_ARG_ENABLE(tabling,

View File

@ -43,8 +43,8 @@ OBJS=gecode_yap.o
SOBJS=gecode_yap.@SO@
GECODE_VERSION = @GECODE_VERSION@
CODEGEN=$(srcdir)/code-generator.py
DISJUNCTOR = -DDISJUNCTOR
GECODE_LIBS = @GECODE_EXTRALIBS@ -lgecodesupport -lgecodekernel -lgecodeint -lgecodeset -lgecodesearch
all: $(SOBJS) gecode.yap
@ -59,7 +59,7 @@ gecode_yap.o: \
$(CXX) -c -I$(srcdir)/$(GECODE_VERSION) $(CXXFLAGS) $(DISJUNCTOR) -o $@ $<
@DO_SECOND_LD@gecode_yap.@SO@: gecode_yap.o
@DO_SECOND_LD@ @SHLIB_LD@ -o gecode_yap.@SO@ gecode_yap.o $(LDFLAGS) -lgecodeint -lgecodeset -lgecodesearch @EXTRA_LIBS_FOR_DLLS@
@DO_SECOND_LD@ @SHLIB_LD@ -o gecode_yap.@SO@ gecode_yap.o $(LDFLAGS) $(GECODE_LIBS) @EXTRA_LIBS_FOR_DLLS@
gecode.yap: $(srcdir)/gecode_yap_hand_written.yap $(srcdir)/$(GECODE_VERSION)/gecode_yap_auto_generated.yap
cat $^ > $@