PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/ext/standard/config.m4

https://github.com/kennyb/php-broken
m4 | 537 lines | 383 code | 52 blank | 102 comment | 0 complexity | 06f37786a622f729be5a43a850946799 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause
  1. dnl $Id: config.m4,v 1.80.2.3.2.3 2007/07/11 11:56:03 jani Exp $ -*- autoconf -*-
  2. divert(3)dnl
  3. PHP_ARG_ENABLE(binary-serialization, whether binary serialization is default,
  4. [ --enable-binary-serialization enable binary serialization],no)
  5. #AC_ARG_ENABLE(binary-serialization,
  6. #[ --enable-binary-serialization Enable binary serialization],[
  7. # USE_BINARY_SERIALIZATION=$enableval
  8. #],[
  9. # USE_BINARY_SERIALIZATION=no
  10. #])
  11. #AC_MSG_CHECKING(whether to binary serialization)
  12. #AC_MSG_RESULT($USE_BINARY_SERIALIZATION)
  13. if test "$PHP_BINARY_SERIALIZATION" = "yes"; then
  14. AC_DEFINE(USE_BINARY_SERIALIZATION, 1, [ use binary serialization instead of text serialization ])
  15. fi
  16. dnl
  17. dnl Check if flush should be called explicitly after buffered io
  18. dnl
  19. AC_CACHE_CHECK([whether flush should be called explicitly after a buffered io], ac_cv_flush_io,[
  20. AC_TRY_RUN( [
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. int main(int argc, char **argv)
  24. {
  25. char *filename = tmpnam(NULL);
  26. char buffer[64];
  27. int result = 0;
  28. FILE *fp = fopen(filename, "wb");
  29. if (NULL == fp)
  30. return 0;
  31. fputs("line 1\n", fp);
  32. fputs("line 2\n", fp);
  33. fclose(fp);
  34. fp = fopen(filename, "rb+");
  35. if (NULL == fp)
  36. return 0;
  37. fgets(buffer, sizeof(buffer), fp);
  38. fputs("line 3\n", fp);
  39. rewind(fp);
  40. fgets(buffer, sizeof(buffer), fp);
  41. if (0 != strcmp(buffer, "line 1\n"))
  42. result = 1;
  43. fgets(buffer, sizeof(buffer), fp);
  44. if (0 != strcmp(buffer, "line 3\n"))
  45. result = 1;
  46. fclose(fp);
  47. unlink(filename);
  48. exit(result);
  49. }
  50. ],[
  51. ac_cv_flush_io=no
  52. ],[
  53. ac_cv_flush_io=yes
  54. ],[
  55. ac_cv_flush_io=no
  56. ])])
  57. if test "$ac_cv_flush_io" = "yes"; then
  58. AC_DEFINE(HAVE_FLUSHIO, 1, [Define if flush should be called explicitly after a buffered io.])
  59. fi
  60. dnl
  61. dnl Check for crypt() capabilities
  62. dnl
  63. if test "$ac_cv_func_crypt" = "no"; then
  64. AC_CHECK_LIB(crypt, crypt, [
  65. LIBS="-lcrypt $LIBS -lcrypt"
  66. AC_DEFINE(HAVE_CRYPT, 1, [ ])
  67. ])
  68. fi
  69. AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[
  70. AC_TRY_RUN([
  71. #if HAVE_UNISTD_H
  72. #include <unistd.h>
  73. #endif
  74. #if HAVE_CRYPT_H
  75. #include <crypt.h>
  76. #endif
  77. main() {
  78. #if HAVE_CRYPT
  79. exit (strcmp((char *)crypt("rasmuslerdorf","rl"),"rl.3StKT.4T8M"));
  80. #else
  81. exit(0);
  82. #endif
  83. }],[
  84. ac_cv_crypt_des=yes
  85. ],[
  86. ac_cv_crypt_des=no
  87. ],[
  88. ac_cv_crypt_des=yes
  89. ])])
  90. if test "$ac_cv_crypt_des" = "yes"; then
  91. ac_result=1
  92. else
  93. ac_result=0
  94. fi
  95. AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, $ac_result, [Whether the system supports standard DES salt])
  96. AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[
  97. AC_TRY_RUN([
  98. #if HAVE_UNISTD_H
  99. #include <unistd.h>
  100. #endif
  101. #if HAVE_CRYPT_H
  102. #include <crypt.h>
  103. #endif
  104. main() {
  105. #if HAVE_CRYPT
  106. exit (strcmp((char *)crypt("rasmuslerdorf","_J9..rasm"),"_J9..rasmBYk8r9AiWNc"));
  107. #else
  108. exit(0);
  109. #endif
  110. }],[
  111. ac_cv_crypt_ext_des=yes
  112. ],[
  113. ac_cv_crypt_ext_des=no
  114. ],[
  115. ac_cv_crypt_ext_des=no
  116. ])])
  117. if test "$ac_cv_crypt_ext_des" = "yes"; then
  118. ac_result=1
  119. else
  120. ac_result=0
  121. fi
  122. AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, $ac_result, [Whether the system supports extended DES salt])
  123. AC_CACHE_CHECK(for MD5 crypt, ac_cv_crypt_md5,[
  124. AC_TRY_RUN([
  125. #if HAVE_UNISTD_H
  126. #include <unistd.h>
  127. #endif
  128. #if HAVE_CRYPT_H
  129. #include <crypt.h>
  130. #endif
  131. main() {
  132. #if HAVE_CRYPT
  133. char salt[15], answer[40];
  134. salt[0]='$'; salt[1]='1'; salt[2]='$';
  135. salt[3]='r'; salt[4]='a'; salt[5]='s';
  136. salt[6]='m'; salt[7]='u'; salt[8]='s';
  137. salt[9]='l'; salt[10]='e'; salt[11]='$';
  138. salt[12]='\0';
  139. strcpy(answer,salt);
  140. strcat(answer,"rISCgZzpwk3UhDidwXvin0");
  141. exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
  142. #else
  143. exit(0);
  144. #endif
  145. }],[
  146. ac_cv_crypt_md5=yes
  147. ],[
  148. ac_cv_crypt_md5=no
  149. ],[
  150. ac_cv_crypt_md5=no
  151. ])])
  152. if test "$ac_cv_crypt_md5" = "yes"; then
  153. ac_result=1
  154. else
  155. if test "$ac_cv_crypt_des" != "yes"; then
  156. PHP_DEBUG_MACRO(debug.log)
  157. fi
  158. ac_result=0
  159. fi
  160. AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, $ac_result, [Whether the system supports MD5 salt])
  161. AC_CACHE_CHECK(for Blowfish crypt, ac_cv_crypt_blowfish,[
  162. AC_TRY_RUN([
  163. #if HAVE_UNISTD_H
  164. #include <unistd.h>
  165. #endif
  166. #if HAVE_CRYPT_H
  167. #include <crypt.h>
  168. #endif
  169. main() {
  170. #if HAVE_CRYPT
  171. char salt[30], answer[70];
  172. salt[0]='$'; salt[1]='2'; salt[2]='a'; salt[3]='$'; salt[4]='0'; salt[5]='7'; salt[6]='$'; salt[7]='\0';
  173. strcat(salt,"rasmuslerd............");
  174. strcpy(answer,salt);
  175. strcpy(&answer[29],"nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra");
  176. exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
  177. #else
  178. exit(0);
  179. #endif
  180. }],[
  181. ac_cv_crypt_blowfish=yes
  182. ],[
  183. ac_cv_crypt_blowfish=no
  184. ],[
  185. ac_cv_crypt_blowfish=no
  186. ])])
  187. if test "$ac_cv_crypt_blowfish" = "yes"; then
  188. ac_result=1
  189. else
  190. ac_result=0
  191. fi
  192. AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, $ac_result, [Whether the system supports BlowFish salt])
  193. dnl
  194. dnl Check for available functions
  195. dnl
  196. AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan)
  197. AC_FUNC_FNMATCH
  198. divert(5)dnl
  199. dnl
  200. dnl Check for regex library type
  201. dnl
  202. PHP_ARG_WITH(regex,,
  203. [ --with-regex=TYPE regex library type: system, apache, php. [TYPE=php]
  204. WARNING: Do NOT use unless you know what you are doing!], php, no)
  205. case $PHP_REGEX in
  206. system)
  207. if test "$PHP_SAPI" = "apache" || test "$PHP_SAPI" = "apache2filter" || test "$PHP_SAPI" = "apache2handler"; then
  208. REGEX_TYPE=php
  209. else
  210. REGEX_TYPE=system
  211. fi
  212. ;;
  213. apache)
  214. REGEX_TYPE=apache
  215. ;;
  216. php)
  217. REGEX_TYPE=php
  218. ;;
  219. *)
  220. REGEX_TYPE=php
  221. AC_MSG_WARN(Invalid regex library type selected. Using default value: php)
  222. ;;
  223. esac
  224. if test "$REGEX_TYPE" = "php"; then
  225. AC_DEFINE(HAVE_REGEX_T_RE_MAGIC, 1, [ ])
  226. AC_DEFINE(HSREGEX,1,[ ])
  227. AC_DEFINE(REGEX,1,[ ])
  228. PHP_ADD_SOURCES(regex, regcomp.c regexec.c regerror.c regfree.c)
  229. elif test "$REGEX_TYPE" = "system"; then
  230. AC_DEFINE(REGEX,0,[ ])
  231. dnl Check if field re_magic exists in struct regex_t
  232. AC_CACHE_CHECK([whether field re_magic exists in struct regex_t], ac_cv_regex_t_re_magic, [
  233. AC_TRY_COMPILE([#include <sys/types.h>
  234. #include <regex.h>], [regex_t rt; rt.re_magic;],
  235. [ac_cv_regex_t_re_magic=yes], [ac_cv_regex_t_re_magic=no])])
  236. if test "$ac_cv_regex_t_re_magic" = "yes"; then
  237. AC_DEFINE([HAVE_REGEX_T_RE_MAGIC], [ ], 1)
  238. fi
  239. fi
  240. AC_MSG_CHECKING([which regex library to use])
  241. AC_MSG_RESULT([$REGEX_TYPE])
  242. dnl
  243. dnl round fuzz
  244. dnl
  245. AC_MSG_CHECKING([whether rounding works as expected])
  246. AC_TRY_RUN([
  247. #include <math.h>
  248. /* keep this out-of-line to prevent use of gcc inline floor() */
  249. double somefn(double n) {
  250. return floor(n*pow(10,2) + 0.5);
  251. }
  252. int main() {
  253. return somefn(0.045)/10.0 != 0.5;
  254. }
  255. ],[
  256. PHP_ROUND_FUZZ=0.5
  257. AC_MSG_RESULT(yes)
  258. ],[
  259. PHP_ROUND_FUZZ=0.50000000001
  260. AC_MSG_RESULT(no)
  261. ],[
  262. PHP_ROUND_FUZZ=0.50000000001
  263. AC_MSG_RESULT(cross compile)
  264. ])
  265. AC_DEFINE_UNQUOTED(PHP_ROUND_FUZZ, $PHP_ROUND_FUZZ, [ see #24142 ])
  266. dnl
  267. dnl Check if there is a support means of creating a new process
  268. dnl and defining which handles it receives
  269. dnl
  270. AC_CACHE_VAL(php_can_support_proc_open,[
  271. AC_CHECK_FUNCS(fork CreateProcess, [
  272. php_can_support_proc_open=yes
  273. break
  274. ],[
  275. php_can_support_proc_open=no
  276. ])])
  277. AC_MSG_CHECKING([if your OS can spawn processes with inherited handles])
  278. if test "$php_can_support_proc_open" = "yes"; then
  279. AC_MSG_RESULT(yes)
  280. AC_DEFINE(PHP_CAN_SUPPORT_PROC_OPEN,1, [Define if your system has fork/vfork/CreateProcess])
  281. else
  282. AC_MSG_RESULT(no)
  283. fi
  284. dnl getopt long options disabled for now
  285. dnl as we can't be sure that we get the right getopt.h here
  286. dnl using the standard AC_CHECK macros
  287. dnl AC_CHECK_HEADERS(getopt.h)
  288. dnl AC_CHECK_FUNCS(getopt_long getopt_long_only)
  289. if test "$PHP_SAPI" = "cgi" || test "$PHP_SAPI" = "cli" || test "$PHP_SAPI" = "embed"; then
  290. AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])
  291. fi
  292. dnl
  293. dnl Detect library functions needed by php dns_xxx functions
  294. dnl ext/standard/dns.h will collect these in a single define: HAVE_DNS_FUNCS
  295. dnl
  296. PHP_CHECK_FUNC(res_nmkquery, resolv, bind, socket)
  297. PHP_CHECK_FUNC(res_nsend, resolv, bind, socket)
  298. PHP_CHECK_FUNC(dn_expand, resolv, bind, socket)
  299. dnl
  300. dnl Check if atof() accepts NAN
  301. dnl
  302. AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[
  303. AC_TRY_RUN([
  304. #include <math.h>
  305. #include <stdlib.h>
  306. #ifdef HAVE_ISNAN
  307. #define zend_isnan(a) isnan(a)
  308. #elif defined(HAVE_FPCLASS)
  309. #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
  310. #else
  311. #define zend_isnan(a) 0
  312. #endif
  313. int main(int argc, char** argv)
  314. {
  315. return zend_isnan(atof("NAN")) ? 0 : 1;
  316. }
  317. ],[
  318. ac_cv_atof_accept_nan=yes
  319. ],[
  320. ac_cv_atof_accept_nan=no
  321. ],[
  322. ac_cv_atof_accept_nan=no
  323. ])])
  324. if test "$ac_cv_atof_accept_nan" = "yes"; then
  325. AC_DEFINE([HAVE_ATOF_ACCEPTS_NAN], 1, [whether atof() accepts NAN])
  326. fi
  327. dnl
  328. dnl Check if atof() accepts INF
  329. dnl
  330. AC_CACHE_CHECK(whether atof() accepts INF, ac_cv_atof_accept_inf,[
  331. AC_TRY_RUN([
  332. #include <math.h>
  333. #include <stdlib.h>
  334. #ifdef HAVE_ISINF
  335. #define zend_isinf(a) isinf(a)
  336. #elif defined(INFINITY)
  337. /* Might not work, but is required by ISO C99 */
  338. #define zend_isinf(a) (((a)==INFINITY)?1:0)
  339. #elif defined(HAVE_FPCLASS)
  340. #define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
  341. #else
  342. #define zend_isinf(a) 0
  343. #endif
  344. int main(int argc, char** argv)
  345. {
  346. return zend_isinf(atof("INF")) && zend_isinf(atof("-INF")) ? 0 : 1;
  347. }
  348. ],[
  349. ac_cv_atof_accept_inf=yes
  350. ],[
  351. ac_cv_atof_accept_inf=no
  352. ],[
  353. ac_cv_atof_accept_inf=no
  354. ])])
  355. if test "$ac_cv_atof_accept_inf" = "yes"; then
  356. AC_DEFINE([HAVE_ATOF_ACCEPTS_INF], 1, [whether atof() accepts INF])
  357. fi
  358. dnl
  359. dnl Check if HUGE_VAL == INF
  360. dnl
  361. AC_CACHE_CHECK(whether HUGE_VAL == INF, ac_cv_huge_val_inf,[
  362. AC_TRY_RUN([
  363. #include <math.h>
  364. #include <stdlib.h>
  365. #ifdef HAVE_ISINF
  366. #define zend_isinf(a) isinf(a)
  367. #elif defined(INFINITY)
  368. /* Might not work, but is required by ISO C99 */
  369. #define zend_isinf(a) (((a)==INFINITY)?1:0)
  370. #elif defined(HAVE_FPCLASS)
  371. #define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
  372. #else
  373. #define zend_isinf(a) 0
  374. #endif
  375. int main(int argc, char** argv)
  376. {
  377. return zend_isinf(HUGE_VAL) ? 0 : 1;
  378. }
  379. ],[
  380. ac_cv_huge_val_inf=yes
  381. ],[
  382. ac_cv_huge_val_inf=no
  383. ],[
  384. ac_cv_huge_val_inf=yes
  385. ])])
  386. dnl This is the most probable fallback so we assume yes in case of cross compile.
  387. if test "$ac_cv_huge_val_inf" = "yes"; then
  388. AC_DEFINE([HAVE_HUGE_VAL_INF], 1, [whether HUGE_VAL == INF])
  389. fi
  390. dnl
  391. dnl Check if HUGE_VAL + -HUGEVAL == NAN
  392. dnl
  393. AC_CACHE_CHECK(whether HUGE_VAL + -HUGEVAL == NAN, ac_cv_huge_val_nan,[
  394. AC_TRY_RUN([
  395. #include <math.h>
  396. #include <stdlib.h>
  397. #ifdef HAVE_ISNAN
  398. #define zend_isnan(a) isnan(a)
  399. #elif defined(HAVE_FPCLASS)
  400. #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
  401. #else
  402. #define zend_isnan(a) 0
  403. #endif
  404. int main(int argc, char** argv)
  405. {
  406. #if defined(__sparc__) && !(__GNUC__ >= 3)
  407. /* prevent bug #27830 */
  408. return 1;
  409. #else
  410. return zend_isnan(HUGE_VAL + -HUGE_VAL) ? 0 : 1;
  411. #endif
  412. }
  413. ],[
  414. ac_cv_huge_val_nan=yes
  415. ],[
  416. ac_cv_huge_val_nan=no
  417. ],[
  418. ac_cv_huge_val_nan=yes
  419. ])])
  420. dnl This is the most probable fallback so we assume yes in case of cross compile.
  421. if test "$ac_cv_huge_val_nan" = "yes"; then
  422. AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN])
  423. fi
  424. dnl
  425. dnl Check for strptime()
  426. dnl
  427. AC_CACHE_CHECK(whether strptime() declaration fails, ac_cv_strptime_decl_fails,[
  428. AC_TRY_COMPILE([
  429. #include <time.h>
  430. ],[
  431. #ifndef HAVE_STRPTIME
  432. #error no strptime() on this platform
  433. #else
  434. /* use invalid strptime() declaration to see if it fails to compile */
  435. int strptime(const char *s, const char *format, struct tm *tm);
  436. #endif
  437. ],[
  438. ac_cv_strptime_decl_fails=no
  439. ],[
  440. ac_cv_strptime_decl_fails=yes
  441. ])])
  442. if test "$ac_cv_strptime_decl_fails" = "yes"; then
  443. AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], 1, [whether strptime() declaration fails])
  444. fi
  445. dnl
  446. dnl Check for i18n capabilities
  447. dnl
  448. AC_CHECK_HEADERS([wchar.h])
  449. AC_CHECK_FUNCS([mblen])
  450. AC_CHECK_FUNCS([mbrlen mbsinit],,,[
  451. #ifdef HAVE_WCHAR_H
  452. # include <wchar.h>
  453. #endif
  454. ])
  455. AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],[
  456. AC_TRY_COMPILE([
  457. #ifdef HAVE_WCHAR_H
  458. # include <wchar.h>
  459. #endif
  460. ],[
  461. int __tmp__() { mbstate_t a; }
  462. ],[
  463. ac_cv_type_mbstate_t=yes
  464. ],[
  465. ac_cv_type_mbstate_t=no
  466. ])])
  467. if test "$ac_cv_type_mbstate_t" = "yes"; then
  468. AC_DEFINE([HAVE_MBSTATE_T], 1, [Define if your system has mbstate_t in wchar.h])
  469. fi
  470. dnl
  471. dnl Setup extension sources
  472. dnl
  473. PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \
  474. cyr_convert.c datetime.c dir.c dl.c dns.c exec.c file.c filestat.c \
  475. flock_compat.c formatted_print.c fsock.c head.c html.c image.c \
  476. info.c iptc.c lcg.c link.c mail.c math.c md5.c metaphone.c \
  477. microtime.c pack.c pageinfo.c quot_print.c rand.c \
  478. reg.c soundex.c string.c scanf.c syslog.c type.c uniqid.c url.c \
  479. url_scanner.c var.c versioning.c assert.c strnatcmp.c levenshtein.c \
  480. incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \
  481. http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \
  482. var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \
  483. filters.c proc_open.c streamsfuncs.c http.c)
  484. PHP_ADD_MAKEFILE_FRAGMENT
  485. PHP_INSTALL_HEADERS([ext/standard/])