Reimplemented improvement on relative paths in a way that should keep the configuration system working for relative paths

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@25907 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2008-01-09 17:44:12 +00:00
parent 71f4581d16
commit 6fa640ca9a
4 changed files with 79 additions and 32 deletions

View file

@ -1,3 +1,12 @@
2008-01-09 Nicola Pero <nicola.pero@meta-innovation.com>
* relative_path.sh: Added optional third parameter to specify
whether 'strict' or 'short' output is required. Default to
'strict' so that the configuration system works.
* Instance/application.make: Use 'short' option to
relative_path.sh to get more compact paths.
* Instance/framework.make: Same change.
2008-01-09 Nicola Pero <nicola.pero@meta-innovation.com> 2008-01-09 Nicola Pero <nicola.pero@meta-innovation.com>
* config.make.in (LN_S_RECURSIVE): New variable. * config.make.in (LN_S_RECURSIVE): New variable.

View file

@ -339,7 +339,7 @@ internal-install-app-wrapper: $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_LDIR)
$(ECHO_NOTHING)\ $(ECHO_NOTHING)\
cd $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_LDIR); \ cd $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_LDIR); \
$(RM_LN_S) $(GNUSTEP_INSTANCE); \ $(RM_LN_S) $(GNUSTEP_INSTANCE); \
$(LN_S_RECURSIVE) `$(REL_PATH_SCRIPT) $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_LDIR) $(APP_INSTALL_DIR)/$(APP_FILE_NAME)` \ $(LN_S_RECURSIVE) `$(REL_PATH_SCRIPT) $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_LDIR) $(APP_INSTALL_DIR)/$(APP_FILE_NAME) short` \
$(GNUSTEP_INSTANCE)$(END_ECHO) $(GNUSTEP_INSTANCE)$(END_ECHO)
else else
# Not sure that we can use relative paths with 'exec' in a portable # Not sure that we can use relative paths with 'exec' in a portable

View file

