Commit 77f71d7d authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Rewrite dlopen detection using modern autoconf language constructs

parent 5928d31e
......@@ -20769,9 +20769,9 @@ SO_STRIP="cat"
 
# Check whether --with-dlopen was given.
if test "${with_dlopen+set}" = set; then :
withval=$with_dlopen; dlopen="$withval"
withval=$with_dlopen;
else
dlopen="auto"
with_dlopen="auto"
fi
 
 
......@@ -20779,26 +20779,26 @@ fi
#
# If PIC is disabled, dlopen must also be
#
if test "auto" = "$dlopen"; then
if test "no" = "$pic_mode"; then
dlopen="no"
else
dlopen="yes"
fi
elif test "yes" = "$dlopen"; then
if test "no" = "$pic_mode"; then
as_fn_error $? "--with-dlopen requires PIC" "$LINENO" 5
fi
if test "$pic_mode" = "no"; then :
case $with_dlopen in #(
auto) :
with_dlopen="no" ;; #(
yes) :
as_fn_error $? "--with-dlopen requires PIC" "$LINENO" 5 ;; #(
*) :
;;
esac
fi
 
if test "yes" = "$dlopen"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if ${ac_cv_lib_dl_dlopen+:} false; then :
case $with_dlopen in #(
auto|yes) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
$as_echo_n "checking for library containing dlopen... " >&6; }
if ${ac_cv_search_dlopen+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $LIBS"
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
 
......@@ -20817,27 +20817,39 @@ return dlopen ();
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_dl_dlopen=yes
else
ac_cv_lib_dl_dlopen=no
for ac_lib in '' dl; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_dlopen=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
conftest$ac_exeext
if ${ac_cv_search_dlopen+:} false; then :
break
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
have_dl=yes
done
if ${ac_cv_search_dlopen+:} false; then :
else
have_dl=no
ac_cv_search_dlopen=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
$as_echo "$ac_cv_search_dlopen" >&6; }
ac_res=$ac_cv_search_dlopen
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
if test "yes" = "$have_dl"; then
LIBS="-ldl $LIBS"
fi
for ac_func in dlopen dlclose dlsym
fi
for ac_func in dlopen dlclose dlsym
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
......@@ -20845,82 +20857,108 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
with_dlopen="yes"
else
dlopen=no
with_dlopen="no"
fi
done
 
;; #(
*) :
;;
esac
if test "$with_dlopen" = "yes"; then :
case $host in #(
*-linux*|*-gnu*) :
SO_CFLAGS="-fPIC"
SO_LDFLAGS=""
if test "$ac_cv_search_dlopen" != "none required"; then :
if test "$use_libtool" = "yes"; then :
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
 
if test "yes" = "$dlopen"; then
case $host in
*-linux*|*-gnu*)
SO_CFLAGS="-fPIC"
SO_LDFLAGS=""
if test "yes" = "$have_dl"
then
if test "yes" = "$use_libtool"; then
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
else
SO_LDFLAGS="-shared"
SO_LD="ld"
fi
;;
*-freebsd*|*-openbsd*)
LDFLAGS="${LDFLAGS} -Wl,-E"
SO_CFLAGS="-fpic"
if test "yes" = "$use_libtool"; then
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
;;
*-netbsd*)
SO_CFLAGS="-fpic"
SO_LDFLAGS="-Bshareable -x"
SO_LD="ld"
SO_STRIP="sed -e s/-Wl,//g"
;;
*-solaris*)
SO_CFLAGS="-KPIC"
SO_LDFLAGS="-G -z text"
SO_LD="ld"
;;
*)
SO_CFLAGS="-fPIC"
;;
esac
else
 
if test "X$GCC" = "Xyes"; then
SO_CFLAGS="-fPIC"
if test -z "$SO_LD"
then
if test "yes" = "$use_libtool"; then
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
fi
fi
SO_LDFLAGS="-shared"
SO_LD="ld"
 
# If we still don't know how to make shared objects, don't make any.
if test -n "$SO_LD"; then
SO_TARGETS="\${SO_TARGETS}"
fi
;; #(
*-freebsd*|*-openbsd*) :
LDFLAGS="${LDFLAGS} -Wl,-E"
SO_CFLAGS="-fpic"
if test "$use_libtool" = "yes"; then :
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
;; #(
*-netbsd*) :
SO_CFLAGS="-fpic"
SO_LDFLAGS="-Bshareable -x"
SO_LD="ld"
SO_STRIP="sed -e s/-Wl,//g"
;; #(
*-solaris*) :
SO_CFLAGS="-KPIC"
SO_LDFLAGS="-G -z text"
SO_LD="ld"
;; #(
*) :
SO_CFLAGS="-fPIC"
;;
esac
if test "$GCC" = "yes"; then :
SO_CFLAGS="-fPIC"
if test -z "$SO_LD"; then :
if test "$use_libtool" = "yes"; then :
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
fi
fi
# If we still don't know how to make shared objects, don't make any.
if test -n "$SO_LD"; then :
SO_TARGETS="\${SO_TARGETS}"
 
$as_echo "#define ISC_DLZ_DLOPEN 1" >>confdefs.h
 
