1## This file is copied from GNATCOLL. Ideally, XML/Ada should 2## depend on gnatcoll and let the latter compute once and for all 3## whether the system supports shared libraries and whether the 4## user wants them, but this is not the case currently. 5 6 7AC_DEFUN(AM_SO_SUFFIX, 8[ 9 case $target_os in 10 *darwin*) SO_EXT=.dylib ;; 11 *cygwin*|*mingw*) SO_EXT=.dll ;; 12 *) SO_EXT=.so ;; 13 esac 14 AC_SUBST(SO_EXT) 15]) 16 17############################################################# 18# Checking for build type 19############################################################# 20 21AC_DEFUN(CHECK_BUILD_TYPE, 22[ 23 AC_ARG_ENABLE(build, 24 [AC_HELP_STRING( 25 [--enable-build=<type>], 26 [Default build type for the library (Debug, Production)])], 27 BUILD_TYPE=$enableval, 28 BUILD_TYPE=Production) 29 AC_SUBST(BUILD_TYPE) 30] 31) 32 33############################################################# 34# Check whether GNAT on that target supports building shared 35# libraries 36# The following variables is exported by configure: 37# @gprbuild@: the gprbuild command to use 38# @GNAT_BUILDS_SHARED@: either "yes" or "no" 39# @DEFAULT_LIBRARY_TYPE@: either "static" or "relocatable" 40# This is only set to "relocatable" if the user explicitly 41# added --enable-shared. Otherwise, even if we detect that 42# shared libs are available, we will still use static as the 43# safe default. 44############################################################# 45 46AC_DEFUN(AM_GNAT_BUILDS_SHARED, 47[ 48 AC_MSG_CHECKING(whether gnat can build shared libs) 49 50 DEFAULT_LIBRARY_TYPE=static 51 52 AC_ARG_ENABLE(shared, 53 [AC_HELP_STRING( 54 [--disable-shared], 55 [Disable building of shared libraries]) 56AC_HELP_STRING( 57 [--enable-shared], 58 [Build shared libraries if supported on the target 59Make them the installation default])], 60 [GNAT_BUILDS_SHARED=$enableval 61 if test $enableval = yes; then 62 DEFAULT_LIBRARY_TYPE=relocatable 63 fi], 64 [GNAT_BUILDS_SHARED=yes]) 65 66 gprinstall=gprinstall 67 AC_SUBST(gprinstall) 68 69 gprbuild=gprbuild 70 AC_SUBST(gprbuild) 71 72 if test x$GNAT_BUILDS_SHARED = xyes; then 73 # Create a temporary directory (from "info autoconf") 74 : ${TMPDIR=/tmp} 75 { 76 tmp=`(umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null` \ 77 && test -n "$tmp" && test -d "$tmp" 78 } || { 79 tmp=$TMPDIR/foo$$-$RANDOM 80 (umask 077 && mkdir -p "$tmp") 81 } || exit $? 82 83 mkdir $tmp/lib 84 echo "package Foo is end Foo;" > $tmp/foo.ads 85 cat > $tmp/lib.gpr <<EOF 86project Lib is 87 for Source_Dirs use ("."); 88 for Library_Dir use "lib"; 89 for Library_Name use "lib"; 90 for Library_Kind use "relocatable"; 91end Lib; 92EOF 93 94 if test "x$host_alias" != "x$target_alias"; then 95 $gprbuild --target=$target_alias -c -q -P$tmp/lib 2>/dev/null 96 else 97 $gprbuild -c -q -P$tmp/lib 2>/dev/null 98 fi 99 if test $? = 0 ; then 100 GNAT_BUILDS_SHARED=yes 101 else 102 GNAT_BUILDS_SHARED=no 103 fi 104 rm -rf $tmp 105 AC_MSG_RESULT($GNAT_BUILDS_SHARED) 106 else 107 AC_MSG_RESULT([no (--disabled-shared)]) 108 fi 109 110 AC_SUBST(GNAT_BUILDS_SHARED) 111 AC_SUBST(DEFAULT_LIBRARY_TYPE) 112]) 113