PageRenderTime 33ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/ext/standard/config.m4

https://github.com/leeight/php-src
m4 | 585 lines | 411 code | 64 blank | 110 comment | 0 complexity | 19da3c976b96b9ecb046d0c4870abd56 MD5 | raw file
  1. dnl $Id$ -*- autoconf -*-
  2. divert(3)dnl
  3. dnl
  4. dnl Check if flush should be called explicitly after buffered io
  5. dnl
  6. AC_CACHE_CHECK([whether flush should be called explicitly after a buffered io], ac_cv_flush_io,[
  7. AC_TRY_RUN( [
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. int main(int argc, char **argv)
  11. {
  12. char *filename = tmpnam(NULL);
  13. char buffer[64];
  14. int result = 0;
  15. FILE *fp = fopen(filename, "wb");
  16. if (NULL == fp)
  17. return 0;
  18. fputs("line 1\n", fp);
  19. fputs("line 2\n", fp);
  20. fclose(fp);
  21. fp = fopen(filename, "rb+");
  22. if (NULL == fp)
  23. return 0;
  24. fgets(buffer, sizeof(buffer), fp);
  25. fputs("line 3\n", fp);
  26. rewind(fp);
  27. fgets(buffer, sizeof(buffer), fp);
  28. if (0 != strcmp(buffer, "line 1\n"))
  29. result = 1;
  30. fgets(buffer, sizeof(buffer), fp);
  31. if (0 != strcmp(buffer, "line 3\n"))
  32. result = 1;
  33. fclose(fp);
  34. unlink(filename);
  35. exit(result);
  36. }
  37. ],[
  38. ac_cv_flush_io=no
  39. ],[
  40. ac_cv_flush_io=yes
  41. ],[
  42. ac_cv_flush_io=no
  43. ])])
  44. if test "$ac_cv_flush_io" = "yes"; then
  45. AC_DEFINE(HAVE_FLUSHIO, 1, [Define if flush should be called explicitly after a buffered io.])
  46. fi
  47. dnl
  48. dnl Check for crypt() capabilities
  49. dnl
  50. if test "$ac_cv_func_crypt" = "no"; then
  51. AC_CHECK_LIB(crypt, crypt, [
  52. LIBS="-lcrypt $LIBS -lcrypt"
  53. AC_DEFINE(HAVE_CRYPT, 1, [ ])
  54. ])
  55. fi
  56. AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[
  57. AC_TRY_RUN([
  58. #if HAVE_UNISTD_H
  59. #include <unistd.h>
  60. #endif
  61. #if HAVE_CRYPT_H
  62. #include <crypt.h>
  63. #endif
  64. main() {
  65. #if HAVE_CRYPT
  66. exit (strcmp((char *)crypt("rasmuslerdorf","rl"),"rl.3StKT.4T8M"));
  67. #else
  68. exit(0);
  69. #endif
  70. }],[
  71. ac_cv_crypt_des=yes
  72. ],[
  73. ac_cv_crypt_des=no
  74. ],[
  75. ac_cv_crypt_des=yes
  76. ])])
  77. AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[
  78. AC_TRY_RUN([
  79. #if HAVE_UNISTD_H
  80. #include <unistd.h>
  81. #endif
  82. #if HAVE_CRYPT_H
  83. #include <crypt.h>
  84. #endif
  85. main() {
  86. #if HAVE_CRYPT
  87. exit (strcmp((char *)crypt("rasmuslerdorf","_J9..rasm"),"_J9..rasmBYk8r9AiWNc"));
  88. #else
  89. exit(0);
  90. #endif
  91. }],[
  92. ac_cv_crypt_ext_des=yes
  93. ],[
  94. ac_cv_crypt_ext_des=no
  95. ],[
  96. ac_cv_crypt_ext_des=no
  97. ])])
  98. AC_CACHE_CHECK(for MD5 crypt, ac_cv_crypt_md5,[
  99. AC_TRY_RUN([
  100. #if HAVE_UNISTD_H
  101. #include <unistd.h>
  102. #endif
  103. #if HAVE_CRYPT_H
  104. #include <crypt.h>
  105. #endif
  106. main() {
  107. #if HAVE_CRYPT
  108. char salt[15], answer[40];
  109. salt[0]='$'; salt[1]='1'; salt[2]='$';
  110. salt[3]='r'; salt[4]='a'; salt[5]='s';
  111. salt[6]='m'; salt[7]='u'; salt[8]='s';
  112. salt[9]='l'; salt[10]='e'; salt[11]='$';
  113. salt[12]='\0';
  114. strcpy(answer,salt);
  115. strcat(answer,"rISCgZzpwk3UhDidwXvin0");
  116. exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
  117. #else
  118. exit(0);
  119. #endif
  120. }],[
  121. ac_cv_crypt_md5=yes
  122. ],[
  123. ac_cv_crypt_md5=no
  124. ],[
  125. ac_cv_crypt_md5=no
  126. ])])
  127. AC_CACHE_CHECK(for Blowfish crypt, ac_cv_crypt_blowfish,[
  128. AC_TRY_RUN([
  129. #if HAVE_UNISTD_H
  130. #include <unistd.h>
  131. #endif
  132. #if HAVE_CRYPT_H
  133. #include <crypt.h>
  134. #endif
  135. main() {
  136. #if HAVE_CRYPT
  137. char salt[30], answer[70];
  138. salt[0]='$'; salt[1]='2'; salt[2]='a'; salt[3]='$'; salt[4]='0'; salt[5]='7'; salt[6]='$'; salt[7]='\0';
  139. strcat(salt,"rasmuslerd............");
  140. strcpy(answer,salt);
  141. strcpy(&answer[29],"nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra");
  142. exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
  143. #else
  144. exit(0);
  145. #endif
  146. }],[
  147. ac_cv_crypt_blowfish=yes
  148. ],[
  149. ac_cv_crypt_blowfish=no
  150. ],[
  151. ac_cv_crypt_blowfish=no
  152. ])])
  153. AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_SHA512,[
  154. AC_TRY_RUN([
  155. #if HAVE_UNISTD_H
  156. #include <unistd.h>
  157. #endif
  158. #if HAVE_CRYPT_H
  159. #include <crypt.h>
  160. #endif
  161. main() {
  162. #if HAVE_CRYPT
  163. char salt[30], answer[80];
  164. salt[0]='$'; salt[1]='6'; salt[2]='$'; salt[3]='$'; salt[4]='b'; salt[5]='a'; salt[6]='r'; salt[7]='\0';
  165. strcpy(answer, salt);
  166. strcpy(&answer[29],"$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.");
  167. exit (strcmp((char *)crypt("foo",salt),answer));
  168. #else
  169. exit(0);
  170. #endif
  171. }],[
  172. ac_cv_crypt_SHA512=yes
  173. ],[
  174. ac_cv_crypt_SHA512=no
  175. ],[
  176. ac_cv_crypt_SHA512=no
  177. ])])
  178. AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_SHA256,[
  179. AC_TRY_RUN([
  180. #if HAVE_UNISTD_H
  181. #include <unistd.h>
  182. #endif
  183. #if HAVE_CRYPT_H
  184. #include <crypt.h>
  185. #endif
  186. main() {
  187. #if HAVE_CRYPT
  188. char salt[30], answer[80];
  189. salt[0]='$'; salt[1]='5'; salt[2]='$'; salt[3]='$'; salt[4]='s'; salt[5]='a'; salt[6]='l'; salt[7]='t'; salt[8]='s'; salt[9]='t'; salt[10]='r'; salt[11]='i'; salt[12]='n'; salt[13]='g'; salt[14]='\0';
  190. strcat(salt,"");
  191. strcpy(answer, salt);
  192. strcpy(&answer[29], "$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5");
  193. exit (strcmp((char *)crypt("foo",salt),answer));
  194. #else
  195. exit(0);
  196. #endif
  197. }],[
  198. ac_cv_crypt_SHA256=yes
  199. ],[
  200. ac_cv_crypt_SHA256=no
  201. ],[
  202. ac_cv_crypt_SHA256=no
  203. ])])
  204. dnl
  205. dnl If one of them is missing, use our own implementation, portable code is then possible
  206. dnl
  207. if test "$ac_cv_crypt_blowfish" = "no" || test "$ac_cv_crypt_des" = "no" || test "$ac_cv_crypt_ext_des" = "no" || test "x$php_crypt_r" = "x0"; then
  208. dnl
  209. dnl Check for __alignof__ support in the compiler
  210. dnl
  211. AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[
  212. AC_TRY_COMPILE([
  213. ],[
  214. int align = __alignof__(int);
  215. ],[
  216. ac_cv_alignof_exists=yes
  217. ],[
  218. ac_cv_alignof_exists=no
  219. ])])
  220. if test "$ac_cv_alignof_exists" = "yes"; then
  221. AC_DEFINE([HAVE_ALIGNOF], 1, [whether the compiler supports __alignof__])
  222. fi
  223. dnl
  224. dnl Check for __attribute__ ((__aligned__)) support in the compiler
  225. dnl
  226. AC_CACHE_CHECK(whether the compiler supports aligned attribute, ac_cv_attribute_aligned,[
  227. AC_TRY_COMPILE([
  228. ],[
  229. unsigned char test[32] __attribute__ ((__aligned__ (__alignof__ (int))));
  230. ],[
  231. ac_cv_attribute_aligned=yes
  232. ],[
  233. ac_cv_attribute_aligned=no
  234. ])])
  235. if test "$ac_cv_attribute_aligned" = "yes"; then
  236. AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1, [whether the compiler supports __attribute__ ((__aligned__))])
  237. fi
  238. AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 1, [Whether PHP has to use its own crypt_r for blowfish, des, ext des and md5])
  239. AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, 1, [Whether the system supports standard DES salt])
  240. AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, 1, [Whether the system supports BlowFish salt])
  241. AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, 1, [Whether the system supports extended DES salt])
  242. AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, 1, [Whether the system supports MD5 salt])
  243. AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, 1, [Whether the system supports SHA512 salt])
  244. AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, 1, [Whether the system supports SHA256 salt])
  245. PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
  246. else
  247. if test "$ac_cv_crypt_des" = "yes"; then
  248. ac_result=1
  249. ac_crypt_des=1
  250. else
  251. ac_result=0
  252. ac_crypt_des=0
  253. fi
  254. AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, $ac_result, [Whether the system supports standard DES salt])
  255. if test "$ac_cv_crypt_blowfish" = "yes"; then
  256. ac_result=1
  257. ac_crypt_blowfish=1
  258. else
  259. ac_result=0
  260. ac_crypt_blowfish=0
  261. fi
  262. AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, $ac_result, [Whether the system supports BlowFish salt])
  263. if test "$ac_cv_crypt_ext_des" = "yes"; then
  264. ac_result=1
  265. ac_crypt_edes=1
  266. else
  267. ac_result=0
  268. ac_crypt_edes=0
  269. fi
  270. AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, $ac_result, [Whether the system supports extended DES salt])
  271. if test "$ac_cv_crypt_md5" = "yes"; then
  272. ac_result=1
  273. ac_crypt_md5=1
  274. else
  275. ac_result=0
  276. ac_crypt_md5=0
  277. fi
  278. AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, $ac_result, [Whether the system supports MD5 salt])
  279. if test "$ac_cv_crypt_sha512" = "yes"; then
  280. ac_result=1
  281. ac_crypt_sha512=1
  282. else
  283. ac_result=0
  284. ac_crypt_sha512=0
  285. fi
  286. AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, $ac_result, [Whether the system supports SHA512 salt])
  287. if test "$ac_cv_crypt_sha256" = "yes"; then
  288. ac_result=1
  289. ac_crypt_sha256=1
  290. else
  291. ac_result=0
  292. ac_crypt_sha256=0
  293. fi
  294. AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, $ac_result, [Whether the system supports SHA256 salt])
  295. AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des])
  296. fi
  297. dnl
  298. dnl Check for available functions
  299. dnl
  300. AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy)
  301. AC_FUNC_FNMATCH
  302. divert(5)dnl
  303. dnl
  304. dnl Check if there is a support means of creating a new process
  305. dnl and defining which handles it receives
  306. dnl
  307. AC_CHECK_FUNCS(fork CreateProcess, [
  308. php_can_support_proc_open=yes
  309. break
  310. ],[
  311. php_can_support_proc_open=no
  312. ])
  313. AC_MSG_CHECKING([if your OS can spawn processes with inherited handles])
  314. if test "$php_can_support_proc_open" = "yes"; then
  315. AC_MSG_RESULT(yes)
  316. AC_DEFINE(PHP_CAN_SUPPORT_PROC_OPEN,1, [Define if your system has fork/vfork/CreateProcess])
  317. else
  318. AC_MSG_RESULT(no)
  319. fi
  320. if test "$PHP_SAPI" = "cgi" || test "$PHP_SAPI" = "cli" || test "$PHP_SAPI" = "embed"; then
  321. AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])
  322. fi
  323. dnl
  324. dnl Detect library functions needed by php dns_xxx functions
  325. dnl ext/standard/php_dns.h will collect these in a single define: HAVE_FULL_DNS_FUNCS
  326. dnl
  327. PHP_CHECK_FUNC(res_nsearch, resolv, bind, socket)
  328. PHP_CHECK_FUNC(dns_search, resolv, bind, socket)
  329. PHP_CHECK_FUNC(dn_expand, resolv, bind, socket)
  330. PHP_CHECK_FUNC(dn_skipname, resolv, bind, socket)
  331. dnl
  332. dnl These are old deprecated functions
  333. dnl
  334. PHP_CHECK_FUNC(res_search, resolv, bind, socket)
  335. dnl
  336. dnl Check if atof() accepts NAN
  337. dnl
  338. AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[
  339. AC_TRY_RUN([
  340. #include <math.h>
  341. #include <stdlib.h>
  342. #ifdef HAVE_ISNAN
  343. #define zend_isnan(a) isnan(a)
  344. #elif defined(HAVE_FPCLASS)
  345. #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
  346. #else
  347. #define zend_isnan(a) 0
  348. #endif
  349. int main(int argc, char** argv)
  350. {
  351. return zend_isnan(atof("NAN")) ? 0 : 1;
  352. }
  353. ],[
  354. ac_cv_atof_accept_nan=yes
  355. ],[
  356. ac_cv_atof_accept_nan=no
  357. ],[
  358. ac_cv_atof_accept_nan=no
  359. ])])
  360. if test "$ac_cv_atof_accept_nan" = "yes"; then
  361. AC_DEFINE([HAVE_ATOF_ACCEPTS_NAN], 1, [whether atof() accepts NAN])
  362. fi
  363. dnl
  364. dnl Check if atof() accepts INF
  365. dnl
  366. AC_CACHE_CHECK(whether atof() accepts INF, ac_cv_atof_accept_inf,[
  367. AC_TRY_RUN([
  368. #include <math.h>
  369. #include <stdlib.h>
  370. #ifdef HAVE_ISINF
  371. #define zend_isinf(a) isinf(a)
  372. #elif defined(INFINITY)
  373. /* Might not work, but is required by ISO C99 */
  374. #define zend_isinf(a) (((a)==INFINITY)?1:0)
  375. #elif defined(HAVE_FPCLASS)
  376. #define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
  377. #else
  378. #define zend_isinf(a) 0
  379. #endif
  380. int main(int argc, char** argv)
  381. {
  382. return zend_isinf(atof("INF")) && zend_isinf(atof("-INF")) ? 0 : 1;
  383. }
  384. ],[
  385. ac_cv_atof_accept_inf=yes
  386. ],[
  387. ac_cv_atof_accept_inf=no
  388. ],[
  389. ac_cv_atof_accept_inf=no
  390. ])])
  391. if test "$ac_cv_atof_accept_inf" = "yes"; then
  392. AC_DEFINE([HAVE_ATOF_ACCEPTS_INF], 1, [whether atof() accepts INF])
  393. fi
  394. dnl
  395. dnl Check if HUGE_VAL == INF
  396. dnl
  397. AC_CACHE_CHECK(whether HUGE_VAL == INF, ac_cv_huge_val_inf,[
  398. AC_TRY_RUN([
  399. #include <math.h>
  400. #include <stdlib.h>
  401. #ifdef HAVE_ISINF
  402. #define zend_isinf(a) isinf(a)
  403. #elif defined(INFINITY)
  404. /* Might not work, but is required by ISO C99 */
  405. #define zend_isinf(a) (((a)==INFINITY)?1:0)
  406. #elif defined(HAVE_FPCLASS)
  407. #define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
  408. #else
  409. #define zend_isinf(a) 0
  410. #endif
  411. int main(int argc, char** argv)
  412. {
  413. return zend_isinf(HUGE_VAL) ? 0 : 1;
  414. }
  415. ],[
  416. ac_cv_huge_val_inf=yes
  417. ],[
  418. ac_cv_huge_val_inf=no
  419. ],[
  420. ac_cv_huge_val_inf=yes
  421. ])])
  422. dnl This is the most probable fallback so we assume yes in case of cross compile.
  423. if test "$ac_cv_huge_val_inf" = "yes"; then
  424. AC_DEFINE([HAVE_HUGE_VAL_INF], 1, [whether HUGE_VAL == INF])
  425. fi
  426. dnl
  427. dnl Check if HUGE_VAL + -HUGEVAL == NAN
  428. dnl
  429. AC_CACHE_CHECK(whether HUGE_VAL + -HUGEVAL == NAN, ac_cv_huge_val_nan,[
  430. AC_TRY_RUN([
  431. #include <math.h>
  432. #include <stdlib.h>
  433. #ifdef HAVE_ISNAN
  434. #define zend_isnan(a) isnan(a)
  435. #elif defined(HAVE_FPCLASS)
  436. #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
  437. #else
  438. #define zend_isnan(a) 0
  439. #endif
  440. int main(int argc, char** argv)
  441. {
  442. #if defined(__sparc__) && !(__GNUC__ >= 3)
  443. /* prevent bug #27830 */
  444. return 1;
  445. #else
  446. return zend_isnan(HUGE_VAL + -HUGE_VAL) ? 0 : 1;
  447. #endif
  448. }
  449. ],[
  450. ac_cv_huge_val_nan=yes
  451. ],[
  452. ac_cv_huge_val_nan=no
  453. ],[
  454. ac_cv_huge_val_nan=yes
  455. ])])
  456. dnl This is the most probable fallback so we assume yes in case of cross compile.
  457. if test "$ac_cv_huge_val_nan" = "yes"; then
  458. AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN])
  459. fi
  460. dnl
  461. dnl Check for strptime()
  462. dnl
  463. AC_CACHE_CHECK(whether strptime() declaration fails, ac_cv_strptime_decl_fails,[
  464. AC_TRY_COMPILE([
  465. #include <time.h>
  466. ],[
  467. #ifndef HAVE_STRPTIME
  468. #error no strptime() on this platform
  469. #else
  470. /* use invalid strptime() declaration to see if it fails to compile */
  471. int strptime(const char *s, const char *format, struct tm *tm);
  472. #endif
  473. ],[
  474. ac_cv_strptime_decl_fails=no
  475. ],[
  476. ac_cv_strptime_decl_fails=yes
  477. ])])
  478. if test "$ac_cv_strptime_decl_fails" = "yes"; then
  479. AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], 1, [whether strptime() declaration fails])
  480. fi
  481. dnl
  482. dnl Check for i18n capabilities
  483. dnl
  484. AC_CHECK_HEADERS([wchar.h])
  485. AC_CHECK_FUNCS([mblen])
  486. AC_CHECK_FUNCS([mbrlen mbsinit],,,[
  487. #ifdef HAVE_WCHAR_H
  488. # include <wchar.h>
  489. #endif
  490. ])
  491. AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],[
  492. AC_TRY_COMPILE([
  493. #ifdef HAVE_WCHAR_H
  494. # include <wchar.h>
  495. #endif
  496. ],[
  497. int __tmp__() { mbstate_t a; }
  498. ],[
  499. ac_cv_type_mbstate_t=yes
  500. ],[
  501. ac_cv_type_mbstate_t=no
  502. ])])
  503. if test "$ac_cv_type_mbstate_t" = "yes"; then
  504. AC_DEFINE([HAVE_MBSTATE_T], 1, [Define if your system has mbstate_t in wchar.h])
  505. fi
  506. dnl
  507. dnl Setup extension sources
  508. dnl
  509. PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \
  510. cyr_convert.c datetime.c dir.c dl.c dns.c exec.c file.c filestat.c \
  511. flock_compat.c formatted_print.c fsock.c head.c html.c image.c \
  512. info.c iptc.c lcg.c link.c mail.c math.c md5.c metaphone.c \
  513. microtime.c pack.c pageinfo.c quot_print.c rand.c \
  514. soundex.c string.c scanf.c syslog.c type.c uniqid.c url.c \
  515. var.c versioning.c assert.c strnatcmp.c levenshtein.c \
  516. incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \
  517. http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \
  518. var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \
  519. filters.c proc_open.c streamsfuncs.c http.c)
  520. PHP_ADD_MAKEFILE_FRAGMENT
  521. PHP_INSTALL_HEADERS([ext/standard/])