1#!/bin/sh 2 3# not a normal autoconf configure script 4# grab the file ../../perlvars that mapserver made for the perl mapscript 5# build, and use gcc and ld flags 6 7if [ ! -f ../../perlvars ] ; then 8 echo "you must build MapServer first." 9 exit 10fi 11 12MAPSERVERHOME=`head -1 ../../mapscriptvars | tail -1` 13MAPSERVERDEFS=`head -2 ../../mapscriptvars | tail -1` 14MAPSERVERINCS=`head -3 ../../mapscriptvars | tail -1` 15MAPSERVERLIBS=`head -4 ../../mapscriptvars | tail -1` 16 17# make sure link to mapscript.i exists 18 19if [ ! -f mapscript.i ] ; then 20 ln -s ../mapscript.i mapscript.i 21fi 22 23# check for --with-tcl= and/or --with-swig= 24with_tcl=/usr/local 25with_swig=/usr/local 26with_linker_cc=no 27for arg in $* 28do 29 case $arg in 30 --help) 31 echo "mapscript tcl configure options:" 32 echo "--with-tcl=dir where to find tcl (lib/tclConfig.sh)" 33 echo "--with-swig=dir where to find swig (include/swig.h)" 34 echo "--with-linker-cc use the compiler as linker front-end \ 35 (see README)" 36 exit 37 ;; 38 --with-tcl=*) 39 save_if=$IFS 40 IFS== 41 set -- $arg 42 with_tcl=$2 43 IFS=$save_ifs 44 ;; 45 --with-swig=*) 46 save_if=$IFS 47 IFS== 48 set -- $arg 49 with_swig=$2 50 IFS=$save_ifs 51 ;; 52 --with-linker-cc) 53 with_linker_cc=yes 54 ;; 55 esac 56done 57 58 59# look for Tcl configs 60 61echo "looking for Tcl in $with_tcl" 62if [ ! -f $with_tcl/lib/tclConfig.sh ] ; then 63 echo "can not find tclConfig.sh in $with_tcl" 64 exit 65fi 66echo " found lib/tclConfig.sh in $with_tcl" 67 68# look for swig 69 70echo "looking for Swig in $with_swig" 71if [ ! -f $with_swig/include/swig.h ] ; then 72 echo "can not find swig.h in $with_swig/include" 73 echo "using pre-built swig tcl interface" 74 # mapscript_wrap.c included in package 75else 76 echo " found include/swig.h in $with_swig" 77fi 78SWIGDIR=$with_swig 79 80 81# source the tcl Configs 82 83. $with_tcl/lib/tclConfig.sh 84echo "tcl version = $TCL_VERSION" 85 86 87# if --with-linker-cc option set, then change ld command to use TCL_CC 88 89if test "$with_linker_cc" = "yes" ; then 90 # get cc command, without any options that may be present 91 eval set -- $TCL_CC 92 cc="$1" 93 # get any linker command options 94 eval set -- $TCL_SHLIB_LD 95 shift 96 # build the new command using cc and linker options 97 TCL_SHLIB_LD="$cc $*" 98fi 99 100 101# ugh. Tcl's tclConfig.sh only provides TCL_LD_SEARCH_FLAGS appropriate for 102# use with 'cc'. if 'ld' is the shared library loader, the flags 103# might be wrong, try to fix. this problem is often found on 104# Solaris, HP-UX, IRIX, {Free,Open,Net}BSD, OSF, Dec/Compaq Unix 105 106# first, get the shared lib loader command, should be ld or *cc 107 108eval set -- $TCL_SHLIB_LD 109ldcmd=`basename $1` 110if test "$ldcmd" = "ld" ; then 111 112 # this machine uses ld, now see if a flag begins with -Wl 113 114 newarg="" 115 eval set -- $TCL_LD_SEARCH_FLAGS 116 space="" 117 for arg in $* 118 do 119 case $TCL_LD_SEARCH_FLAGS in 120 -Wl*) 121 # yep, here's our problem child 122 # strip off first arg, change "," to " " via sh set hack 123 IFSsave="$IFS" 124 IFS="," 125 eval set -- $arg 126 IFS="$IFSsave" 127 shift 128 arg="$*" 129 ;; 130 *) 131 newarg="$newarg$space$arg" 132 ;; 133 esac 134 space=" " 135 done 136 TCL_LD_SEARCH_FLAGS="$newarg" 137fi 138 139# also check for Solaris loader flags '-z text', which causes unresolved 140# link errors, because we're mixing -fPIC code (mapscript_wrap.o) with 141# non -fPIC code (libmap.a, etc.) the resulting libMapscript.so will be 142# mixed, so don't cause the link to fail. 143 144TCL_SHLIB_LD=`echo $TCL_SHLIB_LD | sed -e 's/-z text//'` 145 146 147# fix up LIB_RUNTIME_DIR for those systems that leave it out 148 149if test -z "$LIB_RUNTIME_DIR" ; then 150 LIB_RUNTIME_DIR=$with_tcl/lib 151fi 152 153 154# create our Makefile 155 156echo "creating Makefile" 157 158sed -e "s%@MAPSERVERHOME@%$MAPSERVERHOME%g" \ 159 -e "s%@MAPSERVERDEFS@%$MAPSERVERDEFS%g" \ 160 -e "s%@MAPSERVERINCS@%$MAPSERVERINCS%g" \ 161 -e "s%@MAPSERVERLIBS@%$MAPSERVERLIBS%g" \ 162 -e "s%@TCL_PREFIX@%$TCL_PREFIX%g" \ 163 -e "s%@TCL_EXEC_PREFIX@%$TCL_EXEC_PREFIX%g" \ 164 -e "s%@TCL_CC@%$TCL_CC%g" \ 165 -e "s%@TCL_DEFS@%$TCL_DEFS%g" \ 166 -e "s%@TCL_SHLIB_SUFFIX@%$TCL_SHLIB_SUFFIX%g" \ 167 -e "s%@TCL_SHLIB_CFLAGS@%$TCL_SHLIB_CFLAGS%g" \ 168 -e "s%@TCL_LD_SEARCH_FLAGS@%$TCL_LD_SEARCH_FLAGS%g" \ 169 -e "s%@TCL_SHLIB_LD@%$TCL_SHLIB_LD%g" \ 170 -e "s%@TCL_LIB_SPEC@%$TCL_LIB_SPEC%g" \ 171 -e "s%@TCL_STUB_LIB_SPEC@%$TCL_STUB_LIB_SPEC%g" \ 172 -e "s%@TCL_LIBS@%$TCL_LIBS%g" \ 173 -e "s%@LIB_RUNTIME_DIR@%$LIB_RUNTIME_DIR%g" \ 174 -e "s%@TCL_DBGX@%$TCL_DBGX%g" \ 175 -e "s%@SWIGDIR@%$SWIGDIR%g" \ 176 <Makefile.in >Makefile 177 178 179