Skip site navigation (1)Skip section navigation (2)
Date:      	Thu, 12 Nov 1998 16:32:30 -0500
From:      David Holland <dholland@cs.toronto.edu>
To:        kline@thought.org (Gary Kline)
Cc:        dholland@cs.toronto.edu, joelh@gnu.org, kline@tao.thought.org, hackers@FreeBSD.ORG
Subject:   Re: bsd make to gnu make conversion, anyone??
Message-ID:  <98Nov12.163233edt.37768-2936@qew.cs.toronto.edu>
In-Reply-To: <19981112122005.C7958@thought.org> from "Gary Kline" at Nov 12, 98 03:20:05 pm

next in thread | previous in thread | raw e-mail | index | archive | help
 > 
 > On Thu, Nov 12, 1998 at 02:12:14PM -0500, David Holland wrote:
 > >  > This is the cleanest solution.  Still, if you want alternatives, I
 > >  > haven't tried this, but foreach may work here, as a generalization of
 > >  > for:
 > >  > 
 > >  > define do-lang
 > >  > $(lang).mv.cat: $(.CURDIR)/nls/$(lang)/mv.msg
 > >  > 	gencat -new $(.TARGET) $(.ALLSRC)
 > >  > endef
 > >  > $(foreach lang,$(LANGS),$(do-lang))

Another thing you can do is

support.mk: Makefile
	echo $(LANGS) | awk '{ for (i=1; i<=NF; i++) print $$i;}' |\
	 awk '{ printf "%s.mv.cat $$(.CURDIR)/nls/%s/mv.msg\n", $$1, $$1}' |\
	 awk '{ printf "%s: %s\n\tgencat -new %s %s\n\n", \
		$$1, $$2, $$1, $$2}' > support.mk
include support.mk

There are assorted possible variations on this...

 > > eww.
 > > 
 > > I didn't know this would work.
 > 
 > 
 > 	As written it doesn't.  I carefully tried it in a test
 > 	case late last night.  But it may after I've played
 > 	around with it; tweaked it.

alas. Here I'd hoped you'd found a general solution for .for in
gmake. 

 > > (Before you tell me to put my code where my mouth is, I looked into
 > > this at one point and concluded it would take me longer to figure out
 > > how gmake's parser worked than to write a whole new make. So I
 > > didn't. Why doesn't it use yacc?)
 > 
 > 	I've never looked at the guts, but one of our hackers did;
 > 	added some features.  Not adding the BSD syntax, obviously.
 > 	....

hm..

 > > Two reasons; one that issuing complex shell commands makes make -n
 > > output less useful (for an extreme case of this, try make -n install
 > > in gnu binutils), and the other that when you do loops in the shell
 > > they don't always terminate on error like you (usually) want.
 > > 
 > > For install this may not be that significant, but when you're doing
 > > recursion into subdirectories it sucketh. Hard.

So yeah, here's how you do subdirectories in gmake, in case anyone's
interested:

SUBDIRS=a b c d
TARGETS=all install depend clean


TMP1:=$(foreach dir, $(SUBDIRS), $(TARGETS))
TMP2:=$(foreach dir, $(SUBDIRS), $(foreach tgt, $(TARGETS), $(dir)/))
TMP3:=$(join $(TMP2), $(TMP1))
TMP4:=$(patsubst %, %/%, $(SUBDIRS))

$(TARGETS): %: $(TMP4)

$(TMP3): %:
	@echo $(MAKE) -C $(patsubst %/, %, $(dir $@)) $(notdir $@)


-- 
   - David A. Holland             | (please continue to send non-list mail to
     dholland@cs.utoronto.ca      | dholland@hcs.harvard.edu. yes, I moved.)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?98Nov12.163233edt.37768-2936>