acinclude.m4 79 KB

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