@@ -10,6 +10,13 @@ systems:
1010* Haiku: network library has it for internal purposes, not intended for usage
1111 from the system headers.
1212
13+ Result variables:
14+
15+ * HAVE_FUNC_GETHOSTBYNAME_R_6
16+ * HAVE_FUNC_GETHOSTBYNAME_R_5
17+ * HAVE_FUNC_GETHOSTBYNAME_R_3
18+ * HAVE_GETHOSTBYNAME_R
19+
1320See also:
1421https://www.gnu.org/software/autoconf-archive/ax_func_which_gethostbyname_r.html
1522#]=============================================================================]
@@ -18,6 +25,15 @@ include(CheckPrototypeDefinition)
1825include (CMakePushCheckState)
1926include (PHP/SearchLibraries)
2027
28+ set (HAVE_FUNC_GETHOSTBYNAME_R_6 FALSE )
29+ set (HAVE_FUNC_GETHOSTBYNAME_R_5 FALSE )
30+ set (HAVE_FUNC_GETHOSTBYNAME_R_3 FALSE )
31+ set (HAVE_GETHOSTBYNAME_R FALSE )
32+
33+ if (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
34+ return ()
35+ endif ()
36+
2137function (_php_check_gethostbyname_r)
2238 # Check whether gethostname_r() is available. On systems that have it, it is
2339 # mostly in the default libraries (C library) - Linux, Solaris 11.4...
@@ -26,18 +42,16 @@ function(_php_check_gethostbyname_r)
2642 HEADERS netdb.h
2743 LIBRARIES
2844 nsl # Solaris <= 11.3, illumos
29- RESULT_VARIABLE PHP_HAS_GETHOSTBYNAME_R
30- LIBRARY_VARIABLE PHP_HAS_GETHOSTBYNAME_R_LIBRARY
45+ RESULT_VARIABLE PHP_HAVE_GETHOSTBYNAME_R
46+ LIBRARY_VARIABLE PHP_HAVE_GETHOSTBYNAME_R_LIBRARY
3147 )
32- if (NOT PHP_HAS_GETHOSTBYNAME_R)
48+
49+ if (NOT PHP_HAVE_GETHOSTBYNAME_R)
3350 return ()
3451 endif ()
3552
36- if (
37- DEFINED PHP_HAS_GETHOSTBYNAME_R_6
38- OR DEFINED PHP_HAS_GETHOSTBYNAME_R_5
39- OR DEFINED PHP_HAS_GETHOSTBYNAME_R_3
40- )
53+ # Skip in consecutive configuration phases.
54+ if (DEFINED PHP_HAVE_FUNC_GETHOSTBYNAME_R_6)
4155 return ()
4256 endif ()
4357
@@ -53,9 +67,9 @@ function(_php_check_gethostbyname_r)
5367 size_t buflen, struct hostent **result, int *h_errnop)"
5468 "0"
5569 netdb.h
56- PHP_HAS_GETHOSTBYNAME_R_6
70+ PHP_HAVE_FUNC_GETHOSTBYNAME_R_6
5771 )
58- if (PHP_HAS_GETHOSTBYNAME_R_6 )
72+ if (PHP_HAVE_FUNC_GETHOSTBYNAME_R_6 )
5973 cmake_pop_check_state()
6074 message (CHECK_PASS "six" )
6175 return ()
@@ -68,9 +82,9 @@ function(_php_check_gethostbyname_r)
6882 char *buffer, int buflen, int *h_errnop)"
6983 "0"
7084 netdb.h
71- PHP_HAS_GETHOSTBYNAME_R_5
85+ PHP_HAVE_FUNC_GETHOSTBYNAME_R_5
7286 )
73- if (PHP_HAS_GETHOSTBYNAME_R_5 )
87+ if (PHP_HAVE_FUNC_GETHOSTBYNAME_R_5 )
7488 cmake_pop_check_state()
7589 message (CHECK_PASS "five" )
7690 return ()
@@ -83,9 +97,9 @@ function(_php_check_gethostbyname_r)
8397 struct hostent_data *data)"
8498 "0"
8599 netdb.h
86- PHP_HAS_GETHOSTBYNAME_R_3
100+ PHP_HAVE_FUNC_GETHOSTBYNAME_R_3
87101 )
88- if (PHP_HAS_GETHOSTBYNAME_R_3 )
102+ if (PHP_HAVE_FUNC_GETHOSTBYNAME_R_3 )
89103 cmake_pop_check_state()
90104 message (CHECK_PASS "three" )
91105 return ()
@@ -97,19 +111,21 @@ endfunction()
97111
98112_php_check_gethostbyname_r()
99113
100- set (HAVE_FUNC_GETHOSTBYNAME_R_6 "${PHP_HAS_GETHOSTBYNAME_R_6 } " )
101- set (HAVE_FUNC_GETHOSTBYNAME_R_5 "${PHP_HAS_GETHOSTBYNAME_R_5 } " )
102- set (HAVE_FUNC_GETHOSTBYNAME_R_3 "${PHP_HAS_GETHOSTBYNAME_R_3 } " )
114+ set (HAVE_FUNC_GETHOSTBYNAME_R_6 "${PHP_HAVE_FUNC_GETHOSTBYNAME_R_6 } " )
115+ set (HAVE_FUNC_GETHOSTBYNAME_R_5 "${PHP_HAVE_FUNC_GETHOSTBYNAME_R_5 } " )
116+ set (HAVE_FUNC_GETHOSTBYNAME_R_3 "${PHP_HAVE_FUNC_GETHOSTBYNAME_R_3 } " )
103117
104118if (
105119 HAVE_FUNC_GETHOSTBYNAME_R_6
106120 OR HAVE_FUNC_GETHOSTBYNAME_R_5
107121 OR HAVE_FUNC_GETHOSTBYNAME_R_3
108122)
109123 set (HAVE_GETHOSTBYNAME_R TRUE )
110- if (PHP_HAS_GETHOSTBYNAME_R_LIBRARY)
111- target_link_libraries (php_config INTERFACE ${PHP_HAS_GETHOSTBYNAME_R_LIBRARY} )
124+
125+ if (PHP_HAVE_GETHOSTBYNAME_R_LIBRARY)
126+ target_link_libraries (
127+ php_config
128+ INTERFACE ${PHP_HAVE_GETHOSTBYNAME_R_LIBRARY}
129+ )
112130 endif ()
113- else ()
114- set (HAVE_GETHOSTBYNAME_R FALSE )
115131endif ()
0 commit comments