From owner-freebsd-questions Sun Dec 17 9:39: 6 2000 From owner-freebsd-questions@FreeBSD.ORG Sun Dec 17 09:39:02 2000 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id 7FC2237B400 for ; Sun, 17 Dec 2000 09:39:01 -0800 (PST) Received: (qmail 90614 invoked by uid 100); 17 Dec 2000 17:39:00 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14908.64052.192903.920128@guru.mired.org> Date: Sun, 17 Dec 2000 11:39:00 -0600 (CST) To: Marc W Cc: questions@freebsd.org Subject: Re: Makefile Q In-Reply-To: <49999083@toto.iv> X-Mailer: VM 6.75 under 21.1 (patch 10) "Capitol Reef" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Marc W types: > Hello! > > Hope this an appropriate question for the list. I've got a Makefile > and it's got the usual stuff in it, but there's one place where I can't quite > find a way to make the rules generic. I have to run some header files through > Trolltech's MOC, and then compile the output. > > So, my rules have to be like: > > OBJS=moc_widget.o moc_moo.o main.o > > .cc.o: > $(CC) $(CFLAGS) etc ... > > moc_widget.cc: widget.h > $(MOC) widget.h -o widget.cc > > moc_moo.cc: moo.h > $(MOC) moo.h -o moo.cc > > This kinda sucks because for each header I add that needs to be > preprocessed, I have to add a new target. > > Now, what I'd REALLY like is something like: > > > OBJS=moc_widget.o moc_moo.o main.o > > .cc.o: > $(CC) $(CFLAGS) etc ... > > moc_$(SOMETHING).cc: > $(MOC) $(SOMETHING).h -o moc_$(SOMETHING).cc > > Any suggestions on how to do this or something similar? I believe you want a rule that looks like so: .h.cc: $(MOC) `echo $(.IMPSRC) | sed -e s/moc_// -e s/cc/h/` -o $(.IMPSRC) though i'm not sure about passing backticks through the rules. It would be much simpler if ytou had the moc_ on the .h files as well, os it would be: .h.cc: $(MOC) $(PREFIX).h -o $(IMPSRC) http://www.mired.org/home/mwm/ Independent WWW/Unix/FreeBSD consultant, email for more information.cho To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message