Code

Initial revision
[rrdtool-all.git] / contrib / php4 / acinclude.m4
1 dnl $Id$
2 dnl
3 dnl This file contains local autoconf functions.
5 sinclude(dynlib.m4)
7 dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD)
8 dnl
9 dnl Use this macro, if you need to add libraries and or library search
10 dnl paths to the PHP build system which are only given in compiler
11 dnl notation.
12 dnl
13 AC_DEFUN(PHP_EVAL_LIBLINE,[
14   for ac_i in $1; do
15     case "$ac_i" in
16     -l*)
17       ac_ii=`echo $ac_i|cut -c 3-`
18       AC_ADD_LIBRARY($ac_ii,,$2)
19     ;;
20     -L*)
21       ac_ii=`echo $ac_i|cut -c 3-`
22       AC_ADD_LIBPATH($ac_ii,$2)
23     ;;
24     esac
25   done
26 ])
28 dnl PHP_EVAL_INCLINE(LINE)
29 dnl
30 dnl Use this macro, if you need to add header search paths to the PHP
31 dnl build system which are only given in compiler notation.
32 dnl
33 AC_DEFUN(PHP_EVAL_INCLINE,[
34   for ac_i in $1; do
35     case "$ac_i" in
36     -I*)
37       ac_ii=`echo $ac_i|cut -c 3-`
38       AC_ADD_INCLUDE($ac_ii)
39     ;;
40     esac
41   done
42 ])
43         
44 AC_DEFUN(PHP_READDIR_R_TYPE,[
45   dnl HAVE_READDIR_R is also defined by libmysql
46   AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
47   if test "$ac_cv_func_readdir_r" = "yes"; then
48   AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
49     AC_TRY_RUN([
50 #define _REENTRANT
51 #include <sys/types.h>
52 #include <dirent.h>
54 main() {
55         DIR *dir;
56         struct dirent entry, *pentry;
58         dir = opendir("/");
59         if (!dir) 
60                 exit(1);
61         if (readdir_r(dir, &entry, &pentry) == 0)
62                 exit(0);
63         exit(1);
64 }
65     ],[
66       ac_cv_what_readdir_r=POSIX
67     ],[
68       AC_TRY_CPP([
69 #define _REENTRANT
70 #include <sys/types.h>
71 #include <dirent.h>
72 int readdir_r(DIR *, struct dirent *);
73         ],[
74           ac_cv_what_readdir_r=old-style
75         ],[
76           ac_cv_what_readdir_r=none
77       ])
78     ],[
79       ac_cv_what_readdir_r=none
80    ])
81   ])
82     case "$ac_cv_what_readdir_r" in
83     POSIX)
84       AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
85     old-style)
86       AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
87     esac
88   fi
89 ])
91 AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[
92   PHP_SUBST(SHLIB_SUFFIX_NAME)
93   SHLIB_SUFFIX_NAME=so
94   case "$host_alias" in
95   *hpux*)
96         SHLIB_SUFFIX_NAME=sl
97         ;;
98   esac
99 ])
101 AC_DEFUN(PHP_DEBUG_MACRO,[
102   DEBUG_LOG="$1"
103   cat >$1 <<X
104 CONFIGURE:  $CONFIGURE_COMMAND
105 CC:         $CC
106 CFLAGS:     $CFLAGS
107 CPPFLAGS:   $CPPFLAGS
108 CXX:        $CXX
109 CXXFLAGS:   $CXXFLAGS
110 INCLUDES:   $INCLUDES
111 LDFLAGS:    $LDFLAGS
112 LIBS:       $LIBS
113 DLIBS:      $DLIBS
114 SAPI:       $PHP_SAPI
115 PHP_RPATHS: $PHP_RPATHS
116 uname -a:   `uname -a`
119     cat >conftest.$ac_ext <<X
120 main()
122   exit(0);
125     (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
126     rm -fr conftest*
127 ])
128         
129 AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
130   AC_MSG_CHECKING(for missing declarations of reentrant functions)
131   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
132     :
133   ],[
134     AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
135   ])
136   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
137     :
138   ],[
139     AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
140   ])
141   AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
142     :
143   ],[
144     AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
145   ])
146   AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
147     :
148   ],[
149     AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
150   ])
151   AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
152     :
153   ],[
154     AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
155   ])
156   AC_MSG_RESULT(done)
157 ])
159 dnl
160 dnl PHP_LIBGCC_LIBPATH(gcc)
161 dnl Stores the location of libgcc in libgcc_libpath
162 dnl
163 AC_DEFUN(PHP_LIBGCC_LIBPATH,[
164   changequote({,})
165   libgcc_libpath="`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'`"
166   changequote([,])
167 ])
169 AC_DEFUN(PHP_ARG_ANALYZE,[
170 case "[$]$1" in
171 shared,*)
172   ext_output="yes, shared"
173   ext_shared=yes
174   $1=`echo $ac_n "[$]$1$ac_c"|sed s/^shared,//`
175   ;;
176 shared)
177   ext_output="yes, shared"
178   ext_shared=yes
179   $1=yes
180   ;;
181 no)
182   ext_output="no"
183   ext_shared=no
184   ;;
185 *)
186   ext_output="yes"
187   ext_shared=no
188   ;;
189 esac
191 if test "$php_always_shared" = "yes"; then
192   ext_output="yes, shared"
193   ext_shared=yes
194   test "[$]$1" = "no" && $1=yes
195 fi
197 AC_MSG_RESULT($ext_output)
198 ])
200 dnl
201 dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val])
202 dnl Sets PHP_ARG_NAME either to the user value or to the default value.
203 dnl default-val defaults to no. 
204 dnl
205 AC_DEFUN(PHP_ARG_WITH,[
206 PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
207 ])
209 AC_DEFUN(PHP_REAL_ARG_WITH,[
210 AC_MSG_CHECKING($2)
211 AC_ARG_WITH($1,[$3],$5=[$]withval,$5=ifelse($4,,no,$4))
212 PHP_ARG_ANALYZE($5)
213 ])
215 dnl
216 dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val])
217 dnl Sets PHP_ARG_NAME either to the user value or to the default value.
218 dnl default-val defaults to no. 
219 dnl
220 AC_DEFUN(PHP_ARG_ENABLE,[
221 PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
222 ])
224 AC_DEFUN(PHP_REAL_ARG_ENABLE,[
225 AC_MSG_CHECKING($2)
226 AC_ARG_ENABLE($1,[$3],$5=[$]enableval,$5=ifelse($4,,no,$4))
227 PHP_ARG_ANALYZE($5)
228 ])
230 AC_DEFUN(PHP_MODULE_PTR,[
231   EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1,"
232 ])
233  
234 AC_DEFUN(PHP_CONFIG_NICE,[
235   rm -f $1
236   cat >$1<<EOF
237 #! /bin/sh
239 # Created by configure
241 EOF
243   for arg in [$]0 "[$]@"; do
244     echo "\"[$]arg\" \\" >> $1
245   done
246   echo '"[$]@"' >> $1
247   chmod +x $1
248 ])
250 AC_DEFUN(PHP_TIME_R_TYPE,[
251 AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
252 AC_TRY_RUN([
253 #include <time.h>
254 #include <stdlib.h>
256 main() {
257 char buf[27];
258 struct tm t;
259 time_t old = 0;
260 int r, s;
262 s = gmtime_r(&old, &t);
263 r = (int) asctime_r(&t, buf, 26);
264 if (r == s && s == 0) exit(0);
265 exit(1);
267 ],[
268   ac_cv_time_r_type=hpux
269 ],[
270   ac_cv_time_r_type=POSIX
271 ],[
272   ac_cv_time_r_type=POSIX
273 ])
274 ])
275 if test "$ac_cv_time_r_type" = "hpux"; then
276   AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x])
277 fi
278 ])
280 AC_DEFUN(PHP_SUBST,[
281   PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
282   AC_SUBST($1)
283 ])
285 AC_DEFUN(PHP_FAST_OUTPUT,[
286   PHP_FAST_OUTPUT_FILES="$PHP_FAST_OUTPUT_FILES $1"
287 ])
289 AC_DEFUN(PHP_MKDIR_P_CHECK,[
290   AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
291     test -d conftestdir && rm -rf conftestdir
292     mkdir -p conftestdir/somedir >/dev/null 2>&1
293     if test -d conftestdir/somedir; then
294       ac_cv_mkdir_p=yes
295     else
296       ac_cv_mkdir_p=no
297     fi
298     rm -rf conftestdir
299   ])
300 ])
302 AC_DEFUN(PHP_GEN_CONFIG_VARS,[
303   PHP_MKDIR_P_CHECK
304   echo creating config_vars.mk
305   > config_vars.mk
306   for i in $PHP_VAR_SUBST; do
307     eval echo "$i = \$$i" >> config_vars.mk
308   done
309 ])
311 AC_DEFUN(PHP_GEN_MAKEFILES,[
312   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $PHP_FAST_OUTPUT_FILES
313 ])
315 AC_DEFUN(PHP_TM_GMTOFF,[
316 AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
317 [AC_TRY_COMPILE([#include <sys/types.h>
318 #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
319   ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
321 if test "$ac_cv_struct_tm_gmtoff" = yes; then
322   AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
323 fi
324 ])
326 dnl PHP_CONFIGURE_PART(MESSAGE)
327 dnl Idea borrowed from mm
328 AC_DEFUN(PHP_CONFIGURE_PART,[
329   AC_MSG_RESULT()
330   AC_MSG_RESULT(${T_MD}$1${T_ME})
331 ])
333 AC_DEFUN(PHP_PROG_SENDMAIL,[
334 AC_PATH_PROG(PROG_SENDMAIL, sendmail, /usr/lib/sendmail, $PATH:/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib)
335 if test -n "$PROG_SENDMAIL"; then
336   AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail])
337 fi
338 ])
340 AC_DEFUN(PHP_RUNPATH_SWITCH,[
341 dnl check for -R, etc. switch
342 AC_MSG_CHECKING(if compiler supports -R)
343 AC_CACHE_VAL(php_cv_cc_dashr,[
344         SAVE_LIBS="${LIBS}"
345         LIBS="-R /usr/lib ${LIBS}"
346         AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
347         LIBS="${SAVE_LIBS}"])
348 AC_MSG_RESULT($php_cv_cc_dashr)
349 if test $php_cv_cc_dashr = "yes"; then
350         ld_runpath_switch="-R"
351 else
352         AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
353         AC_CACHE_VAL(php_cv_cc_rpath,[
354                 SAVE_LIBS="${LIBS}"
355                 LIBS="-Wl,-rpath,/usr/lib ${LIBS}"
356                 AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
357                 LIBS="${SAVE_LIBS}"])
358         AC_MSG_RESULT($php_cv_cc_rpath)
359         if test $php_cv_cc_rpath = "yes"; then
360                 ld_runpath_switch="-Wl,-rpath,"
361         else
362                 dnl something innocuous
363                 ld_runpath_switch="-L"
364         fi
365 fi
366 ])
368 AC_DEFUN(PHP_STRUCT_FLOCK,[
369 AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
370     AC_TRY_COMPILE([
371 #include <unistd.h>
372 #include <fcntl.h>
373         ],
374         [struct flock x;],
375         [
376           ac_cv_struct_flock=yes
377         ],[
378           ac_cv_struct_flock=no
379         ])
381 if test "$ac_cv_struct_flock" = "yes" ; then
382     AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
383 fi
384 ])
386 AC_DEFUN(PHP_SOCKLEN_T,[
387 AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
388   AC_TRY_COMPILE([
389 #include <sys/types.h>
390 #include <sys/socket.h>
391 ],[
392 socklen_t x;
393 ],[
394   ac_cv_socklen_t=yes
395 ],[
396   ac_cv_socklen_t=no
397 ]))
398 if test "$ac_cv_socklen_t" = "yes"; then
399   AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
400 fi
401 ])
403 dnl
404 dnl PHP_SET_SYM_FILE(path)
405 dnl
406 dnl set the path of the file which contains the symbol export list
407 dnl
408 AC_DEFUN(PHP_SET_SYM_FILE,
410   PHP_SYM_FILE="$1"
411 ])
413 dnl
414 dnl PHP_BUILD_THREAD_SAFE
415 dnl
416 AC_DEFUN(PHP_BUILD_THREAD_SAFE,[
417   enable_experimental_zts=yes
418   if test "$pthreads_working" != "yes"; then
419     AC_MSG_ERROR(ZTS currently requires working POSIX threads. Your system does not support this.)
420   fi
421 ])
423 dnl
424 dnl PHP_BUILD_SHARED
425 dnl
426 AC_DEFUN(PHP_BUILD_SHARED,[
427   php_build_target=shared
428 ])
430 dnl
431 dnl PHP_BUILD_STATIC
432 dnl
433 AC_DEFUN(PHP_BUILD_STATIC,[
434   php_build_target=static
435 ])
437 dnl
438 dnl PHP_BUILD_PROGRAM
439 dnl
440 AC_DEFUN(PHP_BUILD_PROGRAM,[
441   php_build_target=program
442 ])
444 dnl
445 dnl AC_PHP_ONCE(namespace, variable, code)
446 dnl
447 dnl execute code, if variable is not set in namespace
448 dnl
449 AC_DEFUN(AC_PHP_ONCE,[
450   changequote({,})
451   unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'`
452   changequote([,])
453   cmd="echo $ac_n \"\$$1$unique$ac_c\""
454   if test -n "$unique" && test "`eval $cmd`" = "" ; then
455     eval "$1$unique=set"
456     $3
457   fi
458 ])
460 dnl
461 dnl AC_EXPAND_PATH(path, variable)
462 dnl
463 dnl expands path to an absolute path and assigns it to variable
464 dnl
465 AC_DEFUN(AC_EXPAND_PATH,[
466   if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
467     $2="$1"
468   else
469     changequote({,})
470     ep_dir="`echo $1|sed 's%/*[^/][^/]*$%%'`"
471     changequote([,])
472     ep_realdir="`(cd \"$ep_dir\" && pwd)`"
473     $2="$ep_realdir/`basename \"$1\"`"
474   fi
475 ])
477 dnl
478 dnl AC_ADD_LIBPATH(path[, shared-libadd])
479 dnl
480 dnl add a library to linkpath/runpath
481 dnl
482 AC_DEFUN(AC_ADD_LIBPATH,[
483   if test "$1" != "/usr/lib"; then
484     AC_EXPAND_PATH($1, ai_p)
485     if test "$ext_shared" = "yes" && test -n "$2"; then
486       $2="-R$1 -L$1 [$]$2"
487     else
488       AC_PHP_ONCE(LIBPATH, $ai_p, [
489         test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$ai_p"
490         LDFLAGS="$LDFLAGS -L$ai_p"
491         PHP_RPATHS="$PHP_RPATHS $ai_p"
492       ])
493     fi
494   fi
495 ])
497 dnl
498 dnl AC_BUILD_RPATH()
499 dnl
500 dnl builds RPATH from PHP_RPATHS
501 dnl
502 AC_DEFUN(AC_BUILD_RPATH,[
503   if test "$PHP_RPATH" = "yes" && test -n "$PHP_RPATHS"; then
504     OLD_RPATHS="$PHP_RPATHS"
505     PHP_RPATHS=""
506     for i in $OLD_RPATHS; do
507       PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
508       PHP_RPATHS="$PHP_RPATHS -R $i"
509       NATIVE_RPATHS="$NATIVE_RPATHS ${ld_runpath_switch}$i"
510     done
511   fi
512 ])
514 dnl
515 dnl AC_ADD_INCLUDE(path)
516 dnl
517 dnl add a include path
518 dnl
519 AC_DEFUN(AC_ADD_INCLUDE,[
520   if test "$1" != "/usr/include"; then
521     AC_EXPAND_PATH($1, ai_p)
522     AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
523       INCLUDES="$INCLUDES -I$ai_p"
524     ])
525   fi
526 ])
528 AC_DEFUN(PHP_X_ADD_LIBRARY,[
529   ifelse($2,,$3="-l$1 [$]$3", $3="[$]$3 -l$1")
530 ])
532 dnl
533 dnl AC_ADD_LIBRARY(library[, append[, shared-libadd]])
534 dnl
535 dnl add a library to the link line
536 dnl
537 AC_DEFUN(AC_ADD_LIBRARY,[
538  case "$1" in
539  c|c_r|pthread*) ;;
540  *)
541 ifelse($3,,[
542    AC_PHP_ONCE(LIBRARY, $1, [
543      PHP_X_ADD_LIBRARY($1,$2,LIBS)
544    ])
545 ],[
546    if test "$ext_shared" = "yes"; then
547      PHP_X_ADD_LIBRARY($1,$2,$3)
548    else
549      AC_ADD_LIBRARY($1,$2)
550    fi
551 ])
552   ;;
553   esac
554 ])
556 dnl
557 dnl AC_ADD_LIBRARY_DEFER(library[, append])
558 dnl
559 dnl add a library to the link line (deferred)
560 AC_DEFUN(AC_ADD_LIBRARY_DEFER,[
561   AC_PHP_ONCE(LIBRARY, $1, [
562     ifelse($#, 1, DLIBS="-l$1 $DLIBS", DLIBS="$DLIBS -l$1")
563   ])
564 ])
566 dnl
567 dnl AC_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
568 dnl
569 dnl add a library to the link line and path to linkpath/runpath.
570 dnl if shared-libadd is not empty and $ext_shared is yes,
571 dnl shared-libadd will be assigned the library information
572 dnl
573 AC_DEFUN(AC_ADD_LIBRARY_WITH_PATH,[
574 ifelse($3,,[
575   if test -n "$2"; then
576     AC_ADD_LIBPATH($2)
577   fi
578   AC_ADD_LIBRARY($1)
579 ],[
580   if test "$ext_shared" = "yes"; then
581     $3="-l$1 [$]$3"
582     if test -n "$2"; then
583       AC_ADD_LIBPATH($2,$3)
584     fi
585   else
586     AC_ADD_LIBRARY_WITH_PATH($1,$2)
587   fi
588 ])
589 ])
591 dnl
592 dnl AC_ADD_LIBRARY_DEFER_WITH_PATH(library, path)
593 dnl
594 dnl add a library to the link line (deferred)
595 dnl and path to linkpath/runpath (not deferred)
596 dnl
597 AC_DEFUN(AC_ADD_LIBRARY_DEFER_WITH_PATH,[
598   AC_ADD_LIBPATH($2)
599   AC_ADD_LIBRARY_DEFER($1)
600 ])
602 AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[
603   LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
604 ])
606 dnl
607 dnl Check for cc option
608 dnl
609 AC_DEFUN(AC_CHECK_CC_OPTION,[
610   echo "main(){return 0;}" > conftest.$ac_ext
611   opt="$1"
612   changequote({,})
613   var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'`
614   changequote([,])
615   AC_MSG_CHECKING([if compiler supports -$1 really])
616   ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
617   if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
618     eval php_cc_$var=no
619         AC_MSG_RESULT(no)
620   else
621     if eval ./conftest 2>/dev/null ; then
622       eval php_cc_$var=yes
623           AC_MSG_RESULT(yes)
624     else
625       eval php_cc_$var=no
626           AC_MSG_RESULT(no)
627     fi
628   fi
629 ])
631 AC_DEFUN(PHP_REGEX,[
633 if test "$REGEX_TYPE" = "php"; then
634   REGEX_LIB=regex/libregex.la
635   REGEX_DIR=regex
636   AC_DEFINE(HSREGEX,1,[ ])
637   AC_DEFINE(REGEX,1,[ ])
638   PHP_FAST_OUTPUT(regex/Makefile)
639 elif test "$REGEX_TYPE" = "system"; then
640   AC_DEFINE(REGEX,0,[ ])
641 fi
643 AC_MSG_CHECKING(which regex library to use)
644 AC_MSG_RESULT($REGEX_TYPE)
646 PHP_SUBST(REGEX_DIR)
647 PHP_SUBST(REGEX_LIB)
648 PHP_SUBST(HSREGEX)
649 ])
651 dnl
652 dnl See if we have broken header files like SunOS has.
653 dnl
654 AC_DEFUN(AC_MISSING_FCLOSE_DECL,[
655   AC_MSG_CHECKING([for fclose declaration])
656   AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
657     AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
658     AC_MSG_RESULT(ok)
659   ],[
660     AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
661     AC_MSG_RESULT(missing)
662   ])
663 ])
665 dnl
666 dnl Check for broken sprintf()
667 dnl
668 AC_DEFUN(AC_BROKEN_SPRINTF,[
669   AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
670     AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
671       ac_cv_broken_sprintf=no
672     ],[
673       ac_cv_broken_sprintf=yes
674     ],[
675       ac_cv_broken_sprintf=no
676     ])
677   ])
678   if test "$ac_cv_broken_sprintf" = "yes"; then
679     AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [ ])
680   else
681     AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [ ])
682   fi
683 ])
685 dnl
686 dnl PHP_EXTENSION(extname [, shared])
687 dnl
688 dnl Includes an extension in the build.
689 dnl
690 dnl "extname" is the name of the ext/ subdir where the extension resides
691 dnl "shared" can be set to "shared" or "yes" to build the extension as
692 dnl a dynamically loadable library.
693 dnl
694 AC_DEFUN(PHP_EXTENSION,[
695   EXT_SUBDIRS="$EXT_SUBDIRS $1"
696   
697   if test -d "$abs_srcdir/ext/$1"; then
698 dnl ---------------------------------------------- Internal Module
699     ext_builddir="ext/$1"
700     ext_srcdir="$abs_srcdir/ext/$1"
701   else
702 dnl ---------------------------------------------- External Module
703     ext_builddir="."
704     ext_srcdir="$abs_srcdir"
705   fi
707   if test "$2" != "shared" && test "$2" != "yes"; then
708 dnl ---------------------------------------------- Static module
709     LIB_BUILD($ext_builddir)
710     EXT_LTLIBS="$EXT_LTLIBS $ext_builddir/lib$1.la"
711     EXT_STATIC="$EXT_STATIC $1"
712   else 
713 dnl ---------------------------------------------- Shared module
714     LIB_BUILD($ext_builddir,yes)
715     AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z-,A-Z_), 1, Whether to build $1 as dynamic module)
716   fi
718   PHP_FAST_OUTPUT($ext_builddir/Makefile)
719 ])
721 PHP_SUBST(EXT_SUBDIRS)
722 PHP_SUBST(EXT_STATIC)
723 PHP_SUBST(EXT_SHARED)
724 PHP_SUBST(EXT_LIBS)
725 PHP_SUBST(EXT_LTLIBS)
727 dnl
728 dnl Solaris requires main code to be position independent in order
729 dnl to let shared objects find symbols.  Weird.  Ugly.
730 dnl
731 dnl Must be run after all --with-NN options that let the user
732 dnl choose dynamic extensions, and after the gcc test.
733 dnl
734 AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
735   AC_MSG_CHECKING(whether -fPIC is required)
736   if test "$EXT_SHARED" != ""; then
737     os=`uname -sr 2>/dev/null`
738     case "$os" in
739         "SunOS 5.6"|"SunOS 5.7")
740           case "$CC" in
741             gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
742             *) CFLAGS="$CFLAGS -fpic";;
743           esac
744           AC_MSG_RESULT(yes);;
745         *)
746           AC_MSG_RESULT(no);;
747     esac
748   else
749     AC_MSG_RESULT(no)
750   fi
751 ])
753 dnl
754 dnl Checks whether $withval is "shared" or starts with "shared,XXX"
755 dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
756 dnl from $withval.
757 dnl
758 AC_DEFUN(PHP_WITH_SHARED,[
759     case $withval in
760         shared)
761             shared=yes
762             withval=yes
763             ;;
764         shared,*)
765             shared=yes
766             withval=`echo $withval | sed -e 's/^shared,//'`      
767             ;;
768         *)
769             shared=no
770             ;;
771     esac
772     if test -n "$php_always_shared"; then
773                 shared=yes
774         fi
775 ])
777 dnl The problem is that the default compilation flags in Solaris 2.6 won't
778 dnl let programs access large files;  you need to tell the compiler that
779 dnl you actually want your programs to work on large files.  For more
780 dnl details about this brain damage please see:
781 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
783 dnl Written by Paul Eggert <eggert@twinsun.com>.
785 AC_DEFUN(AC_SYS_LFS,
786 [dnl
787   # If available, prefer support for large files unless the user specified
788   # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
789   AC_MSG_CHECKING(whether large file support needs explicit enabling)
790   ac_getconfs=''
791   ac_result=yes
792   ac_set=''
793   ac_shellvars='CPPFLAGS LDFLAGS LIBS'
794   for ac_shellvar in $ac_shellvars; do
795     case $ac_shellvar in
796       CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
797       *) ac_lfsvar=LFS_$ac_shellvar ;;
798     esac
799     eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
800     (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
801     ac_getconf=`getconf $ac_lfsvar`
802     ac_getconfs=$ac_getconfs$ac_getconf
803     eval ac_test_$ac_shellvar=\$ac_getconf
804   done
805   case "$ac_result$ac_getconfs" in
806     yes) ac_result=no ;;
807   esac
808   case "$ac_result$ac_set" in
809     yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
810   esac
811   AC_MSG_RESULT($ac_result)
812   case $ac_result in
813     yes)
814       for ac_shellvar in $ac_shellvars; do
815         eval $ac_shellvar=\$ac_test_$ac_shellvar
816       done ;;
817   esac
818 ])
820 AC_DEFUN(AC_SOCKADDR_SA_LEN,[
821   AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
822     AC_TRY_COMPILE([#include <sys/types.h>
823 #include <sys/socket.h>],
824     [struct sockaddr s; s.sa_len;],
825     [ac_cv_sockaddr_sa_len=yes
826      AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])],
827     [ac_cv_sockaddr_sa_len=no])
828   ])
829 ])
832 dnl ## PHP_AC_OUTPUT(file)
833 dnl ## adds "file" to the list of files generated by AC_OUTPUT
834 dnl ## This macro can be used several times.
835 AC_DEFUN(PHP_OUTPUT,[
836   PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
837 ])
839 AC_DEFUN(PHP_DECLARED_TIMEZONE,[
840   AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
841     AC_TRY_COMPILE([
842 #include <sys/types.h>
843 #include <time.h>
844 #ifdef HAVE_SYS_TIME_H
845 #include <sys/time.h>
846 #endif
847 ],[
848     time_t foo = (time_t) timezone;
849 ],[
850   ac_cv_declared_timezone=yes
851 ],[
852   ac_cv_declared_timezone=no
853 ])])
854   if test "$ac_cv_declared_timezone" = "yes"; then
855     AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
856   fi
857 ])
859 AC_DEFUN(PHP_EBCDIC,[
860   AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
861   AC_TRY_RUN( [
862 int main(void) { 
863   return (unsigned char)'A' != (unsigned char)0xC1; 
864
865 ],[
866   ac_cv_ebcdic="yes"
867 ],[
868   ac_cv_ebcdic="no"
869 ],[
870   ac_cv_ebcdic="no"
871 ])])
872   if test "$ac_cv_ebcdic" = "yes"; then
873     AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
874   fi
875 ])