makefiles: Merge the relpath functionality into makedep.

oldstable
Alexandre Julliard 2013-11-08 21:11:59 +01:00
parent 9b5e6ce0f2
commit 067d3f0ddb
8 changed files with 88 additions and 121 deletions

1
.gitignore vendored
View File

@ -306,7 +306,6 @@ tools/fnt2fon
tools/make_ctests
tools/make_xftmpl
tools/makedep
tools/relpath
tools/sfnt2fnt
tools/widl/parser.tab.c
tools/widl/parser.tab.h

View File

@ -59,7 +59,6 @@ RUNTEST = $(top_srcdir)/tools/runtest
MAKECTESTS = $(TOOLSDIR)/tools/make_ctests$(TOOLSEXT)
MAKEXFTMPL = $(TOOLSDIR)/tools/make_xftmpl$(TOOLSEXT)
MAKEDEP = $(TOOLSDIR)/tools/makedep$(TOOLSEXT)
RELPATH = $(TOOLSDIR)/tools/relpath$(TOOLSEXT)
SFNT2FNT = $(TOOLSDIR)/tools/sfnt2fnt$(TOOLSEXT)
WIDL = $(TOOLSDIR)/tools/widl/widl$(TOOLSEXT)
WINEBUILD = $(TOOLSDIR)/tools/winebuild/winebuild$(TOOLSEXT)

12
configure vendored
View File

