Commit 67e8dc68 authored by Alexandre Julliard's avatar Alexandre Julliard

Added configure check for the soname of libraries that we load

dynamically. Added a few other configure macros, and moved all macros into aclocal.m4.
parent a081e238
dnl Macros used to build the Wine configure script
dnl
dnl Copyright 2002 Alexandre Julliard
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2.1 of the License, or (at your option) any later version.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
dnl **** Get the ldd program name; used by WINE_GET_SONAME ****
dnl
dnl Usage: WINE_PATH_LDD
dnl
AC_DEFUN([WINE_PATH_LDD],[AC_PATH_PROG(LDD,ldd,true,/sbin:/usr/sbin:$PATH)])
dnl **** Extract the soname of a library ****
dnl
dnl Usage: WINE_GET_SONAME(LIBRARY, FUNCTION, [OTHER_LIBRARIES])
dnl
AC_DEFUN([WINE_GET_SONAME],
[AC_REQUIRE([WINE_PATH_LDD])
AC_CACHE_CHECK([for -l$1 soname], ac_cv_lib_soname_$1,
[ac_get_soname_save_LIBS=$LIBS
LIBS="-l$1 $3 $LIBS"
AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
[ac_cv_lib_soname_$1=`$ac_cv_path_LDD conftest$ac_exeext | grep lib$1\\.so | sed 's/^[[ ]]*\([[^ ]]*\)[[ ]]*=>.*$/\1/'`
if test "x$ac_cv_lib_soname_$1" = "x"
then
ac_cv_lib_soname_$1="lib$1.so"
fi],
[ac_cv_lib_soname_$1="lib$1.so"])
LIBS=$ac_get_soname_save_LIBS])
if test "x$ac_cv_lib_soname_$1" != xNONE
then AC_DEFINE_UNQUOTED(AS_TR_CPP(SONAME_LIB$1),"$ac_cv_lib_soname_$1",
[Define to the soname of the lib$1 library.])dnl
fi])
dnl **** Check if a structure contains a specified member ****
dnl
dnl Usage: WINE_CHECK_STRUCT_MEMBER(struct,member,[includes,[action-if-found,[action-if-not-found]]])
dnl
AC_DEFUN([WINE_CHECK_STRUCT_MEMBER],
[AC_CACHE_CHECK([for $2 in struct $1], ac_cv_c_$1_$2,
AC_TRY_COMPILE([$3],[struct $1 s; s.$2 = 0],ac_cv_c_$1_$2="yes",ac_cv_c_$1_$2="no"))
AS_IF([ test "x$ac_cv_c_$1_$2" = "xyes"],[$4],[$5])
])
dnl **** Check for reentrant libc ****
dnl
dnl Usage: WINE_CHECK_ERRNO(errno-name,[action-if-yes,[action-if-no]])
dnl
dnl For cross-compiling we blindly assume that libc is reentrant. This is
dnl ok since non-reentrant libc is quite rare (mostly old libc5 versions).
dnl
AC_DEFUN([WINE_CHECK_ERRNO],
[AC_CACHE_CHECK([for reentrant libc: $1],[wine_cv_libc_r_$1],
[AC_TRY_RUN([int myerrno = 0;
char buf[256];
int *$1(){return &myerrno;}
main(){connect(0,buf,255); exit(!myerrno);}],
wine_cv_libc_r_$1=yes, wine_cv_libc_r_$1=no,
wine_cv_libc_r_$1=yes)])
AS_IF([test "$wine_cv_libc_r_$1" = "yes"],[$2],[$3])])
dnl **** Link C code with an assembly file ****
dnl
dnl Usage: WINE_TRY_ASM_LINK(asm-code,includes,function,[action-if-found,[action-if-not-found]])
dnl
AC_DEFUN([WINE_TRY_ASM_LINK],
[ac_try_asm_link_saved_libs=$LIBS
LIBS="conftest_asm.s $LIBS"
cat > conftest_asm.s <<EOF
$1
EOF
AC_TRY_LINK([$2],[$3],[$4],[$5])
rm -f conftest_asm.s
LIBS=$ac_try_asm_link_saved_libs])
dnl **** Check if we can link an empty program with special CFLAGS ****
dnl
dnl Usage: WINE_TRY_CFLAGS(flags,[action-if-yes,[action-if-no]])
dnl
AC_DEFUN([WINE_TRY_CFLAGS],
[ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS $1"
AC_TRY_LINK([],[],[$2],[$3])
CFLAGS=$ac_wine_try_cflags_saved])
dnl **** Create non-existent directories from config.status ****
dnl
dnl Usage: WINE_CONFIG_EXTRA_DIR(dirname)
dnl
AC_DEFUN([WINE_CONFIG_EXTRA_DIR],
[AC_CONFIG_COMMANDS([$1],[test -d "$1" || (AC_MSG_NOTICE([creating $1]) && mkdir "$1")])])
......@@ -622,13 +622,9 @@ int main(void) {
fi
dnl Check for -mpreferred-stack-boundary
AC_CACHE_CHECK([for gcc -mpreferred-stack-boundary=2 support],
ac_cv_c_gcc_stack_boundary,
[saved_cflags=$CFLAGS
CFLAGS="$CFLAGS -mpreferred-stack-boundary=2"
AC_TRY_COMPILE(,[return 0],ac_cv_c_gcc_stack_boundary="yes",ac_cv_c_gcc_stack_boundary="no")
CFLAGS=$saved_cflags
])
AC_CACHE_CHECK([for gcc -mpreferred-stack-boundary=2 support], ac_cv_c_gcc_stack_boundary,
[WINE_TRY_CFLAGS([-mpreferred-stack-boundary=2],
ac_cv_c_gcc_stack_boundary="yes",ac_cv_c_gcc_stack_boundary="no")])
if test "$ac_cv_c_gcc_stack_boundary" = "yes"
then
CFLAGS="$CFLAGS -mpreferred-stack-boundary=2"
......@@ -637,18 +633,13 @@ fi
dnl **** Check if we need to place .type inside a .def directive ****
AC_CACHE_CHECK([whether .type must sit inside a .def directive],
ac_cv_c_type_in_def,
[saved_libs=$LIBS
LIBS="conftest_asm.s $LIBS"
cat > conftest_asm.s <<EOF
.globl _ac_test
AC_CACHE_CHECK([whether .type must sit inside a .def directive], ac_cv_c_type_in_def,
WINE_TRY_ASM_LINK(
[ .globl _ac_test
.def _ac_test; .scl 2; .type 32; .endef
_ac_test:
.long 0
EOF
AC_TRY_LINK(,,ac_cv_c_type_in_def="yes",ac_cv_c_type_in_def="no")
LIBS=$saved_libs])
.long 0],,,
ac_cv_c_type_in_def="yes",ac_cv_c_type_in_def="no"))
if test "$ac_cv_c_type_in_def" = "yes"
then
AC_DEFINE(NEED_TYPE_IN_DEF, 1, [Define if .type asm directive must be inside a .def directive])
......@@ -656,18 +647,14 @@ fi
dnl **** Check for underscore on external symbols ****
AC_CACHE_CHECK([whether external symbols need an underscore prefix],
ac_cv_c_extern_prefix,
[saved_libs=$LIBS
LIBS="conftest_asm.s $LIBS"
cat > conftest_asm.s <<EOF
.globl _ac_test
AC_CACHE_CHECK([whether external symbols need an underscore prefix], ac_cv_c_extern_prefix,
WINE_TRY_ASM_LINK(
[ .globl _ac_test
_ac_test:
.long 0
EOF
AC_TRY_LINK([extern int ac_test;],[if (ac_test) return 1],
ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no")
LIBS=$saved_libs])
.long 0],
[extern int ac_test;],
[if (ac_test) return 1],
ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no"))
if test "$ac_cv_c_extern_prefix" = "yes"
then
AC_DEFINE(NEED_UNDERSCORE_PREFIX, 1,
......@@ -676,43 +663,25 @@ fi
dnl **** Check whether stdcall symbols need to be decorated ****
AC_CACHE_CHECK([whether stdcall symbols need to be decorated],
ac_cv_c_stdcall_decoration,
[saved_libs=$LIBS
LIBS="conftest_asm.s $LIBS"
if test "$ac_cv_c_extern_prefix" = "yes"
then
cat > conftest_asm.s <<EOF
.globl _ac_test@0
AC_CACHE_CHECK([whether stdcall symbols need to be decorated], ac_cv_c_stdcall_decoration,
WINE_TRY_ASM_LINK(
[ .globl _ac_test@0
_ac_test@0:
EOF
else
cat > conftest_asm.s <<EOF
.globl ac_test@0
ac_test@0:
EOF
fi
AC_TRY_LINK([extern void __attribute__((__stdcall__)) ac_test(void);],
[ac_test(); return 0],
ac_cv_c_stdcall_decoration="yes",ac_cv_c_stdcall_decoration="no")
LIBS=$saved_libs])
ac_test@0:],
[extern void __attribute__((__stdcall__)) ac_test(void);],
[ac_test()],
ac_cv_c_stdcall_decoration="yes",ac_cv_c_stdcall_decoration="no"))
if test "$ac_cv_c_stdcall_decoration" = "yes"
then
AC_DEFINE(NEED_STDCALL_DECORATION, 1,
[Define if stdcall symbols need to be decorated])
AC_DEFINE(NEED_STDCALL_DECORATION, 1, [Define if stdcall symbols need to be decorated])
fi
dnl **** Check for .string in assembler ****
AC_CACHE_CHECK([whether assembler accepts .string],
ac_cv_c_asm_string,
[saved_libs=$LIBS
LIBS="conftest_asm.s $LIBS"
cat > conftest_asm.s <<EOF
.string "test"
EOF
AC_TRY_LINK(,,ac_cv_c_asm_string="yes",ac_cv_c_asm_string="no")
LIBS=$saved_libs])
AC_CACHE_CHECK([whether assembler accepts .string], ac_cv_c_asm_string,
WINE_TRY_ASM_LINK(
[ .string "test"],,,ac_cv_c_asm_string="yes",ac_cv_c_asm_string="no"))
if test "$ac_cv_c_asm_string" = "yes"
then
AC_DEFINE(HAVE_ASM_STRING, 1, [Define to use .string instead of .ascii])
......@@ -745,24 +714,17 @@ case $host_os in
if test "$LIBEXT" = "so"
then
AC_CACHE_CHECK([whether we can build a GNU style ELF dll],ac_cv_c_dll_gnuelf,
[saved_cflags=$CFLAGS
CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0,-Bsymbolic"
AC_TRY_LINK(,[return 1],ac_cv_c_dll_gnuelf="yes",ac_cv_c_dll_gnuelf="no")
CFLAGS=$saved_cflags
])
AC_CACHE_CHECK([whether we can build a GNU style ELF dll], ac_cv_c_dll_gnuelf,
[WINE_TRY_CFLAGS([-fPIC -shared -Wl,-soname,conftest.so.1.0,-Bsymbolic],
ac_cv_c_dll_gnuelf="yes",ac_cv_c_dll_gnuelf="no")])
if test "$ac_cv_c_dll_gnuelf" = "yes"
then
LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%)"
LDDLLFLAGS="-Wl,-Bsymbolic"
else
AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll,
ac_cv_c_dll_unixware,
[saved_cflags=$CFLAGS
CFLAGS="$CFLAGS -fPIC -Wl,-G,-h,conftest.so.1.0,-B,symbolic"
AC_TRY_LINK(,[return 1],ac_cv_c_dll_unixware="yes",ac_cv_c_dll_unixware="no")
CFLAGS=$saved_cflags
])
AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll, ac_cv_c_dll_unixware,
[WINE_TRY_CFLAGS([-fPIC -Wl,-G,-h,conftest.so.1.0,-B,symbolic],
ac_cv_c_dll_unixware="yes",ac_cv_c_dll_unixware="no")])
if test "$ac_cv_c_dll_unixware" = "yes"
then
LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,%)"
......@@ -807,38 +769,31 @@ AC_SUBST(LDDLLFLAGS)
AC_SUBST(LIBEXT)
AC_SUBST(LDPATH)
dnl **** Check for reentrant libc ****
dnl
dnl For cross-compiling we blindly assume that libc is reentrant. This is
dnl ok since non-reentrant libc is quite rare (mostly old libc5 versions).
AC_DEFUN([WINE_CHECK_ERRNO],
[
AC_CACHE_CHECK(for reentrant libc: $1, wine_cv_libc_r_$1,
[AC_TRY_RUN([int myerrno = 0;
char buf[256];
int *$1(){return &myerrno;}
main(){connect(0,buf,255); exit(!myerrno);}],
wine_cv_libc_r_$1=yes, wine_cv_libc_r_$1=no,
wine_cv_libc_r_$1=yes )
])
if test "$wine_cv_libc_r_$1" = "yes"
dnl **** Get the soname for libraries that we load dynamically ****
if test "$LIBEXT" = "so"
then
wine_cv_libc_reentrant=$1
WINE_GET_SONAME(X11,XCreateWindow,[$X_LIBS $X_EXTRA_LIBS])
WINE_GET_SONAME(Xext,XextCreateExtension,[$X_LIBS -lX11 $X_EXTRA_LIBS])
WINE_GET_SONAME(Xrender,XRenderQueryExtension,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
WINE_GET_SONAME(freetype,FT_Init_FreeType,[$X_LIBS])
fi
])
dnl **** Check for reentrant libc ****
wine_cv_libc_reentrant=no
dnl Linux style errno location
WINE_CHECK_ERRNO(__errno_location)
dnl FreeBSD style errno location
WINE_CHECK_ERRNO(__error)
dnl Solaris style errno location
WINE_CHECK_ERRNO(___errno)
dnl UnixWare style errno location
WINE_CHECK_ERRNO(__thr_errno)
dnl NetBSD style errno location
WINE_CHECK_ERRNO(__errno)
WINE_CHECK_ERRNO([__errno_location], [wine_cv_libc_reentrant=__errno_location],
dnl FreeBSD style errno location
WINE_CHECK_ERRNO([__error], [wine_cv_libc_reentrant=__error],
dnl Solaris style errno location
WINE_CHECK_ERRNO([___errno], [wine_cv_libc_reentrant=___errno],
dnl UnixWare style errno location
WINE_CHECK_ERRNO([__thr_errno], [wine_cv_libc_reentrant=__thr_errno],
dnl NetBSD style errno location
WINE_CHECK_ERRNO([__errno], [wine_cv_libc_reentrant=__errno])
))))
if test "$wine_cv_libc_reentrant" != "no"
then
......@@ -1151,17 +1106,6 @@ then
fi
fi
dnl *** Check for some structure members
dnl Macro to check if a structure contains a specified member
dnl Usage: WINE_CHECK_STRUCT_MEMBER(struct,member,[includes,[action-if-found,[action-if-not-found]]])
AC_DEFUN([WINE_CHECK_STRUCT_MEMBER],
[AC_CACHE_CHECK([for $2 in struct $1], ac_cv_c_$1_$2,
AC_TRY_COMPILE([$3],[struct $1 s; s.$2 = 0],ac_cv_c_$1_$2="yes",ac_cv_c_$1_$2="no"))
AS_IF([ test "x$ac_cv_c_$1_$2" = "xyes"],[$4],[$5])
])
dnl **** FIXME: what about mixed cases, where we need two of them? ***
WINE_CHECK_STRUCT_MEMBER(statfs,f_bfree,
......@@ -1238,11 +1182,6 @@ fi
dnl **** Generate output files ****
dnl Macro to create non-existent directories from config.status
dnl Usage: WINE_CONFIG_EXTRA_DIR(dirname)
AC_DEFUN([WINE_CONFIG_EXTRA_DIR],
[AC_CONFIG_COMMANDS([$1],[test -d "$1" || (AC_MSG_NOTICE([creating $1]) && mkdir "$1")])])
AH_TOP([#define __WINE_CONFIG_H])
WINE_CONFIG_EXTRA_DIR(controls)
......
......@@ -73,6 +73,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(font);
#include <freetype/fttrigon.h>
#endif
#ifndef SONAME_LIBFREETYPE
#define SONAME_LIBFREETYPE "libfreetype.so"
#endif
static FT_Library library = 0;
static void *ft_handle = NULL;
......@@ -242,7 +246,7 @@ static BOOL AddFontFileToList(char *file)
for(insertface = &family->FirstFace; *insertface;
insertface = &(*insertface)->next) {
if(!strcmpW((*insertface)->StyleName, StyleW)) {
ERR("Already loaded font %s %s\n", debugstr_w(family->FamilyName),
WARN("Already loaded font %s %s\n", debugstr_w(family->FamilyName),
debugstr_w(StyleW));
HeapFree(GetProcessHeap(), 0, StyleW);
pFT_Done_Face(ft_face);
......@@ -449,7 +453,7 @@ BOOL WineEngInit(void)
TRACE("\n");
ft_handle = wine_dlopen("libfreetype.so", RTLD_NOW, NULL, 0);
ft_handle = wine_dlopen(SONAME_LIBFREETYPE, RTLD_NOW, NULL, 0);
if(!ft_handle) {
WINE_MESSAGE(
"Wine cannot find the FreeType font library. To enable Wine to\n"
......
......@@ -78,6 +78,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
FT_LOAD_IGNORE_TRANSFORM | \
FT_LOAD_LINEAR_DESIGN )
#ifndef SONAME_LIBFREETYPE
#define SONAME_LIBFREETYPE "libfreetype.so"
#endif
static void *ft_handle = NULL;
#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL;
......@@ -590,7 +594,7 @@ BOOL PSDRV_GetTrueTypeMetrics(void)
return TRUE;
ft_handle = wine_dlopen("libfreetype.so", RTLD_NOW, NULL, 0);
ft_handle = wine_dlopen(SONAME_LIBFREETYPE, RTLD_NOW, NULL, 0);
if(!ft_handle) {
WINE_MESSAGE(
"Wine cannot find the FreeType font library. To enable Wine to\n"
......
......@@ -82,6 +82,17 @@ static INT mru = -1;
static int antialias = 1;
/* some default values just in case */
#ifndef SONAME_LIBX11
#define SONAME_LIBX11 "libX11.so"
#endif
#ifndef SONAME_LIBXEXT
#define SONAME_LIBXEXT "libXext.so"
#endif
#ifndef SONAME_LIBXRENDER
#define SONAME_LIBXRENDER "libXrender.so"
#endif
static void *xrender_handle;
#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
......@@ -111,10 +122,9 @@ void X11DRV_XRender_Init(void)
int error_base, event_base, i;
XRenderPictFormat pf;
/* FIXME: should find correct soname at compile time */
if (!wine_dlopen("libX11.so", RTLD_NOW|RTLD_GLOBAL, NULL, 0)) return;
if (!wine_dlopen("libXext.so", RTLD_NOW|RTLD_GLOBAL, NULL, 0)) return;
xrender_handle = wine_dlopen("libXrender.so", RTLD_NOW, NULL, 0);
if (!wine_dlopen(SONAME_LIBX11, RTLD_NOW|RTLD_GLOBAL, NULL, 0)) return;
if (!wine_dlopen(SONAME_LIBXEXT, RTLD_NOW|RTLD_GLOBAL, NULL, 0)) return;
xrender_handle = wine_dlopen(SONAME_LIBXRENDER, RTLD_NOW, NULL, 0);
if(!xrender_handle) return;
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(xrender_handle, #f, NULL, 0)) == NULL) goto sym_not_found;
......
......@@ -638,6 +638,18 @@
/* The size of a `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG
/* Define to the soname of the libfreetype library. */
#undef SONAME_LIBFREETYPE
/* Define to the soname of the libX11 library. */
#undef SONAME_LIBX11
/* Define to the soname of the libXext library. */
#undef SONAME_LIBXEXT
/* Define to the soname of the libXrender library. */
#undef SONAME_LIBXRENDER
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
......
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