config.m4 11 KB

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