delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/03/13:26:25

Message-Id: <200004031534.KAA02746@darwin.sfbr.org>
Date: Mon, 3 Apr 2000 10:34:18 -0500 (CDT)
From: Jeff Williams <jeffw AT darwin DOT sfbr DOT org>
Subject: using `notdir' inside a loop in a makefile
To: djgpp AT delorie DOT com
MIME-Version: 1.0
X-Mailer: dtmail 1.3.0 @(#)CDE Version 1.3.4 SunOS 5.7 sun4u sparc
Reply-To: djgpp AT delorie DOT com

Would someone please explain why the following makefile fragment
doesn't behave as expected?  Something about using `notdir' inside
the `for' loop isn't working as desired.

subdirs = ./dir1/foo.1 ./dir2/bar.2
test:
        for k in $(subdirs) ; do \
                echo $$k ; \
                echo $(notdir $$k) ; \
        done
        
Here's the output I get:
        
% make test
for k in ./dir1/foo.1 ./dir2/bar.2 ; do \
        echo $k ; \
        echo $k ; \
done

./dir1/foo.1
./dir1/foo.1
./dir2/bar.2
./dir2/bar.2

but the output I *want* is

./dir1/foo.1
foo.1
./dir2/bar.2
bar.2

TIA---jtw

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019