Skip to content

Commit c188621

Browse files
authored
PHPC-2133: Fix building with SRV support on FreeBSD (#1432)
1 parent b93f7c2 commit c188621

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

scripts/autotools/libmongoc/CheckResolv.m4

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ dnl Disable Windows DNSAPI
22
AC_SUBST(MONGOC_HAVE_DNSAPI, 0)
33

44
found_resolv="no"
5+
libc_has_resolv="no"
56

6-
old_LIBS="$LIBS"
7+
if test "$os_aix" = "yes" -o "$os_freebsd" = "yes"; then
8+
libc_has_resolv="yes"
9+
fi
710

8-
dnl Link libresolv for detection (note: on AIX, resolv functions are in libc)
9-
if test "$os_aix" != "yes"; then
10-
LIBS="$LIBS -lresolv"
11+
dnl Temporarily link libresolv for detection if necessary
12+
if test "$libc_has_resolv" = "no"; then
13+
old_LIBS="$LIBS"
14+
LIBS="$LIBS -lresolv"
1115
fi
1216

1317
dnl Thread-safe DNS query function for _mongoc_client_get_srv.
@@ -93,9 +97,10 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
9397
])
9498
])
9599

96-
LIBS="$old_LIBS"
100+
if test "$libc_has_resolv" = "no"; then
101+
LIBS="$old_LIBS"
97102

98-
dnl Link libresolv if needed (note: on AIX, resolv functions are in libc)
99-
AS_IF([test "$found_resolv" = "yes" -a "$os_aix" != "yes"],[
100-
PHP_ADD_LIBRARY([resolv],,[MONGODB_SHARED_LIBADD])
101-
])
103+
AS_IF([test "$found_resolv" = "yes"],[
104+
PHP_ADD_LIBRARY([resolv],,[MONGODB_SHARED_LIBADD])
105+
])
106+
fi
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
dnl Ignore OpenSSL deprecation warnings on OSX
22
AS_IF([test "$os_darwin" = "yes"],
33
[AX_CHECK_COMPILE_FLAG([-Wno-deprecated-declarations], [STD_CFLAGS="$STD_CFLAGS -Wno-deprecated-declarations"])])
4+
45
dnl We know there are some cast-align issues on OSX
56
AS_IF([test "$os_darwin" = "yes"],
67
[AX_CHECK_COMPILE_FLAG([-Wno-cast-align], [STD_CFLAGS="$STD_CFLAGS -Wno-cast-align"])])
78
AS_IF([test "$os_darwin" = "yes"],
89
[AX_CHECK_COMPILE_FLAG([-Wno-unneeded-internal-declaration], [STD_CFLAGS="$STD_CFLAGS -Wno-unneeded-internal-declaration"])])
910
AS_IF([test "$os_darwin" = "yes"],
1011
[AX_CHECK_COMPILE_FLAG([-Wno-error=unused-command-line-argument], [STD_CFLAGS="$STD_CFLAGS -Wno-error=unused-command-line-argument"])])
12+
13+
dnl Enable non-standard features on FreeBSD with __BSD_VISIBLE=1
14+
if test "$os_freebsd" = "yes"; then
15+
PHP_MONGODB_BUNDLED_CFLAGS="$PHP_MONGODB_BUNDLED_CFLAGS -D__BSD_VISIBLE=1"
16+
fi

0 commit comments

Comments
 (0)