@ -7284,7 +7284,7 @@ clean::
LIBEXT="dylib"
DLLFLAGS="$DLLFLAGS -fPIC"
LIBWINE_LDFLAGS="-multiply_defined suppress"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(RELPATH) \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_LOCAL="-Wl,-rpath,@loader_path/\$(top_builddir)/libs/wine"
COREFOUNDATIONLIB="-framework CoreFoundation"
@ -7454,7 +7454,7 @@ fi
LIBWINE_RULES="
all: libwine.dylib
libwine.\$(VERSION).dylib: \$(OBJS) \$(RELPATH) Makefile.in
libwine.\$(VERSION).dylib: \$(OBJS) Makefile.in
\$(CC) -dynamiclib -install_name @rpath/libwine.\$(SOVERSION).dylib -Wl,-rpath,@loader_path/ -compatibility_version \$(SOVERSION) -current_version \$(VERSION) \$(OBJS) \$(EXTRALIBS) \$(LDFLAGS) \$(LIBS) -o \$@
libwine.\$(SOVERSION).dylib: libwine.\$(VERSION).dylib
@ -7545,7 +7545,7 @@ eval ac_res=\$$as_ac_var
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if test `eval 'as_val=${'$as_ac_var'};$as_echo "$as_val"'` = yes; then :
LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(RELPATH) \$(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`
@ -7573,7 +7573,7 @@ eval ac_res=\$$as_ac_var
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if test `eval 'as_val=${'$as_ac_var'};$as_echo "$as_val"'` = yes; then :
LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(RELPATH) \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_LOCAL="-Wl,-R,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"
fi
fi
@ -7819,7 +7819,7 @@ eval ac_res=\$$as_ac_var
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if test `eval 'as_val=${'$as_ac_var'};$as_echo "$as_val"'` = yes; then :
LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(RELPATH) \$(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`
@ -7847,7 +7847,7 @@ eval ac_res=\$$as_ac_var
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if test `eval 'as_val=${'$as_ac_var'};$as_echo "$as_val"'` = yes; then :
LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(RELPATH) \$(bindir) \$(libdir)\`"
LDRPATH_INSTALL="-Wl,-R,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \$(bindir) \$(libdir)\`"
LDRPATH_LOCAL="-Wl,-R,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"
fi
fi

View File

@ -745,7 +745,7 @@ clean::
LIBEXT="dylib"
DLLFLAGS="$DLLFLAGS -fPIC"
LIBWINE_LDFLAGS="-multiply_defined suppress"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(RELPATH) \$(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(COREFOUNDATIONLIB,"-framework CoreFoundation")
@ -848,7 +848,7 @@ clean::
AC_SUBST(LIBWINE_RULES,["
all: libwine.dylib
libwine.\$(VERSION).dylib: \$(OBJS) \$(RELPATH) Makefile.in
libwine.\$(VERSION).dylib: \$(OBJS) Makefile.in
\$(CC) -dynamiclib -install_name @rpath/libwine.\$(SOVERSION).dylib -Wl,-rpath,@loader_path/ -compatibility_version \$(SOVERSION) -current_version \$(VERSION) \$(OBJS) \$(EXTRALIBS) \$(LDFLAGS) \$(LIBS) -o \$@
libwine.\$(SOVERSION).dylib: libwine.\$(VERSION).dylib
@ -891,10 +891,10 @@ wine_info.plist: wine_info.plist.in \$(top_builddir)/include/config.h
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
[LDEXECFLAGS="-Wl,--export-dynamic"])
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(RELPATH) \$(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/\`\$(RELPATH) \$(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],
@ -955,10 +955,10 @@ wine-installed: main.o Makefile.in
[LDEXECFLAGS="-Wl,--export-dynamic"])
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(RELPATH) \$(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/\`\$(RELPATH) \$(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],

View File

@ -4,10 +4,10 @@ EXTRADEFS = -DWINE_UNICODE_API="" \
-DBINDIR='"$(bindir)"' \
-DDLLDIR='"$(dlldir)"' \
-DDLLPREFIX='"$(DLLPREFIX)"' \
-DLIB_TO_BINDIR=\"`$(RELPATH) $(libdir) $(bindir)`\" \
-DLIB_TO_DLLDIR=\"`$(RELPATH) $(libdir) $(dlldir)`\" \
-DBIN_TO_DLLDIR=\"`$(RELPATH) $(bindir) $(dlldir)`\" \
-DBIN_TO_DATADIR=\"`$(RELPATH) $(bindir) $(datadir)/wine`\"
-DLIB_TO_BINDIR=\"`$(MAKEDEP) -R $(libdir) $(bindir)`\" \
-DLIB_TO_DLLDIR=\"`$(MAKEDEP) -R $(libdir) $(dlldir)`\" \
-DBIN_TO_DLLDIR=\"`$(MAKEDEP) -R $(bindir) $(dlldir)`\" \
-DBIN_TO_DATADIR=\"`$(MAKEDEP) -R $(bindir) $(datadir)/wine`\"
STATICLIB = libwine_static.a
VERSION = 1.0
@ -113,11 +113,6 @@ EXTRA_OBJS = version.o
version.c: dummy
version=`(GIT_DIR=$(top_srcdir)/.git git describe HEAD 2>/dev/null || echo "wine-@PACKAGE_VERSION@") | sed -n -e '$$s/\(.*\)/const char wine_build[] = "\1";/p'` && (echo $$version | cmp -s - $@) || echo $$version >$@ || ($(RM) $@ && exit 1)
$(OBJS): $(RELPATH)
$(RELPATH):
@cd $(TOOLSDIR)/tools && $(MAKE) relpath$(TOOLSEXT)
# Make sure that make_makefiles sees the generated rules
install install-lib::
install install-dev::

View File

@ -5,7 +5,6 @@ PROGRAMS = \
fnt2fon$(EXEEXT) \
make_ctests$(EXEEXT) \
make_xftmpl$(EXEEXT) \
relpath$(EXEEXT) \
sfnt2fnt$(EXEEXT) \
wineapploader
@ -20,7 +19,6 @@ C_SRCS = \
make_ctests.c \
make_xftmpl.c \
makedep.c \
relpath.c \
sfnt2fnt.c
EXTRASUBDIRS = winapi
@ -47,10 +45,7 @@ make_xftmpl$(EXEEXT): make_xftmpl.o
fnt2fon$(EXEEXT): fnt2fon.o
$(CC) $(CFLAGS) -o $@ fnt2fon.o $(LIBPORT) $(LDFLAGS)
relpath$(EXEEXT): relpath.o
$(CC) $(CFLAGS) -o $@ relpath.o $(LIBPORT) $(LDFLAGS)
sfnt2fnt$(EXEEXT): sfnt2fnt.o relpath$(EXEEXT)
sfnt2fnt$(EXEEXT): sfnt2fnt.o
$(CC) $(CFLAGS) -o $@ sfnt2fnt.o $(LIBWINE_STATIC) $(LIBPORT) $(LDFLAGS) $(FREETYPELIBS)
wineapploader: wineapploader.in

View File

@ -102,18 +102,20 @@ static const char *top_obj_dir;
static const char *OutputFileName = "Makefile";
static const char *Separator = "### Dependencies";
static const char *input_file_name;
static int relative_dir_mode;
static int input_line;
static FILE *output_file;
static const char Usage[] =
"Usage: makedep [options] [files]\n"
"Options:\n"
" -Idir Search for include files in directory 'dir'\n"
" -Cdir Search for source files in directory 'dir'\n"
" -Sdir Set the top source directory\n"
" -Tdir Set the top object directory\n"
" -fxxx Store output in file 'xxx' (default: Makefile)\n"
" -sxxx Use 'xxx' as separator (default: \"### Dependencies\")\n";
" -Idir Search for include files in directory 'dir'\n"
" -Cdir Search for source files in directory 'dir'\n"
" -Sdir Set the top source directory\n"
" -Tdir Set the top object directory\n"
" -R from to Compute the relative path between two directories\n"
" -fxxx Store output in file 'xxx' (default: Makefile)\n"
" -sxxx Use 'xxx' as separator (default: \"### Dependencies\")\n";
#ifndef __GNUC__
@ -289,6 +291,52 @@ static char *replace_extension( const char *name, unsigned int old_len, const ch
}
/*******************************************************************
* get_relative_path
*
* Determine where the destination path is located relative to the 'from' path.
*/
static char *get_relative_path( const char *from, const char *dest )
{
const char *start;
char *ret, *p;
unsigned int dotdots = 0;
/* a path of "." is equivalent to an empty path */
if (!strcmp( from, "." )) from = "";
for (;;)
{
while (*from == '/') from++;
while (*dest == '/') dest++;
start = dest; /* save start of next path element */
if (!*from) break;
while (*from && *from != '/' && *from == *dest) { from++; dest++; }
if ((!*from || *from == '/') && (!*dest || *dest == '/')) continue;
/* count remaining elements in 'from' */
do
{
dotdots++;
while (*from && *from != '/') from++;
while (*from == '/') from++;
}
while (*from);
break;
}
if (!start[0] && !dotdots) return NULL; /* empty path */
ret = xmalloc( 3 * dotdots + strlen( start ) + 1 );
for (p = ret; dotdots; dotdots--, p += 3) memcpy( p, "../", 3 );
if (start[0]) strcpy( p, start );
else p[-1] = 0; /* remove trailing slash */
return ret;
}
/*******************************************************************
* get_line
*/
@ -1304,6 +1352,9 @@ static void parse_option( const char *opt )
case 'f':
if (opt[2]) OutputFileName = opt + 2;
break;
case 'R':
relative_dir_mode = 1;
break;
case 's':
if (opt[2]) Separator = opt + 2;
else Separator = NULL;
@ -1339,6 +1390,20 @@ int main( int argc, char *argv[] )
else i++;
}
if (relative_dir_mode)
{
char *relpath;
if (argc != 3)
{
fprintf( stderr, "Option -r needs two directories\n%s", Usage );
exit( 1 );
}
relpath = get_relative_path( argv[1], argv[2] );
printf( "%s\n", relpath ? relpath : "." );
exit( 0 );
}
/* ignore redundant source paths */
if (src_dir && !strcmp( src_dir, "." )) src_dir = NULL;
if (top_src_dir && top_obj_dir && !strcmp( top_src_dir, top_obj_dir )) top_src_dir = NULL;

View File

@ -1,86 +0,0 @@
/*
* Compute the relative path needed to go from one Unix dir to another
*
* Copyright 2006 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* determine where the destination path is located relative to the 'from' path */
static const char *get_relative_path( const char *from, const char *dest, unsigned int *dotdots )
{
#define DIR_END(p) (*(p) == 0 || *(p) == '/')
const char *start;
/* a path of "." is equivalent to an empty path */
if (!strcmp( from, "." )) from = "";
*dotdots = 0;
for (;;)
{
while (*from == '/') from++;
while (*dest == '/') dest++;
start = dest; /* save start of next path element */
if (!*from) break;
while (!DIR_END(from) && *from == *dest) { from++; dest++; }
if (DIR_END(from) && DIR_END(dest)) continue;
/* count remaining elements in 'from' */
do
{
(*dotdots)++;
while (!DIR_END(from)) from++;
while (*from == '/') from++;
}
while (*from);
break;
}
return start;
#undef DIR_END
}
int main( int argc, char *argv[] )
{
const char *start;
unsigned int dotdots = 0;
if (argc != 3)
{
fprintf( stderr, "Usage: %s fromdir todir\n", argv[0] );
exit(1);
}
start = get_relative_path( argv[1], argv[2], &dotdots );
if (!start[0] && !dotdots) printf( ".\n" );
else
{
while (dotdots)
{
printf( ".." );
dotdots--;
if (dotdots || start[0]) printf( "/" );
}
printf( "%s\n", start );
}
exit(0);
}