@@ -9,7 +9,6 @@ Result variables:
99* HAVE_CRYPT_R
1010* CRYPT_R_CRYPTD
1111* CRYPT_R_STRUCT_CRYPT_DATA
12- * CRYPT_R_GNU_SOURCE
1312#]=============================================================================]
1413
1514include (CheckIncludeFiles)
@@ -20,6 +19,15 @@ include(CMakePushCheckState)
2019
2120# Check whether crypt() and crypt_r() are available.
2221function (_php_ext_standard_check_crypt)
22+ # Skip in consecutive configuration phases.
23+ if (PHP_HAVE_CRYPT_H AND PHP_HAVE_CRYPT AND PHP_HAVE_CRYPT_R)
24+ set (HAVE_CRYPT_H ${PHP_HAVE_CRYPT_H} )
25+ set (HAVE_CRYPT ${PHP_HAVE_CRYPT} )
26+ set (HAVE_CRYPT_R ${PHP_HAVE_CRYPT_R} )
27+
28+ return (PROPAGATE HAVE_CRYPT_H HAVE_CRYPT HAVE_CRYPT_R)
29+ endif ()
30+
2331 message (CHECK_START "Checking basic crypt functionality" )
2432
2533 cmake_push_check_state(RESET)
@@ -64,6 +72,21 @@ endfunction()
6472
6573# Detect the style of crypt_r() if any is available.
6674function (_php_ext_standard_check_crypt_r)
75+ # Skip in consecutive configuration phases.
76+ if (DEFINED PHP_CRYPT_R_CRYPTD)
77+ set (CRYPT_R_CRYPTD ${PHP_CRYPT_R_CRYPTD} PARENT_SCOPE)
78+
79+ if (DEFINED PHP_CRYPT_R_STRUCT_CRYPT_DATA)
80+ set (
81+ CRYPT_R_STRUCT_CRYPT_DATA
82+ ${PHP_CRYPT_R_STRUCT_CRYPT_DATA}
83+ PARENT_SCOPE
84+ )
85+ endif ()
86+
87+ return ()
88+ endif ()
89+
6790 message (CHECK_START "Checking crypt_r() data struct" )
6891
6992 cmake_push_check_state(RESET)
@@ -89,26 +112,6 @@ function(_php_ext_standard_check_crypt_r)
89112 return ()
90113 endif ()
91114
92- check_source_compiles(C [[
93- #define _REENTRANT 1
94- #include <crypt.h>
95-
96- int main(void)
97- {
98- struct crypt_data buffer;
99- crypt_r("passwd", "hash", &buffer);
100-
101- return 0;
102- }
103- ]] PHP_CRYPT_R_STRUCT_CRYPT_DATA)
104- set (CRYPT_R_STRUCT_CRYPT_DATA ${PHP_CRYPT_R_STRUCT_CRYPT_DATA} PARENT_SCOPE)
105-
106- if (PHP_CRYPT_R_STRUCT_CRYPT_DATA)
107- message (CHECK_PASS "struct crypt_data" )
108- cmake_pop_check_state()
109- return ()
110- endif ()
111-
112115 cmake_push_check_state()
113116 list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
114117 check_source_compiles(C [[
@@ -122,38 +125,34 @@ function(_php_ext_standard_check_crypt_r)
122125
123126 return 0;
124127 }
125- ]] PHP_CRYPT_R_GNU_SOURCE)
126- set (CRYPT_R_GNU_SOURCE ${PHP_CRYPT_R_GNU_SOURCE} PARENT_SCOPE)
128+ ]] PHP_CRYPT_R_STRUCT_CRYPT_DATA)
127129 cmake_pop_check_state()
128130
129- if (PHP_CRYPT_R_GNU_SOURCE)
130- set (CRYPT_R_STRUCT_CRYPT_DATA TRUE PARENT_SCOPE)
131- message (CHECK_PASS "GNU struct crypt_data" )
132- cmake_pop_check_state()
133- return ()
134- endif ()
135-
136- check_source_compiles(C [[
137- #include <stdlib.h>
138- #include <unistd.h>
131+ if (NOT PHP_CRYPT_R_STRUCT_CRYPT_DATA)
132+ unset (PHP_CRYPT_R_STRUCT_CRYPT_DATA CACHE )
139133
140- int main(void)
141- {
142- struct crypt_data buffer;
143- crypt_r("passwd", "hash", &buffer);
134+ check_source_compiles(C [[
135+ #include <stdlib.h>
136+ #include <unistd.h>
144137
145- return 0;
146- }
147- ]] PHP_HAVE_CRYPT_R_STRUCT_CRYPT_DATA)
138+ int main(void)
139+ {
140+ struct crypt_data buffer;
141+ crypt_r("passwd", "hash", &buffer);
148142
149- if (PHP_HAVE_CRYPT_R_STRUCT_CRYPT_DATA)
150- set (CRYPT_R_STRUCT_CRYPT_DATA TRUE PARENT_SCOPE)
151- message (CHECK_PASS "struct crypt_data" )
152- cmake_pop_check_state()
153- return ()
143+ return 0;
144+ }
145+ ]] PHP_CRYPT_R_STRUCT_CRYPT_DATA)
154146 endif ()
155147 cmake_pop_check_state()
156148
149+ set (CRYPT_R_STRUCT_CRYPT_DATA ${PHP_CRYPT_R_STRUCT_CRYPT_DATA} PARENT_SCOPE)
150+
151+ if (PHP_CRYPT_R_STRUCT_CRYPT_DATA)
152+ message (CHECK_PASS "struct crypt_data" )
153+ return ()
154+ endif ()
155+
157156 message (CHECK_FAIL "none" )
158157
159158 message (
@@ -165,6 +164,17 @@ endfunction()
165164
166165# Check if crypt library is usable.
167166function (_php_ext_standard_check_crypt_is_usable)
167+ # Skip in consecutive configuration phases.
168+ if (
169+ PHP_HAVE_CRYPT_BLOWFISH
170+ AND PHP_HAVE_CRYPT_EXT_DES
171+ AND PHP_HAVE_CRYPT_MD5
172+ AND PHP_HAVE_CRYPT_SHA256
173+ AND PHP_HAVE_CRYPT_SHA512
174+ )
175+ return ()
176+ endif ()
177+
168178 cmake_push_check_state(RESET)
169179 set (CMAKE_REQUIRED_QUIET TRUE )
170180
0 commit comments