acinclude.m4 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327
  1. dnl
  2. dnl This file contains local autoconf functions.
  3. dnl
  4. dnl -------------------------------------------------------------------------
  5. dnl Output stylize macros for configure (help/runtime)
  6. dnl -------------------------------------------------------------------------
  7. dnl
  8. dnl PHP_HELP_SEPARATOR(title)
  9. dnl
  10. dnl Adds separator title into the configure --help display.
  11. dnl
  12. AC_DEFUN([PHP_HELP_SEPARATOR],[
  13. AC_ARG_ENABLE([],[
  14. $1
  15. ],[])
  16. ])
  17. dnl
  18. dnl PHP_CONFIGURE_PART(title)
  19. dnl
  20. dnl Adds separator title configure output (idea borrowed from mm)
  21. dnl
  22. AC_DEFUN([PHP_CONFIGURE_PART],[
  23. AC_MSG_RESULT()
  24. AC_MSG_RESULT([${T_MD}$1${T_ME}])
  25. ])
  26. dnl -------------------------------------------------------------------------
  27. dnl Build system helper macros
  28. dnl -------------------------------------------------------------------------
  29. dnl
  30. dnl PHP_DEF_HAVE(what)
  31. dnl
  32. dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'
  33. dnl
  34. AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])])
  35. dnl
  36. dnl PHP_RUN_ONCE(namespace, variable, code)
  37. dnl
  38. dnl execute code, if variable is not set in namespace
  39. dnl
  40. AC_DEFUN([PHP_RUN_ONCE],[
  41. changequote({,})
  42. unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'`
  43. changequote([,])
  44. cmd="echo $ac_n \"\$$1$unique$ac_c\""
  45. if test -n "$unique" && test "`eval $cmd`" = "" ; then
  46. eval "$1$unique=set"
  47. $3
  48. fi
  49. ])
  50. dnl
  51. dnl PHP_EXPAND_PATH(path, variable)
  52. dnl
  53. dnl expands path to an absolute path and assigns it to variable
  54. dnl
  55. AC_DEFUN([PHP_EXPAND_PATH],[
  56. if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  57. $2=$1
  58. else
  59. changequote({,})
  60. ep_dir=`echo $1|$SED 's%/*[^/][^/]*/*$%%'`
  61. changequote([,])
  62. ep_realdir=`(cd "$ep_dir" && pwd)`
  63. $2="$ep_realdir"/`basename "$1"`
  64. fi
  65. ])
  66. dnl
  67. dnl PHP_DEFINE(WHAT [, value[, directory]])
  68. dnl
  69. dnl Creates builddir/include/what.h and in there #define WHAT value
  70. dnl
  71. AC_DEFUN([PHP_DEFINE],[
  72. [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h]
  73. ])
  74. dnl
  75. dnl PHP_SUBST(varname)
  76. dnl
  77. dnl Adds variable with it's value into Makefile, e.g.:
  78. dnl CC = gcc
  79. dnl
  80. AC_DEFUN([PHP_SUBST],[
  81. PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
  82. ])
  83. dnl
  84. dnl PHP_SUBST_OLD(varname)
  85. dnl
  86. dnl Same as PHP_SUBST() but also substitutes all @VARNAME@
  87. dnl instances in every file passed to AC_OUTPUT
  88. dnl
  89. AC_DEFUN([PHP_SUBST_OLD],[
  90. PHP_SUBST($1)
  91. AC_SUBST($1)
  92. ])
  93. dnl
  94. dnl PHP_OUTPUT(file)
  95. dnl
  96. dnl Adds "file" to the list of files generated by AC_OUTPUT
  97. dnl This macro can be used several times.
  98. dnl
  99. AC_DEFUN([PHP_OUTPUT],[
  100. PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  101. ])
  102. dnl -------------------------------------------------------------------------
  103. dnl Build system base macros
  104. dnl -------------------------------------------------------------------------
  105. dnl
  106. dnl PHP_CANONICAL_HOST_TARGET
  107. dnl
  108. AC_DEFUN([PHP_CANONICAL_HOST_TARGET],[
  109. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  110. AC_REQUIRE([AC_CANONICAL_TARGET])dnl
  111. dnl Make sure we do not continue if host_alias is empty.
  112. if test -z "$host_alias" && test -n "$host"; then
  113. host_alias=$host
  114. fi
  115. if test -z "$host_alias"; then
  116. AC_MSG_ERROR([host_alias is not set!])
  117. fi
  118. ])
  119. dnl
  120. dnl PHP_INIT_BUILD_SYSTEM
  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/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
  152. dnl of the most recently added extension. $(srcdir) and $(builddir)
  153. dnl are substituted with the proper paths. Can be used to supply
  154. dnl custom rules and/or additional targets.
  155. dnl
  156. AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
  157. ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
  158. ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
  159. ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
  160. test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
  161. ])
  162. dnl
  163. dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
  164. dnl
  165. dnl Adds sources which are located relative to source-path to the
  166. dnl array of type type. Sources are processed with optional
  167. dnl special-flags which are passed to the compiler. Sources
  168. dnl can be either written in C or C++ (filenames shall end in .c
  169. dnl or .cpp, respectively).
  170. dnl
  171. dnl Note: If source-path begins with a "/", the "/" is removed and
  172. dnl the path is interpreted relative to the top build-directory.
  173. dnl
  174. dnl which array to append to?
  175. AC_DEFUN([PHP_ADD_SOURCES],[
  176. PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS))
  177. ])
  178. dnl
  179. dnl _PHP_ASSIGN_BUILD_VARS(type)
  180. dnl internal, don't use
  181. AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[
  182. ifelse($1,shared,[
  183. b_c_pre=$shared_c_pre
  184. b_cxx_pre=$shared_cxx_pre
  185. b_c_meta=$shared_c_meta
  186. b_cxx_meta=$shared_cxx_meta
  187. b_c_post=$shared_c_post
  188. b_cxx_post=$shared_cxx_post
  189. ],[
  190. b_c_pre=$php_c_pre
  191. b_cxx_pre=$php_cxx_pre
  192. b_c_meta=$php_c_meta
  193. b_cxx_meta=$php_cxx_meta
  194. b_c_post=$php_c_post
  195. b_cxx_post=$php_cxx_post
  196. ])dnl
  197. b_lo=[$]$1_lo
  198. ])
  199. dnl
  200. dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
  201. dnl
  202. dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the
  203. dnl name of the array target-var directly, as well as whether
  204. dnl shared objects will be built from the sources.
  205. dnl
  206. dnl Should not be used directly.
  207. dnl
  208. AC_DEFUN([PHP_ADD_SOURCES_X],[
  209. dnl relative to source- or build-directory?
  210. dnl ac_srcdir/ac_bdir include trailing slash
  211. case $1 in
  212. ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;;
  213. /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
  214. *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
  215. esac
  216. dnl how to build .. shared or static?
  217. ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))
  218. dnl iterate over the sources
  219. old_IFS=[$]IFS
  220. for ac_src in $2; do
  221. dnl remove the suffix
  222. IFS=.
  223. set $ac_src
  224. ac_obj=[$]1
  225. IFS=$old_IFS
  226. dnl append to the array which has been dynamically chosen at m4 time
  227. $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
  228. dnl choose the right compiler/flags/etc. for the source-file
  229. case $ac_src in
  230. *.c[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
  231. *.s[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
  232. *.S[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
  233. *.cpp|*.cc|*.cxx[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;;
  234. esac
  235. dnl create a rule for the object/source combo
  236. cat >>Makefile.objects<<EOF
  237. $ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src
  238. $ac_comp
  239. EOF
  240. done
  241. ])
  242. dnl -------------------------------------------------------------------------
  243. dnl Compiler characteristics checks
  244. dnl -------------------------------------------------------------------------
  245. dnl
  246. dnl PHP_TARGET_RDYNAMIC
  247. dnl
  248. dnl Checks whether -rdynamic is supported by the compiler. This
  249. dnl is necessary for some targets to populate the global symbol
  250. dnl table. Otherwise, dynamic modules would not be able to resolve
  251. dnl PHP-related symbols.
  252. dnl
  253. dnl If successful, adds -rdynamic to PHP_LDFLAGS.
  254. dnl
  255. AC_DEFUN([PHP_TARGET_RDYNAMIC],[
  256. if test -n "$GCC"; then
  257. PHP_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes)
  258. if test "$gcc_rdynamic" = "yes"; then
  259. PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic"
  260. fi
  261. fi
  262. ])
  263. dnl
  264. dnl PHP_RUNPATH_SWITCH
  265. dnl
  266. dnl Checks for -R, etc. switch
  267. dnl
  268. AC_DEFUN([PHP_RUNPATH_SWITCH],[
  269. AC_MSG_CHECKING([if compiler supports -R])
  270. AC_CACHE_VAL(php_cv_cc_dashr,[
  271. SAVE_LIBS=$LIBS
  272. LIBS="-R /usr/$PHP_LIBDIR $LIBS"
  273. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],[php_cv_cc_dashr=yes],[php_cv_cc_dashr=no])
  274. LIBS=$SAVE_LIBS])
  275. AC_MSG_RESULT([$php_cv_cc_dashr])
  276. if test $php_cv_cc_dashr = "yes"; then
  277. ld_runpath_switch=-R
  278. else
  279. AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  280. AC_CACHE_VAL(php_cv_cc_rpath,[
  281. SAVE_LIBS=$LIBS
  282. LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
  283. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],[php_cv_cc_rpath=yes],[php_cv_cc_rpath=no])
  284. LIBS=$SAVE_LIBS])
  285. AC_MSG_RESULT([$php_cv_cc_rpath])
  286. if test $php_cv_cc_rpath = "yes"; then
  287. ld_runpath_switch=-Wl,-rpath,
  288. else
  289. dnl something innocuous
  290. ld_runpath_switch=-L
  291. fi
  292. fi
  293. if test "$PHP_RPATH" = "no"; then
  294. ld_runpath_switch=
  295. fi
  296. ])
  297. dnl
  298. dnl PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found)
  299. dnl
  300. AC_DEFUN([PHP_CHECK_GCC_ARG],[
  301. gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z=-,a-z__)
  302. AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z=-,a-z__), [
  303. echo 'void somefunc() { };' > conftest.c
  304. cmd='$CC $1 -c conftest.c'
  305. if eval $cmd 2>&1 | $EGREP -e $1 >/dev/null ; then
  306. ac_result=no
  307. else
  308. ac_result=yes
  309. fi
  310. eval $gcc_arg_name=$ac_result
  311. rm -f conftest.*
  312. ])
  313. if eval test "\$$gcc_arg_name" = "yes"; then
  314. $2
  315. else
  316. :
  317. $3
  318. fi
  319. ])
  320. dnl
  321. dnl PHP_LIBGCC_LIBPATH(gcc)
  322. dnl
  323. dnl Stores the location of libgcc in libgcc_libpath
  324. dnl
  325. AC_DEFUN([PHP_LIBGCC_LIBPATH],[
  326. changequote({,})
  327. libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'`
  328. changequote([,])
  329. ])
  330. dnl -------------------------------------------------------------------------
  331. dnl Macros to modify LIBS, INCLUDES, etc. variables
  332. dnl -------------------------------------------------------------------------
  333. dnl
  334. dnl PHP_REMOVE_USR_LIB(NAME)
  335. dnl
  336. dnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME
  337. dnl
  338. AC_DEFUN([PHP_REMOVE_USR_LIB],[
  339. unset ac_new_flags
  340. for i in [$]$1; do
  341. case [$]i in
  342. -L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;;
  343. *[)] ac_new_flags="[$]ac_new_flags [$]i" ;;
  344. esac
  345. done
  346. $1=[$]ac_new_flags
  347. ])
  348. dnl
  349. dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD)
  350. dnl
  351. dnl Use this macro, if you need to add libraries and or library search
  352. dnl paths to the PHP build system which are only given in compiler
  353. dnl notation.
  354. dnl
  355. AC_DEFUN([PHP_EVAL_LIBLINE],[
  356. for ac_i in $1; do
  357. case $ac_i in
  358. -pthread[)]
  359. if test "$ext_shared" = "yes"; then
  360. $2="[$]$2 -pthread"
  361. else
  362. PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"])
  363. PHP_RUN_ONCE(EXTRA_LDFLAGS_PROGRAM, [$ac_i],
  364. [EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $ac_i"])
  365. fi
  366. ;;
  367. -l*[)]
  368. ac_ii=`echo $ac_i|cut -c 3-`
  369. PHP_ADD_LIBRARY($ac_ii,1,$2)
  370. ;;
  371. -L*[)]
  372. ac_ii=`echo $ac_i|cut -c 3-`
  373. PHP_ADD_LIBPATH($ac_ii,$2)
  374. ;;
  375. esac
  376. done
  377. ])
  378. dnl
  379. dnl PHP_EVAL_INCLINE(headerline)
  380. dnl
  381. dnl Use this macro, if you need to add header search paths to the PHP
  382. dnl build system which are only given in compiler notation.
  383. dnl
  384. AC_DEFUN([PHP_EVAL_INCLINE],[
  385. for ac_i in $1; do
  386. case $ac_i in
  387. -I*[)]
  388. ac_ii=`echo $ac_i|cut -c 3-`
  389. PHP_ADD_INCLUDE($ac_ii)
  390. ;;
  391. esac
  392. done
  393. ])
  394. dnl internal, don't use
  395. AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[
  396. PHP_RUN_ONCE(LIBPATH, $1, [
  397. test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
  398. LDFLAGS="$LDFLAGS -L$1"
  399. PHP_RPATHS="$PHP_RPATHS $1"
  400. ])
  401. ])dnl
  402. dnl
  403. dnl
  404. dnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD])
  405. dnl
  406. dnl Adds a path to linkpath/runpath (LDFLAGS)
  407. dnl
  408. AC_DEFUN([PHP_ADD_LIBPATH],[
  409. if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
  410. PHP_EXPAND_PATH($1, ai_p)
  411. ifelse([$2],,[
  412. _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  413. ],[
  414. if test "$ext_shared" = "yes"; then
  415. $2="-L$ai_p [$]$2"
  416. test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2"
  417. else
  418. _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  419. fi
  420. ])
  421. fi
  422. ])
  423. dnl
  424. dnl PHP_UTILIZE_RPATHS()
  425. dnl
  426. dnl builds RPATHS/LDFLAGS from PHP_RPATHS
  427. dnl
  428. AC_DEFUN([PHP_UTILIZE_RPATHS],[
  429. OLD_RPATHS=$PHP_RPATHS
  430. unset PHP_RPATHS
  431. for i in $OLD_RPATHS; do
  432. dnl Can be passed to native cc/libtool
  433. PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  434. dnl Libtool-specific
  435. PHP_RPATHS="$PHP_RPATHS -R $i"
  436. dnl cc-specific
  437. NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
  438. done
  439. if test "$PHP_RPATH" = "no"; then
  440. unset PHP_RPATHS
  441. unset NATIVE_RPATHS
  442. fi
  443. ])
  444. dnl
  445. dnl PHP_ADD_INCLUDE(path [,before])
  446. dnl
  447. dnl add an include path.
  448. dnl if before is 1, add in the beginning of INCLUDES.
  449. dnl
  450. AC_DEFUN([PHP_ADD_INCLUDE],[
  451. if test "$1" != "/usr/include"; then
  452. PHP_EXPAND_PATH($1, ai_p)
  453. PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [
  454. if test "$2"; then
  455. INCLUDES="-I$ai_p $INCLUDES"
  456. else
  457. INCLUDES="$INCLUDES -I$ai_p"
  458. fi
  459. ])
  460. fi
  461. ])
  462. dnl internal, don't use
  463. AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl
  464. ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl
  465. ])dnl
  466. dnl
  467. dnl internal, don't use
  468. AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[
  469. case $1 in
  470. c|c_r|pthread*[)] ;;
  471. *[)] ifelse($3,,[
  472. _PHP_X_ADD_LIBRARY($1,$2,$5)
  473. ],[
  474. if test "$ext_shared" = "yes"; then
  475. _PHP_X_ADD_LIBRARY($1,$2,$3)
  476. else
  477. $4($1,$2)
  478. fi
  479. ]) ;;
  480. esac
  481. ])dnl
  482. dnl
  483. dnl
  484. dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
  485. dnl
  486. dnl add a library to the link line
  487. dnl
  488. AC_DEFUN([PHP_ADD_LIBRARY],[
  489. _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
  490. ])
  491. dnl
  492. dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
  493. dnl
  494. dnl add a library to the link line (deferred, not used during configure)
  495. dnl
  496. AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[
  497. _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
  498. ])
  499. dnl
  500. dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  501. dnl
  502. dnl add a library to the link line and path to linkpath/runpath.
  503. dnl if shared-libadd is not empty and $ext_shared is yes,
  504. dnl shared-libadd will be assigned the library information
  505. dnl
  506. AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[
  507. ifelse($3,,[
  508. if test -n "$2"; then
  509. PHP_ADD_LIBPATH($2)
  510. fi
  511. PHP_ADD_LIBRARY($1)
  512. ],[
  513. if test "$ext_shared" = "yes"; then
  514. $3="-l$1 [$]$3"
  515. if test -n "$2"; then
  516. PHP_ADD_LIBPATH($2,$3)
  517. fi
  518. else
  519. PHP_ADD_LIBRARY_WITH_PATH($1,$2)
  520. fi
  521. ])
  522. ])
  523. dnl
  524. dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
  525. dnl
  526. dnl add a library to the link line (deferred)
  527. dnl and path to linkpath/runpath (not deferred)
  528. dnl if shared-libadd is not empty and $ext_shared is yes,
  529. dnl shared-libadd will be assigned the library information
  530. dnl
  531. AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[
  532. ifelse($3,,[
  533. if test -n "$2"; then
  534. PHP_ADD_LIBPATH($2)
  535. fi
  536. PHP_ADD_LIBRARY_DEFER($1)
  537. ],[
  538. if test "$ext_shared" = "yes"; then
  539. $3="-l$1 [$]$3"
  540. if test -n "$2"; then
  541. PHP_ADD_LIBPATH($2,$3)
  542. fi
  543. else
  544. PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
  545. fi
  546. ])
  547. ])
  548. dnl
  549. dnl PHP_ADD_FRAMEWORK(framework [,before])
  550. dnl
  551. dnl add a (Darwin / Mac OS X) framework to the link
  552. dnl line. if before is 1, the framework is added
  553. dnl to the beginning of the line.
  554. dnl
  555. AC_DEFUN([PHP_ADD_FRAMEWORK], [
  556. PHP_RUN_ONCE(FRAMEWORKS, $1, [
  557. if test "$2"; then
  558. PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS"
  559. else
  560. PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1"
  561. fi
  562. ])
  563. ])
  564. dnl
  565. dnl PHP_ADD_FRAMEWORKPATH(path [,before])
  566. dnl
  567. dnl add a (Darwin / Mac OS X) framework path to the link
  568. dnl and include lines. default paths include (but are
  569. dnl not limited to) /Local/Library/Frameworks and
  570. dnl /System/Library/Frameworks, so these don't need
  571. dnl to be specifically added. if before is 1, the
  572. dnl framework path is added to the beginning of the
  573. dnl relevant lines.
  574. dnl
  575. AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [
  576. PHP_EXPAND_PATH($1, ai_p)
  577. PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [
  578. if test "$2"; then
  579. PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH"
  580. else
  581. PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p"
  582. fi
  583. ])
  584. ])
  585. dnl
  586. dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path)
  587. dnl
  588. dnl Adds a (Darwin / Mac OS X) framework path and the
  589. dnl framework itself to the link and include lines.
  590. dnl
  591. AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [
  592. PHP_ADD_FRAMEWORKPATH($2)
  593. PHP_ADD_FRAMEWORK($1)
  594. ])
  595. dnl
  596. dnl PHP_SET_LIBTOOL_VARIABLE(var)
  597. dnl
  598. dnl Set libtool variable
  599. dnl
  600. AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[
  601. if test -z "$LIBTOOL"; then
  602. LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
  603. else
  604. LIBTOOL="$LIBTOOL $1"
  605. fi
  606. ])
  607. dnl -------------------------------------------------------------------------
  608. dnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE
  609. dnl -------------------------------------------------------------------------
  610. dnl PHP_ARG_ANALYZE_EX
  611. dnl internal
  612. AC_DEFUN([PHP_ARG_ANALYZE_EX],[
  613. ext_output="yes, shared"
  614. ext_shared=yes
  615. case [$]$1 in
  616. shared,*[)]
  617. $1=`echo "[$]$1"|$SED 's/^shared,//'`
  618. ;;
  619. shared[)]
  620. $1=yes
  621. ;;
  622. no[)]
  623. ext_output=no
  624. ext_shared=no
  625. ;;
  626. *[)]
  627. ext_output=yes
  628. ext_shared=no
  629. ;;
  630. esac
  631. PHP_ALWAYS_SHARED([$1])
  632. ])
  633. dnl PHP_ARG_ANALYZE
  634. dnl internal
  635. AC_DEFUN([PHP_ARG_ANALYZE],[
  636. ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)])
  637. ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
  638. ])
  639. dnl
  640. dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]])
  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,
  643. dnl and will overwrite any previous variable of that name.
  644. dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
  645. dnl the PHP_ARG_ANALYZE_EX.
  646. dnl
  647. AC_DEFUN([PHP_ARG_WITH],[
  648. php_with_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
  649. PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
  650. ])
  651. dnl PHP_REAL_ARG_WITH
  652. dnl internal
  653. AC_DEFUN([PHP_REAL_ARG_WITH],[
  654. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  655. AC_ARG_WITH($1,[$3],$5=[$]withval,
  656. [
  657. $5=ifelse($4,,no,$4)
  658. ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
  659. ])
  660. PHP_ARG_ANALYZE($5,[$2],$6)
  661. ])
  662. dnl
  663. dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])
  664. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  665. dnl default-val defaults to no. This will also set the variable ext_shared,
  666. dnl and will overwrite any previous variable of that name.
  667. dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
  668. dnl the PHP_ARG_ANALYZE_EX.
  669. dnl
  670. AC_DEFUN([PHP_ARG_ENABLE],[
  671. php_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
  672. PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
  673. ])
  674. dnl PHP_REAL_ARG_ENABLE
  675. dnl internal
  676. AC_DEFUN([PHP_REAL_ARG_ENABLE],[
  677. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  678. AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
  679. [
  680. $5=ifelse($4,,no,$4)
  681. ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
  682. ])
  683. PHP_ARG_ANALYZE($5,[$2],$6)
  684. ])
  685. dnl -------------------------------------------------------------------------
  686. dnl Build macros
  687. dnl -------------------------------------------------------------------------
  688. dnl
  689. dnl PHP_BUILD_THREAD_SAFE
  690. dnl
  691. AC_DEFUN([PHP_BUILD_THREAD_SAFE],[
  692. enable_maintainer_zts=yes
  693. if test "$pthreads_working" != "yes"; then
  694. AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
  695. fi
  696. ])
  697. dnl
  698. dnl PHP_REQUIRE_CXX
  699. dnl
  700. AC_DEFUN([PHP_REQUIRE_CXX],[
  701. if test -z "$php_cxx_done"; then
  702. AC_PROG_CXX
  703. AC_PROG_CXXCPP
  704. PHP_ADD_LIBRARY(stdc++)
  705. php_cxx_done=yes
  706. fi
  707. ])
  708. dnl
  709. dnl PHP_BUILD_SHARED
  710. dnl
  711. AC_DEFUN([PHP_BUILD_SHARED],[
  712. PHP_BUILD_PROGRAM
  713. OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
  714. php_sapi_module=shared
  715. php_c_pre=$shared_c_pre
  716. php_c_meta=$shared_c_meta
  717. php_c_post=$shared_c_post
  718. php_cxx_pre=$shared_cxx_pre
  719. php_cxx_meta=$shared_cxx_meta
  720. php_cxx_post=$shared_cxx_post
  721. php_lo=$shared_lo
  722. ])
  723. dnl
  724. dnl PHP_BUILD_STATIC
  725. dnl
  726. AC_DEFUN([PHP_BUILD_STATIC],[
  727. PHP_BUILD_PROGRAM
  728. OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
  729. php_sapi_module=static
  730. ])
  731. dnl
  732. dnl PHP_BUILD_BUNDLE
  733. dnl
  734. AC_DEFUN([PHP_BUILD_BUNDLE],[
  735. PHP_BUILD_PROGRAM
  736. OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
  737. php_sapi_module=static
  738. ])
  739. dnl
  740. dnl PHP_BUILD_PROGRAM
  741. dnl
  742. AC_DEFUN([PHP_BUILD_PROGRAM],[
  743. php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  744. php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
  745. php_c_post=
  746. php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  747. php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
  748. php_cxx_post=
  749. php_lo=lo
  750. case $with_pic in
  751. yes) pic_setting='-prefer-pic';;
  752. no) pic_setting='-prefer-non-pic';;
  753. esac
  754. shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  755. shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
  756. shared_c_post=
  757. shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  758. shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
  759. shared_cxx_post=
  760. shared_lo=lo
  761. ])
  762. dnl
  763. dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext)
  764. dnl
  765. dnl Basically sets up the link-stage for building module-name
  766. dnl from object_var in build-dir.
  767. dnl
  768. AC_DEFUN([PHP_SHARED_MODULE],[
  769. install_modules="install-modules"
  770. suffix=la
  771. case $host_alias in
  772. *aix*[)]
  773. additional_flags="-Wl,-G"
  774. ;;
  775. esac
  776. if test "x$5" = "xyes"; then
  777. PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix"
  778. else
  779. PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
  780. fi
  781. PHP_SUBST($2)
  782. cat >>Makefile.objects<<EOF
  783. \$(phplibdir)/$1.$suffix: $3/$1.$suffix
  784. \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
  785. $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
  786. \$(LIBTOOL) --mode=link ifelse($4,,[\$(CC)],[\$(CXX)]) \$(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)
  787. EOF
  788. ])
  789. dnl
  790. dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
  791. dnl
  792. dnl Selects the SAPI name and type (static, shared, bundle, program)
  793. dnl and optionally also the source-files for the SAPI-specific
  794. dnl objects.
  795. dnl
  796. AC_DEFUN([PHP_SELECT_SAPI],[
  797. if test "$2" = "program"; then
  798. PHP_BINARIES="$PHP_BINARIES $1"
  799. elif test "$PHP_SAPI" != "none"; then
  800. AC_MSG_ERROR([
  801. +--------------------------------------------------------------------+
  802. | *** ATTENTION *** |
  803. | |
  804. | You've configured multiple SAPIs to be build. You can build only |
  805. | one SAPI module plus CGI, CLI and FPM binaries at the same time. |
  806. +--------------------------------------------------------------------+
  807. ])
  808. else
  809. PHP_SAPI=$1
  810. fi
  811. PHP_ADD_BUILD_DIR([sapi/$1])
  812. PHP_INSTALLED_SAPIS="$PHP_INSTALLED_SAPIS $1"
  813. ifelse($2,program,[
  814. PHP_BUILD_PROGRAM
  815. install_binaries="install-binaries"
  816. install_binary_targets="$install_binary_targets install-$1"
  817. PHP_SUBST(PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)
  818. ifelse($3,,,[PHP_ADD_SOURCES_X([sapi/$1],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)])
  819. ],[
  820. case "$2" in
  821. static[)] PHP_BUILD_STATIC;;
  822. shared[)] PHP_BUILD_SHARED;;
  823. bundle[)] PHP_BUILD_BUNDLE;;
  824. esac
  825. install_sapi="install-sapi"
  826. ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
  827. ])
  828. ])
  829. dnl deprecated
  830. AC_DEFUN([PHP_EXTENSION],[
  831. sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
  832. PHP_NEW_EXTENSION($1, $sources, $2, $3)
  833. if test -r "$ext_srcdir/Makefile.frag"; then
  834. PHP_ADD_MAKEFILE_FRAGMENT
  835. fi
  836. ])
  837. AC_DEFUN([PHP_ADD_BUILD_DIR],[
  838. ifelse($2,,[
  839. BUILD_DIR="$BUILD_DIR $1"
  840. ], [
  841. $php_shtool mkdir -p $1
  842. ])
  843. ])
  844. AC_DEFUN([PHP_GEN_BUILD_DIRS],[
  845. $php_shtool mkdir -p $BUILD_DIR
  846. ])
  847. dnl
  848. dnl PHP_NEW_EXTENSION(extname, sources [, shared [, sapi_class [, extra-cflags [, cxx [, zend_ext]]]]])
  849. dnl
  850. dnl Includes an extension in the build.
  851. dnl
  852. dnl "extname" is the name of the extension.
  853. dnl "sources" is a list of files relative to the subdir which are used
  854. dnl to build the extension.
  855. dnl "shared" can be set to "shared" or "yes" to build the extension as
  856. dnl a dynamically loadable library. Optional parameter "sapi_class" can
  857. dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
  858. dnl "extra-cflags" are passed to the compiler, with
  859. dnl @ext_srcdir@ and @ext_builddir@ being substituted.
  860. dnl "cxx" can be used to indicate that a C++ shared module is desired.
  861. dnl "zend_ext" indicates a zend extension.
  862. AC_DEFUN([PHP_NEW_EXTENSION],[
  863. ext_builddir=[]PHP_EXT_BUILDDIR($1)
  864. ext_srcdir=[]PHP_EXT_SRCDIR($1)
  865. ext_dir=[]PHP_EXT_DIR($1)
  866. ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`])
  867. if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
  868. dnl ---------------------------------------------- Static module
  869. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
  870. PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,)
  871. EXT_STATIC="$EXT_STATIC $1;$ext_dir"
  872. if test "$3" != "nocli"; then
  873. EXT_CLI_STATIC="$EXT_CLI_STATIC $1;$ext_dir"
  874. fi
  875. else
  876. if test "$3" = "shared" || test "$3" = "yes"; then
  877. dnl ---------------------------------------------- Shared module
  878. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes
  879. PHP_ADD_SOURCES_X($ext_dir,$2,$ac_extra,shared_objects_$1,yes)
  880. PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7)
  881. AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
  882. fi
  883. fi
  884. if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
  885. dnl ---------------------------------------------- CLI static module
  886. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
  887. case "$PHP_SAPI" in
  888. cgi|embed|phpdbg[)]
  889. PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,)
  890. EXT_STATIC="$EXT_STATIC $1;$ext_dir"
  891. ;;
  892. *[)]
  893. PHP_ADD_SOURCES($ext_dir,$2,$ac_extra,cli)
  894. ;;
  895. esac
  896. EXT_CLI_STATIC="$EXT_CLI_STATIC $1;$ext_dir"
  897. fi
  898. PHP_ADD_BUILD_DIR($ext_builddir)
  899. dnl Set for phpize builds only
  900. dnl ---------------------------
  901. if test "$ext_builddir" = "."; then
  902. PHP_PECL_EXTENSION=$1
  903. PHP_SUBST(PHP_PECL_EXTENSION)
  904. fi
  905. ])
  906. dnl
  907. dnl PHP_WITH_SHARED
  908. dnl
  909. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  910. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  911. dnl from $withval.
  912. dnl
  913. AC_DEFUN([PHP_WITH_SHARED],[
  914. PHP_ARG_ANALYZE_EX(withval)
  915. shared=$ext_shared
  916. unset ext_shared ext_output
  917. ])
  918. dnl
  919. dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf])
  920. dnl
  921. dnl This macro is scanned by genif.sh when it builds the internal functions
  922. dnl list, so that modules can be init'd in the correct order
  923. dnl $1 = name of extension, $2 = extension upon which it depends
  924. dnl $3 = optional: if true, it's ok for $2 to have not been configured
  925. dnl default is false and should halt the build.
  926. dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION.
  927. dnl The extension on which it depends must also have been configured.
  928. dnl See ADD_EXTENSION_DEP in win32 build
  929. dnl
  930. AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
  931. am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
  932. is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
  933. is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
  934. if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
  935. AC_MSG_ERROR([
  936. You've configured extension $1 to build statically, but it
  937. depends on extension $2, which you've configured to build shared.
  938. You either need to build $1 shared or build $2 statically for the
  939. build to be successful.
  940. ])
  941. fi
  942. if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then
  943. AC_MSG_ERROR([
  944. You've configured extension $1, which depends on extension $2,
  945. but you've either not enabled $2, or have disabled it.
  946. ])
  947. fi
  948. dnl Some systems require that we link $2 to $1 when building
  949. ])
  950. dnl -------------------------------------------------------------------------
  951. dnl Checks for structures, typedefs, broken functions, etc.
  952. dnl -------------------------------------------------------------------------
  953. dnl Internal helper macros
  954. dnl
  955. dnl _PHP_DEF_HAVE_FILE(what, filename)
  956. AC_DEFUN([_PHP_DEF_HAVE_FILE], [
  957. php_def_have_what=HAVE_[]`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' `
  958. echo "#define $php_def_have_what 1" >> $2
  959. ])
  960. dnl
  961. dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
  962. dnl
  963. AC_DEFUN([_PHP_CHECK_SIZEOF], [
  964. php_cache_value=php_cv_sizeof_[]$1
  965. AC_CACHE_VAL(php_cv_sizeof_[]$1, [
  966. old_LIBS=$LIBS
  967. LIBS=
  968. old_LDFLAGS=$LDFLAGS
  969. LDFLAGS=
  970. AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
  971. #if STDC_HEADERS
  972. #include <stdlib.h>
  973. #include <stddef.h>
  974. #endif
  975. #ifdef HAVE_INTTYPES_H
  976. #include <inttypes.h>
  977. #endif
  978. #ifdef HAVE_UNISTD_H
  979. #include <unistd.h>
  980. #endif
  981. $3
  982. int main()
  983. {
  984. FILE *fp = fopen("conftestval", "w");
  985. if (!fp) return(1);
  986. fprintf(fp, "%d\n", sizeof($1));
  987. return(0);
  988. }
  989. ]])], [
  990. eval $php_cache_value=`cat conftestval`
  991. ], [
  992. eval $php_cache_value=0
  993. ], [
  994. ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
  995. ])
  996. LDFLAGS=$old_LDFLAGS
  997. LIBS=$old_LIBS
  998. ])
  999. if eval test "\$$php_cache_value" != "0"; then
  1000. ifelse([$4],[],:,[$4])
  1001. ifelse([$5],[],,[else $5])
  1002. fi
  1003. ])
  1004. dnl
  1005. dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
  1006. dnl
  1007. AC_DEFUN([PHP_CHECK_SIZEOF], [
  1008. AC_MSG_CHECKING([size of $1])
  1009. _PHP_CHECK_SIZEOF($1, $2, $3, [
  1010. AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
  1011. AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
  1012. ])
  1013. AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
  1014. ])
  1015. dnl
  1016. dnl PHP_CHECK_TYPES(type-list, include-file [, extra-headers])
  1017. dnl
  1018. AC_DEFUN([PHP_CHECK_TYPES], [
  1019. for php_typename in $1; do
  1020. AC_MSG_CHECKING([whether $php_typename exists])
  1021. _PHP_CHECK_SIZEOF($php_typename, 0, $3, [
  1022. _PHP_DEF_HAVE_FILE($php_typename, $2)
  1023. AC_MSG_RESULT([yes])
  1024. ], [
  1025. AC_MSG_RESULT([no])
  1026. ])
  1027. done
  1028. ])
  1029. dnl
  1030. dnl PHP_CHECK_IN_ADDR_T
  1031. dnl
  1032. AC_DEFUN([PHP_CHECK_IN_ADDR_T], [
  1033. dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
  1034. AC_MSG_CHECKING([for in_addr_t])
  1035. AC_CACHE_VAL(ac_cv_type_in_addr_t,
  1036. [AC_EGREP_CPP(dnl
  1037. changequote(<<,>>)dnl
  1038. <<in_addr_t[^a-zA-Z_0-9]>>dnl
  1039. changequote([,]), [#include <sys/types.h>
  1040. #if STDC_HEADERS
  1041. #include <stdlib.h>
  1042. #include <stddef.h>
  1043. #endif
  1044. #ifdef HAVE_NETINET_IN_H
  1045. #include <netinet/in.h>
  1046. #endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
  1047. AC_MSG_RESULT([$ac_cv_type_in_addr_t])
  1048. if test $ac_cv_type_in_addr_t = no; then
  1049. AC_DEFINE(in_addr_t, u_int, [ ])
  1050. fi
  1051. ])
  1052. dnl
  1053. dnl PHP_TIME_R_TYPE
  1054. dnl
  1055. dnl Check type of reentrant time-related functions
  1056. dnl Type can be: irix, hpux or POSIX
  1057. dnl
  1058. AC_DEFUN([PHP_TIME_R_TYPE],[
  1059. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  1060. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1061. #include <time.h>
  1062. main() {
  1063. char buf[27];
  1064. struct tm t;
  1065. time_t old = 0;
  1066. int r, s;
  1067. s = gmtime_r(&old, &t);
  1068. r = (int) asctime_r(&t, buf, 26);
  1069. if (r == s && s == 0) return (0);
  1070. return (1);
  1071. }
  1072. ]])],[
  1073. ac_cv_time_r_type=hpux
  1074. ],[
  1075. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1076. #include <time.h>
  1077. main() {
  1078. struct tm t, *s;
  1079. time_t old = 0;
  1080. char buf[27], *p;
  1081. s = gmtime_r(&old, &t);
  1082. p = asctime_r(&t, buf, 26);
  1083. if (p == buf && s == &t) return (0);
  1084. return (1);
  1085. }
  1086. ]])],[
  1087. ac_cv_time_r_type=irix
  1088. ],[
  1089. ac_cv_time_r_type=POSIX
  1090. ],[
  1091. ac_cv_time_r_type=POSIX
  1092. ])
  1093. ],[
  1094. ac_cv_time_r_type=POSIX
  1095. ])
  1096. ])
  1097. case $ac_cv_time_r_type in
  1098. hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
  1099. irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
  1100. esac
  1101. ])
  1102. dnl
  1103. dnl PHP_DOES_PWRITE_WORK
  1104. dnl internal
  1105. AC_DEFUN([PHP_DOES_PWRITE_WORK],[
  1106. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1107. #include <sys/types.h>
  1108. #include <sys/stat.h>
  1109. #include <fcntl.h>
  1110. #include <unistd.h>
  1111. #include <errno.h>
  1112. $1
  1113. int main() {
  1114. int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
  1115. if (fd < 0) return 1;
  1116. if (pwrite(fd, "text", 4, 0) != 4) return 1;
  1117. /* Linux glibc breakage until 2.2.5 */
  1118. if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) return 1;
  1119. return 0;
  1120. }
  1121. ]])],[
  1122. ac_cv_pwrite=yes
  1123. ],[
  1124. ac_cv_pwrite=no
  1125. ],[
  1126. ac_cv_pwrite=no
  1127. ])
  1128. ])
  1129. dnl PHP_DOES_PREAD_WORK
  1130. dnl internal
  1131. AC_DEFUN([PHP_DOES_PREAD_WORK],[
  1132. echo test > conftest_in
  1133. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1134. #include <sys/types.h>
  1135. #include <sys/stat.h>
  1136. #include <fcntl.h>
  1137. #include <unistd.h>
  1138. #include <errno.h>
  1139. $1
  1140. int main() {
  1141. char buf[3];
  1142. int fd = open("conftest_in", O_RDONLY);
  1143. if (fd < 0) return 1;
  1144. if (pread(fd, buf, 2, 0) != 2) return 1;
  1145. /* Linux glibc breakage until 2.2.5 */
  1146. if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) return 1;
  1147. return 0;
  1148. }
  1149. ]])],[
  1150. ac_cv_pread=yes
  1151. ],[
  1152. ac_cv_pread=no
  1153. ],[
  1154. ac_cv_pread=no
  1155. ])
  1156. rm -f conftest_in
  1157. ])
  1158. dnl
  1159. dnl PHP_PWRITE_TEST
  1160. dnl
  1161. AC_DEFUN([PHP_PWRITE_TEST],[
  1162. AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
  1163. PHP_DOES_PWRITE_WORK
  1164. if test "$ac_cv_pwrite" = "no"; then
  1165. PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
  1166. if test "$ac_cv_pwrite" = "yes"; then
  1167. ac_cv_pwrite=64
  1168. fi
  1169. fi
  1170. ])
  1171. if test "$ac_cv_pwrite" != "no"; then
  1172. AC_DEFINE(HAVE_PWRITE, 1, [ ])
  1173. if test "$ac_cv_pwrite" = "64"; then
  1174. AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
  1175. fi
  1176. fi
  1177. ])
  1178. dnl
  1179. dnl PHP_PREAD_TEST
  1180. dnl
  1181. AC_DEFUN([PHP_PREAD_TEST],[
  1182. AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
  1183. PHP_DOES_PREAD_WORK
  1184. if test "$ac_cv_pread" = "no"; then
  1185. PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
  1186. if test "$ac_cv_pread" = "yes"; then
  1187. ac_cv_pread=64
  1188. fi
  1189. fi
  1190. ])
  1191. if test "$ac_cv_pread" != "no"; then
  1192. AC_DEFINE(HAVE_PREAD, 1, [ ])
  1193. if test "$ac_cv_pread" = "64"; then
  1194. AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
  1195. fi
  1196. fi
  1197. ])
  1198. dnl
  1199. dnl PHP_MISSING_TIME_R_DECL
  1200. dnl
  1201. AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
  1202. AC_MSG_CHECKING([for missing declarations of reentrant functions])
  1203. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)() = localtime_r]])],[
  1204. :
  1205. ],[
  1206. AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  1207. ])
  1208. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)() = gmtime_r]])],[
  1209. :
  1210. ],[
  1211. AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  1212. ])
  1213. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)() = asctime_r]])],[
  1214. :
  1215. ],[
  1216. AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  1217. ])
  1218. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)() = ctime_r]])],[
  1219. :
  1220. ],[
  1221. AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  1222. ])
  1223. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[char *(*func)() = strtok_r]])],[
  1224. :
  1225. ],[
  1226. AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  1227. ])
  1228. AC_MSG_RESULT([done])
  1229. ])
  1230. dnl
  1231. dnl PHP_READDIR_R_TYPE
  1232. dnl
  1233. AC_DEFUN([PHP_READDIR_R_TYPE],[
  1234. dnl HAVE_READDIR_R is also defined by libmysql
  1235. AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
  1236. if test "$ac_cv_func_readdir_r" = "yes"; then
  1237. AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
  1238. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1239. #define _REENTRANT
  1240. #include <sys/types.h>
  1241. #include <dirent.h>
  1242. #include <unistd.h>
  1243. #ifndef PATH_MAX
  1244. #define PATH_MAX 1024
  1245. #endif
  1246. int main() {
  1247. DIR *dir;
  1248. char entry[sizeof(struct dirent)+PATH_MAX];
  1249. struct dirent *pentry = (struct dirent *) &entry;
  1250. dir = opendir("/");
  1251. if (!dir)
  1252. return 1;
  1253. if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) {
  1254. close(dir);
  1255. return 0;
  1256. }
  1257. close(dir);
  1258. return 1;
  1259. }
  1260. ]])],[
  1261. ac_cv_what_readdir_r=POSIX
  1262. ],[
  1263. AC_PREPROC_IFELSE([
  1264. AC_LANG_SOURCE([[
  1265. #define _REENTRANT
  1266. #include <sys/types.h>
  1267. #include <dirent.h>
  1268. int readdir_r(DIR *, struct dirent *);
  1269. ]])],[
  1270. ac_cv_what_readdir_r=old-style
  1271. ],[
  1272. ac_cv_what_readdir_r=none
  1273. ])
  1274. ],[
  1275. ac_cv_what_readdir_r=none
  1276. ])
  1277. ])
  1278. case $ac_cv_what_readdir_r in
  1279. POSIX)
  1280. AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
  1281. old-style)
  1282. AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
  1283. esac
  1284. fi
  1285. ])
  1286. dnl
  1287. dnl PHP_TM_GMTOFF
  1288. dnl
  1289. AC_DEFUN([PHP_TM_GMTOFF],[
  1290. AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  1291. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  1292. #include <$ac_cv_struct_tm>]], [[struct tm tm; tm.tm_gmtoff;]])],
  1293. [ac_cv_struct_tm_gmtoff=yes], [ac_cv_struct_tm_gmtoff=no])])
  1294. if test "$ac_cv_struct_tm_gmtoff" = yes; then
  1295. AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
  1296. fi
  1297. ])
  1298. dnl
  1299. dnl PHP_STRUCT_FLOCK
  1300. dnl
  1301. AC_DEFUN([PHP_STRUCT_FLOCK],[
  1302. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  1303. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1304. #include <unistd.h>
  1305. #include <fcntl.h>
  1306. ]], [[struct flock x;]])],[
  1307. ac_cv_struct_flock=yes
  1308. ],[
  1309. ac_cv_struct_flock=no
  1310. ])
  1311. )
  1312. if test "$ac_cv_struct_flock" = "yes" ; then
  1313. AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  1314. fi
  1315. ])
  1316. dnl
  1317. dnl PHP_SOCKLEN_T
  1318. dnl
  1319. AC_DEFUN([PHP_SOCKLEN_T],[
  1320. AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
  1321. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1322. #include <sys/types.h>
  1323. #include <sys/socket.h>
  1324. ]],[[
  1325. socklen_t x;
  1326. ]])],[
  1327. ac_cv_socklen_t=yes
  1328. ],[
  1329. ac_cv_socklen_t=no
  1330. ]))
  1331. if test "$ac_cv_socklen_t" = "yes"; then
  1332. AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
  1333. fi
  1334. ])
  1335. dnl
  1336. dnl PHP_MISSING_FCLOSE_DECL
  1337. dnl
  1338. dnl See if we have broken header files like SunOS has.
  1339. dnl
  1340. AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
  1341. AC_MSG_CHECKING([for fclose declaration])
  1342. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[int (*func)() = fclose]])],[
  1343. AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  1344. AC_MSG_RESULT([ok])
  1345. ],[
  1346. AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  1347. AC_MSG_RESULT([missing])
  1348. ])
  1349. ])
  1350. dnl
  1351. dnl PHP_AC_BROKEN_SPRINTF
  1352. dnl
  1353. dnl Check for broken sprintf(), C99 conformance
  1354. dnl
  1355. AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[
  1356. AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
  1357. AC_RUN_IFELSE([AC_LANG_SOURCE([[main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }]])],[
  1358. ac_cv_broken_sprintf=no
  1359. ],[
  1360. ac_cv_broken_sprintf=yes
  1361. ],[
  1362. ac_cv_broken_sprintf=no
  1363. ])
  1364. ])
  1365. if test "$ac_cv_broken_sprintf" = "yes"; then
  1366. AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform])
  1367. else
  1368. AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform])
  1369. fi
  1370. ])
  1371. dnl
  1372. dnl PHP_AC_BROKEN_SNPRINTF
  1373. dnl
  1374. dnl Check for broken snprintf(), C99 conformance
  1375. dnl
  1376. AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
  1377. AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
  1378. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1379. #define NULL (0L)
  1380. main() {
  1381. char buf[20];
  1382. int res = 0;
  1383. res = res || (snprintf(buf, 2, "marcus") != 6);
  1384. res = res || (buf[1] != '\0');
  1385. /* Implementations may consider this as an encoding error */
  1386. snprintf(buf, 0, "boerger");
  1387. /* However, they MUST ignore the pointer */
  1388. res = res || (buf[0] != 'm');
  1389. res = res || (snprintf(NULL, 0, "boerger") != 7);
  1390. res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
  1391. exit(res);
  1392. }
  1393. ]])],[
  1394. ac_cv_broken_snprintf=no
  1395. ],[
  1396. ac_cv_broken_snprintf=yes
  1397. ],[
  1398. ac_cv_broken_snprintf=no
  1399. ])
  1400. ])
  1401. if test "$ac_cv_broken_snprintf" = "yes"; then
  1402. AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
  1403. else
  1404. AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
  1405. fi
  1406. ])
  1407. dnl
  1408. dnl PHP_SOLARIS_PIC_WEIRDNESS
  1409. dnl
  1410. dnl Solaris requires main code to be position independent in order
  1411. dnl to let shared objects find symbols. Weird. Ugly.
  1412. dnl
  1413. dnl Must be run after all --with-NN options that let the user
  1414. dnl choose dynamic extensions, and after the gcc test.
  1415. dnl
  1416. AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[
  1417. AC_MSG_CHECKING([whether -fPIC is required])
  1418. if test -n "$EXT_SHARED"; then
  1419. os=`uname -sr 2>/dev/null`
  1420. case $os in
  1421. "SunOS 5.6"|"SunOS 5.7"[)]
  1422. case $CC in
  1423. gcc*|egcs*)
  1424. CFLAGS="$CFLAGS -fPIC";;
  1425. *[)]
  1426. CFLAGS="$CFLAGS -fpic";;
  1427. esac
  1428. AC_MSG_RESULT([yes]);;
  1429. *[)]
  1430. AC_MSG_RESULT([no]);;
  1431. esac
  1432. else
  1433. AC_MSG_RESULT([no])
  1434. fi
  1435. ])
  1436. dnl
  1437. dnl PHP_SYS_LFS
  1438. dnl
  1439. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  1440. dnl let programs access large files; you need to tell the compiler that
  1441. dnl you actually want your programs to work on large files. For more
  1442. dnl details about this brain damage please see:
  1443. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  1444. dnl
  1445. dnl Written by Paul Eggert <eggert@twinsun.com>.
  1446. dnl
  1447. AC_DEFUN([PHP_SYS_LFS],
  1448. [dnl
  1449. # If available, prefer support for large files unless the user specified
  1450. # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  1451. AC_MSG_CHECKING([whether large file support needs explicit enabling])
  1452. ac_getconfs=''
  1453. ac_result=yes
  1454. ac_set=''
  1455. ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  1456. for ac_shellvar in $ac_shellvars; do
  1457. case $ac_shellvar in
  1458. CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;;
  1459. *[)] ac_lfsvar=LFS_$ac_shellvar ;;
  1460. esac
  1461. eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  1462. (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  1463. ac_getconf=`getconf $ac_lfsvar`
  1464. ac_getconfs=$ac_getconfs$ac_getconf
  1465. eval ac_test_$ac_shellvar=\$ac_getconf
  1466. done
  1467. case "$ac_result$ac_getconfs" in
  1468. yes[)] ac_result=no ;;
  1469. esac
  1470. case "$ac_result$ac_set" in
  1471. yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings"
  1472. esac
  1473. AC_MSG_RESULT([$ac_result])
  1474. case $ac_result in
  1475. yes[)]
  1476. for ac_shellvar in $ac_shellvars; do
  1477. eval $ac_shellvar=\$ac_test_$ac_shellvar
  1478. done ;;
  1479. esac
  1480. ])
  1481. dnl
  1482. dnl PHP_SOCKADDR_CHECKS
  1483. dnl
  1484. AC_DEFUN([PHP_SOCKADDR_CHECKS], [
  1485. dnl Check for struct sockaddr_storage exists
  1486. AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
  1487. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  1488. #include <sys/socket.h>]],
  1489. [[struct sockaddr_storage s; s]])],
  1490. [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
  1491. ])
  1492. if test "$ac_cv_sockaddr_storage" = "yes"; then
  1493. AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
  1494. fi
  1495. dnl Check if field sa_len exists in struct sockaddr
  1496. AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  1497. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  1498. #include <sys/socket.h>]], [[static struct sockaddr sa; int n = (int) sa.sa_len; return n;]])],
  1499. [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
  1500. ])
  1501. if test "$ac_cv_sockaddr_sa_len" = "yes"; then
  1502. AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
  1503. fi
  1504. ])
  1505. dnl
  1506. dnl PHP_DECLARED_TIMEZONE
  1507. dnl
  1508. AC_DEFUN([PHP_DECLARED_TIMEZONE],[
  1509. AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
  1510. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1511. #include <sys/types.h>
  1512. #include <time.h>
  1513. #ifdef HAVE_SYS_TIME_H
  1514. #include <sys/time.h>
  1515. #endif
  1516. ]],[[
  1517. time_t foo = (time_t) timezone;
  1518. ]])],[
  1519. ac_cv_declared_timezone=yes
  1520. ],[
  1521. ac_cv_declared_timezone=no
  1522. ])])
  1523. if test "$ac_cv_declared_timezone" = "yes"; then
  1524. AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
  1525. fi
  1526. ])
  1527. dnl
  1528. dnl PHP_EBCDIC
  1529. dnl
  1530. AC_DEFUN([PHP_EBCDIC], [
  1531. AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  1532. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1533. int main(void) {
  1534. return (unsigned char)'A' != (unsigned char)0xC1;
  1535. }
  1536. ]])],[
  1537. ac_cv_ebcdic=yes
  1538. ],[
  1539. ac_cv_ebcdic=no
  1540. ],[
  1541. ac_cv_ebcdic=no
  1542. ])])
  1543. if test "$ac_cv_ebcdic" = "yes"; then
  1544. AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
  1545. fi
  1546. ])
  1547. dnl
  1548. dnl PHP_BROKEN_GETCWD
  1549. dnl
  1550. dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
  1551. dnl component of the path has execute but not read permissions
  1552. dnl
  1553. AC_DEFUN([PHP_BROKEN_GETCWD],[
  1554. AC_MSG_CHECKING([for broken getcwd])
  1555. os=`uname -sr 2>/dev/null`
  1556. case $os in
  1557. SunOS*[)]
  1558. AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
  1559. AC_MSG_RESULT([yes]);;
  1560. *[)]
  1561. AC_MSG_RESULT([no]);;
  1562. esac
  1563. ])
  1564. dnl
  1565. dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
  1566. dnl
  1567. AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
  1568. AC_MSG_CHECKING([for broken libc stdio])
  1569. AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[
  1570. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1571. #include <stdio.h>
  1572. #include <unistd.h>
  1573. int main(int argc, char *argv[])
  1574. {
  1575. FILE *fp;
  1576. long position;
  1577. char *filename = tmpnam(NULL);
  1578. fp = fopen(filename, "w");
  1579. if (fp == NULL) {
  1580. perror("fopen");
  1581. return 2;
  1582. }
  1583. fputs("foobar", fp);
  1584. fclose(fp);
  1585. fp = fopen(filename, "a+");
  1586. position = ftell(fp);
  1587. fclose(fp);
  1588. unlink(filename);
  1589. if (position == 0)
  1590. return 1;
  1591. return 0;
  1592. }
  1593. ]])],
  1594. [_cv_have_broken_glibc_fopen_append=no],
  1595. [_cv_have_broken_glibc_fopen_append=yes],
  1596. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1597. #include <features.h>
  1598. ]], [[
  1599. #if !__GLIBC_PREREQ(2,2)
  1600. choke me
  1601. #endif
  1602. ]])],
  1603. [_cv_have_broken_glibc_fopen_append=yes],
  1604. [_cv_have_broken_glibc_fopen_append=no])
  1605. ])])
  1606. if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then
  1607. AC_MSG_RESULT(yes)
  1608. AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
  1609. else
  1610. AC_MSG_RESULT(no)
  1611. fi
  1612. ])
  1613. dnl
  1614. dnl PHP_BROKEN_GCC_STRLEN_OPT
  1615. dnl
  1616. dnl Early releases of GCC 8 shipped with a strlen() optimization bug, so they
  1617. dnl didn't properly handle the `char val[1]` struct hack. See bug #76510.
  1618. dnl
  1619. AC_DEFUN([PHP_BROKEN_GCC_STRLEN_OPT], [
  1620. AC_CACHE_CHECK([for broken gcc optimize-strlen],ac_cv_have_broken_gcc_strlen_opt,[
  1621. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1622. #include <stdlib.h>
  1623. #include <string.h>
  1624. #include <stdio.h>
  1625. struct s
  1626. {
  1627. int i;
  1628. char c[1];
  1629. };
  1630. int main()
  1631. {
  1632. struct s *s = malloc(sizeof(struct s) + 3);
  1633. s->i = 3;
  1634. strcpy(s->c, "foo");
  1635. return strlen(s->c+1) == 2;
  1636. }
  1637. ]])],[
  1638. ac_cv_have_broken_gcc_strlen_opt=yes
  1639. ],[
  1640. ac_cv_have_broken_gcc_strlen_opt=no
  1641. ],[
  1642. ac_cv_have_broken_gcc_strlen_opt=no
  1643. ])])
  1644. if test "$ac_cv_have_broken_gcc_strlen_opt" = "yes"; then
  1645. CFLAGS="$CFLAGS -fno-optimize-strlen"
  1646. fi
  1647. ])
  1648. dnl
  1649. dnl PHP_FOPENCOOKIE
  1650. dnl
  1651. AC_DEFUN([PHP_FOPENCOOKIE], [
  1652. AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes])
  1653. if test "$have_glibc_fopencookie" = "yes"; then
  1654. dnl this comes in two flavors:
  1655. dnl newer glibcs (since 2.1.2 ? )
  1656. dnl have a type called cookie_io_functions_t
  1657. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1658. #define _GNU_SOURCE
  1659. #include <stdio.h>
  1660. ]], [[cookie_io_functions_t cookie;]])],[have_cookie_io_functions_t=yes],[])
  1661. if test "$have_cookie_io_functions_t" = "yes"; then
  1662. cookie_io_functions_t=cookie_io_functions_t
  1663. have_fopen_cookie=yes
  1664. dnl even newer glibcs have a different seeker definition...
  1665. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1666. #define _GNU_SOURCE
  1667. #include <stdio.h>
  1668. struct cookiedata {
  1669. __off64_t pos;
  1670. };
  1671. __ssize_t reader(void *cookie, char *buffer, size_t size)
  1672. { return size; }
  1673. __ssize_t writer(void *cookie, const char *buffer, size_t size)
  1674. { return size; }
  1675. int closer(void *cookie)
  1676. { return 0; }
  1677. int seeker(void *cookie, __off64_t *position, int whence)
  1678. { ((struct cookiedata*)cookie)->pos = *position; return 0; }
  1679. cookie_io_functions_t funcs = {reader, writer, seeker, closer};
  1680. int main() {
  1681. struct cookiedata g = { 0 };
  1682. FILE *fp = fopencookie(&g, "r", funcs);
  1683. if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
  1684. return 0;
  1685. return 1;
  1686. }
  1687. ]])], [
  1688. cookie_io_functions_use_off64_t=yes
  1689. ], [
  1690. cookie_io_functions_use_off64_t=no
  1691. ], [
  1692. cookie_io_functions_use_off64_t=no
  1693. ])
  1694. else
  1695. dnl older glibc versions (up to 2.1.2 ?)
  1696. dnl call it _IO_cookie_io_functions_t
  1697. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1698. #define _GNU_SOURCE
  1699. #include <stdio.h>
  1700. ]], [[_IO_cookie_io_functions_t cookie;]])], [have_IO_cookie_io_functions_t=yes], [])
  1701. if test "$have_cookie_io_functions_t" = "yes" ; then
  1702. cookie_io_functions_t=_IO_cookie_io_functions_t
  1703. have_fopen_cookie=yes
  1704. fi
  1705. fi
  1706. if test "$have_fopen_cookie" = "yes" ; then
  1707. AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  1708. AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  1709. if test "$cookie_io_functions_use_off64_t" = "yes" ; then
  1710. AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
  1711. fi
  1712. fi
  1713. fi
  1714. ])
  1715. dnl -------------------------------------------------------------------------
  1716. dnl Library/function existence and build sanity checks
  1717. dnl -------------------------------------------------------------------------
  1718. dnl
  1719. dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
  1720. dnl
  1721. dnl Wrapper for AC_CHECK_LIB
  1722. dnl
  1723. AC_DEFUN([PHP_CHECK_LIBRARY], [
  1724. save_old_LDFLAGS=$LDFLAGS
  1725. ac_stuff="$5"
  1726. save_ext_shared=$ext_shared
  1727. ext_shared=yes
  1728. PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
  1729. AC_CHECK_LIB([$1],[$2],[
  1730. LDFLAGS=$save_old_LDFLAGS
  1731. ext_shared=$save_ext_shared
  1732. $3
  1733. ],[
  1734. LDFLAGS=$save_old_LDFLAGS
  1735. ext_shared=$save_ext_shared
  1736. unset ac_cv_lib_$1[]_$2
  1737. $4
  1738. ])dnl
  1739. ])
  1740. dnl
  1741. dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
  1742. dnl
  1743. dnl El cheapo wrapper for AC_CHECK_LIB
  1744. dnl
  1745. AC_DEFUN([PHP_CHECK_FRAMEWORK], [
  1746. save_old_LDFLAGS=$LDFLAGS
  1747. LDFLAGS="-framework $1 $LDFLAGS"
  1748. dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
  1749. dnl rewriting AC_CHECK_LIB is overkill and this only affects
  1750. dnl the "checking.." output anyway.
  1751. AC_CHECK_LIB(c,[$2],[
  1752. LDFLAGS=$save_old_LDFLAGS
  1753. $3
  1754. ],[
  1755. LDFLAGS=$save_old_LDFLAGS
  1756. $4
  1757. ])
  1758. ])
  1759. dnl
  1760. dnl PHP_CHECK_FUNC_LIB(func, libs)
  1761. dnl
  1762. dnl This macro checks whether 'func' or '__func' exists
  1763. dnl in the specified library.
  1764. dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
  1765. dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC
  1766. dnl
  1767. dnl
  1768. dnl autoconf undefines the builtin "shift" :-(
  1769. dnl If possible, we use the builtin shift anyway, otherwise we use
  1770. dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
  1771. ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
  1772. define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
  1773. ])
  1774. dnl
  1775. AC_DEFUN([PHP_CHECK_FUNC_LIB],[
  1776. ifelse($2,,:,[
  1777. unset ac_cv_lib_$2[]_$1
  1778. unset ac_cv_lib_$2[]___$1
  1779. unset found
  1780. AC_CHECK_LIB($2, $1, [found=yes], [
  1781. AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
  1782. ])
  1783. if test "$found" = "yes"; then
  1784. ac_libs=$LIBS
  1785. LIBS="$LIBS -l$2"
  1786. AC_RUN_IFELSE([AC_LANG_SOURCE([[main() { return (0); }]])],[found=yes],[found=no],[found=no])
  1787. LIBS=$ac_libs
  1788. fi
  1789. if test "$found" = "yes"; then
  1790. PHP_ADD_LIBRARY($2)
  1791. PHP_DEF_HAVE($1)
  1792. PHP_DEF_HAVE(lib$2)
  1793. ac_cv_func_$1=yes
  1794. else
  1795. PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
  1796. fi
  1797. ])
  1798. ])
  1799. dnl
  1800. dnl PHP_CHECK_FUNC(func, ...)
  1801. dnl
  1802. dnl This macro checks whether 'func' or '__func' exists
  1803. dnl in the default libraries and as a fall back in the specified library.
  1804. dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
  1805. dnl
  1806. AC_DEFUN([PHP_CHECK_FUNC],[
  1807. unset ac_cv_func_$1
  1808. unset ac_cv_func___$1
  1809. unset found
  1810. AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
  1811. case $found in
  1812. yes[)]
  1813. PHP_DEF_HAVE($1)
  1814. ac_cv_func_$1=yes
  1815. ;;
  1816. ifelse($#,1,,[
  1817. *[)] PHP_CHECK_FUNC_LIB($@) ;;
  1818. ])
  1819. esac
  1820. ])
  1821. dnl
  1822. dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]])
  1823. dnl
  1824. dnl This macro checks whether build works and given function exists.
  1825. dnl
  1826. AC_DEFUN([PHP_TEST_BUILD], [
  1827. old_LIBS=$LIBS
  1828. LIBS="$4 $LIBS"
  1829. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1830. $5
  1831. char $1();
  1832. int main() {
  1833. $1();
  1834. return 0;
  1835. }
  1836. ]])],[
  1837. LIBS=$old_LIBS
  1838. $2
  1839. ],[
  1840. LIBS=$old_LIBS
  1841. $3
  1842. ],[
  1843. LIBS=$old_LIBS
  1844. ])
  1845. ])
  1846. dnl -------------------------------------------------------------------------
  1847. dnl Platform characteristics checks
  1848. dnl -------------------------------------------------------------------------
  1849. dnl
  1850. dnl PHP_SHLIB_SUFFIX_NAMES
  1851. dnl
  1852. dnl Determines link library suffix SHLIB_SUFFIX_NAME
  1853. dnl which can be: .so, .sl or .dylib
  1854. dnl
  1855. dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME
  1856. dnl suffix can be: .so or .sl
  1857. dnl
  1858. AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
  1859. AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
  1860. PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
  1861. PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
  1862. SHLIB_SUFFIX_NAME=so
  1863. SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
  1864. case $host_alias in
  1865. *hpux*[)]
  1866. SHLIB_SUFFIX_NAME=sl
  1867. SHLIB_DL_SUFFIX_NAME=sl
  1868. ;;
  1869. *darwin*[)]
  1870. SHLIB_SUFFIX_NAME=dylib
  1871. SHLIB_DL_SUFFIX_NAME=so
  1872. ;;
  1873. esac
  1874. ])
  1875. dnl
  1876. dnl PHP_CHECK_64BIT([do if 32], [do if 64])
  1877. dnl
  1878. dnl This macro is used to detect if we're at 64-bit platform or not.
  1879. dnl It could be useful for those external libs, that have different precompiled
  1880. dnl versions in different directories.
  1881. dnl
  1882. AC_DEFUN([PHP_CHECK_64BIT],[
  1883. AC_CHECK_SIZEOF(long int, 4)
  1884. AC_MSG_CHECKING([checking if we're at 64-bit platform])
  1885. if test "$ac_cv_sizeof_long_int" = "4" ; then
  1886. AC_MSG_RESULT([no])
  1887. $1
  1888. else
  1889. AC_MSG_RESULT([yes])
  1890. $2
  1891. fi
  1892. ])
  1893. dnl
  1894. dnl PHP_C_BIGENDIAN
  1895. dnl
  1896. dnl Replacement macro for AC_C_BIGENDIAN
  1897. dnl
  1898. AC_DEFUN([PHP_C_BIGENDIAN],
  1899. [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
  1900. [
  1901. ac_cv_c_bigendian_php=unknown
  1902. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1903. int main(void)
  1904. {
  1905. short one = 1;
  1906. char *cp = (char *)&one;
  1907. if (*cp == 0) {
  1908. return(0);
  1909. } else {
  1910. return(1);
  1911. }
  1912. }
  1913. ]])], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
  1914. ])
  1915. if test $ac_cv_c_bigendian_php = yes; then
  1916. AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
  1917. fi
  1918. ])
  1919. dnl -------------------------------------------------------------------------
  1920. dnl Checks for programs: PHP_PROG_<program>
  1921. dnl -------------------------------------------------------------------------
  1922. dnl
  1923. dnl PHP_PROG_SENDMAIL
  1924. dnl
  1925. dnl Search for the sendmail binary
  1926. dnl
  1927. AC_DEFUN([PHP_PROG_SENDMAIL], [
  1928. PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
  1929. AC_PATH_PROG(PROG_SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$PHP_ALT_PATH)
  1930. PHP_SUBST(PROG_SENDMAIL)
  1931. ])
  1932. dnl
  1933. dnl PHP_PROG_AWK
  1934. dnl
  1935. dnl Some vendors force mawk before gawk; mawk is broken so we don't like that
  1936. dnl
  1937. AC_DEFUN([PHP_PROG_AWK], [
  1938. AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
  1939. case "$AWK" in
  1940. *mawk)
  1941. AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
  1942. ;;
  1943. *gawk)
  1944. ;;
  1945. bork)
  1946. AC_MSG_ERROR([Could not find awk; Install GNU awk])
  1947. ;;
  1948. *)
  1949. AC_MSG_CHECKING([if $AWK is broken])
  1950. if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
  1951. AC_MSG_RESULT([yes])
  1952. AC_MSG_ERROR([You should install GNU awk])
  1953. else
  1954. AC_MSG_RESULT([no])
  1955. fi
  1956. ;;
  1957. esac
  1958. PHP_SUBST(AWK)
  1959. ])
  1960. dnl
  1961. dnl PHP_PROG_BISON
  1962. dnl
  1963. dnl Search for bison and check it's version
  1964. dnl
  1965. AC_DEFUN([PHP_PROG_BISON], [
  1966. AC_PROG_YACC
  1967. LIBZEND_BISON_CHECK
  1968. PHP_SUBST(YACC)
  1969. ])
  1970. dnl
  1971. dnl PHP_PROG_RE2C
  1972. dnl
  1973. dnl Search for the re2c binary and check the version
  1974. dnl
  1975. AC_DEFUN([PHP_PROG_RE2C],[
  1976. AC_CHECK_PROG(RE2C, re2c, re2c)
  1977. if test -n "$RE2C"; then
  1978. AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
  1979. re2c_vernum=`$RE2C --vernum 2>/dev/null`
  1980. if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then
  1981. php_cv_re2c_version=invalid
  1982. else
  1983. php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
  1984. fi
  1985. ])
  1986. fi
  1987. case $php_cv_re2c_version in
  1988. ""|invalid[)]
  1989. AC_MSG_WARN([You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.])
  1990. RE2C="exit 0;"
  1991. ;;
  1992. esac
  1993. PHP_SUBST(RE2C)
  1994. ])
  1995. dnl -------------------------------------------------------------------------
  1996. dnl Common setup macros: PHP_SETUP_<what>
  1997. dnl -------------------------------------------------------------------------
  1998. dnl
  1999. dnl PHP_SETUP_ICU([shared-add])
  2000. dnl
  2001. dnl Common setup macro for ICU
  2002. dnl
  2003. AC_DEFUN([PHP_SETUP_ICU],[
  2004. PHP_ARG_WITH(icu-dir,,
  2005. [ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no)
  2006. if test "$PHP_ICU_DIR" = "no"; then
  2007. PHP_ICU_DIR=DEFAULT
  2008. fi
  2009. AC_MSG_CHECKING([for location of ICU headers and libraries])
  2010. found_icu=no
  2011. dnl First try to find pkg-config
  2012. if test -z "$PKG_CONFIG"; then
  2013. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2014. fi
  2015. dnl If pkg-config is found try using it
  2016. if test "$PHP_ICU_DIR" = "DEFAULT" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists icu-uc icu-io icu-i18n; then
  2017. if $PKG_CONFIG --atleast-version=4.0 icu-uc; then
  2018. found_icu=yes
  2019. icu_version_full=`$PKG_CONFIG --modversion icu-uc`
  2020. ac_IFS=$IFS
  2021. IFS="."
  2022. set $icu_version_full
  2023. IFS=$ac_IFS
  2024. icu_version=`expr [$]1 \* 1000 + [$]2`
  2025. AC_MSG_RESULT([found $icu_version_full])
  2026. ICU_LIBS=`$PKG_CONFIG --libs icu-uc icu-io icu-i18n`
  2027. ICU_INCS=`$PKG_CONFIG --cflags-only-I icu-uc icu-io icu-i18n`
  2028. ICU_CXXFLAGS=`$PKG_CONFIG --variable=CXXFLAGS icu-uc`
  2029. ICU_CXXFLAGS="$ICU_CXXFLAGS -DU_USING_ICU_NAMESPACE=1"
  2030. AC_MSG_RESULT([found $ICU_VERSION])
  2031. PHP_EVAL_LIBLINE($ICU_LIBS, $1)
  2032. PHP_EVAL_INCLINE($ICU_INCS)
  2033. else
  2034. AC_MSG_ERROR([ICU version 4.0 or later required.])
  2035. fi
  2036. fi
  2037. dnl If pkg-config fails for some reason, revert to the old method
  2038. if test "$found_icu" = "no"; then
  2039. if test "$PHP_ICU_DIR" = "DEFAULT"; then
  2040. dnl Try to find icu-config
  2041. AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
  2042. else
  2043. ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
  2044. fi
  2045. dnl Trust icu-config to know better what the install prefix is..
  2046. icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
  2047. if test "$?" != "0" || test -z "$icu_install_prefix"; then
  2048. AC_MSG_RESULT([not found])
  2049. AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
  2050. else
  2051. AC_MSG_RESULT([$icu_install_prefix])
  2052. dnl Check ICU version
  2053. AC_MSG_CHECKING([for ICU 4.0 or greater])
  2054. icu_version_full=`$ICU_CONFIG --version`
  2055. ac_IFS=$IFS
  2056. IFS="."
  2057. set $icu_version_full
  2058. IFS=$ac_IFS
  2059. icu_version=`expr [$]1 \* 1000 + [$]2`
  2060. AC_MSG_RESULT([found $icu_version_full])
  2061. if test "$icu_version" -lt "4000"; then
  2062. AC_MSG_ERROR([ICU version 4.0 or later is required])
  2063. fi
  2064. ICU_VERSION=$icu_version
  2065. ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
  2066. ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
  2067. PHP_EVAL_INCLINE($ICU_INCS)
  2068. PHP_EVAL_LIBLINE($ICU_LIBS, $1)
  2069. ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
  2070. if test "$icu_version" -ge "49000"; then
  2071. ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
  2072. ICU_CFLAGS="-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
  2073. fi
  2074. if test "$icu_version" -ge "60000"; then
  2075. ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"
  2076. fi
  2077. fi
  2078. fi
  2079. ICU_CFLAGS="$ICU_CFLAGS -DU_DEFINE_FALSE_AND_TRUE=1"
  2080. ])
  2081. dnl
  2082. dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]])
  2083. dnl
  2084. dnl Common setup macro for kerberos
  2085. dnl
  2086. AC_DEFUN([PHP_SETUP_KERBEROS],[
  2087. found_kerberos=no
  2088. unset KERBEROS_CFLAGS
  2089. unset KERBEROS_LIBS
  2090. dnl First try to find krb5-config
  2091. if test -z "$KRB5_CONFIG"; then
  2092. AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin])
  2093. fi
  2094. dnl If krb5-config is found try using it
  2095. if test "$PHP_KERBEROS" != "no" && test -x "$KRB5_CONFIG"; then
  2096. KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi`
  2097. KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi`
  2098. if test -n "$KERBEROS_LIBS"; then
  2099. found_kerberos=yes
  2100. PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1)
  2101. PHP_EVAL_INCLINE($KERBEROS_CFLAGS)
  2102. fi
  2103. fi
  2104. dnl If still not found use old skool method
  2105. if test "$found_kerberos" = "no"; then
  2106. if test "$PHP_KERBEROS" = "yes"; then
  2107. PHP_KERBEROS="/usr/kerberos /usr/local /usr"
  2108. fi
  2109. for i in $PHP_KERBEROS; do
  2110. if test -f $i/$PHP_LIBDIR/libkrb5.a || test -f $i/$PHP_LIBDIR/libkrb5.$SHLIB_SUFFIX_NAME; then
  2111. PHP_KERBEROS_DIR=$i
  2112. break
  2113. fi
  2114. done
  2115. if test "$PHP_KERBEROS_DIR"; then
  2116. found_kerberos=yes
  2117. PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/$PHP_LIBDIR, $1)
  2118. PHP_ADD_LIBRARY(gssapi_krb5, 1, $1)
  2119. PHP_ADD_LIBRARY(krb5, 1, $1)
  2120. PHP_ADD_LIBRARY(k5crypto, 1, $1)
  2121. PHP_ADD_LIBRARY(com_err, 1, $1)
  2122. PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include)
  2123. fi
  2124. fi
  2125. if test "$found_kerberos" = "yes"; then
  2126. ifelse([$2],[],:,[$2])
  2127. ifelse([$3],[],,[else $3])
  2128. fi
  2129. ])
  2130. dnl
  2131. dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
  2132. dnl
  2133. dnl Common setup macro for openssl
  2134. dnl
  2135. AC_DEFUN([PHP_SETUP_OPENSSL],[
  2136. found_openssl=no
  2137. unset OPENSSL_INCDIR
  2138. unset OPENSSL_LIBDIR
  2139. dnl Empty variable means 'no'
  2140. test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
  2141. test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
  2142. dnl Fallbacks for different configure options
  2143. if test "$PHP_OPENSSL" != "no"; then
  2144. PHP_OPENSSL_DIR=$PHP_OPENSSL
  2145. elif test "$PHP_IMAP_SSL" != "no"; then
  2146. PHP_OPENSSL_DIR=$PHP_IMAP_SSL
  2147. fi
  2148. dnl First try to find pkg-config
  2149. if test -z "$PKG_CONFIG"; then
  2150. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2151. fi
  2152. dnl If pkg-config is found try using it
  2153. if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
  2154. if $PKG_CONFIG --atleast-version=1.0.1 openssl; then
  2155. found_openssl=yes
  2156. OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
  2157. OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
  2158. OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
  2159. else
  2160. AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.])
  2161. fi
  2162. if test -n "$OPENSSL_LIBS"; then
  2163. PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
  2164. fi
  2165. if test -n "$OPENSSL_INCS"; then
  2166. PHP_EVAL_INCLINE($OPENSSL_INCS)
  2167. fi
  2168. fi
  2169. dnl If pkg-config fails for some reason, revert to the old method
  2170. if test "$found_openssl" = "no"; then
  2171. if test "$PHP_OPENSSL_DIR" = "yes"; then
  2172. PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
  2173. fi
  2174. for i in $PHP_OPENSSL_DIR; do
  2175. if test -r $i/include/openssl/evp.h; then
  2176. OPENSSL_INCDIR=$i/include
  2177. fi
  2178. if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
  2179. OPENSSL_LIBDIR=$i/$PHP_LIBDIR
  2180. fi
  2181. test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
  2182. done
  2183. if test -z "$OPENSSL_INCDIR"; then
  2184. AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
  2185. fi
  2186. if test -z "$OPENSSL_LIBDIR"; then
  2187. AC_MSG_ERROR([Cannot find OpenSSL's libraries])
  2188. fi
  2189. old_CPPFLAGS=$CPPFLAGS
  2190. CPPFLAGS=-I$OPENSSL_INCDIR
  2191. AC_MSG_CHECKING([for OpenSSL version])
  2192. AC_EGREP_CPP(yes,[
  2193. #include <openssl/opensslv.h>
  2194. #if OPENSSL_VERSION_NUMBER >= 0x10001001L
  2195. yes
  2196. #endif
  2197. ],[
  2198. AC_MSG_RESULT([>= 1.0.1])
  2199. ],[
  2200. AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.])
  2201. ])
  2202. CPPFLAGS=$old_CPPFLAGS
  2203. PHP_ADD_INCLUDE($OPENSSL_INCDIR)
  2204. PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
  2205. PHP_ADD_LIBRARY(crypto,,$1)
  2206. ],[
  2207. AC_MSG_ERROR([libcrypto not found!])
  2208. ],[
  2209. -L$OPENSSL_LIBDIR
  2210. ])
  2211. old_LIBS=$LIBS
  2212. LIBS="$LIBS -lcrypto"
  2213. PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
  2214. found_openssl=yes
  2215. ],[
  2216. AC_MSG_ERROR([libssl not found!])
  2217. ],[
  2218. -L$OPENSSL_LIBDIR
  2219. ])
  2220. LIBS=$old_LIBS
  2221. PHP_ADD_LIBRARY(ssl,,$1)
  2222. PHP_ADD_LIBRARY(crypto,,$1)
  2223. PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
  2224. fi
  2225. if test "$found_openssl" = "yes"; then
  2226. dnl For apache 1.3.x static build
  2227. OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
  2228. AC_SUBST(OPENSSL_INCDIR_OPT)
  2229. ifelse([$2],[],:,[$2])
  2230. ifelse([$3],[],,[else $3])
  2231. fi
  2232. ])
  2233. dnl
  2234. dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
  2235. dnl
  2236. dnl Common setup macro for iconv
  2237. dnl
  2238. AC_DEFUN([PHP_SETUP_ICONV], [
  2239. found_iconv=no
  2240. unset ICONV_DIR
  2241. # Create the directories for a VPATH build:
  2242. $php_shtool mkdir -p ext/iconv
  2243. echo > ext/iconv/php_have_bsd_iconv.h
  2244. echo > ext/iconv/php_have_ibm_iconv.h
  2245. echo > ext/iconv/php_have_glibc_iconv.h
  2246. echo > ext/iconv/php_have_libiconv.h
  2247. echo > ext/iconv/php_have_iconv.h
  2248. echo > ext/iconv/php_php_iconv_impl.h
  2249. echo > ext/iconv/php_iconv_aliased_libiconv.h
  2250. echo > ext/iconv/php_php_iconv_h_path.h
  2251. echo > ext/iconv/php_iconv_supports_errno.h
  2252. dnl
  2253. dnl Check libc first if no path is provided in --with-iconv
  2254. dnl
  2255. if test "$PHP_ICONV" = "yes"; then
  2256. dnl Reset LIBS temporarily as it may have already been included
  2257. dnl -liconv in.
  2258. LIBS_save="$LIBS"
  2259. LIBS=
  2260. AC_CHECK_FUNC(iconv, [
  2261. found_iconv=yes
  2262. ],[
  2263. AC_CHECK_FUNC(libiconv,[
  2264. PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
  2265. AC_DEFINE(HAVE_LIBICONV, 1, [ ])
  2266. found_iconv=yes
  2267. ])
  2268. ])
  2269. LIBS="$LIBS_save"
  2270. fi
  2271. dnl
  2272. dnl Check external libs for iconv funcs
  2273. dnl
  2274. if test "$found_iconv" = "no"; then
  2275. for i in $PHP_ICONV /usr/local /usr; do
  2276. if test -r $i/include/giconv.h; then
  2277. AC_DEFINE(HAVE_GICONV_H, 1, [ ])
  2278. ICONV_DIR=$i
  2279. iconv_lib_name=giconv
  2280. break
  2281. elif test -r $i/include/iconv.h; then
  2282. ICONV_DIR=$i
  2283. iconv_lib_name=iconv
  2284. break
  2285. fi
  2286. done
  2287. if test -z "$ICONV_DIR"; then
  2288. AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
  2289. fi
  2290. if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
  2291. test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
  2292. then
  2293. PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
  2294. found_iconv=yes
  2295. PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
  2296. AC_DEFINE(HAVE_LIBICONV,1,[ ])
  2297. PHP_DEFINE([ICONV_ALIASED_LIBICONV],1,[ext/iconv])
  2298. AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv])
  2299. ], [
  2300. PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
  2301. found_iconv=yes
  2302. ], [], [
  2303. -L$ICONV_DIR/$PHP_LIBDIR
  2304. ])
  2305. ], [
  2306. -L$ICONV_DIR/$PHP_LIBDIR
  2307. ])
  2308. fi
  2309. fi
  2310. if test "$found_iconv" = "yes"; then
  2311. PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
  2312. AC_DEFINE(HAVE_ICONV,1,[ ])
  2313. if test -n "$ICONV_DIR"; then
  2314. PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1)
  2315. PHP_ADD_INCLUDE($ICONV_DIR/include)
  2316. fi
  2317. $2
  2318. ifelse([$3],[],,[else $3])
  2319. fi
  2320. ])
  2321. dnl
  2322. dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
  2323. dnl
  2324. dnl Common setup macro for libxml
  2325. dnl
  2326. AC_DEFUN([PHP_SETUP_LIBXML], [
  2327. found_libxml=no
  2328. dnl First try to find xml2-config
  2329. AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
  2330. [
  2331. for i in $PHP_LIBXML_DIR /usr/local /usr; do
  2332. if test -x "$i/bin/xml2-config"; then
  2333. ac_cv_php_xml2_config_path="$i/bin/xml2-config"
  2334. break
  2335. fi
  2336. done
  2337. ])
  2338. if test -x "$ac_cv_php_xml2_config_path"; then
  2339. XML2_CONFIG="$ac_cv_php_xml2_config_path"
  2340. libxml_full_version=`$XML2_CONFIG --version`
  2341. ac_IFS=$IFS
  2342. IFS="."
  2343. set $libxml_full_version
  2344. IFS=$ac_IFS
  2345. LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
  2346. if test "$LIBXML_VERSION" -ge "2006011"; then
  2347. found_libxml=yes
  2348. LIBXML_LIBS=`$XML2_CONFIG --libs`
  2349. LIBXML_INCS=`$XML2_CONFIG --cflags`
  2350. else
  2351. AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
  2352. fi
  2353. fi
  2354. dnl If xml2-config fails, try pkg-config
  2355. if test "$found_libxml" = "no"; then
  2356. if test -z "$PKG_CONFIG"; then
  2357. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2358. fi
  2359. dnl If pkg-config is found try using it
  2360. if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libxml-2.0; then
  2361. if $PKG_CONFIG --atleast-version=2.6.11 libxml-2.0; then
  2362. found_libxml=yes
  2363. LIBXML_LIBS=`$PKG_CONFIG --libs libxml-2.0`
  2364. LIBXML_INCS=`$PKG_CONFIG --cflags-only-I libxml-2.0`
  2365. else
  2366. AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
  2367. fi
  2368. fi
  2369. fi
  2370. if test "$found_libxml" = "yes"; then
  2371. PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
  2372. PHP_EVAL_INCLINE($LIBXML_INCS)
  2373. dnl Check that build works with given libs
  2374. AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
  2375. PHP_TEST_BUILD(xmlInitParser,
  2376. [
  2377. php_cv_libxml_build_works=yes
  2378. ], [
  2379. AC_MSG_RESULT(no)
  2380. AC_MSG_ERROR([build test failed. Please check the config.log for details.])
  2381. ], [
  2382. [$]$1
  2383. ])
  2384. ])
  2385. if test "$php_cv_libxml_build_works" = "yes"; then
  2386. AC_DEFINE(HAVE_LIBXML, 1, [ ])
  2387. fi
  2388. $2
  2389. ifelse([$3],[],,[else $3])
  2390. fi
  2391. ])
  2392. dnl -------------------------------------------------------------------------
  2393. dnl Misc. macros
  2394. dnl -------------------------------------------------------------------------
  2395. dnl
  2396. dnl PHP_INSTALL_HEADERS(path [, file ...])
  2397. dnl
  2398. dnl PHP header files to be installed
  2399. dnl
  2400. AC_DEFUN([PHP_INSTALL_HEADERS],[
  2401. ifelse([$2],[],[
  2402. for header_file in $1; do
  2403. PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
  2404. INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
  2405. ])
  2406. done
  2407. ], [
  2408. header_path=$1
  2409. for header_file in $2; do
  2410. hp_hf="$header_path/$header_file"
  2411. PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
  2412. INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
  2413. ])
  2414. done
  2415. ])
  2416. ])
  2417. dnl
  2418. dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
  2419. dnl
  2420. dnl This macro is used to get a comparable
  2421. dnl version for apache1/2.
  2422. dnl
  2423. AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
  2424. ac_output=`$1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
  2425. ac_IFS=$IFS
  2426. IFS="- /.
  2427. "
  2428. set $ac_output
  2429. IFS=$ac_IFS
  2430. APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
  2431. ])
  2432. dnl
  2433. dnl PHP_DEBUG_MACRO(filename)
  2434. dnl
  2435. AC_DEFUN([PHP_DEBUG_MACRO],[
  2436. DEBUG_LOG=$1
  2437. cat >$1 <<X
  2438. CONFIGURE: $CONFIGURE_COMMAND
  2439. CC: $CC
  2440. CFLAGS: $CFLAGS
  2441. CPPFLAGS: $CPPFLAGS
  2442. CXX: $CXX
  2443. CXXFLAGS: $CXXFLAGS
  2444. INCLUDES: $INCLUDES
  2445. LDFLAGS: $LDFLAGS
  2446. LIBS: $LIBS
  2447. DLIBS: $DLIBS
  2448. SAPI: $PHP_SAPI
  2449. PHP_RPATHS: $PHP_RPATHS
  2450. uname -a: `uname -a`
  2451. X
  2452. cat >conftest.$ac_ext <<X
  2453. main()
  2454. {
  2455. exit(0);
  2456. }
  2457. X
  2458. (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
  2459. rm -fr conftest*
  2460. ])
  2461. dnl
  2462. dnl PHP_CONFIG_NICE(filename)
  2463. dnl
  2464. dnl Generates the config.nice file
  2465. dnl
  2466. AC_DEFUN([PHP_CONFIG_NICE],[
  2467. AC_REQUIRE([AC_PROG_EGREP])
  2468. AC_REQUIRE([LT_AC_PROG_SED])
  2469. PHP_SUBST_OLD(EGREP)
  2470. PHP_SUBST_OLD(SED)
  2471. test -f $1 && mv $1 $1.old
  2472. rm -f $1.old
  2473. cat >$1<<EOF
  2474. #! /bin/sh
  2475. #
  2476. # Created by configure
  2477. EOF
  2478. clean_configure_args=$ac_configure_args
  2479. for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do
  2480. eval val=\$$var
  2481. if test -n "$val"; then
  2482. echo "$var='$val' \\" >> $1
  2483. if test `expr "X$ac_configure_args" : ".*${var}.*"` != 0; then
  2484. clean_configure_args=$(echo $clean_configure_args | sed -e "s#'$var=$val'##")
  2485. fi
  2486. fi
  2487. done
  2488. echo "'[$]0' \\" >> $1
  2489. if test `expr " [$]0" : " '.*"` = 0; then
  2490. CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
  2491. else
  2492. CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
  2493. fi
  2494. CONFIGURE_ARGS="$clean_configure_args"
  2495. while test "X$CONFIGURE_ARGS" != "X";
  2496. do
  2497. if CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\('[[^']]*'\)"`
  2498. then
  2499. CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *'[[^']]*' \(.*\)"`
  2500. elif CURRENT_ARG=`expr "X$CONFIGURE_ARGS" : "X *\([[^ ]]*\)"`
  2501. then
  2502. CONFIGURE_ARGS=`expr "X$CONFIGURE_ARGS" : "X *[[^ ]]* \(.*\)"`
  2503. CURRENT_ARG="'$CURRENT_ARG'"
  2504. else
  2505. break
  2506. fi
  2507. $as_echo "$CURRENT_ARG \\" >>$1
  2508. CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $CURRENT_ARG"
  2509. done
  2510. echo '"[$]@"' >> $1
  2511. chmod +x $1
  2512. CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS"
  2513. PHP_SUBST_OLD(CONFIGURE_COMMAND)
  2514. PHP_SUBST_OLD(CONFIGURE_OPTIONS)
  2515. ])
  2516. dnl
  2517. dnl PHP_CHECK_CONFIGURE_OPTIONS
  2518. dnl
  2519. AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
  2520. for arg in $ac_configure_args; do
  2521. case $arg in
  2522. --with-*[)]
  2523. arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
  2524. ;;
  2525. --without-*[)]
  2526. arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
  2527. ;;
  2528. --enable-*[)]
  2529. arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
  2530. ;;
  2531. --disable-*[)]
  2532. arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
  2533. ;;
  2534. *[)]
  2535. continue
  2536. ;;
  2537. esac
  2538. case $arg_name in
  2539. # Allow --disable-all / --enable-all
  2540. enable-all[)];;
  2541. # Allow certain libtool options
  2542. enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
  2543. # Allow certain TSRM options
  2544. with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads [)];;
  2545. # Allow certain Zend options
  2546. with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
  2547. # All the rest must be set using the PHP_ARG_* macros
  2548. # PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name>
  2549. *[)]
  2550. # Options that exist before PHP 6
  2551. if test "$PHP_MAJOR_VERSION" -lt "6"; then
  2552. case $arg_name in
  2553. enable-zend-multibyte[)] continue;;
  2554. esac
  2555. fi
  2556. is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
  2557. if eval test "x\$$is_arg_set" = "x"; then
  2558. PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS
  2559. [$]arg"
  2560. fi
  2561. ;;
  2562. esac
  2563. done
  2564. ])
  2565. dnl
  2566. dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]])
  2567. dnl
  2568. AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[
  2569. AC_CACHE_CHECK([for PDO includes], pdo_cv_inc_path, [
  2570. AC_MSG_CHECKING([for PDO includes])
  2571. if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
  2572. pdo_cv_inc_path=$abs_srcdir/ext
  2573. elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
  2574. pdo_cv_inc_path=$abs_srcdir/ext
  2575. elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then
  2576. pdo_cv_inc_path=$phpincludedir/ext
  2577. fi
  2578. ])
  2579. if test -n "$pdo_cv_inc_path"; then
  2580. ifelse([$1],[],:,[$1])
  2581. else
  2582. ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2])
  2583. fi
  2584. ])
  2585. dnl
  2586. dnl PHP_DETECT_ICC
  2587. dnl Detect Intel C++ Compiler and unset $GCC if ICC found
  2588. AC_DEFUN([PHP_DETECT_ICC],
  2589. [
  2590. ICC="no"
  2591. AC_MSG_CHECKING([for icc])
  2592. AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
  2593. ICC="no"
  2594. AC_MSG_RESULT([no]),
  2595. ICC="yes"
  2596. GCC="no"
  2597. AC_MSG_RESULT([yes])
  2598. )
  2599. ])
  2600. dnl PHP_DETECT_SUNCC
  2601. dnl Detect if the systems default compiler is suncc.
  2602. dnl We also set some useful CFLAGS if the user didn't set any
  2603. AC_DEFUN([PHP_DETECT_SUNCC],[
  2604. SUNCC="no"
  2605. AC_MSG_CHECKING([for suncc])
  2606. AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C],
  2607. SUNCC="no"
  2608. AC_MSG_RESULT([no]),
  2609. SUNCC="yes"
  2610. GCC="no"
  2611. test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
  2612. GCC=""
  2613. AC_MSG_RESULT([yes])
  2614. )
  2615. ])
  2616. dnl
  2617. dnl PHP_CRYPT_R_STYLE
  2618. dnl detect the style of crypt_r() is any is available
  2619. dnl see APR_CHECK_CRYPT_R_STYLE() for original version
  2620. dnl
  2621. AC_DEFUN([PHP_CRYPT_R_STYLE],
  2622. [
  2623. AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
  2624. php_cv_crypt_r_style=none
  2625. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2626. #define _REENTRANT 1
  2627. #include <crypt.h>
  2628. ]], [[
  2629. CRYPTD buffer;
  2630. crypt_r("passwd", "hash", &buffer);
  2631. ]])],[php_cv_crypt_r_style=cryptd],[])
  2632. if test "$php_cv_crypt_r_style" = "none"; then
  2633. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2634. #define _REENTRANT 1
  2635. #include <crypt.h>
  2636. ]],[[
  2637. struct crypt_data buffer;
  2638. crypt_r("passwd", "hash", &buffer);
  2639. ]])],[php_cv_crypt_r_style=struct_crypt_data],[])
  2640. fi
  2641. if test "$php_cv_crypt_r_style" = "none"; then
  2642. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2643. #define _REENTRANT 1
  2644. #define _GNU_SOURCE
  2645. #include <crypt.h>
  2646. ]],[[
  2647. struct crypt_data buffer;
  2648. crypt_r("passwd", "hash", &buffer);
  2649. ]])],[php_cv_crypt_r_style=struct_crypt_data_gnu_source],[])
  2650. fi
  2651. ])
  2652. if test "$php_cv_crypt_r_style" = "cryptd"; then
  2653. AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
  2654. fi
  2655. if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
  2656. AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
  2657. fi
  2658. if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
  2659. AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
  2660. fi
  2661. if test "$php_cv_crypt_r_style" = "none"; then
  2662. AC_MSG_ERROR([Unable to detect data struct used by crypt_r])
  2663. fi
  2664. ])
  2665. dnl
  2666. dnl PHP_TEST_WRITE_STDOUT
  2667. dnl
  2668. AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
  2669. AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
  2670. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  2671. #ifdef HAVE_UNISTD_H
  2672. #include <unistd.h>
  2673. #endif
  2674. #define TEXT "This is the test message -- "
  2675. main()
  2676. {
  2677. int n;
  2678. n = write(1, TEXT, sizeof(TEXT)-1);
  2679. return (!(n == sizeof(TEXT)-1));
  2680. }
  2681. ]])],[
  2682. ac_cv_write_stdout=yes
  2683. ],[
  2684. ac_cv_write_stdout=no
  2685. ],[
  2686. ac_cv_write_stdout=no
  2687. ])
  2688. ])
  2689. if test "$ac_cv_write_stdout" = "yes"; then
  2690. AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
  2691. fi
  2692. ])
  2693. dnl
  2694. dnl PHP_INIT_DTRACE(providerdesc, header-file, sources [, module])
  2695. dnl
  2696. AC_DEFUN([PHP_INIT_DTRACE],[
  2697. dnl Set paths properly when called from extension
  2698. case "$4" in
  2699. ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir;;
  2700. /*[)] ac_srcdir=`echo "$4"|cut -c 2-`"/"; ac_bdir=$ac_srcdir;;
  2701. *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$4/";;
  2702. esac
  2703. dnl providerdesc
  2704. ac_provsrc=$1
  2705. old_IFS=[$]IFS
  2706. IFS=.
  2707. set $ac_provsrc
  2708. ac_provobj=[$]1
  2709. IFS=$old_IFS
  2710. dnl header-file
  2711. ac_hdrobj=$2
  2712. dnl Add providerdesc.o or .lo into global objects when needed
  2713. case $host_alias in
  2714. *freebsd*)
  2715. PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o"
  2716. PHP_LDFLAGS="$PHP_LDFLAGS -lelf"
  2717. ;;
  2718. *solaris*)
  2719. PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo"
  2720. ;;
  2721. *linux*)
  2722. PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo"
  2723. ;;
  2724. esac
  2725. dnl DTrace objects
  2726. old_IFS=[$]IFS
  2727. for ac_src in $3; do
  2728. IFS=.
  2729. set $ac_src
  2730. ac_obj=[$]1
  2731. IFS=$old_IFS
  2732. PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo"
  2733. done;
  2734. case [$]php_sapi_module in
  2735. shared[)]
  2736. for ac_lo in $PHP_DTRACE_OBJS; do
  2737. dtrace_objs="[$]dtrace_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`"
  2738. done;
  2739. ;;
  2740. *[)]
  2741. dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
  2742. ;;
  2743. esac
  2744. dnl Generate Makefile.objects entries
  2745. dnl The empty $ac_provsrc command stops an implicit circular dependency
  2746. dnl in GNU Make which causes the .d file to be overwritten (Bug 61268)
  2747. cat>>Makefile.objects<<EOF
  2748. $abs_srcdir/$ac_provsrc:;
  2749. $ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc
  2750. CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
  2751. \$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
  2752. EOF
  2753. case $host_alias in
  2754. *solaris*|*linux*)
  2755. dtrace_prov_name="`echo $ac_provsrc | $SED -e 's#\(.*\)\/##'`.o"
  2756. dtrace_lib_dir="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/[^/]*#\1#'`/.libs"
  2757. dtrace_d_obj="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/\([^/]*\)#\1/.libs/\2#'`.o"
  2758. dtrace_nolib_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
  2759. for ac_lo in $PHP_DTRACE_OBJS; do
  2760. dtrace_lib_objs="[$]dtrace_lib_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`"
  2761. done;
  2762. dnl Always attempt to create both PIC and non-PIC DTrace objects (Bug 63692)
  2763. cat>>Makefile.objects<<EOF
  2764. $ac_bdir[$]ac_provsrc.lo: \$(PHP_DTRACE_OBJS)
  2765. echo "[#] Generated by Makefile for libtool" > \$[]@
  2766. @test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir
  2767. 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 [\\]
  2768. echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
  2769. else [\\]
  2770. echo "pic_object='none'" >> \$[]@ [;\\]
  2771. fi
  2772. 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 [\\]
  2773. echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\]
  2774. else [\\]
  2775. echo "non_pic_object='none'" >> \$[]@ [;\\]
  2776. fi
  2777. EOF
  2778. ;;
  2779. *)
  2780. cat>>Makefile.objects<<EOF
  2781. $ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS)
  2782. CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
  2783. EOF
  2784. ;;
  2785. esac
  2786. ])
  2787. dnl
  2788. dnl PHP_CHECK_STDINT_TYPES
  2789. dnl
  2790. AC_DEFUN([PHP_CHECK_STDINT_TYPES], [
  2791. AC_CHECK_SIZEOF([short], 2)
  2792. AC_CHECK_SIZEOF([int], 4)
  2793. AC_CHECK_SIZEOF([long], 4)
  2794. AC_CHECK_SIZEOF([long long], 8)
  2795. AC_CHECK_TYPES([int8, int16, int32, int64, int8_t, int16_t, int32_t, int64_t, uint8, uint16, uint32, uint64, uint8_t, uint16_t, uint32_t, uint64_t, u_int8_t, u_int16_t, u_int32_t, u_int64_t], [], [], [
  2796. #if HAVE_STDINT_H
  2797. # include <stdint.h>
  2798. #endif
  2799. #if HAVE_SYS_TYPES_H
  2800. # include <sys/types.h>
  2801. #endif
  2802. ])
  2803. AC_DEFINE([PHP_HAVE_STDINT_TYPES], [1], [Checked for stdint types])
  2804. ])
  2805. dnl PHP_CHECK_BUILTIN_EXPECT
  2806. AC_DEFUN([PHP_CHECK_BUILTIN_EXPECT], [
  2807. AC_MSG_CHECKING([for __builtin_expect])
  2808. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2809. return __builtin_expect(1,1) ? 1 : 0;
  2810. ]])], [
  2811. have_builtin_expect=1
  2812. AC_MSG_RESULT([yes])
  2813. ], [
  2814. have_builtin_expect=0
  2815. AC_MSG_RESULT([no])
  2816. ])
  2817. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_EXPECT], [$have_builtin_expect], [Whether the compiler supports __builtin_expect])
  2818. ])
  2819. dnl PHP_CHECK_BUILTIN_CLZ
  2820. AC_DEFUN([PHP_CHECK_BUILTIN_CLZ], [
  2821. AC_MSG_CHECKING([for __builtin_clz])
  2822. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2823. return __builtin_clz(1) ? 1 : 0;
  2824. ]])], [
  2825. have_builtin_clz=1
  2826. AC_MSG_RESULT([yes])
  2827. ], [
  2828. have_builtin_clz=0
  2829. AC_MSG_RESULT([no])
  2830. ])
  2831. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CLZ], [$have_builtin_clz], [Whether the compiler supports __builtin_clz])
  2832. ])
  2833. dnl PHP_CHECK_BUILTIN_CTZL
  2834. AC_DEFUN([PHP_CHECK_BUILTIN_CTZL], [
  2835. AC_MSG_CHECKING([for __builtin_ctzl])
  2836. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2837. return __builtin_ctzl(2L) ? 1 : 0;
  2838. ]])], [
  2839. have_builtin_ctzl=1
  2840. AC_MSG_RESULT([yes])
  2841. ], [
  2842. have_builtin_ctzl=0
  2843. AC_MSG_RESULT([no])
  2844. ])
  2845. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZL], [$have_builtin_ctzl], [Whether the compiler supports __builtin_ctzl])
  2846. ])
  2847. dnl PHP_CHECK_BUILTIN_CTZLL
  2848. AC_DEFUN([PHP_CHECK_BUILTIN_CTZLL], [
  2849. AC_MSG_CHECKING([for __builtin_ctzll])
  2850. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2851. return __builtin_ctzll(2LL) ? 1 : 0;
  2852. ]])], [
  2853. have_builtin_ctzll=1
  2854. AC_MSG_RESULT([yes])
  2855. ], [
  2856. have_builtin_ctzll=0
  2857. AC_MSG_RESULT([no])
  2858. ])
  2859. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZLL], [$have_builtin_ctzll], [Whether the compiler supports __builtin_ctzll])
  2860. ])
  2861. dnl PHP_CHECK_BUILTIN_SMULL_OVERFLOW
  2862. AC_DEFUN([PHP_CHECK_BUILTIN_SMULL_OVERFLOW], [
  2863. AC_MSG_CHECKING([for __builtin_smull_overflow])
  2864. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2865. long tmpvar;
  2866. return __builtin_smull_overflow(3, 7, &tmpvar);
  2867. ]])], [
  2868. have_builtin_smull_overflow=1
  2869. AC_MSG_RESULT([yes])
  2870. ], [
  2871. have_builtin_smull_overflow=0
  2872. AC_MSG_RESULT([no])
  2873. ])
  2874. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULL_OVERFLOW],
  2875. [$have_builtin_smull_overflow], [Whether the compiler supports __builtin_smull_overflow])
  2876. ])
  2877. dnl PHP_CHECK_BUILTIN_SMULLL_OVERFLOW
  2878. AC_DEFUN([PHP_CHECK_BUILTIN_SMULLL_OVERFLOW], [
  2879. AC_MSG_CHECKING([for __builtin_smulll_overflow])
  2880. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2881. long long tmpvar;
  2882. return __builtin_smulll_overflow(3, 7, &tmpvar);
  2883. ]])], [
  2884. have_builtin_smulll_overflow=1
  2885. AC_MSG_RESULT([yes])
  2886. ], [
  2887. have_builtin_smulll_overflow=0
  2888. AC_MSG_RESULT([no])
  2889. ])
  2890. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULLL_OVERFLOW],
  2891. [$have_builtin_smulll_overflow], [Whether the compiler supports __builtin_smulll_overflow])
  2892. ])
  2893. dnl PHP_CHECK_BUILTIN_SADDL_OVERFLOW
  2894. AC_DEFUN([PHP_CHECK_BUILTIN_SADDL_OVERFLOW], [
  2895. AC_MSG_CHECKING([for __builtin_saddl_overflow])
  2896. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2897. long tmpvar;
  2898. return __builtin_saddl_overflow(3, 7, &tmpvar);
  2899. ]])], [
  2900. have_builtin_saddl_overflow=1
  2901. AC_MSG_RESULT([yes])
  2902. ], [
  2903. have_builtin_saddl_overflow=0
  2904. AC_MSG_RESULT([no])
  2905. ])
  2906. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDL_OVERFLOW],
  2907. [$have_builtin_saddl_overflow], [Whether the compiler supports __builtin_saddl_overflow])
  2908. ])
  2909. dnl PHP_CHECK_BUILTIN_SADDLL_OVERFLOW
  2910. AC_DEFUN([PHP_CHECK_BUILTIN_SADDLL_OVERFLOW], [
  2911. AC_MSG_CHECKING([for __builtin_saddll_overflow])
  2912. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2913. long long tmpvar;
  2914. return __builtin_saddll_overflow(3, 7, &tmpvar);
  2915. ]])], [
  2916. have_builtin_saddll_overflow=1
  2917. AC_MSG_RESULT([yes])
  2918. ], [
  2919. have_builtin_saddll_overflow=0
  2920. AC_MSG_RESULT([no])
  2921. ])
  2922. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDLL_OVERFLOW],
  2923. [$have_builtin_saddll_overflow], [Whether the compiler supports __builtin_saddll_overflow])
  2924. ])
  2925. dnl PHP_CHECK_BUILTIN_SSUBL_OVERFLOW
  2926. AC_DEFUN([PHP_CHECK_BUILTIN_SSUBL_OVERFLOW], [
  2927. AC_MSG_CHECKING([for __builtin_ssubl_overflow])
  2928. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2929. long tmpvar;
  2930. return __builtin_ssubl_overflow(3, 7, &tmpvar);
  2931. ]])], [
  2932. have_builtin_ssubl_overflow=1
  2933. AC_MSG_RESULT([yes])
  2934. ], [
  2935. have_builtin_ssubl_overflow=0
  2936. AC_MSG_RESULT([no])
  2937. ])
  2938. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBL_OVERFLOW],
  2939. [$have_builtin_ssubl_overflow], [Whether the compiler supports __builtin_ssubl_overflow])
  2940. ])
  2941. dnl PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW
  2942. AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [
  2943. AC_MSG_CHECKING([for __builtin_ssubll_overflow])
  2944. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2945. long long tmpvar;
  2946. return __builtin_ssubll_overflow(3, 7, &tmpvar);
  2947. ]])], [
  2948. have_builtin_ssubll_overflow=1
  2949. AC_MSG_RESULT([yes])
  2950. ], [
  2951. have_builtin_ssubll_overflow=0
  2952. AC_MSG_RESULT([no])
  2953. ])
  2954. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW],
  2955. [$have_builtin_ssubll_overflow], [Whether the compiler supports __builtin_ssubll_overflow])
  2956. ])
  2957. dnl PHP_CHECK_BUILTIN_CPU_INIT
  2958. AC_DEFUN([PHP_CHECK_BUILTIN_CPU_INIT], [
  2959. AC_MSG_CHECKING([for __builtin_cpu_init])
  2960. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2961. return __builtin_cpu_init()? 1 : 0;
  2962. ]])], [
  2963. have_builtin_cpu_init=1
  2964. AC_MSG_RESULT([yes])
  2965. ], [
  2966. have_builtin_cpu_init=0
  2967. AC_MSG_RESULT([no])
  2968. ])
  2969. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_INIT],
  2970. [$have_builtin_cpu_init], [Whether the compiler supports __builtin_cpu_init])
  2971. ])
  2972. dnl PHP_CHECK_BUILTIN_CPU_SUPPORTS
  2973. AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [
  2974. AC_MSG_CHECKING([for __builtin_cpu_supports])
  2975. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
  2976. return __builtin_cpu_supports("sse")? 1 : 0;
  2977. ]])], [
  2978. have_builtin_cpu_supports=1
  2979. AC_MSG_RESULT([yes])
  2980. ], [
  2981. have_builtin_cpu_supports=0
  2982. AC_MSG_RESULT([no])
  2983. ])
  2984. AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CPU_SUPPORTS],
  2985. [$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports])
  2986. ])
  2987. dnl PHP_CHECK_CPU_SUPPORTS
  2988. AC_DEFUN([PHP_CHECK_CPU_SUPPORTS], [
  2989. AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_INIT])
  2990. AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_SUPPORTS])
  2991. have_ext_instructions=0
  2992. if test $have_builtin_cpu_supports = 1; then
  2993. AC_MSG_CHECKING([for $1 instructions supports])
  2994. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  2995. int main() {
  2996. return __builtin_cpu_supports("$1")? 0 : 1;
  2997. }
  2998. ]])], [
  2999. have_ext_instructions=1
  3000. AC_MSG_RESULT([yes])
  3001. ], [
  3002. AC_MSG_RESULT([no])
  3003. ], [AC_MSG_RESULT([no])])
  3004. fi
  3005. AC_DEFINE_UNQUOTED(AS_TR_CPP([PHP_HAVE_$1_INSTRUCTIONS]),
  3006. [$have_ext_instructions], [Whether the compiler supports $1 instructions])
  3007. ])
  3008. dnl Load the AX_CHECK_COMPILE_FLAG macro from the autoconf archive.
  3009. m4_include([build/ax_check_compile_flag.m4])
  3010. m4_include([build/ax_gcc_func_attribute.m4])