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