config.m4 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. dnl -*- autoconf -*-
  2. dnl
  3. dnl Check if flush should be called explicitly after buffered io
  4. dnl
  5. AC_CACHE_CHECK([whether flush should be called explicitly after a buffered io], ac_cv_flush_io,[
  6. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <unistd.h>
  11. int main(int argc, char **argv)
  12. {
  13. char *filename = tmpnam(NULL);
  14. char buffer[64];
  15. int result = 0;
  16. FILE *fp = fopen(filename, "wb");
  17. if (NULL == fp)
  18. return 0;
  19. fputs("line 1\n", fp);
  20. fputs("line 2\n", fp);
  21. fclose(fp);
  22. fp = fopen(filename, "rb+");
  23. if (NULL == fp)
  24. return 0;
  25. fgets(buffer, sizeof(buffer), fp);
  26. fputs("line 3\n", fp);
  27. rewind(fp);
  28. fgets(buffer, sizeof(buffer), fp);
  29. if (0 != strcmp(buffer, "line 1\n"))
  30. result = 1;
  31. fgets(buffer, sizeof(buffer), fp);
  32. if (0 != strcmp(buffer, "line 3\n"))
  33. result = 1;
  34. fclose(fp);
  35. unlink(filename);
  36. exit(result);
  37. }
  38. ]])],[
  39. ac_cv_flush_io=no
  40. ],[
  41. ac_cv_flush_io=yes
  42. ],[
  43. ac_cv_flush_io=no
  44. ])])
  45. if test "$ac_cv_flush_io" = "yes"; then
  46. AC_DEFINE(HAVE_FLUSHIO, 1, [Define if flush should be called explicitly after a buffered io.])
  47. fi
  48. dnl
  49. dnl Check for crypt() capabilities
  50. dnl
  51. if test "$ac_cv_func_crypt" = "no"; then
  52. AC_CHECK_LIB(crypt, crypt, [
  53. LIBS="-lcrypt $LIBS -lcrypt"
  54. AC_DEFINE(HAVE_CRYPT, 1, [ ])
  55. ])
  56. fi
  57. AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[
  58. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  59. #include <string.h>
  60. #if HAVE_UNISTD_H
  61. #include <unistd.h>
  62. #endif
  63. #if HAVE_CRYPT_H
  64. #include <crypt.h>
  65. #endif
  66. int main() {
  67. #if HAVE_CRYPT
  68. char *encrypted = crypt("rasmuslerdorf","rl");
  69. return !encrypted || strcmp(encrypted,"rl.3StKT.4T8M");
  70. #else
  71. return 1;
  72. #endif
  73. }]])],[
  74. ac_cv_crypt_des=yes
  75. ],[
  76. ac_cv_crypt_des=no
  77. ],[
  78. ac_cv_crypt_des=yes
  79. ])])
  80. AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[
  81. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  82. #include <string.h>
  83. #if HAVE_UNISTD_H
  84. #include <unistd.h>
  85. #endif
  86. #if HAVE_CRYPT_H
  87. #include <crypt.h>
  88. #endif
  89. int main() {
  90. #if HAVE_CRYPT
  91. char *encrypted = crypt("rasmuslerdorf","_J9..rasm");
  92. return !encrypted || strcmp(encrypted,"_J9..rasmBYk8r9AiWNc");
  93. #else
  94. return 1;
  95. #endif
  96. }]])],[
  97. ac_cv_crypt_ext_des=yes
  98. ],[
  99. ac_cv_crypt_ext_des=no
  100. ],[
  101. ac_cv_crypt_ext_des=no
  102. ])])
  103. AC_CACHE_CHECK(for MD5 crypt, ac_cv_crypt_md5,[
  104. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  105. #include <string.h>
  106. #if HAVE_UNISTD_H
  107. #include <unistd.h>
  108. #endif
  109. #if HAVE_CRYPT_H
  110. #include <crypt.h>
  111. #endif
  112. int main() {
  113. #if HAVE_CRYPT
  114. char salt[15], answer[40];
  115. char *encrypted;
  116. salt[0]='$'; salt[1]='1'; salt[2]='$';
  117. salt[3]='r'; salt[4]='a'; salt[5]='s';
  118. salt[6]='m'; salt[7]='u'; salt[8]='s';
  119. salt[9]='l'; salt[10]='e'; salt[11]='$';
  120. salt[12]='\0';
  121. strcpy(answer,salt);
  122. strcat(answer,"rISCgZzpwk3UhDidwXvin0");
  123. encrypted = crypt("rasmuslerdorf",salt);
  124. return !encrypted || strcmp(encrypted,answer);
  125. #else
  126. return 1;
  127. #endif
  128. }]])],[
  129. ac_cv_crypt_md5=yes
  130. ],[
  131. ac_cv_crypt_md5=no
  132. ],[
  133. ac_cv_crypt_md5=no
  134. ])])
  135. AC_CACHE_CHECK(for Blowfish crypt, ac_cv_crypt_blowfish,[
  136. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  137. #include <string.h>
  138. #if HAVE_UNISTD_H
  139. #include <unistd.h>
  140. #endif
  141. #if HAVE_CRYPT_H
  142. #include <crypt.h>
  143. #endif
  144. int main() {
  145. #if HAVE_CRYPT
  146. char salt[30], answer[70];
  147. char *encrypted;
  148. salt[0]='$'; salt[1]='2'; salt[2]='a'; salt[3]='$'; salt[4]='0'; salt[5]='7'; salt[6]='$'; salt[7]='\0';
  149. strcat(salt,"rasmuslerd............");
  150. strcpy(answer,salt);
  151. strcpy(&answer[29],"nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra");
  152. encrypted = crypt("rasmuslerdorf",salt);
  153. return !encrypted || strcmp(encrypted,answer);
  154. #else
  155. return 1;
  156. #endif
  157. }]])],[
  158. ac_cv_crypt_blowfish=yes
  159. ],[
  160. ac_cv_crypt_blowfish=no
  161. ],[
  162. ac_cv_crypt_blowfish=no
  163. ])])
  164. AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_sha512,[
  165. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  166. #include <string.h>
  167. #if HAVE_UNISTD_H
  168. #include <unistd.h>
  169. #endif
  170. #if HAVE_CRYPT_H
  171. #include <crypt.h>
  172. #endif
  173. int main() {
  174. #if HAVE_CRYPT
  175. char salt[21], answer[21+86];
  176. char *encrypted;
  177. strcpy(salt,"\$6\$rasmuslerdorf\$");
  178. strcpy(answer, salt);
  179. strcat(answer, "EeHCRjm0bljalWuALHSTs1NB9ipEiLEXLhYeXdOpx22gmlmVejnVXFhd84cEKbYxCo.XuUTrW.RLraeEnsvWs/");
  180. encrypted = crypt("rasmuslerdorf",salt);
  181. return !encrypted || strcmp(encrypted,answer);
  182. #else
  183. return 1;
  184. #endif
  185. }]])],[
  186. ac_cv_crypt_sha512=yes
  187. ],[
  188. ac_cv_crypt_sha512=no
  189. ],[
  190. ac_cv_crypt_sha512=no
  191. ])])
  192. AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_sha256,[
  193. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  194. #include <string.h>
  195. #if HAVE_UNISTD_H
  196. #include <unistd.h>
  197. #endif
  198. #if HAVE_CRYPT_H
  199. #include <crypt.h>
  200. #endif
  201. int main() {
  202. #if HAVE_CRYPT
  203. char salt[21], answer[21+43];
  204. char *encrypted;
  205. strcpy(salt,"\$5\$rasmuslerdorf\$");
  206. strcpy(answer, salt);
  207. strcat(answer, "cFAm2puLCujQ9t.0CxiFIIvFi4JyQx5UncCt/xRIX23");
  208. encrypted = crypt("rasmuslerdorf",salt);
  209. return !encrypted || strcmp(encrypted,answer);
  210. #else
  211. return 1;
  212. #endif
  213. }]])],[
  214. ac_cv_crypt_sha256=yes
  215. ],[
  216. ac_cv_crypt_sha256=no
  217. ],[
  218. ac_cv_crypt_sha256=no
  219. ])])
  220. dnl
  221. dnl If one of them is missing, use our own implementation, portable code is then possible
  222. dnl
  223. if test "$ac_cv_crypt_blowfish" = "no" || test "$ac_cv_crypt_des" = "no" || test "$ac_cv_crypt_ext_des" = "no" || test "$ac_cv_crypt_md5" = "no" || test "$ac_cv_crypt_sha512" = "no" || test "$ac_cv_crypt_sha256" = "no" || test "x$php_crypt_r" = "x0"; then
  224. dnl
  225. dnl Check for __alignof__ support in the compiler
  226. dnl
  227. AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[
  228. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  229. ]],[[
  230. int align = __alignof__(int);
  231. ]])],[
  232. ac_cv_alignof_exists=yes
  233. ],[
  234. ac_cv_alignof_exists=no
  235. ])])
  236. if test "$ac_cv_alignof_exists" = "yes"; then
  237. AC_DEFINE([HAVE_ALIGNOF], 1, [whether the compiler supports __alignof__])
  238. fi
  239. 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])
  240. PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
  241. else
  242. AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des])
  243. fi
  244. dnl
  245. dnl Check for __attribute__ ((__aligned__)) support in the compiler
  246. dnl
  247. AC_CACHE_CHECK(whether the compiler supports aligned attribute, ac_cv_attribute_aligned,[
  248. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  249. ]],[[
  250. unsigned char test[32] __attribute__ ((__aligned__ (__alignof__ (int))));
  251. ]])],[
  252. ac_cv_attribute_aligned=yes
  253. ],[
  254. ac_cv_attribute_aligned=no
  255. ])])
  256. if test "$ac_cv_attribute_aligned" = "yes"; then
  257. AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1, [whether the compiler supports __attribute__ ((__aligned__))])
  258. fi
  259. dnl
  260. dnl Check for available functions
  261. dnl
  262. dnl log2 could be used to improve the log function, however it requires C99. The check for log2 should be turned on,
  263. dnl as soon as we support C99.
  264. AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass mempcpy strpncpy)
  265. AC_FUNC_FNMATCH
  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_CHECK_FUNCS(fork CreateProcess, [
  271. php_can_support_proc_open=yes
  272. break
  273. ],[
  274. php_can_support_proc_open=no
  275. ])
  276. AC_MSG_CHECKING([if your OS can spawn processes with inherited handles])
  277. if test "$php_can_support_proc_open" = "yes"; then
  278. AC_MSG_RESULT(yes)
  279. AC_DEFINE(PHP_CAN_SUPPORT_PROC_OPEN,1, [Define if your system has fork/vfork/CreateProcess])
  280. else
  281. AC_MSG_RESULT(no)
  282. fi
  283. PHP_ENABLE_CHROOT_FUNC=no
  284. case "$PHP_SAPI" in
  285. embed)
  286. PHP_ENABLE_CHROOT_FUNC=yes
  287. ;;
  288. none)
  289. for PROG in $PHP_BINARIES; do
  290. case "$PROG" in
  291. cgi|cli|phpdbg)
  292. PHP_ENABLE_CHROOT_FUNC=yes
  293. ;;
  294. *)
  295. PHP_ENABLE_CHROOT_FUNC=no
  296. break
  297. ;;
  298. esac
  299. done
  300. ;;
  301. esac
  302. if test "$PHP_ENABLE_CHROOT_FUNC" = "yes"; then
  303. AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])
  304. fi
  305. dnl
  306. dnl Detect library functions needed by php dns_xxx functions
  307. dnl ext/standard/php_dns.h will collect these in a single define: HAVE_FULL_DNS_FUNCS
  308. dnl
  309. PHP_CHECK_FUNC(res_nsearch, resolv, bind, socket)
  310. PHP_CHECK_FUNC(res_ndestroy, resolv, bind, socket)
  311. PHP_CHECK_FUNC(dns_search, resolv, bind, socket)
  312. PHP_CHECK_FUNC(dn_expand, resolv, bind, socket)
  313. PHP_CHECK_FUNC(dn_skipname, resolv, bind, socket)
  314. dnl
  315. dnl These are old deprecated functions
  316. dnl
  317. PHP_CHECK_FUNC(res_search, resolv, bind, socket)
  318. dnl
  319. dnl Check for strptime()
  320. dnl
  321. AC_CACHE_CHECK(whether strptime() declaration fails, ac_cv_strptime_decl_fails,[
  322. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  323. #include <time.h>
  324. ]],[[
  325. #ifndef HAVE_STRPTIME
  326. #error no strptime() on this platform
  327. #else
  328. /* use invalid strptime() declaration to see if it fails to compile */
  329. int strptime(const char *s, const char *format, struct tm *tm);
  330. #endif
  331. ]])],[
  332. ac_cv_strptime_decl_fails=no
  333. ],[
  334. ac_cv_strptime_decl_fails=yes
  335. ])])
  336. if test "$ac_cv_strptime_decl_fails" = "yes"; then
  337. AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], 1, [whether strptime() declaration fails])
  338. fi
  339. dnl
  340. dnl Check for i18n capabilities
  341. dnl
  342. AC_CHECK_HEADERS([wchar.h])
  343. AC_CHECK_FUNCS([mblen mbrlen mbsinit])
  344. AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],[
  345. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  346. #ifdef HAVE_WCHAR_H
  347. # include <wchar.h>
  348. #endif
  349. ]],[[
  350. mbstate_t a;
  351. ]])],[
  352. ac_cv_type_mbstate_t=yes
  353. ],[
  354. ac_cv_type_mbstate_t=no
  355. ])])
  356. if test "$ac_cv_type_mbstate_t" = "yes"; then
  357. AC_DEFINE([HAVE_MBSTATE_T], 1, [Define if your system has mbstate_t in wchar.h])
  358. fi
  359. dnl
  360. dnl Check for atomic operation API availability in Solaris
  361. dnl
  362. AC_CHECK_HEADERS([atomic.h])
  363. dnl
  364. dnl Check for arc4random on BSD systems
  365. dnl
  366. AC_CHECK_DECLS([arc4random_buf])
  367. dnl
  368. dnl Check for argon2
  369. dnl
  370. PHP_ARG_WITH(password-argon2, for Argon2 support,
  371. [ --with-password-argon2[=DIR]
  372. Include Argon2 support in password_*. DIR is the Argon2 shared library path])
  373. if test "$PHP_PASSWORD_ARGON2" != "no"; then
  374. AC_MSG_CHECKING([for Argon2 library])
  375. for i in $PHP_PASSWORD_ARGON2 /usr /usr/local ; do
  376. if test -r $i/include/argon2.h; then
  377. ARGON2_DIR=$i;
  378. AC_MSG_RESULT(found in $i)
  379. break
  380. fi
  381. done
  382. if test -z "$ARGON2_DIR"; then
  383. AC_MSG_RESULT([not found])
  384. AC_MSG_ERROR([Please ensure the argon2 header and library are installed])
  385. fi
  386. PHP_ADD_LIBRARY_WITH_PATH(argon2, $ARGON2_DIR/$PHP_LIBDIR)
  387. PHP_ADD_INCLUDE($ARGON2_DIR/include)
  388. AC_CHECK_LIB(argon2, argon2id_hash_raw, [
  389. LIBS="$LIBS -largon2"
  390. AC_DEFINE(HAVE_ARGON2LIB, 1, [ Define to 1 if you have the <argon2.h> header file ])
  391. ], [
  392. AC_MSG_ERROR([Problem with libargon2.(a|so). Please verify that Argon2 header and libaries >= 20161029 are installed])
  393. ])
  394. fi
  395. dnl
  396. dnl net_get_interfaces
  397. dnl
  398. AC_CHECK_HEADERS([net/if.h],[], [],
  399. [
  400. #ifdef HAVE_SYS_SOCKET_H
  401. #include <sys/socket.h>
  402. #endif
  403. #include <net/if.h>
  404. ])
  405. AC_CHECK_HEADERS([netdb.h])
  406. AC_MSG_CHECKING([for usable getifaddrs])
  407. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  408. #include <sys/types.h>
  409. #include <ifaddrs.h>
  410. ]],[[
  411. struct ifaddrs *interfaces;
  412. if (!getifaddrs(&interfaces)) {
  413. freeifaddrs(interfaces);
  414. }
  415. ]])], [ac_have_getifaddrs=yes], [ac_have_getifaddrs=no])
  416. if test "$ac_have_getifaddrs" = "yes" ; then
  417. AC_DEFINE(HAVE_GETIFADDRS, 1, [whether getifaddrs is present and usable])
  418. AC_MSG_RESULT(yes)
  419. else
  420. AC_MSG_RESULT(no)
  421. fi
  422. dnl
  423. dnl Setup extension sources
  424. dnl
  425. PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \
  426. cyr_convert.c datetime.c dir.c dl.c dns.c exec.c file.c filestat.c \
  427. flock_compat.c formatted_print.c fsock.c head.c html.c image.c \
  428. info.c iptc.c lcg.c link.c mail.c math.c md5.c metaphone.c \
  429. microtime.c pack.c pageinfo.c quot_print.c rand.c mt_rand.c \
  430. soundex.c string.c scanf.c syslog.c type.c uniqid.c url.c \
  431. var.c versioning.c assert.c strnatcmp.c levenshtein.c \
  432. incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \
  433. http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \
  434. var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \
  435. filters.c proc_open.c streamsfuncs.c http.c password.c \
  436. random.c net.c hrtime.c,,,
  437. -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
  438. PHP_ADD_MAKEFILE_FRAGMENT
  439. PHP_INSTALL_HEADERS([ext/standard/])