fi
fi
fi
CFLAGS="$CFLAGS $SO_CFLAGS"
 
 
......
......@@ -3009,102 +3009,91 @@ SO_LD=""
SO_TARGETS=""
SO_STRIP="cat"
AC_ARG_WITH(dlopen,
AC_ARG_WITH([dlopen],
AS_HELP_STRING([--with-dlopen=ARG],
[support dynamically loadable DLZ and DYNDB drivers]),
dlopen="$withval", dlopen="auto")
[], [with_dlopen="auto"])
#
# If PIC is disabled, dlopen must also be
#
if test "auto" = "$dlopen"; then
if test "no" = "$pic_mode"; then
dlopen="no"
else
dlopen="yes"
fi
elif test "yes" = "$dlopen"; then
if test "no" = "$pic_mode"; then
AC_MSG_ERROR([--with-dlopen requires PIC])
fi
fi
if test "yes" = "$dlopen"; then
AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
if test "yes" = "$have_dl"; then
LIBS="-ldl $LIBS"
fi
AC_CHECK_FUNCS(dlopen dlclose dlsym,,dlopen=no)
fi
if test "yes" = "$dlopen"; then
case $host in
*-linux*|*-gnu*)
SO_CFLAGS="-fPIC"
SO_LDFLAGS=""
if test "yes" = "$have_dl"
then
if test "yes" = "$use_libtool"; then
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
else
SO_LDFLAGS="-shared"
SO_LD="ld"
fi
;;
*-freebsd*|*-openbsd*)
LDFLAGS="${LDFLAGS} -Wl,-E"
SO_CFLAGS="-fpic"
if test "yes" = "$use_libtool"; then
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
;;
*-netbsd*)
SO_CFLAGS="-fpic"
SO_LDFLAGS="-Bshareable -x"
SO_LD="ld"
SO_STRIP="sed -e s/-Wl,//g"
;;
*-solaris*)
SO_CFLAGS="-KPIC"
SO_LDFLAGS="-G -z text"
SO_LD="ld"
;;
*)
SO_CFLAGS="-fPIC"
;;
esac
AS_IF([test "$pic_mode" = "no"],
[AS_CASE([$with_dlopen],
[auto],[with_dlopen="no"],
[yes],[AC_MSG_ERROR([--with-dlopen requires PIC])])])
AS_CASE([$with_dlopen],
[auto|yes],[
AC_SEARCH_LIBS([dlopen],[dl])
AC_CHECK_FUNCS([dlopen dlclose dlsym],
[with_dlopen="yes"],
[with_dlopen="no"])
])
if test "X$GCC" = "Xyes"; then
SO_CFLAGS="-fPIC"
if test -z "$SO_LD"
then
if test "yes" = "$use_libtool"; then
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
else
SO_LDFLAGS="-shared"
SO_LD="${CC}"
fi
fi
fi
AS_IF([test "$with_dlopen" = "yes"],
[AS_CASE([$host],
[*-linux*|*-gnu*],[
SO_CFLAGS="-fPIC"
SO_LDFLAGS=""
AS_IF([test "$ac_cv_search_dlopen" != "none required"],[
AS_IF([test "$use_libtool" = "yes"],[
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
],[
SO_LDFLAGS="-shared"
SO_LD="${CC}"
])
],[
SO_LDFLAGS="-shared"
SO_LD="ld"
])
],
[*-freebsd*|*-openbsd*],[
LDFLAGS="${LDFLAGS} -Wl,-E"
SO_CFLAGS="-fpic"
AS_IF([test "$use_libtool" = "yes"],[
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
],[
SO_LDFLAGS="-shared"
SO_LD="${CC}"
])
],
[*-netbsd*],[
SO_CFLAGS="-fpic"
SO_LDFLAGS="-Bshareable -x"
SO_LD="ld"
SO_STRIP="sed -e s/-Wl,//g"
],
[*-solaris*],[
SO_CFLAGS="-KPIC"
SO_LDFLAGS="-G -z text"
SO_LD="ld"
],
[
SO_CFLAGS="-fPIC"
])
AS_IF([test "$GCC" = "yes"],[
SO_CFLAGS="-fPIC"
AS_IF([test -z "$SO_LD"],
[AS_IF([test "$use_libtool" = "yes"],[
SO_LDFLAGS="-Xcompiler -shared"
SO_LD="${CC}"
],[
SO_LDFLAGS="-shared"
SO_LD="${CC}"
])
])
])
# If we still don't know how to make shared objects, don't make any.
AS_IF([test -n "$SO_LD"],
[SO_TARGETS="\${SO_TARGETS}"
AC_DEFINE([ISC_DLZ_DLOPEN], [1],
[Define to allow building of objects for dlopen().])
])
])
# If we still don't know how to make shared objects, don't make any.
if test -n "$SO_LD"; then
SO_TARGETS="\${SO_TARGETS}"
AC_DEFINE(ISC_DLZ_DLOPEN, 1,
[Define to allow building of objects for dlopen().])
fi
fi
CFLAGS="$CFLAGS $SO_CFLAGS"
AC_SUBST(SO)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment