1# Find the location of GAP 2# Sets GAPROOT, GAPARCH and GAP_CPPFLAGS appropriately 3# Can be configured using --with-gaproot=... and CONFIGNAME=... 4####################################################################### 5 6AC_DEFUN([AC_FIND_GAP], 7[ 8 AC_LANG_PUSH([C]) 9 10 # Make sure CDPATH is portably set to a sensible value 11 CDPATH=${ZSH_VERSION+.}: 12 13 GAP_CPPFLAGS="" 14 15 #Allow the user to specify a configname: 16 AC_MSG_CHECKING([for CONFIGNAME]) 17 AC_ARG_VAR(CONFIGNAME, [Set this to the CONFIGNAME of the GAP compilation 18 against which you want to compile this package. Leave this 19 variable empty for GAP versions < 4.5.]) 20 if test "x$CONFIGNAME" = "x"; then 21 SYSINFO="sysinfo.gap" 22 AC_MSG_RESULT([none]) 23 else 24 SYSINFO="sysinfo.gap-$CONFIGNAME" 25 AC_MSG_RESULT([$CONFIGNAME]) 26 fi 27 28 ###################################### 29 # Find the GAP root directory by 30 # checking for the sysinfo.gap file 31 AC_MSG_CHECKING([for GAP root directory]) 32 DEFAULT_GAPROOTS="../.." 33 34 #Allow the user to specify the location of GAP 35 # 36 AC_ARG_WITH(gaproot, 37 [AC_HELP_STRING([--with-gaproot=<path>], [specify root of GAP installation])], 38 [DEFAULT_GAPROOTS="$withval"]) 39 40 havesysinfo=0 41 # Otherwise try likely directories 42 for GAPROOT in ${DEFAULT_GAPROOTS} 43 do 44 # Convert the path to absolute 45 GAPROOT=`cd $GAPROOT > /dev/null 2>&1 && pwd` 46 if test -e ${GAPROOT}/${SYSINFO}; then 47 havesysinfo=1 48 break 49 fi 50 done 51 52 if test "x$havesysinfo" = "x1"; then 53 AC_MSG_RESULT([${GAPROOT}]) 54 else 55 AC_MSG_RESULT([Not found]) 56 57 echo "" 58 echo "********************************************************************" 59 echo " ERROR" 60 echo "" 61 echo " Cannot find your GAP installation. Please specify the location of" 62 echo " GAP's root directory using --with-gaproot=<path>" 63 echo "" 64 echo " The GAP root directory (as far as this package is concerned) is" 65 echo " the one containing the file sysinfo.gap and the subdirectories " 66 echo " src/ and bin/." 67 echo "********************************************************************" 68 echo "" 69 70 AC_MSG_ERROR([Unable to find GAP root directory]) 71 fi 72 73 ##################################### 74 # Now find the architecture 75 76 AC_MSG_CHECKING([for GAP architecture]) 77 GAPARCH="Unknown" 78 . $GAPROOT/$SYSINFO 79 if test "x$GAParch" != "x"; then 80 GAPARCH=$GAParch 81 fi 82 83 AC_ARG_WITH(gaparch, 84 [AC_HELP_STRING([--with-gaparch=<path>], [override GAP architecture string])], 85 [GAPARCH=$withval]) 86 AC_MSG_RESULT([${GAPARCH}]) 87 88 if test "x$GAPARCH" = "xUnknown" -o ! -d $GAPROOT/bin/$GAPARCH ; then 89 echo "" 90 echo "********************************************************************" 91 echo " ERROR" 92 echo "" 93 echo " Found a GAP installation at $GAPROOT but could not find" 94 echo " information about GAP's architecture in the" 95 echo " file ${GAPROOT}/${SYSINFO} or did not find the directory" 96 echo " ${GAPROOT}/bin/${GAPARCH}." 97 echo " This file and directory should be present: please check your" 98 echo " GAP installation." 99 echo "********************************************************************" 100 echo "" 101 102 AC_MSG_ERROR([Unable to find plausible GAParch information.]) 103 fi 104 105 106 AC_MSG_CHECKING([for GAP >= 4.9]) 107 # test if this GAP >= 4.9 108 if test "x$GAP_CPPFLAGS" != x; then 109 AC_MSG_RESULT([yes]) 110 else 111 AC_MSG_RESULT([no]) 112 ##################################### 113 # Now check for the GAP header files 114 115 bad=0 116 AC_MSG_CHECKING([for GAP include files]) 117 if test -r $GAPROOT/src/compiled.h; then 118 AC_MSG_RESULT([$GAPROOT/src/compiled.h]) 119 else 120 AC_MSG_RESULT([Not found]) 121 bad=1 122 fi 123 AC_MSG_CHECKING([for GAP config.h]) 124 if test -r $GAPROOT/bin/$GAPARCH/config.h; then 125 AC_MSG_RESULT([$GAPROOT/bin/$GAPARCH/config.h]) 126 else 127 AC_MSG_RESULT([Not found]) 128 bad=1 129 fi 130 131 if test "x$bad" = "x1"; then 132 echo "" 133 echo "********************************************************************" 134 echo " ERROR" 135 echo "" 136 echo " Failed to find the GAP source header files in src/ and" 137 echo " GAP's config.h in the architecture dependend directory" 138 echo "" 139 echo " The kernel build process expects to find the normal GAP " 140 echo " root directory structure as it is after building GAP itself, and" 141 echo " in particular the files" 142 echo " <gaproot>/sysinfo.gap" 143 echo " <gaproot>/src/<includes>" 144 echo " and <gaproot>/bin/<architecture>/bin/config.h." 145 echo " Please make sure that your GAP root directory structure" 146 echo " conforms to this layout, or give the correct GAP root using" 147 echo " --with-gaproot=<path>" 148 echo "********************************************************************" 149 echo "" 150 AC_MSG_ERROR([Unable to find GAP include files in /src subdirectory]) 151 fi 152 153 ARCHPATH=$GAPROOT/bin/$GAPARCH 154 GAP_CPPFLAGS="-I$GAPROOT -iquote $GAPROOT/src -I$ARCHPATH" 155 156 AC_MSG_CHECKING([for GAP's gmp.h location]) 157 if test -r "$ARCHPATH/extern/gmp/include/gmp.h"; then 158 GAP_CPPFLAGS="$GAP_CPPFLAGS -I$ARCHPATH/extern/gmp/include" 159 AC_MSG_RESULT([$ARCHPATH/extern/gmp/include/gmp.h]) 160 else 161 AC_MSG_RESULT([not found, GAP was compiled without its own GMP]) 162 fi 163 fi 164 165 AC_SUBST(GAPARCH) 166 AC_SUBST(GAPROOT) 167 AC_SUBST(GAP_CPPFLAGS) 168 AC_SUBST(GAP_CFLAGS) 169 AC_SUBST(GAP_LDFLAGS) 170 AC_SUBST(GAP_LIBS) 171 172 AC_LANG_POP([C]) 173]) 174