1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
|
dnl
dnl AC_EXPAND_PATH(path, variable)
dnl
dnl expands path to an absolute path and assigns it to variable
dnl
AC_DEFUN(AC_EXPAND_PATH,[
if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
$2="$1"
else
$2="`pwd`/$1"
fi
])
dnl
dnl AC_PARSE_WITH_LIB_STATIC(with_param, out_libpath, out_isstatic)
dnl
dnl parse a --with-lib=[static,]/path/to/lib string, and set out_libpath
dnl with the library path, and out_isstatic=yes if "static," was there.
dnl
AC_DEFUN(AC_PARSE_WITH_LIB_STATIC,[
if echo "$1" | grep '^static,' >/dev/null ; then
$2=`echo "$1" | sed "s/^static,//"`
$3=yes
else
$2=$1
$3=no
fi
])
AC_DEFUN(AC_COMPILER_PIC,
[
echo 'void f(){}' > conftest.c
if test -z "`${CC} -fPIC -c conftest.c 2>&1`"; then
C_PIC=-fPIC
else
C_PIC=
fi
rm -f conftest*
AC_SUBST(C_PIC,$C_PIC)
])
dnl
dnl check for -R, etc. switch
dnl
dnl This was borrowed and adapted from the PHP configure.in script
dnl
AC_DEFUN(AC_RUNPATH_SWITCH,
[
AC_MSG_CHECKING(if compiler supports -R)
AC_CACHE_VAL(php_cv_cc_dashr,[
SAVE_LIBS="${LIBS}"
LIBS="-R /usr/lib ${LIBS}"
AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
LIBS="${SAVE_LIBS}"])
AC_MSG_RESULT($php_cv_cc_dashr)
if test $php_cv_cc_dashr = "yes"; then
ld_runpath_switch="-R"
apxs_runpath_switch="-Wl,-R'"
fi
if test -z "$ld_runpath_switch" ; then
AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
AC_CACHE_VAL(php_cv_cc_rpath,[
SAVE_LIBS="${LIBS}"
LIBS="-Wl,-rpath,/usr/lib ${LIBS}"
AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
LIBS="${SAVE_LIBS}"])
AC_MSG_RESULT($php_cv_cc_rpath)
if test $php_cv_cc_rpath = "yes"; then
ld_runpath_switch="-Wl,-rpath,"
apxs_runpath_switch="-Wl,'-rpath "
fi
fi
if test -z "$ld_runpath_switch" ; then
AC_MSG_CHECKING([if compiler supports -Wl,-R])
AC_CACHE_VAL(php_cv_cc_dashwlr,[
SAVE_LIBS="${LIBS}"
LIBS="-Wl,-R/usr/lib ${LIBS}"
AC_TRY_LINK([], [], php_cv_cc_dashwlr=yes, php_cv_cc_dashwlr=no)
LIBS="${SAVE_LIBS}"])
AC_MSG_RESULT($php_cv_cc_dashwlr)
if test $php_cv_cc_rpath = "yes"; then
ld_runpath_switch="-Wl,-R"
apxs_runpath_switch="-Wl,-R'"
fi
fi
if test -z "$ld_runpath_switch" ; then
dnl something innocuous
ld_runpath_switch="-L"
apxs_runpath_switch="-L'"
fi
])
dnl
dnl AC_PHP_ONCE(namespace, variable, code)
dnl
dnl execute code, if variable is not set in namespace
dnl
AC_DEFUN(AC_PHP_ONCE,[
unique=`echo $ac_n "$2$ac_c" | tr -c -d a-zA-Z0-9`
cmd="echo $ac_n \"\$$1$unique$ac_c\""
if test -n "$unique" && test "`eval $cmd`" = "" ; then
eval "$1$unique=set"
$3
fi
])
dnl
dnl AC_ADD_RUNPATH(path)
dnl
dnl add a library to linkpath/runpath stored in RPATH
dnl works together with AC_RUNPATH_SWITCH()
dnl
AC_DEFUN(AC_ADD_RUNPATH,[
if test "$1" != "/usr/lib"; then
AC_EXPAND_PATH($1, ai_p)
AC_PHP_ONCE(LIBPATH, $ai_p, [
EXTRA_LIBS="$EXTRA_LIBS -L$ai_p"
dnl if test -n "$APXS" ; then
dnl RPATHS="$RPATHS ${apxs_runpath_switch}$ai_p'"
dnl else
RPATHS="$RPATHS ${ld_runpath_switch}$ai_p"
dnl fi
])
fi
])
dnl
dnl Try to find something to link shared libraries with. Use "c++ -shared"
dnl in preference to "ld -shared" because it will link in required c++
dnl run time support for us.
dnl
AC_DEFUN(AC_LD_SHARED,
[
echo 'void g(); int main(){ g(); return 0; }' > conftest1.c
echo '#include <stdio.h>' > conftest2.c
echo 'void g(); void g(){printf("");}' >> conftest2.c
${CC} ${C_PIC} -c conftest2.c
SO_EXT="so"
SO_COMMAND_NAME="-soname"
export SO_EXT
export SO_COMMAND_NAME
LD_SHARED="/bin/true"
if test ! -z "`uname -a | grep IRIX`" ; then
IRIX_ALL=-all
else
IRIX_ALL=
fi
AC_ARG_WITH(ld-shared,[ --without-ld-shared Disable shared library support],,)
if test "$with_ld_shared" != "" ; then
if test "$with_ld_shared" = "no" ; then
echo "user disabled shared library support."
else
echo "using user supplied .so link command ... $with_ld_shared"
fi
LD_SHARED="$with_ld_shared"
fi
dnl Check For Cygwin case. Actually verify that the produced DLL works.
if test ! -z "`uname -a | grep CYGWIN`" \
-a "$LD_SHARED" = "/bin/true" ; then
if test -z "`gcc -shared conftest2.o -o libconftest.dll`" ; then
if test -z "`${CC} conftest1.c -L./ -lconftest -o conftest1 2>&1`"; then
LD_LIBRARY_PATH_OLD="$LD_LIBRARY_PATH"
if test -z "$LD_LIBRARY_PATH" ; then
LD_LIBRARY_PATH="`pwd`"
else
LD_LIBRARY_PATH="`pwd`:$LD_LIBRARY_PATH"
fi
export LD_LIBRARY_PATH
if test -z "`./conftest1 2>&1`" ; then
echo "checking for Cygwin gcc -shared ... yes"
LD_SHARED="c++ -shared"
SO_EXT="dll"
fi
LD_LIBRARY_PATH="$LD_LIBRARY_PATH_OLD"
fi
fi
fi
dnl Test special MacOS (Darwin) case.
if test ! -z "`uname | grep Darwin`" \
-a "$LD_SHARED" = "/bin/true" ; then
if test -z "`${CXX} -dynamiclib conftest2.o -o libconftest.so 2>&1`" ; then
${CC} -c conftest1.c
if test -z "`${CXX} conftest1.o libconftest.so -o conftest1 2>&1`"; then
DYLD_LIBRARY_PATH_OLD="$DYLD_LIBRARY_PATH"
if test -z "$DYLD_LIBRARY_PATH" ; then
DYLD_LIBRARY_PATH="`pwd`"
else
DYLD_LIBRARY_PATH="`pwd`:$DYLD_LIBRARY_PATH"
fi
export DYLD_LIBRARY_PATH
if test -z "`./conftest1 2>&1`" ; then
echo "checking for ${CXX} -dynamiclib ... yes"
LD_SHARED="${CXX} -dynamiclib -single_module -flat_namespace -undefined suppress"
SO_EXT=dylib
SO_COMMAND_NAME='-dylib_install_name'
fi
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH_OLD"
fi
rm -f conftest1.o
fi
fi
if test "$LD_SHARED" = "/bin/true" \
-a -z "`${CXX} -shared $IRIX_ALL conftest2.o -o libconftest.so 2>&1|grep -v WARNING`" ; then
if test -z "`${CC} conftest1.c libconftest.so -o conftest1 2>&1`"; then
LD_LIBRARY_PATH_OLD="$LD_LIBRARY_PATH"
if test -z "$LD_LIBRARY_PATH" ; then
LD_LIBRARY_PATH="`pwd`"
else
LD_LIBRARY_PATH="`pwd`:$LD_LIBRARY_PATH"
fi
export LD_LIBRARY_PATH
if test -z "`./conftest1 2>&1`" ; then
echo "checking for ${CXX} -shared ... yes"
LD_SHARED="${CXX} -shared $IRIX_ALL"
else
echo "checking for ${CXX} -shared ... no(3)"
fi
LD_LIBRARY_PATH="$LD_LIBRARY_PATH_OLD"
else
echo "checking for ${CXX} -shared ... no(2)"
fi
else
if test "$LD_SHARED" = "/bin/true" ; then
echo "checking for ${CXX} -shared ... no(1)"
fi
fi
if test "$LD_SHARED" = "/bin/true" \
-a -z "`ld -shared conftest2.o -o libconftest.so 2>&1`" ; then
if test -z "`${CC} conftest1.c libconftest.so -o conftest1 2>&1`"; then
LD_LIBRARY_PATH_OLD="$LD_LIBRARY_PATH"
if test -z "$LD_LIBRARY_PATH" ; then
LD_LIBRARY_PATH="`pwd`"
else
LD_LIBRARY_PATH="`pwd`:$LD_LIBRARY_PATH"
fi
export LD_LIBRARY_PATH
if test -z "`./conftest1 2>&1`" ; then
echo "checking for ld -shared ... yes"
LD_SHARED="ld -shared"
fi
LD_LIBRARY_PATH="$LD_LIBRARY_PATH_OLD"
fi
fi
if test "$LD_SHARED" = "/bin/true" ; then
echo "checking for ld -shared ... no"
if test ! -x /bin/true ; then
LD_SHARED=/usr/bin/true
fi
fi
if test "$LD_SHARED" = "no" ; then
if test -x /bin/true ; then
LD_SHARED=/bin/true
else
LD_SHARED=/usr/bin/true
fi
fi
rm -f conftest* libconftest*
AC_SUBST(LD_SHARED,$LD_SHARED)
AC_SUBST(SO_EXT,$SO_EXT)
AC_SUBST(SO_COMMAND_NAME,$SO_COMMAND_NAME)
])
dnl
dnl PHP on OSX (and potentially other platforms) does not use the
dnl same options for creating a shared MapScript that Python
dnl and a normal 'make shared' need to use. The only way around
dnl this is to use our normal LD_SHARED stuff for everything
dnl except MacOSX.
dnl
AC_DEFUN(AC_PHP_LD_SHARED,[
AC_LD_SHARED()
dnl Test special MacOS (Darwin) case.
if test ! -z "`uname | grep Darwin`" ;then
PHP_LD_SHARED="${CXX} -bundle -flat_namespace -undefined suppress"
else
PHP_LD_SHARED=$LD_SHARED
fi
export PHP_LD_SHARED
AC_SUBST(PHP_LD_SHARED,$PHP_LD_SHARED)
])
dnl
dnl The following macro is actually based on the "setup" script that
dnl was included in the php-3.0.14 dl directory and will look at the
dnl Perl compile flags to figure the mechanism to build a shared lib
dnl on this system.
dnl This is the preferred macro for the PHP module, but if perl is not
dnl available then we can always fallback on AC_LD_SHARED above.
dnl
AC_DEFUN(AC_LD_SHARED_FROM_PERL,
[
#
# The following is a massive hack. It tries to steal the
# mechanism for build a dynamic library from Perl's -V output
# If this script fails on this machine, try running 'perl -V'
# manually and pick out the setting for:
#
# cc, optimize, ccflags, ld, cccdlflags and lddlflags
#
# Replace the below definitions with the output you see.
#
if test ! -r "perl.out"; then
perl -V > perl.out
fi
# if the greps and cuts don't do the job, set these manually
PERL_CC="`grep ' cc=' perl.out | cut -d, -f1 | cut -d\' -f2 | grep -v undef`"
PERL_OPT="`grep ' optimize=' perl.out | cut -d, -f2 | cut -d\' -f2 | grep -v undef`"
PERL_CCFLAGS="`grep ' ccflags' perl.out | cut -d, -f1 | grep cflags | cut -d\' -f2 | grep -v undef` `grep ' ccflags' perl.out | cut -d, -f2 | grep ccflags | cut -d\' -f2 | grep -v undef`"
PERL_LD="`grep ' ld=' perl.out | cut -d, -f1 | cut -d\' -f2 | grep -v undef`"
PERL_LFLAGS="`grep ' cccdlflags=' perl.out | cut -d, -f1 | cut -d\' -f2 | grep -v undef`"
PERL_CCDLFLAGS="`grep ' ccdlflags=' perl.out | cut -d, -f4 | cut -d\' -f2 | sed 's, ,,' | grep -v undef`"
PERL_LDDLFLAGS=`grep ' lddlflags' perl.out | cut -d, -f2 | cut -d\' -f2 | grep -v undef`
#--------
#if test -n "$PERL_CCDLFLAGS" ; then
# echo "-------------------------"
# echo "----- IMPORTANT !!! -----"
# echo "-------------------------"
# echo "To use PHP extensions on your OS, you will need to recompile "
# echo "PHP. "
# echo "You need to edit the Makefile in the php3 directory and add "
# echo "$PERL_CCDLFLAGS to the start of the LDFLAGS line at the top "
# echo "of the Makefile. Then type: 'make clean; make' "
# echo "You can still go ahead and build the extensions now by typing"
# echo "'make' in this directory. They just won't work correctly "
# echo "until you recompile your PHP. "
# echo "If you are compiling php as a module, you should also add "
# echo "$PERL_CCDLFLAGS to the start of the EXTRA_LDFLAGS in Apache "
# echo "Configuration file. Note that if you are using the APACI "
# echo "build mechanism you should make this change in the "
# echo "Configuration.tmpl file instead. "
# echo "-------------------------"
# echo "-------------------------"
# echo "-------------------------"
#fi
PERL_CC="$PERL_CC $PERL_OPT $PERL_CCFLAGS -I. -I.. $PERL_LFLAGS"
PERL_LD="$PERL_LD $PERL_LDDLFLAGS $PERL_CCDLFLAGS"
rm -f perl.out
])
|