| delorie.com/archives/browse.cgi | search |
| From: | Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: using `notdir' inside a loop in a makefile |
| Date: | Mon, 03 Apr 2000 20:53:53 +0200 |
| Organization: | NetVision Israel |
| Lines: | 19 |
| Message-ID: | <38E8E8C1.756EF1D1@is.elta.co.il> |
| References: | <200004031534 DOT KAA02746 AT darwin DOT sfbr DOT org> |
| NNTP-Posting-Host: | ras1-p69.rvt.netvision.net.il |
| Mime-Version: | 1.0 |
| X-Trace: | news.netvision.net.il 954787942 20126 62.0.172.71 (3 Apr 2000 18:52:22 GMT) |
| X-Complaints-To: | abuse AT netvision DOT net DOT il |
| NNTP-Posting-Date: | 3 Apr 2000 18:52:22 GMT |
| X-Mailer: | Mozilla 4.7 [en] (Win98; I) |
| X-Accept-Language: | en,ru,hebrew |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Jeff Williams wrote: > > 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 There's no way this is going to work, because $(notdir) is a Make function, while $$k is only expanded when the shell is run by Make. So when Make comes to expand $(notdir), it sees $$k as its argument, and that expands to itself (since it has no leading directories). You want to use `basename $$k` instead.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |