Re: Rules.make minor improvement

Vladimir Volovich (vvv@vvv.vsu.ru)
Tue, 03 Jun 1997 20:52:24 +0400


Hi,

> I got a new bash (1.14.4) and now it works.

Not that bash-1.14.4 is new ;-)
The latest stable bash is 2.0 (ftp://prep.ai.mit.edu/pub/gnu/bash-2.0.tar.gz).

> --> THIS SHOULD DEFINITLY GO INTO Documentation/Changes !!!
>
> This bash was once installed by an old softland distribution and since
> I use tcsh as my favourite shell (and don't care much about shell scripts)
> I never updated it.
>
> now, my links are as expected:
>
> nfs.o -> ../fs/nfs//nfs.o
>
> BUT, with your patch applied, I get this:
>
> nfs.o -> ..//usr/z5/linux/fs/nfs/nfs.o

This is not good, but this is also correct. ;-)

> My source tree is at /usr/z5/linux with a symbolic link /linux pointing
> to it. The top-Makefile calculates the variable TOPDIR as /linux

Yes... Thank you for your report.

* pwd command is not built in tcsh.

* Here is extract from pwd(1) man page:

GNU pwd prints the fully resolved name of the current directory.
That is, all components of the printed name will be actual
directory names -- none will be symbolic links.

* Even if pwd is a shell's built-in, $(shell pwd) statement in Makefile
causes the execution of a stand-alone binary `pwd' (which must
be in $PATH; usually it is /bin/pwd).

* expansion of constructs like $${PWD#$$TOPDIR/}
is done by the shell defined by SHELL variable in Makefile.
It defaults to `/bin/sh'.

Please, try this patch, which should finally work correctly.
I've tested it by running `make modules' from ash, bash, tcsh and zsh. ;-)

--- linux-2.1.42/Rules.make.orig Tue Jun 3 15:51:45 1997
+++ linux-2.1.42/Rules.make Tue Jun 3 20:23:27 1997
@@ -105,9 +105,6 @@
# A rule to make modules
#
ALL_MOBJS = $(MX_OBJS) $(M_OBJS)
-ifneq "$(strip $(ALL_MOBJS))" ""
-PDWN=$(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
-endif
modules: $(ALL_MOBJS) $(MIX_OBJS) $(MI_OBJS) dummy
ifdef MOD_SUB_DIRS
set -e; for i in $(MOD_SUB_DIRS); do $(MAKE) -C $$i modules; done
@@ -129,9 +126,8 @@
endif
endif
ifneq "$(strip $(ALL_MOBJS))" ""
- echo $(PDWN)
cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \
- ln -sf ../$(PDWN)/$$i .; done
+ ln -sf ../$(shell echo $${PWD#$$TOPDIR/})/$$i; done
endif

#
--- linux-2.1.42/Makefile.orig Tue Jun 3 15:51:37 1997
+++ linux-2.1.42/Makefile Tue Jun 3 20:21:14 1997
@@ -21,7 +21,7 @@
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
-TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
+TOPDIR := $(shell pwd)

HPATH = $(TOPDIR)/include
FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net

-- 
With best regards,
                   Vladimir.