From 6fa640ca9a449314c8966e0df59bb2fc563ce4ae Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Wed, 9 Jan 2008 17:44:12 +0000 Subject: [PATCH] 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 --- ChangeLog | 9 ++++ Instance/application.make | 2 +- Instance/framework.make | 12 +++--- relative_path.sh | 88 ++++++++++++++++++++++++++++----------- 4 files changed, 79 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 580f293a..93380390 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-01-09 Nicola Pero + + * 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 * config.make.in (LN_S_RECURSIVE): New variable. diff --git a/Instance/application.make b/Instance/application.make index 3d2cb03a..a547bd2e 100644 --- a/Instance/application.make +++ b/Instance/application.make @@ -339,7 +339,7 @@ internal-install-app-wrapper: $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_LDIR) $(ECHO_NOTHING)\ cd $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_LDIR); \ $(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) else # Not sure that we can use relative paths with 'exec' in a portable diff --git a/Instance/framework.make b/Instance/framework.make index 7e6c81a8..8efc8393 100644 --- a/Instance/framework.make +++ b/Instance/framework.make @@ -510,10 +510,10 @@ ifeq ($(MAKE_CURRENT_VERSION),yes) $(ECHO_NOTHING)cd $(GNUSTEP_BUILD_DIR)/$(GNUSTEP_INSTANCE).framework/$(GNUSTEP_TARGET_LDIR); \ $(RM_LN_S) $(GNUSTEP_INSTANCE) $(FRAMEWORK_LIBRARY_FILE); \ $(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); \ $(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) endif endif @@ -589,7 +589,7 @@ ifeq ($(strip),yes) endif $(ECHO_INSTALLING_HEADERS)cd $(GNUSTEP_HEADERS); \ $(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) ifneq ($(CHOWN_TO),) $(ECHO_CHOWNING)cd $(GNUSTEP_HEADERS); \ @@ -600,11 +600,11 @@ endif $(RM_LN_S) $(FRAMEWORK_LIBRARY_FILE); \ $(RM_LN_S) $(SONAME_FRAMEWORK_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 \ - $(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; \ - $(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),) $(ECHO_CHOWNING)cd $(GNUSTEP_LIBRARIES)/$(GNUSTEP_TARGET_LDIR); \ $(CHOWN) $(CHOWN_TO) $(FRAMEWORK_LIBRARY_FILE); \ diff --git a/relative_path.sh b/relative_path.sh index aef5d7dc..4273c7e2 100755 --- a/relative_path.sh +++ b/relative_path.sh @@ -1,10 +1,10 @@ #!/bin/sh # relative_path.sh # -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2001 - 2007 Free Software Foundation, Inc. # # Author: Nicola Pero -# Date: April 2001 +# Date: April 2001, January 2007 # # 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 # which, when appended to the first one, gives the second one ... more # 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. + + # # # # 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 # directories which are related ... but we don't know how. We only @@ -44,7 +76,7 @@ # you only have the absolute paths) we do - # # 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 # 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 # NSPathUtilities, we have to always output a './' at the beginning of # the result so that gnustep-base recognizes the result as a relative -# path. This means for example that we can't output '../System', we -# have to output './../System'. As soon as a fixed version of -# NSPathUtilities that recognizes '../' as starting a relative path is -# out, we can improve this script by removing the leading './' in that -# case. +# path. This means we use the 'strict' output in that case. + +# mode=strict means we always need to start our output with './'. +# mode=short means we always start our output with '../' or './'. +mode=strict if [ "$#" != 2 ]; then - exit 1 + if [ "$#" != 3 ]; then + exit 1 + else + mode="$3" + fi fi a="$1"; @@ -149,22 +185,24 @@ fi # Ok - now ready to build the result result="." -# Special case - if a is now empty, the second directory was a -# subdirectory of the first. Start the result with '.', so -# that we will get something like ./GNUstep/Frameworks/ -if [ -z "$a" ]; then - result="." -fi +# Special note - if a is now empty, the second directory was a +# subdirectory of the first; we will end up outputting ./$b # Now add as many ../ as there are components in a tmp_IFS="$IFS" IFS=/ for component in $a; do if [ -n "$component" -a "$component" != "." ]; then - if [ -z "$result" ]; then - result=".." - else + if [ "$mode" = "strict" ]; then + # In strict mode, ./../../xxx is required result="$result/.." + else + # In short mode, it's not, we prefer ../../xxx + if [ "$result" = "." ]; then + result=".." + else + result="$result/.." + fi fi fi done @@ -177,11 +215,11 @@ else result="$b" fi -# If there is no difference, there is no relative path to append, -# so we output './' to tell NSPathUtilities.m in gnustep-base to -# replace this with the path to the directory containing the library. -if [ "$result" = "." ]; then - result="./" +if [ "$mode" = "strict" ]; then + # Make sure the result always starts with './' in strict mode + if [ "$result" = "." ]; then + result="./" + fi fi echo "$result"