Skip to content

Commit

Permalink
Fix AC_SEARCH_LIBS on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA committed Jun 4, 2024
1 parent 059fd77 commit 8ceea94
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 12 deletions.
34 changes: 34 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,37 @@ AC_DEFUN([OCAML_CC_SUPPORTS_ATOMIC], [
OCAML_CC_RESTORE_VARIABLES
])

# OCAML_SEARCH_LIBS_MSVC(FUNCTION, SEARCH-LIBS,
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
# [OTHER-LIBRARIES])
# --------------------------------------------------------
# Search for a library defining FUNC, if it's not already available.
#
n# Copied from AC_SEARCH_LIBS, but uses `library.lib` instead of
# `-llibrary` for MSVC.
AC_DEFUN([OCAML_SEARCH_LIBS_MSVC],
[AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$1])dnl
AC_CACHE_CHECK([for library containing $1], [ac_Search],
[ac_func_search_save_LIBS=$LIBS
AC_LANG_CONFTEST([AC_LANG_CALL([], [$1])])
for ac_lib in '' $2; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=$ac_lib.lib
LIBS="$ac_lib.lib $5 $ac_func_search_save_LIBS"
fi
AC_LINK_IFELSE([], [AS_VAR_SET([ac_Search], [$ac_res])])
AS_VAR_SET_IF([ac_Search], [break])
done
AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS])
AS_VAR_COPY([ac_res], [ac_Search])
AS_IF([test "$ac_res" != no],
[test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
$3],
[$4])
AS_VAR_POPDEF([ac_Search])dnl
])
151 changes: 143 additions & 8 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ AS_CASE([$host],
AC_CHECK_FUNCS([socketpair])],
[*-pc-windows],
[cclibs="$cclibs ws2_32.lib"
AC_SEARCH_LIBS([socket], [ws2_32])
OCAML_SEARCH_LIBS_MSVC([socket], [ws2_32])
AC_CHECK_FUNCS([socketpair])],
[*-*-haiku],
[cclibs="$cclibs -lnetwork"
Expand Down Expand Up @@ -1974,10 +1974,13 @@ AC_CHECK_HEADER([termios.h],
[AC_CHECK_FUNC([tcflow], [AC_DEFINE([HAS_TERMIOS], [1])])])])])])])

## gethostname
# Note: detection fails on Windows so hardcoding the result
# (should be debugged later)
AS_CASE([$host],
[*-*-mingw32*|*-pc-windows], [AC_DEFINE([HAVE_GETHOSTNAME], [1])],
[*-*-mingw32*],
[cclibs="$cclibs -lws2_32"
AC_SEARCH_LIBS([gethostname], [ws2_32])],
[*-pc-windows],
[cclibs="$cclibs ws2_32.lib"
OCAML_SEARCH_LIBS_MSVC([gethostname], [ws2_32])],
[AC_CHECK_FUNCS([gethostname])])

## uname
Expand Down

0 comments on commit 8ceea94

Please sign in to comment.