From owner-freebsd-hackers Thu Nov 12 13:33:14 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA24331 for freebsd-hackers-outgoing; Thu, 12 Nov 1998 13:33:14 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from yonge.cs.toronto.edu (yonge.cs.toronto.edu [128.100.1.8]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id NAA24313 for ; Thu, 12 Nov 1998 13:33:12 -0800 (PST) (envelope-from dholland@cs.toronto.edu) Received: from qew.cs.toronto.edu ([128.100.2.15]) by yonge.cs.toronto.edu with SMTP id <86508-8537>; Thu, 12 Nov 1998 16:32:43 -0500 Received: by qew.cs.toronto.edu id <37768-2936>; Thu, 12 Nov 1998 16:32:33 -0500 Subject: Re: bsd make to gnu make conversion, anyone?? From: David Holland To: kline@thought.org (Gary Kline) Date: Thu, 12 Nov 1998 16:32:30 -0500 Cc: dholland@cs.toronto.edu, joelh@gnu.org, kline@tao.thought.org, hackers@FreeBSD.ORG In-Reply-To: <19981112122005.C7958@thought.org> from "Gary Kline" at Nov 12, 98 03:20:05 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <98Nov12.163233edt.37768-2936@qew.cs.toronto.edu> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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