Commit a1515c68 authored by Alexandre Julliard's avatar Alexandre Julliard

makefiles: Automatically add RPATH support for programs that use libwine.

parent e619a15a
......@@ -7847,14 +7847,14 @@ distclean::
wine_binary="wine"
test "x$enable_win64" != "xyes" || wine_binary="wine64"
loader_programs="$wine_binary wine-installed"
loader_programs="$wine_binary"
libwine_soversion=`expr $libwine_version : '\([0-9]*\)\..*'`
LOADER_RULES="
all: wine.inf
install install-lib:: wine-installed
\$(INSTALL_PROGRAM) wine-installed \$(DESTDIR)\$(bindir)/$wine_binary
install install-lib:: $wine_binary-installed
\$(INSTALL_PROGRAM) $wine_binary-installed \$(DESTDIR)\$(bindir)/$wine_binary
uninstall::
\$(RM) \$(DESTDIR)\$(bindir)/$wine_binary
......@@ -8017,7 +8017,7 @@ done
LIBEXT="dylib"
DLLFLAGS="$DLLFLAGS -fPIC"
LIBWINE_LDFLAGS="-multiply_defined suppress"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,-rpath,@loader_path/\$(top_builddir)/libs/wine"
COREFOUNDATION_LIBS="-framework CoreFoundation"
......@@ -8262,11 +8262,9 @@ uninstall::
as_fn_append LOADER_RULES "
$wine_binary: main.o wine_info.plist
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_LOCAL)
wine-installed: main.o wine_info.plist
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_INSTALL)
${wine_binary}_OBJS = main.o
${wine_binary}_LDFLAGS = $LDEXECFLAGS -lwine \$(PTHREAD_LIBS)
$wine_binary $wine_binary-installed: wine_info.plist
"
;;
......@@ -8325,7 +8323,7 @@ eval ac_res=\$$as_ac_var
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,--rpath,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"
else
as_ac_var=`$as_echo "ac_cv_cflags_-fPIC -Wl,-R,\\$ORIGIN/../lib" | $as_tr_sh`
......@@ -8353,7 +8351,7 @@ eval ac_res=\$$as_ac_var
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,-R,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"
fi
fi
......@@ -8432,11 +8430,8 @@ uninstall::
as_fn_append LOADER_RULES "
$wine_binary: main.o
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_LOCAL)
wine-installed: main.o
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_INSTALL)
${wine_binary}_OBJS = main.o
${wine_binary}_LDFLAGS = $LDEXECFLAGS -lwine \$(PTHREAD_LIBS)
"
;;
......@@ -8599,7 +8594,7 @@ eval ac_res=\$$as_ac_var
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,--rpath,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"
else
as_ac_var=`$as_echo "ac_cv_cflags_-fPIC -Wl,-R,\\$ORIGIN/../lib" | $as_tr_sh`
......@@ -8627,7 +8622,7 @@ eval ac_res=\$$as_ac_var
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,-R,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"
fi
fi
......@@ -8819,11 +8814,8 @@ uninstall::
as_fn_append LOADER_RULES "
$wine_binary: main.o
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_LOCAL)
wine-installed: main.o
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_INSTALL)
${wine_binary}_OBJS = main.o
${wine_binary}_LDFLAGS = $LDEXECFLAGS -lwine \$(PTHREAD_LIBS)
"
if test -z "$with_wine64"
then
......@@ -14950,23 +14942,21 @@ case $host_os in
test "$wine_binary" = wine || wine_fn_ignore_file "loader/wine-preloader"
loader_programs="$loader_programs $wine_binary-preloader"
as_fn_append LOADER_RULES "
$wine_binary-preloader: preloader.o
\$(CC) -o \$@ -static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000 preloader.o \$(LIBPORT) \$(LDFLAGS)
preloader_EXTRADEFS = $BUILTINFLAG
${wine_binary}_preloader_OBJS = preloader.o
${wine_binary}_preloader_LDFLAGS = -static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000
install install-lib:: $wine_binary-preloader
\$(INSTALL_PROGRAM) $wine_binary-preloader \$(DESTDIR)\$(bindir)/$wine_binary-preloader
uninstall::
\$(RM) \$(DESTDIR)\$(bindir)/$wine_binary-preloader
preloader_EXTRADEFS = $BUILTINFLAG
" ;;
esac
;;
esac
as_fn_append LOADER_RULES "
EXTRA_TARGETS = $loader_programs
all: $loader_programs
PROGRAMS = $loader_programs
"
......
......@@ -686,14 +686,14 @@ WINE_CONFIG_HELPERS
wine_binary="wine"
test "x$enable_win64" != "xyes" || wine_binary="wine64"
loader_programs="$wine_binary wine-installed"
loader_programs="$wine_binary"
libwine_soversion=`expr $libwine_version : '\([[0-9]]*\)\..*'`
AC_SUBST(LOADER_RULES,["
all: wine.inf
install install-lib:: wine-installed
\$(INSTALL_PROGRAM) wine-installed \$(DESTDIR)\$(bindir)/$wine_binary
install install-lib:: $wine_binary-installed
\$(INSTALL_PROGRAM) $wine_binary-installed \$(DESTDIR)\$(bindir)/$wine_binary
uninstall::
\$(RM) \$(DESTDIR)\$(bindir)/$wine_binary
......@@ -754,7 +754,7 @@ uninstall::
LIBEXT="dylib"
DLLFLAGS="$DLLFLAGS -fPIC"
LIBWINE_LDFLAGS="-multiply_defined suppress"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,-rpath,@loader_path/\$(top_builddir)/libs/wine"
dnl declare needed frameworks
AC_SUBST(COREFOUNDATION_LIBS,"-framework CoreFoundation")
......@@ -891,11 +891,9 @@ uninstall::
"])
AS_VAR_APPEND([LOADER_RULES],["
$wine_binary: main.o wine_info.plist
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_LOCAL)
wine-installed: main.o wine_info.plist
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_INSTALL)
${wine_binary}_OBJS = main.o
${wine_binary}_LDFLAGS = $LDEXECFLAGS -lwine \$(PTHREAD_LIBS)
$wine_binary $wine_binary-installed: wine_info.plist
"])
;;
......@@ -907,10 +905,10 @@ wine-installed: main.o wine_info.plist
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
[LDEXECFLAGS="-Wl,--export-dynamic"])
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,--rpath,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"],
[WINE_TRY_CFLAGS([-fPIC -Wl,-R,\$ORIGIN/../lib],
[LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
[LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,-R,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"])])
WINE_TRY_CFLAGS([-Wl,--enable-new-dtags],
......@@ -940,11 +938,8 @@ uninstall::
"])
AS_VAR_APPEND([LOADER_RULES],["
$wine_binary: main.o
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_LOCAL)
wine-installed: main.o
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_INSTALL)
${wine_binary}_OBJS = main.o
${wine_binary}_LDFLAGS = $LDEXECFLAGS -lwine \$(PTHREAD_LIBS)
"])
;;
......@@ -971,10 +966,10 @@ wine-installed: main.o
[LDEXECFLAGS="-Wl,--export-dynamic"])
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,--rpath,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"],
[WINE_TRY_CFLAGS([-fPIC -Wl,-R,\$ORIGIN/../lib],
[LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
[LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,-R,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"])])
WINE_TRY_CFLAGS([-Wl,--enable-new-dtags],
......@@ -1033,11 +1028,8 @@ uninstall::
"])
AS_VAR_APPEND([LOADER_RULES],["
$wine_binary: main.o
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_LOCAL)
wine-installed: main.o
\$(CC) -o \$@ $LDEXECFLAGS main.o \$(LIBWINE) \$(LIBPORT) \$(EXTRALIBS) \$(LDFLAGS) \$(LDRPATH_INSTALL)
${wine_binary}_OBJS = main.o
${wine_binary}_LDFLAGS = $LDEXECFLAGS -lwine \$(PTHREAD_LIBS)
"])
if test -z "$with_wine64"
then
......@@ -2044,23 +2036,21 @@ case $host_os in
test "$wine_binary" = wine || WINE_IGNORE_FILE("loader/wine-preloader")
loader_programs="$loader_programs $wine_binary-preloader"
AS_VAR_APPEND([LOADER_RULES],["
$wine_binary-preloader: preloader.o
\$(CC) -o \$@ -static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000 preloader.o \$(LIBPORT) \$(LDFLAGS)
preloader_EXTRADEFS = $BUILTINFLAG
${wine_binary}_preloader_OBJS = preloader.o
${wine_binary}_preloader_LDFLAGS = -static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000
install install-lib:: $wine_binary-preloader
\$(INSTALL_PROGRAM) $wine_binary-preloader \$(DESTDIR)\$(bindir)/$wine_binary-preloader
uninstall::
\$(RM) \$(DESTDIR)\$(bindir)/$wine_binary-preloader
preloader_EXTRADEFS = $BUILTINFLAG
"]) ;;
esac
;;
esac
AS_VAR_APPEND([LOADER_RULES],["
EXTRA_TARGETS = $loader_programs
all: $loader_programs
PROGRAMS = $loader_programs
"])
dnl **** Check for functions ****
......
EXTRALIBS = $(PTHREAD_LIBS)
C_SRCS = \
main.c \
preloader.c
......
EXTRALIBS = $(POLL_LIBS) $(RT_LIBS)
PROGRAMS = wineserver
C_SRCS = \
async.c \
......@@ -45,22 +45,12 @@ C_SRCS = \
window.c \
winstation.c
EXTRA_TARGETS = wineserver wineserver-installed
MANPAGES = \
wineserver.de.UTF-8.man.in \
wineserver.fr.UTF-8.man.in \
wineserver.man.in
OBJS = $(C_SRCS:.c=.o)
all: $(EXTRA_TARGETS)
wineserver: $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBWINE) $(LIBPORT) $(LDFLAGS) $(EXTRALIBS) $(LIBS) $(LDRPATH_LOCAL)
wineserver-installed: $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBWINE) $(LIBPORT) $(LDFLAGS) $(EXTRALIBS) $(LIBS) $(LDRPATH_INSTALL)
EXTRALIBS = -lwine $(POLL_LIBS) $(RT_LIBS)
.PHONY: install install-lib uninstall
......
......@@ -1778,6 +1778,8 @@ static struct strarray output_sources( struct makefile *make, struct strarray *t
struct strarray subdirs = empty_strarray;
struct strarray phony_targets = empty_strarray;
struct strarray all_targets = empty_strarray;
char *ldrpath_local = get_expanded_make_variable( make, "LDRPATH_LOCAL" );
char *ldrpath_install = get_expanded_make_variable( make, "LDRPATH_INSTALL" );
for (i = 0; i < linguas.count; i++)
strarray_add( &mo_files, strmake( "%s/%s.mo", top_obj_dir_path( make, "po" ), linguas.str[i] ));
......@@ -2381,6 +2383,28 @@ static struct strarray output_sources( struct makefile *make, struct strarray *t
strarray_addall( &all_libs, libs );
strarray_addall( &all_libs, get_expanded_make_var_array( make,
file_local_var( make->programs.str[i], "LDFLAGS" )));
if (strarray_exists( &all_libs, "-lwine" ))
{
strarray_add( &all_libs, strmake( "-L%s", top_obj_dir_path( make, "libs/wine" )));
if (ldrpath_local && ldrpath_install)
{
char *program_installed = strmake( "%s-installed%s", make->programs.str[i], exe_ext );
output_filename( ldrpath_local );
output_filenames( all_libs );
output_filename( "$(LDFLAGS)" );
output( "\n" );
output( "%s:", obj_dir_path( make, program_installed ) );
output_filenames_obj_dir( make, objs );
output( "\n" );
output( "\t$(CC) -o $@" );
output_filenames_obj_dir( make, objs );
output_filename( ldrpath_install );
strarray_add( &all_targets, program_installed );
}
}
output_filenames( all_libs );
output_filename( "$(LDFLAGS)" );
output( "\n" );
......
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