Skip to content

Commit

Permalink
Reimplemented improvement on relative paths in a way that should keep…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
nicola committed Jan 9, 2008
1 parent 002c78f commit 7fcf4a8
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 32 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2008-01-09 Nicola Pero <[email protected]>

* 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 <[email protected]>

* config.make.in (LN_S_RECURSIVE): New variable.
Expand Down
2 changes: 1 addition & 1 deletion Instance/application.make
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Instance/framework.make
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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); \
Expand All @@ -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); \
Expand Down
88 changes: 63 additions & 25 deletions relative_path.sh
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
# Date: April 2001
# Date: April 2001, January 2007
#
# This file is part of the GNUstep Makefile Package.
#
Expand All @@ -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.


#
# <NB: the paths must be absolute.>
#
# 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
Expand All @@ -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
Expand All @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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"

0 comments on commit 7fcf4a8

Please sign in to comment.