@ -510,10 +510,10 @@ ifeq ($(MAKE_CURRENT_VERSION),yes)
$(ECHO_NOTHING)cd $(GNUSTEP_BUILD_DIR)/$(GNUSTEP_INSTANCE).framework/$(GNUSTEP_TARGET_LDIR); \ $(ECHO_NOTHING)cd $(GNUSTEP_BUILD_DIR)/$(GNUSTEP_INSTANCE).framework/$(GNUSTEP_TARGET_LDIR); \
$(RM_LN_S) $(GNUSTEP_INSTANCE) $(FRAMEWORK_LIBRARY_FILE); \ $(RM_LN_S) $(GNUSTEP_INSTANCE) $(FRAMEWORK_LIBRARY_FILE); \
$(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_TARGET_LDIR) \ $(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_TARGET_LDIR) \
Versions/Current/$(GNUSTEP_TARGET_LDIR)/$(GNUSTEP_INSTANCE)` \ Versions/Current/$(GNUSTEP_TARGET_LDIR)/$(GNUSTEP_INSTANCE) short` \
$(GNUSTEP_INSTANCE); \ $(GNUSTEP_INSTANCE); \
$(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_TARGET_LDIR) \ $(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_TARGET_LDIR) \
Versions/Current/$(GNUSTEP_TARGET_LDIR)/$(FRAMEWORK_LIBRARY_FILE)` \ Versions/Current/$(GNUSTEP_TARGET_LDIR)/$(FRAMEWORK_LIBRARY_FILE) short` \
$(FRAMEWORK_LIBRARY_FILE)$(END_ECHO) $(FRAMEWORK_LIBRARY_FILE)$(END_ECHO)
endif endif
endif endif
@ -589,7 +589,7 @@ ifeq ($(strip),yes)
endif endif
$(ECHO_INSTALLING_HEADERS)cd $(GNUSTEP_HEADERS); \ $(ECHO_INSTALLING_HEADERS)cd $(GNUSTEP_HEADERS); \
$(RM_LN_S) $(HEADER_FILES_INSTALL_DIR); \ $(RM_LN_S) $(HEADER_FILES_INSTALL_DIR); \
$(LN_S_RECURSIVE) `$(REL_PATH_SCRIPT) $(GNUSTEP_HEADERS) $(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_DIR_NAME)/Headers` $(HEADER_FILES_INSTALL_DIR); \ $(LN_S_RECURSIVE) `$(REL_PATH_SCRIPT) $(GNUSTEP_HEADERS) $(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_DIR_NAME)/Headers short` $(HEADER_FILES_INSTALL_DIR); \
$(END_ECHO) $(END_ECHO)
ifneq ($(CHOWN_TO),) ifneq ($(CHOWN_TO),)
$(ECHO_CHOWNING)cd $(GNUSTEP_HEADERS); \ $(ECHO_CHOWNING)cd $(GNUSTEP_HEADERS); \
@ -600,11 +600,11 @@ endif
$(RM_LN_S) $(FRAMEWORK_LIBRARY_FILE); \ $(RM_LN_S) $(FRAMEWORK_LIBRARY_FILE); \
$(RM_LN_S) $(SONAME_FRAMEWORK_FILE); \ $(RM_LN_S) $(SONAME_FRAMEWORK_FILE); \
$(RM_LN_S) $(VERSION_FRAMEWORK_LIBRARY_FILE); \ $(RM_LN_S) $(VERSION_FRAMEWORK_LIBRARY_FILE); \
$(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR) $(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_CURRENT_LIBRARY_DIR_NAME)/$(FRAMEWORK_LIBRARY_FILE)` $(FRAMEWORK_LIBRARY_FILE); \ $(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR) $(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_CURRENT_LIBRARY_DIR_NAME)/$(FRAMEWORK_LIBRARY_FILE) short` $(FRAMEWORK_LIBRARY_FILE); \
if test -r "$(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_CURRENT_LIBRARY_DIR_NAME)/$(SONAME_FRAMEWORK_FILE)"; then \ if test -r "$(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_CURRENT_LIBRARY_DIR_NAME)/$(SONAME_FRAMEWORK_FILE)"; then \
$(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR) $(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_CURRENT_LIBRARY_DIR_NAME)/$(SONAME_FRAMEWORK_FILE)` $(SONAME_FRAMEWORK_FILE); \ $(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR) $(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_CURRENT_LIBRARY_DIR_NAME)/$(SONAME_FRAMEWORK_FILE) short` $(SONAME_FRAMEWORK_FILE); \
fi; \ fi; \
$(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR) $(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_CURRENT_LIBRARY_DIR_NAME)/$(VERSION_FRAMEWORK_LIBRARY_FILE)` $(VERSION_FRAMEWORK_LIBRARY_FILE)$(END_ECHO) $(LN_S) `$(REL_PATH_SCRIPT) $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR) $(FRAMEWORK_INSTALL_DIR)/$(FRAMEWORK_CURRENT_LIBRARY_DIR_NAME)/$(VERSION_FRAMEWORK_LIBRARY_FILE) short` $(VERSION_FRAMEWORK_LIBRARY_FILE)$(END_ECHO)
ifneq ($(CHOWN_TO),) ifneq ($(CHOWN_TO),)
$(ECHO_CHOWNING)cd $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR); \ $(ECHO_CHOWNING)cd $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR); \
$(CHOWN) $(CHOWN_TO) $(FRAMEWORK_LIBRARY_FILE); \ $(CHOWN) $(CHOWN_TO) $(FRAMEWORK_LIBRARY_FILE); \

View file

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
# relative_path.sh # relative_path.sh
# #
# Copyright (C) 2002 Free Software Foundation, Inc. # Copyright (C) 2001 - 2007 Free Software Foundation, Inc.
# #
# Author: Nicola Pero <n.pero@mi.flashnet.it> # Author: Nicola Pero <n.pero@mi.flashnet.it>
# Date: April 2001 # Date: April 2001, January 2007
# #
# This file is part of the GNUstep Makefile Package. # This file is part of the GNUstep Makefile Package.
# #
@ -21,14 +21,46 @@
# This script gets two paths as argument - and outputs a relative path # This script gets two paths as argument - and outputs a relative path
# which, when appended to the first one, gives the second one ... more # which, when appended to the first one, gives the second one ... more
# precisely, the path of minimum length with this property. # precisely, the path of minimum length with this property.
#
# A third optional parameter controls the type of output; if it's set
# to 'strict' it outputs "strict" relative paths that always start
# with the exact sequence of characters './'. If set to 'short' it
# outputs "short" relative paths that might start with './' or with
# '../'. Here are examples:
#
# strict: ./
# short: ./
#
# strict: ./../System
# short: ../System
#
# strict: ./System
# short: ./System
#
# Inside shell scripts (eg, in framework.make) we use the 'short' mode
# because it prevents ugly unnecessary path fragments to get into all
# paths. Inside the configuration system we traditionally use the
# 'strict' mode because NSPathUtilities detects relative paths by
# checking that they start with './'. The 'short' mode might
# become the one used for the configuration system in the future if
# NSPathUtilities learns to detect that '../' also starts a relative
# path.
#
# If no this parameter is provided, 'strict' is assumed for backwards
# compatibility (even if gnustep-make v1 used to default to 'short').
# This might change in the future, so if you are depending on a
# specific behaviour, it's important that you specify the type of
# output you want.
# #
# <NB: the paths must be absolute.> # <NB: the paths must be absolute.>
# #
# for example, # for example,
# #
# $GNUSTEP_MAKEFILES/relative_path.sh /usr/GNUstep/Local /usr/GNUstep/System # $GNUSTEP_MAKEFILES/print_relative_path.sh /usr/GNUstep/Local /usr/GNUstep/System short
# #
# returns ./../System (and not ./../../GNUstep/System which is not the minimum). # returns ../System (and not ../../GNUstep/System which is not the minimum).
# #
# This is needed by `ln -s' to properly create symlinks between # This is needed by `ln -s' to properly create symlinks between
# directories which are related ... but we don't know how. We only # directories which are related ... but we don't know how. We only
@ -44,7 +76,7 @@
# you only have the absolute paths) we do - # you only have the absolute paths) we do -
# #
# cd /usr/GNUstep/System/Library/Libraries/ix86/linux-gnu/gnu-gnu-gnu/ # cd /usr/GNUstep/System/Library/Libraries/ix86/linux-gnu/gnu-gnu-gnu/
# $(LN_S) `$(RELATIVE_PATH_SCRIPT) /usr/GNUstep/System/Frameworks/nicola.framework/Versions/Current/ix86/linux-gnu/gnu-gnu-gnu/libnicola.so /usr/GNUstep/System/Library/Libraries/ix86/linux-gnu/gnu-gnu-gnu/` libnicola.so # $(LN_S) `$(RELATIVE_PATH_SCRIPT) /usr/GNUstep/System/Frameworks/nicola.framework/Versions/Current/ix86/linux-gnu/gnu-gnu-gnu/libnicola.so /usr/GNUstep/System/Library/Libraries/ix86/linux-gnu/gnu-gnu-gnu/ short` libnicola.so
# #
# which creates the link. We need to use the minimum path because # which creates the link. We need to use the minimum path because
# that is the most relocatable possible path. I consider all this a # that is the most relocatable possible path. I consider all this a
@ -58,14 +90,18 @@
# Unfortunately in that case because of limitations in gnustep-base's # Unfortunately in that case because of limitations in gnustep-base's
# NSPathUtilities, we have to always output a './' at the beginning of # NSPathUtilities, we have to always output a './' at the beginning of
# the result so that gnustep-base recognizes the result as a relative # the result so that gnustep-base recognizes the result as a relative
# path. This means for example that we can't output '../System', we # path. This means we use the 'strict' output in that case.
# have to output './../System'. As soon as a fixed version of
# NSPathUtilities that recognizes '../' as starting a relative path is # mode=strict means we always need to start our output with './'.
# out, we can improve this script by removing the leading './' in that # mode=short means we always start our output with '../' or './'.
# case. mode=strict
if [ "$#" != 2 ]; then if [ "$#" != 2 ]; then
exit 1 if [ "$#" != 3 ]; then
exit 1
else
mode="$3"
fi
fi fi
a="$1"; a="$1";
@ -149,22 +185,24 @@ fi
# Ok - now ready to build the result # Ok - now ready to build the result
result="." result="."
# Special case - if a is now empty, the second directory was a # Special note - if a is now empty, the second directory was a
# subdirectory of the first. Start the result with '.', so # subdirectory of the first; we will end up outputting ./$b
# that we will get something like ./GNUstep/Frameworks/
if [ -z "$a" ]; then
result="."
fi
# Now add as many ../ as there are components in a # Now add as many ../ as there are components in a
tmp_IFS="$IFS" tmp_IFS="$IFS"
IFS=/ IFS=/
for component in $a; do for component in $a; do
if [ -n "$component" -a "$component" != "." ]; then if [ -n "$component" -a "$component" != "." ]; then
if [ -z "$result" ]; then if [ "$mode" = "strict" ]; then
result=".." # In strict mode, ./../../xxx is required
else
result="$result/.." result="$result/.."
else
# In short mode, it's not, we prefer ../../xxx
if [ "$result" = "." ]; then
result=".."
else
result="$result/.."
fi
fi fi
fi fi
done done
@ -177,11 +215,11 @@ else
result="$b" result="$b"
fi fi
# If there is no difference, there is no relative path to append, if [ "$mode" = "strict" ]; then
# so we output './' to tell NSPathUtilities.m in gnustep-base to # Make sure the result always starts with './' in strict mode
# replace this with the path to the directory containing the library. if [ "$result" = "." ]; then
if [ "$result" = "." ]; then result="./"
result="./" fi
fi fi
echo "$result" echo "$result"