php.m4 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750
  1. dnl This file contains local autoconf macros.
  2. dnl ----------------------------------------------------------------------------
  3. dnl Output stylize macros for configure (help/runtime).
  4. dnl ----------------------------------------------------------------------------
  5. dnl
  6. dnl PHP_HELP_SEPARATOR(title)
  7. dnl
  8. dnl Adds separator title into the configure --help display.
  9. dnl
  10. AC_DEFUN([PHP_HELP_SEPARATOR],[
  11. AC_ARG_ENABLE([],[
  12. $1
  13. ],[])
  14. ])
  15. dnl
  16. dnl PHP_CONFIGURE_PART(title)
  17. dnl
  18. dnl Adds separator title configure output (idea borrowed from mm).
  19. dnl
  20. AC_DEFUN([PHP_CONFIGURE_PART],[
  21. AC_MSG_RESULT()
  22. AC_MSG_RESULT([${T_MD}$1${T_ME}])
  23. ])
  24. dnl ----------------------------------------------------------------------------
  25. dnl Build system helper macros.
  26. dnl ----------------------------------------------------------------------------
  27. dnl
  28. dnl PHP_DEF_HAVE(what)
  29. dnl
  30. dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'.
  31. dnl
  32. AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])])
  33. dnl
  34. dnl PHP_RUN_ONCE(namespace, variable, code)
  35. dnl
  36. dnl Execute code, if variable is not set in namespace.
  37. dnl
  38. AC_DEFUN([PHP_RUN_ONCE],[
  39. changequote({,})
  40. unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'`
  41. changequote([,])
  42. cmd="echo $ac_n \"\$$1$unique$ac_c\""
  43. if test -n "$unique" && test "`eval $cmd`" = "" ; then
  44. eval "$1$unique=set"
  45. $3
  46. fi
  47. ])
  48. dnl
  49. dnl PHP_EXPAND_PATH(path, variable)
  50. dnl
  51. dnl Expands path to an absolute path and assigns it to variable.
  52. dnl
  53. AC_DEFUN([PHP_EXPAND_PATH],[
  54. if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  55. $2=$1
  56. else
  57. changequote({,})
  58. ep_dir=`echo $1|$SED 's%/*[^/][^/]*/*$%%'`
  59. changequote([,])
  60. ep_realdir=`(cd "$ep_dir" && pwd)`
  61. $2="$ep_realdir"/`basename "$1"`
  62. fi
  63. ])
  64. dnl
  65. dnl PHP_DEFINE(WHAT [, value[, directory]])
  66. dnl
  67. dnl Creates builddir/include/what.h and in there #define WHAT value.
  68. dnl
  69. AC_DEFUN([PHP_DEFINE],[
  70. [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h]
  71. ])
  72. dnl
  73. dnl PHP_SUBST(varname)
  74. dnl
  75. dnl Adds variable with its value into Makefile, e.g.:
  76. dnl CC = gcc
  77. dnl
  78. AC_DEFUN([PHP_SUBST],[
  79. PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
  80. ])
  81. dnl
  82. dnl PHP_SUBST_OLD(varname, [VALUE])
  83. dnl
  84. dnl Same as PHP_SUBST() but also substitutes all @VARNAME@ instances in every
  85. dnl file passed to AC_OUTPUT.
  86. dnl
  87. AC_DEFUN([PHP_SUBST_OLD],[
  88. AC_SUBST($@)
  89. PHP_SUBST([$1])
  90. ])
  91. dnl
  92. dnl PHP_OUTPUT(file)
  93. dnl
  94. dnl Adds "file" to the list of files generated by AC_OUTPUT. This macro can be
  95. dnl used several times.
  96. dnl
  97. AC_DEFUN([PHP_OUTPUT],[
  98. PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  99. ])
  100. dnl ----------------------------------------------------------------------------
  101. dnl Build system base macros.
  102. dnl ----------------------------------------------------------------------------
  103. dnl
  104. dnl PHP_CANONICAL_HOST_TARGET
  105. dnl
  106. AC_DEFUN([PHP_CANONICAL_HOST_TARGET],[
  107. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  108. AC_REQUIRE([AC_CANONICAL_TARGET])dnl
  109. dnl Make sure we do not continue if host_alias is empty.
  110. if test -z "$host_alias" && test -n "$host"; then
  111. host_alias=$host
  112. fi
  113. if test -z "$host_alias"; then
  114. AC_MSG_ERROR([host_alias is not set!])
  115. fi
  116. ])
  117. dnl
  118. dnl PHP_INIT_BUILD_SYSTEM
  119. dnl
  120. dnl Creates build directories and Makefile placeholders.
  121. dnl
  122. AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[
  123. AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
  124. test -d include || $php_shtool mkdir include
  125. > Makefile.objects
  126. > Makefile.fragments
  127. dnl We need to play tricks here to avoid matching the grep line itself.
  128. pattern=define
  129. $EGREP $pattern'.*include/php' $srcdir/configure|$SED 's/.*>//'|xargs touch 2>/dev/null
  130. ])
  131. dnl
  132. dnl PHP_GEN_GLOBAL_MAKEFILE
  133. dnl
  134. dnl Generates the global makefile.
  135. dnl
  136. AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[
  137. cat >Makefile <<EOF
  138. srcdir = $abs_srcdir
  139. builddir = $abs_builddir
  140. top_srcdir = $abs_srcdir
  141. top_builddir = $abs_builddir
  142. EOF
  143. for i in $PHP_VAR_SUBST; do
  144. eval echo "$i = \$$i" >> Makefile
  145. done
  146. cat $abs_srcdir/build/Makefile.global Makefile.fragments Makefile.objects >> Makefile
  147. ])
  148. dnl
  149. dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]])
  150. dnl
  151. dnl Processes a file called Makefile.frag in the source directory of the most
  152. dnl recently added extension. $(srcdir) and $(builddir) are substituted with the
  153. dnl proper paths. Can be used to supply custom rules and/or additional targets.
  154. dnl
  155. AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
  156. ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
  157. ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
  158. ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
  159. test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
  160. ])
  161. dnl
  162. dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
  163. dnl
  164. dnl Adds sources which are located relative to source-path to the array of type
  165. dnl type. Sources are processed with optional special-flags which are passed to
  166. dnl the compiler. Sources can be either written in C or C++ (filenames shall end
  167. dnl in .c or .cpp, respectively).
  168. dnl
  169. dnl Note: If source-path begins with a "/", the "/" is removed and the path is
  170. dnl interpreted relative to the top build-directory.
  171. dnl
  172. dnl Which array to append to?
  173. dnl
  174. AC_DEFUN([PHP_ADD_SOURCES],[
  175. PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS))
  176. ])
  177. dnl
  178. dnl _PHP_ASSIGN_BUILD_VARS(type)
  179. dnl
  180. dnl Internal, don't use.
  181. dnl
  182. AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[
  183. ifelse($1,shared,[
  184. b_c_pre=$shared_c_pre
  185. b_cxx_pre=$shared_cxx_pre
  186. b_c_meta=$shared_c_meta
  187. b_cxx_meta=$shared_cxx_meta
  188. b_c_post=$shared_c_post
  189. b_cxx_post=$shared_cxx_post
  190. ],[
  191. b_c_pre=$php_c_pre
  192. b_cxx_pre=$php_cxx_pre
  193. b_c_meta=$php_c_meta
  194. b_cxx_meta=$php_cxx_meta
  195. b_c_post=$php_c_post
  196. b_cxx_post=$php_cxx_post
  197. ])dnl
  198. b_lo=[$]$1_lo
  199. ])
  200. dnl
  201. dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared]]])
  202. dnl
  203. dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the name of the
  204. dnl array target-var directly, as well as whether shared objects will be built
  205. dnl from the sources. Should not be used directly.
  206. dnl
  207. AC_DEFUN([PHP_ADD_SOURCES_X],[
  208. dnl Relative to source- or build-directory?
  209. dnl ac_srcdir/ac_bdir include trailing slash
  210. case $1 in
  211. ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;;
  212. /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
  213. *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
  214. esac
  215. dnl how to build .. shared or static?
  216. ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))
  217. dnl Iterate over the sources.
  218. old_IFS=[$]IFS
  219. for ac_src in $2; do
  220. dnl Remove the suffix.
  221. IFS=.
  222. set $ac_src
  223. ac_obj=[$]1
  224. IFS=$old_IFS
  225. dnl Append to the array which has been dynamically chosen at m4 time.
  226. $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
  227. dnl Choose the right compiler/flags/etc. for the source-file.
  228. case $ac_src in
  229. *.c[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;;
  230. *.s[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;;
  231. *.S[)] ac_comp="$b_c_pre $ac_inc $b_c_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_c_post" ;;
  232. *.cpp|*.cc|*.cxx[)] ac_comp="$b_cxx_pre $ac_inc $b_cxx_meta $3 -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $b_cxx_post" ;;
  233. esac
  234. dnl Generate Makefiles with dependencies
  235. ac_comp="$ac_comp -MMD -MF $ac_bdir$ac_obj.dep -MT $ac_bdir[$]ac_obj.lo"
  236. dnl Create a rule for the object/source combo.
  237. cat >>Makefile.objects<<EOF
  238. -include $ac_bdir[$]ac_obj.dep
  239. $ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src
  240. $ac_comp
  241. EOF
  242. done
  243. ])
  244. dnl ----------------------------------------------------------------------------
  245. dnl Compiler characteristics checks.
  246. dnl ----------------------------------------------------------------------------
  247. dnl
  248. dnl PHP_RUNPATH_SWITCH
  249. dnl
  250. dnl Checks for -R, etc. switch.
  251. dnl
  252. AC_DEFUN([PHP_RUNPATH_SWITCH],[
  253. AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  254. AC_CACHE_VAL(php_cv_cc_rpath,[
  255. SAVE_LIBS=$LIBS
  256. LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
  257. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],[php_cv_cc_rpath=yes],[php_cv_cc_rpath=no])
  258. LIBS=$SAVE_LIBS])
  259. AC_MSG_RESULT([$php_cv_cc_rpath])
  260. if test $php_cv_cc_rpath = "yes"; then
  261. ld_runpath_switch=-Wl,-rpath,
  262. else
  263. AC_MSG_CHECKING([if compiler supports -R])
  264. AC_CACHE_VAL(php_cv_cc_dashr,[
  265. SAVE_LIBS=$LIBS
  266. LIBS="-R /usr/$PHP_LIBDIR $LIBS"
  267. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],[php_cv_cc_dashr=yes],[php_cv_cc_dashr=no])
  268. LIBS=$SAVE_LIBS])
  269. AC_MSG_RESULT([$php_cv_cc_dashr])
  270. if test $php_cv_cc_dashr = "yes"; then
  271. ld_runpath_switch=-R
  272. else
  273. dnl Something innocuous.
  274. ld_runpath_switch=-L
  275. fi
  276. fi
  277. if test "$PHP_RPATH" = "no"; then
  278. ld_runpath_switch=
  279. fi
  280. ])
  281. AC_DEFUN([PHP_CHECK_GCC_ARG],[
  282. AC_MSG_ERROR([[Use AX_CHECK_COMPILE_FLAG instead]])
  283. ])
  284. dnl
  285. dnl PHP_LIBGCC_LIBPATH(gcc)
  286. dnl
  287. dnl Stores the location of libgcc in libgcc_libpath.
  288. dnl
  289. AC_DEFUN([PHP_LIBGCC_LIBPATH],[
  290. changequote({,})
  291. libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'`
  292. changequote([,])
  293. ])
  294. dnl ----------------------------------------------------------------------------
  295. dnl Macros to modify LIBS, INCLUDES, etc. variables.
  296. dnl ----------------------------------------------------------------------------
  297. dnl
  298. dnl PHP_REMOVE_USR_LIB(NAME)
  299. dnl
  300. dnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME.
  301. dnl
  302. AC_DEFUN([PHP_REMOVE_USR_LIB],[
  303. unset ac_new_flags
  304. for i in [$]$1; do
  305. case [$]i in
  306. -L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;;
  307. *[)] ac_new_flags="[$]ac_new_flags [$]i" ;;
  308. esac
  309. done
  310. $1=[$]ac_new_flags
  311. ])
  312. dnl
  313. dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD)
  314. dnl
  315. dnl Use this macro, if you need to add libraries and or library search paths to
  316. dnl the PHP build system which are only given in compiler notation.
  317. dnl
  318. AC_DEFUN([PHP_EVAL_LIBLINE],[
  319. for ac_i in $1; do
  320. case $ac_i in
  321. -pthread[)]
  322. if test "$ext_shared" = "yes"; then
  323. $2="[$]$2 -pthread"
  324. else
  325. PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"])
  326. PHP_RUN_ONCE(EXTRA_LDFLAGS_PROGRAM, [$ac_i],
  327. [EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $ac_i"])
  328. fi
  329. ;;
  330. -l*[)]
  331. ac_ii=`echo $ac_i|cut -c 3-`
  332. PHP_ADD_LIBRARY($ac_ii,1,$2)
  333. ;;
  334. -L*[)]
  335. ac_ii=`echo $ac_i|cut -c 3-`
  336. PHP_ADD_LIBPATH($ac_ii,$2)
  337. ;;
  338. esac
  339. done
  340. ])
  341. dnl
  342. dnl PHP_EVAL_INCLINE(headerline)
  343. dnl
  344. dnl Use this macro, if you need to add header search paths to the PHP build
  345. dnl system which are only given in compiler notation.
  346. dnl
  347. AC_DEFUN([PHP_EVAL_INCLINE],[
  348. for ac_i in $1; do
  349. case $ac_i in
  350. -I*[)]
  351. ac_ii=`echo $ac_i|cut -c 3-`
  352. PHP_ADD_INCLUDE($ac_ii)
  353. ;;
  354. esac
  355. done
  356. ])
  357. dnl
  358. dnl _PHP_ADD_LIBPATH_GLOBAL(variable)
  359. dnl
  360. dnl Internal, don't use.
  361. dnl
  362. AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[
  363. PHP_RUN_ONCE(LIBPATH, $1, [
  364. test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
  365. LDFLAGS="$LDFLAGS -L$1"
  366. PHP_RPATHS="$PHP_RPATHS $1"
  367. ])
  368. ])
  369. dnl
  370. dnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD])
  371. dnl
  372. dnl Adds a path to linkpath/runpath (LDFLAGS).
  373. dnl
  374. AC_DEFUN([PHP_ADD_LIBPATH],[
  375. if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
  376. PHP_EXPAND_PATH($1, ai_p)
  377. ifelse([$2],,[
  378. _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  379. ],[
  380. if test "$ext_shared" = "yes"; then
  381. $2="-L$ai_p [$]$2"
  382. test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2"
  383. else
  384. _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  385. fi
  386. ])
  387. fi
  388. ])
  389. dnl
  390. dnl PHP_UTILIZE_RPATHS()
  391. dnl
  392. dnl Builds RPATHS/LDFLAGS from PHP_RPATHS.
  393. dnl
  394. AC_DEFUN([PHP_UTILIZE_RPATHS],[
  395. OLD_RPATHS=$PHP_RPATHS
  396. unset PHP_RPATHS
  397. for i in $OLD_RPATHS; do
  398. dnl Can be passed to native cc/libtool
  399. PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  400. dnl Libtool-specific
  401. PHP_RPATHS="$PHP_RPATHS -R $i"
  402. dnl cc-specific
  403. NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
  404. done
  405. if test "$PHP_RPATH" = "no"; then
  406. unset PHP_RPATHS
  407. unset NATIVE_RPATHS
  408. fi
  409. ])
  410. dnl
  411. dnl PHP_ADD_INCLUDE(path [,before])
  412. dnl
  413. dnl Add an include path. If before is 1, add in the beginning of INCLUDES.
  414. dnl
  415. AC_DEFUN([PHP_ADD_INCLUDE],[
  416. if test "$1" != "/usr/include"; then
  417. PHP_EXPAND_PATH($1, ai_p)
  418. PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [
  419. if test "$2"; then
  420. INCLUDES="-I$ai_p $INCLUDES"
  421. else
  422. INCLUDES="$INCLUDES -I$ai_p"
  423. fi
  424. ])
  425. fi
  426. ])
  427. dnl
  428. dnl _PHP_X_ADD_LIBRARY
  429. dnl
  430. dnl Internal, don't use.
  431. dnl
  432. AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl
  433. ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl
  434. ])
  435. dnl
  436. dnl _PHP_ADD_LIBRARY_SKELETON
  437. dnl
  438. dnl Internal, don't use.
  439. dnl
  440. AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[
  441. case $1 in
  442. c|c_r[)] ;;
  443. *[)] ifelse($3,,[
  444. _PHP_X_ADD_LIBRARY($1,$2,$5)
  445. ],[
  446. if test "$ext_shared" = "yes"; then
  447. _PHP_X_ADD_LIBRARY($1,$2,$3)
  448. else
  449. $4($1,$2)
  450. fi
  451. ]) ;;
  452. esac
  453. ])
  454. dnl
  455. dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
  456. dnl
  457. dnl Add a library to the link line.
  458. dnl
  459. AC_DEFUN([PHP_ADD_LIBRARY],[
  460. _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
  461. ])
  462. dnl
  463. dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
  464. dnl
  465. dnl Add a library to the link line (deferred, not used during configure).
  466. dnl
  467. AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[
  468. _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
  469. ])
  470. dnl
  471. dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  472. dnl
  473. dnl Add a library to the link line and path to linkpath/runpath. If
  474. dnl shared-libadd is not empty and $ext_shared is yes, shared-libadd will be
  475. dnl assigned the library information.
  476. dnl
  477. AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[
  478. ifelse($3,,[
  479. if test -n "$2"; then
  480. PHP_ADD_LIBPATH($2)
  481. fi
  482. PHP_ADD_LIBRARY($1)
  483. ],[
  484. if test "$ext_shared" = "yes"; then
  485. $3="-l$1 [$]$3"
  486. if test -n "$2"; then
  487. PHP_ADD_LIBPATH($2,$3)
  488. fi
  489. else
  490. PHP_ADD_LIBRARY_WITH_PATH($1,$2)
  491. fi
  492. ])
  493. ])
  494. dnl
  495. dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
  496. dnl
  497. dnl Add a library to the link line (deferred) and path to linkpath/runpath (not
  498. dnl deferred). If shared-libadd is not empty and $ext_shared is yes,
  499. dnl shared-libadd will be assigned the library information.
  500. dnl
  501. AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[
  502. ifelse($3,,[
  503. if test -n "$2"; then
  504. PHP_ADD_LIBPATH($2)
  505. fi
  506. PHP_ADD_LIBRARY_DEFER($1)
  507. ],[
  508. if test "$ext_shared" = "yes"; then
  509. $3="-l$1 [$]$3"
  510. if test -n "$2"; then
  511. PHP_ADD_LIBPATH($2,$3)
  512. fi
  513. else
  514. PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
  515. fi
  516. ])
  517. ])
  518. dnl
  519. dnl PHP_ADD_FRAMEWORK(framework [,before])
  520. dnl
  521. dnl Add a (Darwin / Mac OS X) framework to the link line. If before is 1, the
  522. dnl framework is added to the beginning of the line.
  523. dnl
  524. AC_DEFUN([PHP_ADD_FRAMEWORK], [
  525. PHP_RUN_ONCE(FRAMEWORKS, $1, [
  526. if test "$2"; then
  527. PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS"
  528. else
  529. PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1"
  530. fi
  531. ])
  532. ])
  533. dnl
  534. dnl PHP_ADD_FRAMEWORKPATH(path [,before])
  535. dnl
  536. dnl Add a (Darwin / Mac OS X) framework path to the link and include lines.
  537. dnl Default paths include (but are not limited to) /Local/Library/Frameworks and
  538. dnl /System/Library/Frameworks, so these don't need to be specifically added. If
  539. dnl before is 1, the framework path is added to the beginning of the relevant
  540. dnl lines.
  541. dnl
  542. AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [
  543. PHP_EXPAND_PATH($1, ai_p)
  544. PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [
  545. if test "$2"; then
  546. PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH"
  547. else
  548. PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p"
  549. fi
  550. ])
  551. ])
  552. dnl
  553. dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path)
  554. dnl
  555. dnl Adds a (Darwin / Mac OS X) framework path and the framework itself to the
  556. dnl link and include lines.
  557. dnl
  558. AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [
  559. PHP_ADD_FRAMEWORKPATH($2)
  560. PHP_ADD_FRAMEWORK($1)
  561. ])
  562. dnl
  563. dnl PHP_SET_LIBTOOL_VARIABLE(var)
  564. dnl
  565. dnl Set libtool variable.
  566. dnl
  567. AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[
  568. if test -z "$LIBTOOL"; then
  569. LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
  570. else
  571. LIBTOOL="$LIBTOOL $1"
  572. fi
  573. ])
  574. dnl ----------------------------------------------------------------------------
  575. dnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE
  576. dnl ----------------------------------------------------------------------------
  577. dnl
  578. dnl PHP_ARG_ANALYZE_EX
  579. dnl
  580. dnl Internal.
  581. dnl
  582. AC_DEFUN([PHP_ARG_ANALYZE_EX],[
  583. ext_output="yes, shared"
  584. ext_shared=yes
  585. case [$]$1 in
  586. shared,*[)]
  587. $1=`echo "[$]$1"|$SED 's/^shared,//'`
  588. ;;
  589. shared[)]
  590. $1=yes
  591. ;;
  592. no[)]
  593. ext_output=no
  594. ext_shared=no
  595. ;;
  596. *[)]
  597. ext_output=yes
  598. ext_shared=no
  599. ;;
  600. esac
  601. PHP_ALWAYS_SHARED([$1])
  602. ])
  603. dnl
  604. dnl PHP_ARG_ANALYZE
  605. dnl
  606. dnl Internal.
  607. dnl
  608. AC_DEFUN([PHP_ARG_ANALYZE],[
  609. ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)])
  610. ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
  611. ])
  612. dnl
  613. dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]])
  614. dnl
  615. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  616. dnl default-val defaults to no. This will also set the variable ext_shared, and
  617. dnl will overwrite any previous variable of that name. If extension-or-not is
  618. dnl yes (default), then do the ENABLE_ALL check and run the PHP_ARG_ANALYZE_EX.
  619. dnl
  620. AC_DEFUN([PHP_ARG_WITH],[
  621. php_with_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
  622. PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
  623. ])
  624. dnl
  625. dnl PHP_REAL_ARG_WITH
  626. dnl
  627. dnl Internal.
  628. dnl
  629. AC_DEFUN([PHP_REAL_ARG_WITH],[
  630. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  631. AC_ARG_WITH($1,[$3],$5=[$]withval,
  632. [
  633. $5=ifelse($4,,no,$4)
  634. ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
  635. ])
  636. PHP_ARG_ANALYZE($5,[$2],$6)
  637. ])
  638. dnl
  639. dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])
  640. dnl
  641. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  642. dnl default-val defaults to no. This will also set the variable ext_shared, and
  643. dnl will overwrite any previous variable of that name. If extension-or-not is
  644. dnl yes (default), then do the ENABLE_ALL check and run the PHP_ARG_ANALYZE_EX.
  645. dnl
  646. AC_DEFUN([PHP_ARG_ENABLE],[
  647. php_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
  648. PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
  649. ])
  650. dnl
  651. dnl PHP_REAL_ARG_ENABLE
  652. dnl
  653. dnl Internal.
  654. dnl
  655. AC_DEFUN([PHP_REAL_ARG_ENABLE],[
  656. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  657. AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
  658. [
  659. $5=ifelse($4,,no,$4)
  660. ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
  661. ])
  662. PHP_ARG_ANALYZE($5,[$2],$6)
  663. ])
  664. dnl ----------------------------------------------------------------------------
  665. dnl Build macros
  666. dnl ----------------------------------------------------------------------------
  667. dnl
  668. dnl PHP_BUILD_THREAD_SAFE
  669. dnl
  670. AC_DEFUN([PHP_BUILD_THREAD_SAFE],[
  671. enable_zts=yes
  672. if test "$pthreads_working" != "yes"; then
  673. AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
  674. fi
  675. ])
  676. dnl
  677. dnl PHP_REQUIRE_CXX
  678. dnl
  679. AC_DEFUN([PHP_REQUIRE_CXX],[
  680. if test -z "$php_cxx_done"; then
  681. AC_PROG_CXX
  682. AC_PROG_CXXCPP
  683. PHP_ADD_LIBRARY(stdc++)
  684. php_cxx_done=yes
  685. fi
  686. ])
  687. dnl
  688. dnl PHP_BUILD_SHARED
  689. dnl
  690. AC_DEFUN([PHP_BUILD_SHARED],[
  691. PHP_BUILD_PROGRAM
  692. OVERALL_TARGET=libphp.la
  693. php_sapi_module=shared
  694. php_c_pre=$shared_c_pre
  695. php_c_meta=$shared_c_meta
  696. php_c_post=$shared_c_post
  697. php_cxx_pre=$shared_cxx_pre
  698. php_cxx_meta=$shared_cxx_meta
  699. php_cxx_post=$shared_cxx_post
  700. php_lo=$shared_lo
  701. ])
  702. dnl
  703. dnl PHP_BUILD_STATIC
  704. dnl
  705. AC_DEFUN([PHP_BUILD_STATIC],[
  706. PHP_BUILD_PROGRAM
  707. OVERALL_TARGET=libphp.la
  708. php_sapi_module=static
  709. ])
  710. dnl
  711. dnl PHP_BUILD_BUNDLE
  712. dnl
  713. AC_DEFUN([PHP_BUILD_BUNDLE],[
  714. PHP_BUILD_PROGRAM
  715. OVERALL_TARGET=libs/libphp.bundle
  716. php_sapi_module=static
  717. ])
  718. dnl
  719. dnl PHP_BUILD_PROGRAM
  720. dnl
  721. AC_DEFUN([PHP_BUILD_PROGRAM],[
  722. php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  723. php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
  724. php_c_post=
  725. php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  726. php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
  727. php_cxx_post=
  728. php_lo=lo
  729. case $with_pic in
  730. yes) pic_setting='-prefer-pic';;
  731. no) pic_setting='-prefer-non-pic';;
  732. esac
  733. shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  734. shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
  735. shared_c_post=
  736. shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  737. shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
  738. shared_cxx_post=
  739. shared_lo=lo
  740. ])
  741. dnl
  742. dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext)
  743. dnl
  744. dnl Basically sets up the link-stage for building module-name from object_var in
  745. dnl build-dir.
  746. dnl
  747. AC_DEFUN([PHP_SHARED_MODULE],[
  748. install_modules="install-modules"
  749. suffix=la
  750. case $host_alias in
  751. *aix*[)]
  752. additional_flags="-Wl,-G"
  753. ;;
  754. esac
  755. if test "x$5" = "xyes"; then
  756. PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix"
  757. else
  758. PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
  759. fi
  760. PHP_SUBST($2)
  761. cat >>Makefile.objects<<EOF
  762. \$(phplibdir)/$1.$suffix: $3/$1.$suffix
  763. \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
  764. $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
  765. \$(LIBTOOL) --mode=link ifelse($4,,[\$(CC)],[\$(CXX)]) -shared \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(LDFLAGS) $additional_flags -o [\$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath \$(phplibdir) \$(EXTRA_LDFLAGS) \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)
  766. EOF
  767. ])
  768. dnl
  769. dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
  770. dnl
  771. dnl Selects the SAPI name and type (static, shared, bundle, program) and
  772. dnl optionally also the source-files for the SAPI-specific objects.
  773. dnl
  774. AC_DEFUN([PHP_SELECT_SAPI],[
  775. if test "$2" = "program"; then
  776. PHP_BINARIES="$PHP_BINARIES $1"
  777. elif test "$PHP_SAPI" != "none"; then
  778. AC_MSG_ERROR([
  779. +--------------------------------------------------------------------+
  780. | *** ATTENTION *** |
  781. | |
  782. | You've configured multiple SAPIs to be built. You can build only |
  783. | one SAPI module plus CGI, CLI and FPM binaries at the same time. |
  784. +--------------------------------------------------------------------+
  785. ])
  786. else
  787. PHP_SAPI=$1
  788. fi
  789. PHP_ADD_BUILD_DIR([sapi/$1])
  790. PHP_INSTALLED_SAPIS="$PHP_INSTALLED_SAPIS $1"
  791. ifelse($2,program,[
  792. PHP_BUILD_PROGRAM
  793. install_binaries="install-binaries"
  794. install_binary_targets="$install_binary_targets install-$1"
  795. PHP_SUBST(PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)
  796. ifelse($3,,,[PHP_ADD_SOURCES_X([sapi/$1],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)])
  797. ],[
  798. case "$2" in
  799. static[)] PHP_BUILD_STATIC;;
  800. shared[)] PHP_BUILD_SHARED;;
  801. bundle[)] PHP_BUILD_BUNDLE;;
  802. esac
  803. install_sapi="install-sapi"
  804. ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
  805. ])
  806. ])
  807. dnl
  808. dnl PHP_ADD_BUILD_DIR
  809. dnl
  810. AC_DEFUN([PHP_ADD_BUILD_DIR],[
  811. ifelse($2,,[
  812. BUILD_DIR="$BUILD_DIR $1"
  813. ], [
  814. $php_shtool mkdir -p $1
  815. ])
  816. ])
  817. dnl
  818. dnl PHP_GEN_BUILD_DIRS
  819. dnl
  820. AC_DEFUN([PHP_GEN_BUILD_DIRS],[
  821. $php_shtool mkdir -p $BUILD_DIR
  822. ])
  823. dnl
  824. dnl PHP_NEW_EXTENSION(extname, sources [, shared [, sapi_class [, extra-cflags [, cxx [, zend_ext]]]]])
  825. dnl
  826. dnl Includes an extension in the build.
  827. dnl
  828. dnl "extname" is the name of the extension.
  829. dnl "sources" is a list of files relative to the subdir which are used to build
  830. dnl the extension.
  831. dnl "shared" can be set to "shared" or "yes" to build the extension as a
  832. dnl dynamically loadable library. Optional parameter "sapi_class" can be set to
  833. dnl "cli" to mark extension build only with CLI or CGI sapi's. "extra-cflags"
  834. dnl are passed to the compiler, with @ext_srcdir@ and @ext_builddir@ being
  835. dnl substituted.
  836. dnl "cxx" can be used to indicate that a C++ shared module is desired.
  837. dnl "zend_ext" indicates a zend extension.
  838. AC_DEFUN([PHP_NEW_EXTENSION],[
  839. ext_builddir=[]PHP_EXT_BUILDDIR($1)
  840. ext_srcdir=[]PHP_EXT_SRCDIR($1)
  841. ext_dir=[]PHP_EXT_DIR($1)
  842. ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`])
  843. if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
  844. dnl ---------------------------------------------- Static module
  845. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
  846. PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,)
  847. EXT_STATIC="$EXT_STATIC $1;$ext_dir"
  848. if test "$3" != "nocli"; then
  849. EXT_CLI_STATIC="$EXT_CLI_STATIC $1;$ext_dir"
  850. fi
  851. else
  852. if test "$3" = "shared" || test "$3" = "yes"; then
  853. dnl ---------------------------------------------- Shared module
  854. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes
  855. PHP_ADD_SOURCES_X($ext_dir,$2,$ac_extra -DZEND_COMPILE_DL_EXT=1,shared_objects_$1,yes)
  856. PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7)
  857. AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
  858. fi
  859. fi
  860. if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
  861. dnl ---------------------------------------------- CLI static module
  862. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
  863. case "$PHP_SAPI" in
  864. cgi|embed|phpdbg[)]
  865. PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,)
  866. EXT_STATIC="$EXT_STATIC $1;$ext_dir"
  867. ;;
  868. *[)]
  869. PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,cli)
  870. ;;
  871. esac
  872. EXT_CLI_STATIC="$EXT_CLI_STATIC $1;$ext_dir"
  873. fi
  874. PHP_ADD_BUILD_DIR($ext_builddir)
  875. dnl Set for phpize builds only.
  876. dnl ---------------------------
  877. if test "$ext_builddir" = "."; then
  878. PHP_PECL_EXTENSION=$1
  879. PHP_SUBST(PHP_PECL_EXTENSION)
  880. fi
  881. ])
  882. dnl
  883. dnl PHP_WITH_SHARED
  884. dnl
  885. dnl Checks whether $withval is "shared" or starts with "shared,XXX" and sets
  886. dnl $shared to "yes" or "no", and removes "shared,?" stuff from $withval.
  887. dnl
  888. AC_DEFUN([PHP_WITH_SHARED],[
  889. PHP_ARG_ANALYZE_EX(withval)
  890. shared=$ext_shared
  891. unset ext_shared ext_output
  892. ])
  893. dnl
  894. dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf])
  895. dnl
  896. dnl This macro is scanned by genif.sh when it builds the internal functions
  897. dnl list, so that modules can be init'd in the correct order
  898. dnl $1 = name of extension, $2 = extension upon which it depends
  899. dnl $3 = optional: if true, it's ok for $2 to have not been configured default
  900. dnl is false and should halt the build. To be effective, this macro must be
  901. dnl invoked *after* PHP_NEW_EXTENSION. The extension on which it depends must
  902. dnl also have been configured. See ADD_EXTENSION_DEP in win32 build.
  903. dnl
  904. AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
  905. am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
  906. is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
  907. is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
  908. if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
  909. AC_MSG_ERROR([
  910. You've configured extension $1 to build statically, but it
  911. depends on extension $2, which you've configured to build shared.
  912. You either need to build $1 shared or build $2 statically for the
  913. build to be successful.
  914. ])
  915. fi
  916. if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then
  917. AC_MSG_ERROR([
  918. You've configured extension $1, which depends on extension $2,
  919. but you've either not enabled $2, or have disabled it.
  920. ])
  921. fi
  922. dnl Some systems require that we link $2 to $1 when building.
  923. ])
  924. dnl ----------------------------------------------------------------------------
  925. dnl Checks for structures, typedefs, broken functions, etc.
  926. dnl ----------------------------------------------------------------------------
  927. dnl
  928. dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
  929. dnl
  930. dnl Internal helper macro.
  931. dnl
  932. AC_DEFUN([_PHP_CHECK_SIZEOF], [
  933. php_cache_value=php_cv_sizeof_[]$1
  934. AC_CACHE_VAL(php_cv_sizeof_[]$1, [
  935. old_LIBS=$LIBS
  936. LIBS=
  937. old_LDFLAGS=$LDFLAGS
  938. LDFLAGS=
  939. AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
  940. #include <stdlib.h>
  941. #include <stddef.h>
  942. #include <inttypes.h>
  943. #ifdef HAVE_UNISTD_H
  944. #include <unistd.h>
  945. #endif
  946. $3
  947. int main()
  948. {
  949. FILE *fp = fopen("conftestval", "w");
  950. if (!fp) return(1);
  951. fprintf(fp, "%d\n", sizeof($1));
  952. return(0);
  953. }
  954. ]])], [
  955. eval $php_cache_value=`cat conftestval`
  956. ], [
  957. eval $php_cache_value=0
  958. ], [
  959. ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
  960. ])
  961. LDFLAGS=$old_LDFLAGS
  962. LIBS=$old_LIBS
  963. ])
  964. if eval test "\$$php_cache_value" != "0"; then
  965. ifelse([$4],[],:,[$4])
  966. ifelse([$5],[],,[else $5])
  967. fi
  968. ])
  969. dnl
  970. dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
  971. dnl
  972. AC_DEFUN([PHP_CHECK_SIZEOF], [
  973. AC_MSG_CHECKING([size of $1])
  974. _PHP_CHECK_SIZEOF($1, $2, $3, [
  975. AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
  976. AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
  977. ])
  978. AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
  979. ])
  980. dnl
  981. dnl PHP_CHECK_IN_ADDR_T
  982. dnl
  983. AC_DEFUN([PHP_CHECK_IN_ADDR_T], [
  984. dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
  985. AC_MSG_CHECKING([for in_addr_t])
  986. AC_CACHE_VAL(ac_cv_type_in_addr_t,
  987. [AC_EGREP_CPP(dnl
  988. changequote(<<,>>)dnl
  989. <<in_addr_t[^a-zA-Z_0-9]>>dnl
  990. changequote([,]), [#include <sys/types.h>
  991. #include <stdlib.h>
  992. #include <stddef.h>
  993. #ifdef HAVE_NETINET_IN_H
  994. #include <netinet/in.h>
  995. #endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
  996. AC_MSG_RESULT([$ac_cv_type_in_addr_t])
  997. if test $ac_cv_type_in_addr_t = no; then
  998. AC_DEFINE(in_addr_t, u_int, [ ])
  999. fi
  1000. ])
  1001. dnl
  1002. dnl PHP_TIME_R_TYPE
  1003. dnl
  1004. dnl Check type of reentrant time-related functions. Type can be: irix, hpux or
  1005. dnl POSIX.
  1006. dnl
  1007. AC_DEFUN([PHP_TIME_R_TYPE],[
  1008. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  1009. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1010. #include <time.h>
  1011. int main() {
  1012. char buf[27];
  1013. struct tm t;
  1014. time_t old = 0;
  1015. int r, s;
  1016. s = gmtime_r(&old, &t);
  1017. r = (int) asctime_r(&t, buf, 26);
  1018. if (r == s && s == 0) return (0);
  1019. return (1);
  1020. }
  1021. ]])],[
  1022. ac_cv_time_r_type=hpux
  1023. ],[
  1024. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1025. #include <time.h>
  1026. int main() {
  1027. struct tm t, *s;
  1028. time_t old = 0;
  1029. char buf[27], *p;
  1030. s = gmtime_r(&old, &t);
  1031. p = asctime_r(&t, buf, 26);
  1032. if (p == buf && s == &t) return (0);
  1033. return (1);
  1034. }
  1035. ]])],[
  1036. ac_cv_time_r_type=irix
  1037. ],[
  1038. ac_cv_time_r_type=POSIX
  1039. ],[
  1040. ac_cv_time_r_type=POSIX
  1041. ])
  1042. ],[
  1043. ac_cv_time_r_type=POSIX
  1044. ])
  1045. ])
  1046. case $ac_cv_time_r_type in
  1047. hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
  1048. irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
  1049. esac
  1050. ])
  1051. dnl
  1052. dnl PHP_DOES_PWRITE_WORK
  1053. dnl
  1054. dnl Internal.
  1055. dnl
  1056. AC_DEFUN([PHP_DOES_PWRITE_WORK],[
  1057. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1058. #include <sys/types.h>
  1059. #include <sys/stat.h>
  1060. #include <fcntl.h>
  1061. #include <unistd.h>
  1062. #include <errno.h>
  1063. #include <stdlib.h>
  1064. $1
  1065. int main() {
  1066. int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
  1067. if (fd < 0) return 1;
  1068. if (pwrite(fd, "text", 4, 0) != 4) return 1;
  1069. /* Linux glibc breakage until 2.2.5 */
  1070. if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) return 1;
  1071. return 0;
  1072. }
  1073. ]])],[
  1074. ac_cv_pwrite=yes
  1075. ],[
  1076. ac_cv_pwrite=no
  1077. ],[
  1078. ac_cv_pwrite=no
  1079. ])
  1080. ])
  1081. dnl
  1082. dnl PHP_DOES_PREAD_WORK
  1083. dnl
  1084. dnl Internal.
  1085. dnl
  1086. AC_DEFUN([PHP_DOES_PREAD_WORK],[
  1087. echo test > conftest_in
  1088. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1089. #include <sys/types.h>
  1090. #include <sys/stat.h>
  1091. #include <fcntl.h>
  1092. #include <unistd.h>
  1093. #include <errno.h>
  1094. #include <stdlib.h>
  1095. $1
  1096. int main() {
  1097. char buf[3];
  1098. int fd = open("conftest_in", O_RDONLY);
  1099. if (fd < 0) return 1;
  1100. if (pread(fd, buf, 2, 0) != 2) return 1;
  1101. /* Linux glibc breakage until 2.2.5 */
  1102. if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) return 1;
  1103. return 0;
  1104. }
  1105. ]])],[
  1106. ac_cv_pread=yes
  1107. ],[
  1108. ac_cv_pread=no
  1109. ],[
  1110. ac_cv_pread=no
  1111. ])
  1112. rm -f conftest_in
  1113. ])
  1114. dnl
  1115. dnl PHP_PWRITE_TEST
  1116. dnl
  1117. AC_DEFUN([PHP_PWRITE_TEST],[
  1118. AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
  1119. PHP_DOES_PWRITE_WORK
  1120. if test "$ac_cv_pwrite" = "no"; then
  1121. PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
  1122. if test "$ac_cv_pwrite" = "yes"; then
  1123. ac_cv_pwrite=64
  1124. fi
  1125. fi
  1126. ])
  1127. if test "$ac_cv_pwrite" != "no"; then
  1128. AC_DEFINE(HAVE_PWRITE, 1, [ ])
  1129. if test "$ac_cv_pwrite" = "64"; then
  1130. AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
  1131. fi
  1132. fi
  1133. ])
  1134. dnl
  1135. dnl PHP_PREAD_TEST
  1136. dnl
  1137. AC_DEFUN([PHP_PREAD_TEST],[
  1138. AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
  1139. PHP_DOES_PREAD_WORK
  1140. if test "$ac_cv_pread" = "no"; then
  1141. PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
  1142. if test "$ac_cv_pread" = "yes"; then
  1143. ac_cv_pread=64
  1144. fi
  1145. fi
  1146. ])
  1147. if test "$ac_cv_pread" != "no"; then
  1148. AC_DEFINE(HAVE_PREAD, 1, [ ])
  1149. if test "$ac_cv_pread" = "64"; then
  1150. AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
  1151. fi
  1152. fi
  1153. ])
  1154. dnl
  1155. dnl PHP_MISSING_TIME_R_DECL
  1156. dnl
  1157. AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
  1158. AC_MSG_CHECKING([for missing declarations of reentrant functions])
  1159. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)() = localtime_r]])],[
  1160. :
  1161. ],[
  1162. AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  1163. ])
  1164. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)() = gmtime_r]])],[
  1165. :
  1166. ],[
  1167. AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  1168. ])
  1169. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)() = asctime_r]])],[
  1170. :
  1171. ],[
  1172. AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  1173. ])
  1174. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)() = ctime_r]])],[
  1175. :
  1176. ],[
  1177. AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  1178. ])
  1179. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[char *(*func)() = strtok_r]])],[
  1180. :
  1181. ],[
  1182. AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  1183. ])
  1184. AC_MSG_RESULT([done])
  1185. ])
  1186. dnl
  1187. dnl PHP_STRUCT_FLOCK
  1188. dnl
  1189. AC_DEFUN([PHP_STRUCT_FLOCK],[
  1190. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  1191. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1192. #include <unistd.h>
  1193. #include <fcntl.h>
  1194. ]], [[struct flock x;]])],[
  1195. ac_cv_struct_flock=yes
  1196. ],[
  1197. ac_cv_struct_flock=no
  1198. ])
  1199. )
  1200. if test "$ac_cv_struct_flock" = "yes" ; then
  1201. AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  1202. fi
  1203. ])
  1204. dnl
  1205. dnl PHP_MISSING_FCLOSE_DECL
  1206. dnl
  1207. dnl See if we have broken header files like SunOS has.
  1208. dnl
  1209. AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
  1210. AC_MSG_CHECKING([for fclose declaration])
  1211. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[int (*func)() = fclose]])],[
  1212. AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  1213. AC_MSG_RESULT([ok])
  1214. ],[
  1215. AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  1216. AC_MSG_RESULT([missing])
  1217. ])
  1218. ])
  1219. dnl
  1220. dnl PHP_SOCKADDR_CHECKS
  1221. dnl
  1222. AC_DEFUN([PHP_SOCKADDR_CHECKS], [
  1223. dnl Check for struct sockaddr_storage exists.
  1224. AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
  1225. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  1226. #include <sys/socket.h>]],
  1227. [[struct sockaddr_storage s; s]])],
  1228. [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
  1229. ])
  1230. if test "$ac_cv_sockaddr_storage" = "yes"; then
  1231. AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
  1232. fi
  1233. dnl Check if field sa_len exists in struct sockaddr.
  1234. AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  1235. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  1236. #include <sys/socket.h>]], [[static struct sockaddr sa; int n = (int) sa.sa_len; return n;]])],
  1237. [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
  1238. ])
  1239. if test "$ac_cv_sockaddr_sa_len" = "yes"; then
  1240. AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
  1241. fi
  1242. ])
  1243. dnl
  1244. dnl PHP_EBCDIC
  1245. dnl
  1246. AC_DEFUN([PHP_EBCDIC], [
  1247. AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  1248. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1249. int main(void) {
  1250. return (unsigned char)'A' != (unsigned char)0xC1;
  1251. }
  1252. ]])],[
  1253. ac_cv_ebcdic=yes
  1254. ],[
  1255. ac_cv_ebcdic=no
  1256. ],[
  1257. ac_cv_ebcdic=no
  1258. ])])
  1259. if test "$ac_cv_ebcdic" = "yes"; then
  1260. AC_MSG_ERROR([PHP does not support EBCDIC targets])
  1261. fi
  1262. ])
  1263. dnl
  1264. dnl PHP_BROKEN_GETCWD
  1265. dnl
  1266. dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
  1267. dnl component of the path has execute but not read permissions.
  1268. dnl
  1269. AC_DEFUN([PHP_BROKEN_GETCWD],[
  1270. AC_MSG_CHECKING([for broken getcwd])
  1271. os=`uname -sr 2>/dev/null`
  1272. case $os in
  1273. SunOS*[)]
  1274. AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
  1275. AC_MSG_RESULT([yes]);;
  1276. *[)]
  1277. AC_MSG_RESULT([no]);;
  1278. esac
  1279. ])
  1280. dnl
  1281. dnl PHP_BROKEN_GCC_STRLEN_OPT
  1282. dnl
  1283. dnl Early releases of GCC 8 shipped with a strlen() optimization bug, so they
  1284. dnl didn't properly handle the `char val[1]` struct hack. See bug #76510.
  1285. dnl
  1286. AC_DEFUN([PHP_BROKEN_GCC_STRLEN_OPT], [
  1287. AC_CACHE_CHECK([for broken gcc optimize-strlen],ac_cv_have_broken_gcc_strlen_opt,[
  1288. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1289. #include <stdlib.h>
  1290. #include <string.h>
  1291. #include <stdio.h>
  1292. struct s
  1293. {
  1294. int i;
  1295. char c[1];
  1296. };
  1297. int main()
  1298. {
  1299. struct s *s = malloc(sizeof(struct s) + 3);
  1300. s->i = 3;
  1301. strcpy(s->c, "foo");
  1302. return strlen(s->c+1) == 2;
  1303. }
  1304. ]])],[
  1305. ac_cv_have_broken_gcc_strlen_opt=yes
  1306. ],[
  1307. ac_cv_have_broken_gcc_strlen_opt=no
  1308. ],[
  1309. ac_cv_have_broken_gcc_strlen_opt=no
  1310. ])])
  1311. if test "$ac_cv_have_broken_gcc_strlen_opt" = "yes"; then
  1312. CFLAGS="$CFLAGS -fno-optimize-strlen"
  1313. fi
  1314. ])
  1315. dnl
  1316. dnl PHP_FOPENCOOKIE
  1317. dnl
  1318. AC_DEFUN([PHP_FOPENCOOKIE], [
  1319. AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes])
  1320. if test "$have_glibc_fopencookie" = "yes"; then
  1321. dnl This comes in two flavors: newer glibcs (since 2.1.2?) have a type called
  1322. dnl cookie_io_functions_t.
  1323. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1324. #define _GNU_SOURCE
  1325. #include <stdio.h>
  1326. ]], [[cookie_io_functions_t cookie;]])],[have_cookie_io_functions_t=yes],[])
  1327. if test "$have_cookie_io_functions_t" = "yes"; then
  1328. cookie_io_functions_t=cookie_io_functions_t
  1329. have_fopen_cookie=yes
  1330. dnl Even newer glibcs have a different seeker definition.
  1331. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1332. #define _GNU_SOURCE
  1333. #include <stdio.h>
  1334. #include <stdlib.h>
  1335. struct cookiedata {
  1336. off64_t pos;
  1337. };
  1338. ssize_t reader(void *cookie, char *buffer, size_t size)
  1339. { return size; }
  1340. ssize_t writer(void *cookie, const char *buffer, size_t size)
  1341. { return size; }
  1342. int closer(void *cookie)
  1343. { return 0; }
  1344. int seeker(void *cookie, off64_t *position, int whence)
  1345. { ((struct cookiedata*)cookie)->pos = *position; return 0; }
  1346. cookie_io_functions_t funcs = {reader, writer, seeker, closer};
  1347. int main() {
  1348. struct cookiedata g = { 0 };
  1349. FILE *fp = fopencookie(&g, "r", funcs);
  1350. if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
  1351. return 0;
  1352. return 1;
  1353. }
  1354. ]])], [
  1355. cookie_io_functions_use_off64_t=yes
  1356. ], [
  1357. cookie_io_functions_use_off64_t=no
  1358. ], [
  1359. dnl Cross compilation.
  1360. case $host_alias in
  1361. *linux*)
  1362. cookie_io_functions_use_off64_t=yes
  1363. ;;
  1364. *)
  1365. cookie_io_functions_use_off64_t=no
  1366. ;;
  1367. esac
  1368. ])
  1369. else
  1370. dnl Older glibc versions (up to 2.1.2?) call it _IO_cookie_io_functions_t.
  1371. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1372. #define _GNU_SOURCE
  1373. #include <stdio.h>
  1374. ]], [[_IO_cookie_io_functions_t cookie;]])], [have_IO_cookie_io_functions_t=yes], [])
  1375. if test "$have_cookie_io_functions_t" = "yes" ; then
  1376. cookie_io_functions_t=_IO_cookie_io_functions_t
  1377. have_fopen_cookie=yes
  1378. fi
  1379. fi
  1380. if test "$have_fopen_cookie" = "yes" ; then
  1381. AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  1382. AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  1383. if test "$cookie_io_functions_use_off64_t" = "yes" ; then
  1384. AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
  1385. fi
  1386. fi
  1387. fi
  1388. ])
  1389. dnl ----------------------------------------------------------------------------
  1390. dnl Library/function existence and build sanity checks.
  1391. dnl ----------------------------------------------------------------------------
  1392. dnl
  1393. dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
  1394. dnl
  1395. dnl Wrapper for AC_CHECK_LIB.
  1396. dnl
  1397. AC_DEFUN([PHP_CHECK_LIBRARY], [
  1398. save_old_LDFLAGS=$LDFLAGS
  1399. ac_stuff="$5"
  1400. save_ext_shared=$ext_shared
  1401. ext_shared=yes
  1402. PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
  1403. AC_CHECK_LIB([$1],[$2],[
  1404. LDFLAGS=$save_old_LDFLAGS
  1405. ext_shared=$save_ext_shared
  1406. $3
  1407. ],[
  1408. LDFLAGS=$save_old_LDFLAGS
  1409. ext_shared=$save_ext_shared
  1410. unset ac_cv_lib_$1[]_$2
  1411. $4
  1412. ])dnl
  1413. ])
  1414. dnl
  1415. dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
  1416. dnl
  1417. dnl El cheapo wrapper for AC_CHECK_LIB.
  1418. dnl
  1419. AC_DEFUN([PHP_CHECK_FRAMEWORK], [
  1420. save_old_LDFLAGS=$LDFLAGS
  1421. LDFLAGS="-framework $1 $LDFLAGS"
  1422. dnl Supplying "c" to AC_CHECK_LIB is technically cheating, but rewriting
  1423. dnl AC_CHECK_LIB is overkill and this only affects the "checking.." output
  1424. dnl anyway.
  1425. AC_CHECK_LIB(c,[$2],[
  1426. LDFLAGS=$save_old_LDFLAGS
  1427. $3
  1428. ],[
  1429. LDFLAGS=$save_old_LDFLAGS
  1430. $4
  1431. ])
  1432. ])
  1433. dnl
  1434. dnl PHP_CHECK_FUNC_LIB(func, libs)
  1435. dnl
  1436. dnl This macro checks whether 'func' or '__func' exists in the specified
  1437. dnl library. Defines HAVE_func and HAVE_library if found and adds the library to
  1438. dnl LIBS. This should be called in the ACTION-IF-NOT-FOUND part of
  1439. dnl PHP_CHECK_FUNC.
  1440. dnl
  1441. dnl autoconf undefines the builtin "shift" :-(
  1442. dnl If possible, we use the builtin shift anyway, otherwise we use the ubercool
  1443. dnl definition that has been tested so far with FreeBSD/GNU m4.
  1444. dnl
  1445. ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
  1446. define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
  1447. ])
  1448. dnl
  1449. dnl PHP_CHECK_FUNC_LIB
  1450. dnl
  1451. AC_DEFUN([PHP_CHECK_FUNC_LIB],[
  1452. ifelse($2,,:,[
  1453. unset ac_cv_lib_$2[]_$1
  1454. unset ac_cv_lib_$2[]___$1
  1455. unset found
  1456. AC_CHECK_LIB($2, $1, [found=yes], [
  1457. AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
  1458. ])
  1459. if test "$found" = "yes"; then
  1460. ac_libs=$LIBS
  1461. LIBS="$LIBS -l$2"
  1462. AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return (0); }]])],[found=yes],[found=no],[
  1463. dnl Cross compilation.
  1464. found=yes
  1465. ])
  1466. LIBS=$ac_libs
  1467. fi
  1468. if test "$found" = "yes"; then
  1469. PHP_ADD_LIBRARY($2)
  1470. PHP_DEF_HAVE($1)
  1471. PHP_DEF_HAVE(lib$2)
  1472. ac_cv_func_$1=yes
  1473. else
  1474. PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
  1475. fi
  1476. ])
  1477. ])
  1478. dnl
  1479. dnl PHP_CHECK_FUNC(func, ...)
  1480. dnl
  1481. dnl This macro checks whether 'func' or '__func' exists in the default libraries
  1482. dnl and as a fall back in the specified library. Defines HAVE_func and
  1483. dnl HAVE_library if found and adds the library to LIBS.
  1484. dnl
  1485. AC_DEFUN([PHP_CHECK_FUNC],[
  1486. unset ac_cv_func_$1
  1487. unset ac_cv_func___$1
  1488. unset found
  1489. AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
  1490. case $found in
  1491. yes[)]
  1492. PHP_DEF_HAVE($1)
  1493. ac_cv_func_$1=yes
  1494. ;;
  1495. ifelse($#,1,,[
  1496. *[)] PHP_CHECK_FUNC_LIB($@) ;;
  1497. ])
  1498. esac
  1499. ])
  1500. dnl
  1501. dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]])
  1502. dnl
  1503. dnl This macro checks whether build works and given function exists.
  1504. dnl
  1505. AC_DEFUN([PHP_TEST_BUILD], [
  1506. old_LIBS=$LIBS
  1507. LIBS="$4 $LIBS"
  1508. AC_LINK_IFELSE([AC_LANG_SOURCE([[
  1509. $5
  1510. char $1();
  1511. int main() {
  1512. $1();
  1513. return 0;
  1514. }
  1515. ]])],[
  1516. LIBS=$old_LIBS
  1517. $2
  1518. ],[
  1519. LIBS=$old_LIBS
  1520. $3
  1521. ])
  1522. ])
  1523. dnl ----------------------------------------------------------------------------
  1524. dnl Platform characteristics checks.
  1525. dnl ----------------------------------------------------------------------------
  1526. dnl
  1527. dnl PHP_SHLIB_SUFFIX_NAMES
  1528. dnl
  1529. dnl Determines link library suffix SHLIB_SUFFIX_NAME which can be: .so, .sl or
  1530. dnl .dylib
  1531. dnl
  1532. dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME suffix can be: .so or
  1533. dnl .sl
  1534. dnl
  1535. AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
  1536. AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
  1537. PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
  1538. PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
  1539. SHLIB_SUFFIX_NAME=so
  1540. SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
  1541. case $host_alias in
  1542. *hpux*[)]
  1543. SHLIB_SUFFIX_NAME=sl
  1544. SHLIB_DL_SUFFIX_NAME=sl
  1545. ;;
  1546. *darwin*[)]
  1547. SHLIB_SUFFIX_NAME=dylib
  1548. SHLIB_DL_SUFFIX_NAME=so
  1549. ;;
  1550. esac
  1551. ])
  1552. dnl
  1553. dnl PHP_C_BIGENDIAN
  1554. dnl
  1555. dnl Replacement macro for AC_C_BIGENDIAN.
  1556. dnl
  1557. AC_DEFUN([PHP_C_BIGENDIAN],
  1558. [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
  1559. [
  1560. ac_cv_c_bigendian_php=unknown
  1561. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1562. int main(void)
  1563. {
  1564. short one = 1;
  1565. char *cp = (char *)&one;
  1566. if (*cp == 0) {
  1567. return(0);
  1568. } else {
  1569. return(1);
  1570. }
  1571. }
  1572. ]])], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
  1573. ])
  1574. if test $ac_cv_c_bigendian_php = yes; then
  1575. AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
  1576. fi
  1577. ])
  1578. dnl ----------------------------------------------------------------------------
  1579. dnl Checks for programs: PHP_PROG_<program>.
  1580. dnl ----------------------------------------------------------------------------
  1581. dnl
  1582. dnl PHP_PROG_SENDMAIL
  1583. dnl
  1584. dnl Search for the sendmail binary.
  1585. dnl
  1586. AC_DEFUN([PHP_PROG_SENDMAIL], [
  1587. PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
  1588. AC_PATH_PROG(PROG_SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$PHP_ALT_PATH)
  1589. PHP_SUBST(PROG_SENDMAIL)
  1590. ])
  1591. dnl
  1592. dnl PHP_PROG_AWK
  1593. dnl
  1594. dnl Some vendors force mawk before gawk; mawk is broken so we don't like that.
  1595. dnl
  1596. AC_DEFUN([PHP_PROG_AWK], [
  1597. AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
  1598. case "$AWK" in
  1599. *mawk)
  1600. AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
  1601. ;;
  1602. *gawk)
  1603. ;;
  1604. bork)
  1605. AC_MSG_ERROR([Could not find awk; Install GNU awk])
  1606. ;;
  1607. *)
  1608. AC_MSG_CHECKING([if $AWK is broken])
  1609. if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
  1610. AC_MSG_RESULT([yes])
  1611. AC_MSG_ERROR([You should install GNU awk])
  1612. else
  1613. AC_MSG_RESULT([no])
  1614. fi
  1615. ;;
  1616. esac
  1617. PHP_SUBST(AWK)
  1618. ])
  1619. dnl
  1620. dnl PHP_PROG_BISON([MIN-VERSION], [EXCLUDED-VERSION...])
  1621. dnl
  1622. dnl Search for bison and optionally check if version is at least the minimum
  1623. dnl required version MIN-VERSION and doesn't match any of the blank separated
  1624. dnl list of excluded versions EXCLUDED-VERSION (for example "3.0 3.2").
  1625. dnl
  1626. AC_DEFUN([PHP_PROG_BISON], [
  1627. AC_CHECK_PROG(YACC, bison, bison)
  1628. ifelse($1,,php_bison_required_version='',php_bison_required_version="$1")
  1629. ifelse($2,,php_bison_excluded_versions='none',php_bison_excluded_versions="$2")
  1630. if test -n "$YACC"; then
  1631. AC_MSG_CHECKING([for bison version])
  1632. php_bison_version=$($YACC --version 2> /dev/null | grep 'GNU Bison' | cut -d ' ' -f 4 | tr -d a-z)
  1633. if test -z "$php_bison_version"; then
  1634. php_bison_version=0.0.0
  1635. fi
  1636. ac_IFS=$IFS; IFS="."
  1637. set $php_bison_version
  1638. IFS=$ac_IFS
  1639. php_bison_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
  1640. php_bison_branch="[$]1.[$]2"
  1641. php_bison_check=ok
  1642. if test -z "$php_bison_required_version" && test -z "$php_bison_num"; then
  1643. php_bison_check=invalid
  1644. elif test -n "$php_bison_required_version"; then
  1645. ac_IFS=$IFS; IFS="."
  1646. set $php_bison_required_version
  1647. IFS=$ac_IFS
  1648. php_bison_required_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
  1649. php_bison_required_version="$php_bison_required_version or later"
  1650. if test -z "$php_bison_num" || test "$php_bison_num" -lt "$php_bison_required_num"; then
  1651. php_bison_check=invalid
  1652. fi
  1653. fi
  1654. for php_bison_check_version in $php_bison_excluded_versions; do
  1655. if test "$php_bison_version" = "$php_bison_check_version" || test "$php_bison_branch" = "$php_bison_check_version"; then
  1656. php_bison_check=invalid
  1657. break
  1658. fi
  1659. done
  1660. if test "$php_bison_check" != "invalid"; then
  1661. PHP_SUBST_OLD([YFLAGS], [-Wall])
  1662. AC_MSG_RESULT([$php_bison_version (ok)])
  1663. else
  1664. AC_MSG_RESULT([$php_bison_version])
  1665. fi
  1666. fi
  1667. case $php_bison_check in
  1668. ""|invalid[)]
  1669. if test ! -f "$abs_srcdir/Zend/zend_language_parser.h" || test ! -f "$abs_srcdir/Zend/zend_language_parser.c"; then
  1670. AC_MSG_ERROR([bison $php_bison_required_version is required to generate PHP parsers (excluded versions: $php_bison_excluded_versions).])
  1671. fi
  1672. YACC="exit 0;"
  1673. ;;
  1674. esac
  1675. PHP_SUBST(YACC)
  1676. ])
  1677. dnl
  1678. dnl PHP_PROG_RE2C([MIN-VERSION])
  1679. dnl
  1680. dnl Search for the re2c and optionally check if version is at least the minimum
  1681. dnl required version MIN-VERSION.
  1682. dnl
  1683. AC_DEFUN([PHP_PROG_RE2C],[
  1684. AC_CHECK_PROG(RE2C, re2c, re2c)
  1685. ifelse($1,,php_re2c_required_version='',php_re2c_required_version="$1")
  1686. if test -n "$RE2C"; then
  1687. AC_MSG_CHECKING([for re2c version])
  1688. php_re2c_version=$($RE2C --version | cut -d ' ' -f 2 2>/dev/null)
  1689. if test -z "$php_re2c_version"; then
  1690. php_re2c_version=0.0.0
  1691. fi
  1692. ac_IFS=$IFS; IFS="."
  1693. set $php_re2c_version
  1694. IFS=$ac_IFS
  1695. php_re2c_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
  1696. php_re2c_check=ok
  1697. if test -z "$php_re2c_required_version" && test -z "$php_re2c_num"; then
  1698. php_re2c_check=invalid
  1699. elif test -n "$php_re2c_required_version"; then
  1700. ac_IFS=$IFS; IFS="."
  1701. set $php_re2c_required_version
  1702. IFS=$ac_IFS
  1703. php_re2c_required_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
  1704. php_re2c_required_version="$php_re2c_required_version or later"
  1705. if test -z "$php_re2c_num" || test "$php_re2c_num" -lt "$php_re2c_required_num"; then
  1706. php_re2c_check=invalid
  1707. fi
  1708. fi
  1709. if test "$php_re2c_check" != "invalid"; then
  1710. AC_MSG_RESULT([$php_re2c_version (ok)])
  1711. else
  1712. AC_MSG_RESULT([$php_re2c_version])
  1713. fi
  1714. fi
  1715. case $php_re2c_check in
  1716. ""|invalid[)]
  1717. if test ! -f "$abs_srcdir/Zend/zend_language_scanner.c"; then
  1718. AC_MSG_ERROR([re2c $php_re2c_required_version is required to generate PHP lexers.])
  1719. fi
  1720. RE2C="exit 0;"
  1721. ;;
  1722. esac
  1723. PHP_SUBST(RE2C)
  1724. ])
  1725. AC_DEFUN([PHP_PROG_PHP],[
  1726. AC_CHECK_PROG(PHP, php, php)
  1727. if test -n "$PHP"; then
  1728. AC_MSG_CHECKING([for php version])
  1729. php_version=$($PHP -v | head -n1 | cut -d ' ' -f 2)
  1730. if test -z "$php_version"; then
  1731. php_version=0.0.0
  1732. fi
  1733. ac_IFS=$IFS; IFS="."
  1734. set $php_version
  1735. IFS=$ac_IFS
  1736. php_version_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
  1737. dnl Minimum supported version for gen_stubs.php is PHP 7.1.
  1738. if test "$php_version_num" -lt 70100; then
  1739. AC_MSG_RESULT([$php_version (too old)])
  1740. unset PHP
  1741. else
  1742. AC_MSG_RESULT([$php_version (ok)])
  1743. fi
  1744. fi
  1745. PHP_SUBST(PHP)
  1746. ])
  1747. dnl ----------------------------------------------------------------------------
  1748. dnl Common setup macros: PHP_SETUP_<what>
  1749. dnl ----------------------------------------------------------------------------
  1750. dnl
  1751. dnl PHP_SETUP_ICU([shared-add])
  1752. dnl
  1753. dnl Common setup macro for ICU.
  1754. dnl
  1755. AC_DEFUN([PHP_SETUP_ICU],[
  1756. PKG_CHECK_MODULES([ICU], [icu-uc >= 50.1 icu-io icu-i18n])
  1757. PHP_EVAL_INCLINE($ICU_CFLAGS)
  1758. PHP_EVAL_LIBLINE($ICU_LIBS, $1)
  1759. ICU_CFLAGS="$ICU_CFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
  1760. ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
  1761. if test "$PKG_CONFIG icu-io --atleast-version=60"; then
  1762. ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"
  1763. fi
  1764. ])
  1765. dnl
  1766. dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
  1767. dnl
  1768. dnl Common setup macro for openssl.
  1769. dnl
  1770. AC_DEFUN([PHP_SETUP_OPENSSL],[
  1771. found_openssl=no
  1772. PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.2], [found_openssl=yes])
  1773. if test "$found_openssl" = "yes"; then
  1774. PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
  1775. PHP_EVAL_INCLINE($OPENSSL_CFLAGS)
  1776. ifelse([$2],[],:,[$2])
  1777. ifelse([$3],[],,[else $3])
  1778. fi
  1779. ])
  1780. dnl
  1781. dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
  1782. dnl
  1783. dnl Common setup macro for iconv.
  1784. dnl
  1785. AC_DEFUN([PHP_SETUP_ICONV], [
  1786. found_iconv=no
  1787. unset ICONV_DIR
  1788. dnl Check libc first if no path is provided in --with-iconv.
  1789. if test "$PHP_ICONV" = "yes"; then
  1790. dnl Reset LIBS temporarily as it may have already been included -liconv in.
  1791. LIBS_save="$LIBS"
  1792. LIBS=
  1793. AC_CHECK_FUNC(iconv, [
  1794. found_iconv=yes
  1795. ],[
  1796. AC_CHECK_FUNC(libiconv,[
  1797. AC_DEFINE(HAVE_LIBICONV, 1, [ ])
  1798. found_iconv=yes
  1799. ])
  1800. ])
  1801. LIBS="$LIBS_save"
  1802. fi
  1803. dnl Check external libs for iconv funcs.
  1804. if test "$found_iconv" = "no"; then
  1805. for i in $PHP_ICONV /usr/local /usr; do
  1806. if test -r $i/include/gnu-libiconv/iconv.h; then
  1807. ICONV_DIR=$i
  1808. ICONV_INCLUDE_DIR=$i/include/gnu-libiconv
  1809. iconv_lib_name=iconv
  1810. break
  1811. elif test -r $i/include/iconv.h; then
  1812. ICONV_DIR=$i
  1813. ICONV_INCLUDE_DIR=$i/include
  1814. iconv_lib_name=iconv
  1815. break
  1816. fi
  1817. done
  1818. if test -z "$ICONV_DIR"; then
  1819. AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
  1820. fi
  1821. if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
  1822. test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME ||
  1823. test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.tbd
  1824. then
  1825. PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
  1826. found_iconv=yes
  1827. AC_DEFINE(HAVE_LIBICONV,1,[ ])
  1828. AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv])
  1829. ], [
  1830. PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
  1831. found_iconv=yes
  1832. ], [], [
  1833. -L$ICONV_DIR/$PHP_LIBDIR
  1834. ])
  1835. ], [
  1836. -L$ICONV_DIR/$PHP_LIBDIR
  1837. ])
  1838. fi
  1839. fi
  1840. if test "$found_iconv" = "yes"; then
  1841. AC_DEFINE(HAVE_ICONV,1,[ ])
  1842. if test -n "$ICONV_DIR"; then
  1843. PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1)
  1844. PHP_ADD_INCLUDE($ICONV_INCLUDE_DIR)
  1845. fi
  1846. $2
  1847. ifelse([$3],[],,[else $3])
  1848. fi
  1849. ])
  1850. dnl
  1851. dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
  1852. dnl
  1853. dnl Common setup macro for libxml.
  1854. dnl
  1855. AC_DEFUN([PHP_SETUP_LIBXML], [
  1856. PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.9.0])
  1857. PHP_EVAL_INCLINE($LIBXML_CFLAGS)
  1858. PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
  1859. AC_DEFINE(HAVE_LIBXML, 1, [ ])
  1860. $2
  1861. ])
  1862. dnl
  1863. dnl PHP_SETUP_EXPAT([shared-add])
  1864. dnl
  1865. dnl Common setup macro for expat.
  1866. dnl
  1867. AC_DEFUN([PHP_SETUP_EXPAT], [
  1868. PKG_CHECK_MODULES([EXPAT], [expat])
  1869. PHP_EVAL_INCLINE($EXPAT_CFLAGS)
  1870. PHP_EVAL_LIBLINE($EXPAT_LIBS, $1)
  1871. AC_DEFINE(HAVE_LIBEXPAT, 1, [ ])
  1872. ])
  1873. dnl ----------------------------------------------------------------------------
  1874. dnl Misc. macros
  1875. dnl ----------------------------------------------------------------------------
  1876. dnl
  1877. dnl PHP_INSTALL_HEADERS(path [, file ...])
  1878. dnl
  1879. dnl PHP header files to be installed.
  1880. dnl
  1881. AC_DEFUN([PHP_INSTALL_HEADERS],[
  1882. ifelse([$2],[],[
  1883. for header_file in $1; do
  1884. PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
  1885. INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
  1886. ])
  1887. done
  1888. ], [
  1889. header_path=$1
  1890. for header_file in $2; do
  1891. hp_hf="$header_path/$header_file"
  1892. PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
  1893. INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
  1894. ])
  1895. done
  1896. ])
  1897. ])
  1898. dnl
  1899. dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
  1900. dnl
  1901. dnl This macro is used to get a comparable version for Apache.
  1902. dnl
  1903. AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
  1904. ac_output=`$1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
  1905. ac_IFS=$IFS
  1906. IFS="- /.
  1907. "
  1908. set $ac_output
  1909. IFS=$ac_IFS
  1910. APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
  1911. ])
  1912. dnl
  1913. dnl PHP_CONFIG_NICE(filename)
  1914. dnl
  1915. dnl This macro creates script file with given filename which includes the last
  1916. dnl configure command run by user. This file is named 'config.nice' in PHP.
  1917. dnl
  1918. AC_DEFUN([PHP_CONFIG_NICE],[
  1919. AC_REQUIRE([AC_PROG_EGREP])
  1920. AC_REQUIRE([AC_PROG_SED])
  1921. PHP_SUBST_OLD(EGREP)
  1922. PHP_SUBST_OLD(SED)
  1923. test -f $1 && mv $1 $1.old
  1924. rm -f $1.old
  1925. cat >$1<<EOF
  1926. #! /bin/sh
  1927. #
  1928. # Created by configure
  1929. EOF
  1930. clean_configure_args=$ac_configure_args
  1931. for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do
  1932. eval val=\$$var
  1933. if test -n "$val"; then
  1934. echo "$var='$val' \\" >> $1
  1935. if test `expr "X$ac_configure_args" : ".*${var}.*"` != 0; then
  1936. clean_configure_args=$(echo $clean_configure_args | sed -e "s#'$var=$val'##")
  1937. fi
  1938. fi
  1939. done
  1940. echo "'[$]0' \\" >> $1
  1941. if test `expr " [$]0" : " '.*"` = 0; then
  1942. CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
  1943. else
  1944. CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
  1945. fi
  1946. CONFIGURE_ARGS="$clean_configure_args"
  1947. while test "X$CONFIGURE_ARGS" != "X";
  1948. do
  1949. if CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\('[[^']]*'\)"`
  1950. then
  1951. CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *'[[^']]*' \(.*\)"`
  1952. elif CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\([[^ ]]*\)"`
  1953. then
  1954. CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *[[^ ]]* \(.*\)"`
  1955. CURRENT_ARG="'$CURRENT_ARG'"
  1956. else
  1957. break
  1958. fi
  1959. $as_echo "$CURRENT_ARG \\" >>$1
  1960. CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $CURRENT_ARG"
  1961. done
  1962. echo '"[$]@"' >> $1
  1963. chmod +x $1
  1964. CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS"
  1965. PHP_SUBST_OLD(CONFIGURE_COMMAND)
  1966. PHP_SUBST_OLD(CONFIGURE_OPTIONS)
  1967. ])
  1968. dnl
  1969. dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]])
  1970. dnl
  1971. AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[
  1972. AC_CACHE_CHECK([for PDO includes], pdo_cv_inc_path, [
  1973. if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
  1974. pdo_cv_inc_path=$abs_srcdir/ext
  1975. elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
  1976. pdo_cv_inc_path=$abs_srcdir/ext
  1977. elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then
  1978. pdo_cv_inc_path=$phpincludedir/ext
  1979. fi
  1980. ])
  1981. if test -n "$pdo_cv_inc_path"; then
  1982. ifelse([$1],[],:,[$1])
  1983. else
  1984. ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2])
  1985. fi
  1986. ])
  1987. dnl
  1988. dnl PHP_DETECT_ICC
  1989. dnl
  1990. dnl Detect Intel C++ Compiler and unset $GCC if ICC found.
  1991. dnl
  1992. AC_DEFUN([PHP_DETECT_ICC],
  1993. [
  1994. ICC="no"
  1995. AC_MSG_CHECKING([for icc])
  1996. AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
  1997. ICC="no"
  1998. AC_MSG_RESULT([no]),
  1999. ICC="yes"
  2000. GCC="no"
  2001. AC_MSG_RESULT([yes])
  2002. )
  2003. ])
  2004. dnl
  2005. dnl PHP_DETECT_SUNCC
  2006. dnl
  2007. dnl Detect if the systems default compiler is suncc. We also set some useful
  2008. dnl CFLAGS if the user didn't set any.
  2009. dnl
  2010. AC_DEFUN([PHP_DETECT_SUNCC],[
  2011. SUNCC="no"
  2012. AC_MSG_CHECKING([for suncc])
  2013. AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C],
  2014. SUNCC="no"
  2015. AC_MSG_RESULT([no]),
  2016. SUNCC="yes"
  2017. GCC="no"
  2018. test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
  2019. GCC=""
  2020. AC_MSG_RESULT([yes])
  2021. )
  2022. ])
  2023. dnl
  2024. dnl PHP_CRYPT_R_STYLE
  2025. dnl
  2026. dnl Detect the style of crypt_r() if any is available.
  2027. dnl See APR_CHECK_CRYPT_R_STYLE() for original version.
  2028. dnl
  2029. AC_DEFUN([PHP_CRYPT_R_STYLE],
  2030. [
  2031. AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
  2032. php_cv_crypt_r_style=none
  2033. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2034. #define _REENTRANT 1
  2035. #include <crypt.h>
  2036. ]], [[
  2037. CRYPTD buffer;
  2038. crypt_r("passwd", "hash", &buffer);
  2039. ]])],[php_cv_crypt_r_style=cryptd],[])
  2040. if test "$php_cv_crypt_r_style" = "none"; then
  2041. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2042. #define _REENTRANT 1
  2043. #include <crypt.h>
  2044. ]],[[
  2045. struct crypt_data buffer;
  2046. crypt_r("passwd", "hash", &buffer);
  2047. ]])],[php_cv_crypt_r_style=struct_crypt_data],[])
  2048. fi
  2049. if test "$php_cv_crypt_r_style" = "none"; then
  2050. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2051. #define _REENTRANT 1
  2052. #define _GNU_SOURCE
  2053. #include <crypt.h>
  2054. ]],[[
  2055. struct crypt_data buffer;
  2056. crypt_r("passwd", "hash", &buffer);
  2057. ]])],[php_cv_crypt_r_style=struct_crypt_data_gnu_source],[])
  2058. fi
  2059. if test "$php_cv_crypt_r_style" = "none"; then
  2060. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2061. #include <stdlib.h>
  2062. #include <unistd.h>
  2063. ]],[[
  2064. struct crypt_data buffer;
  2065. crypt_r("passwd", "hash", &buffer);
  2066. ]])],[php_cv_crypt_r_style=struct_crypt_data],[])
  2067. fi
  2068. ])
  2069. if test "$php_cv_crypt_r_style" = "cryptd"; then
  2070. AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
  2071. fi
  2072. if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
  2073. AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
  2074. fi
  2075. if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
  2076. AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
  2077. fi
  2078. if test "$php_cv_crypt_r_style" = "none"; then
  2079. AC_MSG_ERROR([Unable to detect data struct used by crypt_r])
  2080. fi
  2081. ])
  2082. dnl
  2083. dnl PHP_TEST_WRITE_STDOUT
  2084. dnl
  2085. AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
  2086. AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
  2087. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  2088. #ifdef HAVE_UNISTD_H
  2089. #include <unistd.h>
  2090. #endif
  2091. #define TEXT "This is the test message -- "
  2092. int main()
  2093. {
  2094. int n;
  2095. n = write(1, TEXT, sizeof(TEXT)-1);
  2096. return (!(n == sizeof(TEXT)-1));
  2097. }
  2098. ]])],[
  2099. ac_cv_write_stdout=yes
  2100. ],[
  2101. ac_cv_write_stdout=no
  2102. ],[
  2103. case $host_alias in
  2104. *linux*)
  2105. ac_cv_write_stdout=yes
  2106. ;;
  2107. *)
  2108. ac_cv_write_stdout=no
  2109. ;;
  2110. esac
  2111. ])
  2112. ])
  2113. if test "$ac_cv_write_stdout" = "yes"; then
  2114. AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
  2115. fi
  2116. ])
  2117. dnl
  2118. dnl PHP_INIT_DTRACE(providerdesc, header-file, sources [, module])
  2119. dnl
  2120. AC_DEFUN([PHP_INIT_DTRACE],[
  2121. dnl Set paths properly when called from extension.
  2122. case "$4" in
  2123. ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir;;
  2124. /*[)] ac_srcdir=`echo "$4"|cut -c 2-`"/"; ac_bdir=$ac_srcdir;;
  2125. *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$4/";;
  2126. esac
  2127. dnl providerdesc.
  2128. ac_provsrc=$1
  2129. old_IFS=[$]IFS
  2130. IFS=.
  2131. set $ac_provsrc
  2132. ac_provobj=[$]1
  2133. IFS=$old_IFS
  2134. dnl header-file.
  2135. ac_hdrobj=$2
  2136. dnl Add providerdesc.o or .lo into global objects when needed.
  2137. case $host_alias in
  2138. *freebsd*)
  2139. PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo"
  2140. PHP_LDFLAGS="$PHP_LDFLAGS -lelf"
  2141. ;;
  2142. *solaris*)
  2143. PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo"
  2144. ;;
  2145. *linux*)
  2146. PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo"
  2147. ;;
  2148. esac
  2149. dnl DTrace objects.
  2150. old_IFS=[$]IFS
  2151. for ac_src in $3; do
  2152. IFS=.
  2153. set $ac_src
  2154. ac_obj=[$]1
  2155. IFS=$old_IFS
  2156. PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo"
  2157. done;
  2158. case [$]php_sapi_module in
  2159. shared[)]
  2160. for ac_lo in $PHP_DTRACE_OBJS; do
  2161. dtrace_objs="[$]dtrace_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`"
  2162. done;
  2163. ;;
  2164. *[)]
  2165. dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
  2166. ;;
  2167. esac
  2168. dnl Generate Makefile.objects entries. The empty $ac_provsrc command stops an
  2169. dnl implicit circular dependency in GNU Make which causes the .d file to be
  2170. dnl overwritten (Bug 61268).
  2171. cat>>Makefile.objects<<EOF
  2172. $abs_srcdir/$ac_provsrc:;
  2173. $ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc
  2174. CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
  2175. \$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
  2176. EOF
  2177. case $host_alias in
  2178. *solaris*|*linux*|*freebsd*)
  2179. dtrace_prov_name="`echo $ac_provsrc | $SED -e 's#\(.*\)\/##'`.o"
  2180. dtrace_lib_dir="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/[^/]*#\1#'`/.libs"
  2181. dtrace_d_obj="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/\([^/]*\)#\1/.libs/\2#'`.o"
  2182. dtrace_nolib_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
  2183. for ac_lo in $PHP_DTRACE_OBJS; do
  2184. dtrace_lib_objs="[$]dtrace_lib_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`"
  2185. done;
  2186. dnl Always attempt to create both PIC and non-PIC DTrace objects (Bug 63692)
  2187. cat>>Makefile.objects<<EOF
  2188. $ac_bdir[$]ac_provsrc.lo: \$(PHP_DTRACE_OBJS)
  2189. echo "[#] Generated by Makefile for libtool" > \$[]@
  2190. @test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir
  2191. if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $dtrace_d_obj -s $abs_srcdir/$ac_provsrc $dtrace_lib_objs 2> /dev/null && test -f "$dtrace_d_obj"; then [\\]
  2192. echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
  2193. else [\\]
  2194. echo "pic_object='none'" >> \$[]@ [;\\]
  2195. fi
  2196. if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $ac_bdir[$]ac_provsrc.o -s $abs_srcdir/$ac_provsrc $dtrace_nolib_objs 2> /dev/null && test -f "$ac_bdir[$]ac_provsrc.o"; then [\\]
  2197. echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\]
  2198. else [\\]
  2199. echo "non_pic_object='none'" >> \$[]@ [;\\]
  2200. fi
  2201. EOF
  2202. ;;
  2203. *)
  2204. cat>>Makefile.objects<<EOF
  2205. $ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS)
  2206. CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
  2207. EOF
  2208. ;;
  2209. esac
  2210. ])
  2211. dnl
  2212. dnl PHP_CHECK_STDINT_TYPES
  2213. dnl
  2214. AC_DEFUN([PHP_CHECK_STDINT_TYPES], [
  2215. AC_CHECK_SIZEOF([short])
  2216. AC_CHECK_SIZEOF([int])
  2217. AC_CHECK_SIZEOF([long])
  2218. AC_CHECK_SIZEOF([long long])
  2219. AC_CHECK_SIZEOF([size_t])
  2220. AC_CHECK_SIZEOF([off_t])
  2221. AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t], [], [
  2222. AC_MSG_ERROR([One of the intN_t or uintN_t types is not available])
  2223. ], [
  2224. #include <stdint.h>
  2225. #if HAVE_SYS_TYPES_H
  2226. # include <sys/types.h>
  2227. #endif
  2228. ])
  2229. ])
  2230. dnl
  2231. dnl PHP_CHECK_BUILTIN_EXPECT
  2232. dnl
  2233. AC_DEFUN([PHP_CHECK_BUILTIN_EXPECT], [
  2234. AC_MSG_CHECKING([for __builtin_expect])
  2235. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2236. return __builtin_expect(1,1) ? 1 : 0;
  2237. ]])], [
  2238. have_builtin_expect=1
  2239. AC_MSG_RESULT([yes])
  2240. ], [
  2241. have_builtin_expect=0
  2242. AC_MSG_RESULT([no])
  2243. ])
  2244. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_EXPECT], [$have_builtin_expect], [Whether the compiler supports __builtin_expect])
  2245. ])
  2246. dnl
  2247. dnl PHP_CHECK_BUILTIN_CLZ
  2248. dnl
  2249. AC_DEFUN([PHP_CHECK_BUILTIN_CLZ], [
  2250. AC_MSG_CHECKING([for __builtin_clz])
  2251. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2252. return __builtin_clz(1) ? 1 : 0;
  2253. ]])], [
  2254. have_builtin_clz=1
  2255. AC_MSG_RESULT([yes])
  2256. ], [
  2257. have_builtin_clz=0
  2258. AC_MSG_RESULT([no])
  2259. ])
  2260. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZ], [$have_builtin_clz], [Whether the compiler supports __builtin_clz])
  2261. ])
  2262. dnl
  2263. dnl PHP_CHECK_BUILTIN_CLZL
  2264. dnl
  2265. AC_DEFUN([PHP_CHECK_BUILTIN_CLZL], [
  2266. AC_MSG_CHECKING([for __builtin_clzl])
  2267. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2268. return __builtin_clzl(1) ? 1 : 0;
  2269. ]])], [
  2270. have_builtin_clzl=1
  2271. AC_MSG_RESULT([yes])
  2272. ], [
  2273. have_builtin_clzl=0
  2274. AC_MSG_RESULT([no])
  2275. ])
  2276. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZL], [$have_builtin_clzl], [Whether the compiler supports __builtin_clzl])
  2277. ])
  2278. dnl
  2279. dnl PHP_CHECK_BUILTIN_CLZLL
  2280. dnl
  2281. AC_DEFUN([PHP_CHECK_BUILTIN_CLZLL], [
  2282. AC_MSG_CHECKING([for __builtin_clzll])
  2283. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2284. return __builtin_clzll(1) ? 1 : 0;
  2285. ]])], [
  2286. have_builtin_clzll=1
  2287. AC_MSG_RESULT([yes])
  2288. ], [
  2289. have_builtin_clzll=0
  2290. AC_MSG_RESULT([no])
  2291. ])
  2292. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZLL], [$have_builtin_clzll], [Whether the compiler supports __builtin_clzll])
  2293. ])
  2294. dnl
  2295. dnl PHP_CHECK_BUILTIN_CTZL
  2296. dnl
  2297. AC_DEFUN([PHP_CHECK_BUILTIN_CTZL], [
  2298. AC_MSG_CHECKING([for __builtin_ctzl])
  2299. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2300. return __builtin_ctzl(2L) ? 1 : 0;
  2301. ]])], [
  2302. have_builtin_ctzl=1
  2303. AC_MSG_RESULT([yes])
  2304. ], [
  2305. have_builtin_ctzl=0
  2306. AC_MSG_RESULT([no])
  2307. ])
  2308. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZL], [$have_builtin_ctzl], [Whether the compiler supports __builtin_ctzl])
  2309. ])
  2310. dnl
  2311. dnl PHP_CHECK_BUILTIN_CTZLL
  2312. dnl
  2313. AC_DEFUN([PHP_CHECK_BUILTIN_CTZLL], [
  2314. AC_MSG_CHECKING([for __builtin_ctzll])
  2315. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2316. return __builtin_ctzll(2LL) ? 1 : 0;
  2317. ]])], [
  2318. have_builtin_ctzll=1
  2319. AC_MSG_RESULT([yes])
  2320. ], [
  2321. have_builtin_ctzll=0
  2322. AC_MSG_RESULT([no])
  2323. ])
  2324. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZLL], [$have_builtin_ctzll], [Whether the compiler supports __builtin_ctzll])
  2325. ])
  2326. dnl
  2327. dnl PHP_CHECK_BUILTIN_SMULL_OVERFLOW
  2328. dnl
  2329. AC_DEFUN([PHP_CHECK_BUILTIN_SMULL_OVERFLOW], [
  2330. AC_MSG_CHECKING([for __builtin_smull_overflow])
  2331. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2332. long tmpvar;
  2333. return __builtin_smull_overflow(3, 7, &tmpvar);
  2334. ]])], [
  2335. have_builtin_smull_overflow=1
  2336. AC_MSG_RESULT([yes])
  2337. ], [
  2338. have_builtin_smull_overflow=0
  2339. AC_MSG_RESULT([no])
  2340. ])
  2341. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULL_OVERFLOW],
  2342. [$have_builtin_smull_overflow], [Whether the compiler supports __builtin_smull_overflow])
  2343. ])
  2344. dnl
  2345. dnl PHP_CHECK_BUILTIN_SMULLL_OVERFLOW
  2346. dnl
  2347. AC_DEFUN([PHP_CHECK_BUILTIN_SMULLL_OVERFLOW], [
  2348. AC_MSG_CHECKING([for __builtin_smulll_overflow])
  2349. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2350. long long tmpvar;
  2351. return __builtin_smulll_overflow(3, 7, &tmpvar);
  2352. ]])], [
  2353. have_builtin_smulll_overflow=1
  2354. AC_MSG_RESULT([yes])
  2355. ], [
  2356. have_builtin_smulll_overflow=0
  2357. AC_MSG_RESULT([no])
  2358. ])
  2359. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULLL_OVERFLOW],
  2360. [$have_builtin_smulll_overflow], [Whether the compiler supports __builtin_smulll_overflow])
  2361. ])
  2362. dnl
  2363. dnl PHP_CHECK_BUILTIN_SADDL_OVERFLOW
  2364. dnl
  2365. AC_DEFUN([PHP_CHECK_BUILTIN_SADDL_OVERFLOW], [
  2366. AC_MSG_CHECKING([for __builtin_saddl_overflow])
  2367. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2368. long tmpvar;
  2369. return __builtin_saddl_overflow(3, 7, &tmpvar);
  2370. ]])], [
  2371. have_builtin_saddl_overflow=1
  2372. AC_MSG_RESULT([yes])
  2373. ], [
  2374. have_builtin_saddl_overflow=0
  2375. AC_MSG_RESULT([no])
  2376. ])
  2377. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDL_OVERFLOW],
  2378. [$have_builtin_saddl_overflow], [Whether the compiler supports __builtin_saddl_overflow])
  2379. ])
  2380. dnl
  2381. dnl PHP_CHECK_BUILTIN_SADDLL_OVERFLOW
  2382. dnl
  2383. AC_DEFUN([PHP_CHECK_BUILTIN_SADDLL_OVERFLOW], [
  2384. AC_MSG_CHECKING([for __builtin_saddll_overflow])
  2385. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2386. long long tmpvar;
  2387. return __builtin_saddll_overflow(3, 7, &tmpvar);
  2388. ]])], [
  2389. have_builtin_saddll_overflow=1
  2390. AC_MSG_RESULT([yes])
  2391. ], [
  2392. have_builtin_saddll_overflow=0
  2393. AC_MSG_RESULT([no])
  2394. ])
  2395. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDLL_OVERFLOW],
  2396. [$have_builtin_saddll_overflow], [Whether the compiler supports __builtin_saddll_overflow])
  2397. ])
  2398. dnl
  2399. dnl PHP_CHECK_BUILTIN_SSUBL_OVERFLOW
  2400. dnl
  2401. AC_DEFUN([PHP_CHECK_BUILTIN_SSUBL_OVERFLOW], [
  2402. AC_MSG_CHECKING([for __builtin_ssubl_overflow])
  2403. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2404. long tmpvar;
  2405. return __builtin_ssubl_overflow(3, 7, &tmpvar);
  2406. ]])], [
  2407. have_builtin_ssubl_overflow=1
  2408. AC_MSG_RESULT([yes])
  2409. ], [
  2410. have_builtin_ssubl_overflow=0
  2411. AC_MSG_RESULT([no])
  2412. ])
  2413. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBL_OVERFLOW],
  2414. [$have_builtin_ssubl_overflow], [Whether the compiler supports __builtin_ssubl_overflow])
  2415. ])
  2416. dnl
  2417. dnl PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW
  2418. dnl
  2419. AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [
  2420. AC_MSG_CHECKING([for __builtin_ssubll_overflow])
  2421. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2422. long long tmpvar;
  2423. return __builtin_ssubll_overflow(3, 7, &tmpvar);
  2424. ]])], [
  2425. have_builtin_ssubll_overflow=1
  2426. AC_MSG_RESULT([yes])
  2427. ], [
  2428. have_builtin_ssubll_overflow=0
  2429. AC_MSG_RESULT([no])
  2430. ])
  2431. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW],
  2432. [$have_builtin_ssubll_overflow], [Whether the compiler supports __builtin_ssubll_overflow])
  2433. ])
  2434. dnl
  2435. dnl PHP_CHECK_BUILTIN_CPU_INIT
  2436. dnl
  2437. AC_DEFUN([PHP_CHECK_BUILTIN_CPU_INIT], [
  2438. AC_MSG_CHECKING([for __builtin_cpu_init])
  2439. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2440. return __builtin_cpu_init()? 1 : 0;
  2441. ]])], [
  2442. have_builtin_cpu_init=1
  2443. AC_MSG_RESULT([yes])
  2444. ], [
  2445. have_builtin_cpu_init=0
  2446. AC_MSG_RESULT([no])
  2447. ])
  2448. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_INIT],
  2449. [$have_builtin_cpu_init], [Whether the compiler supports __builtin_cpu_init])
  2450. ])
  2451. dnl
  2452. dnl PHP_CHECK_BUILTIN_CPU_SUPPORTS
  2453. dnl
  2454. AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [
  2455. AC_MSG_CHECKING([for __builtin_cpu_supports])
  2456. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2457. return __builtin_cpu_supports("sse")? 1 : 0;
  2458. ]])], [
  2459. have_builtin_cpu_supports=1
  2460. AC_MSG_RESULT([yes])
  2461. ], [
  2462. have_builtin_cpu_supports=0
  2463. AC_MSG_RESULT([no])
  2464. ])
  2465. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_SUPPORTS],
  2466. [$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports])
  2467. ])
  2468. dnl
  2469. dnl PHP_PATCH_CONFIG_HEADERS([FILE])
  2470. dnl
  2471. dnl PACKAGE_* symbols are automatically defined by Autoconf. When including
  2472. dnl configuration header, warnings about redefined symbols are emitted for such
  2473. dnl symbols if they are defined by multiple libraries. This disables all
  2474. dnl PACKAGE_* symbols in the generated configuration header template FILE. For
  2475. dnl example, main/php_config.h.in for PHP or config.h.in for PHP extensions.
  2476. dnl
  2477. AC_DEFUN([PHP_PATCH_CONFIG_HEADERS], [
  2478. AC_MSG_NOTICE([patching $1])
  2479. $SED -e 's/^#undef PACKAGE_[^ ]*/\/\* & \*\//g' < $srcdir/$1 \
  2480. > $srcdir/$1.tmp && mv $srcdir/$1.tmp $srcdir/$1
  2481. ])