From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 18 Jan 2011 06:09:30 +0000 From: Andy Spencer To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20110118060930.GA1290@c.hsd1.tn.comcast.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue Topicbox-Message-UUID: 9e335fae-ead6-11e9-9d60-3106f5b1d025 On 2011-01-17 19:31, Ciprian Dorin Craciun wrote: > * not all files of the same type are built by using the same rule; > (for example for some files I want to enable debugging, for others > not); thus I don't see how a meta-rule would solve this problem; > (unless I create separate `mk` files or I resort to filename tags -- > for example I would call `*.debug.c` all C files that I want to be Use a variable: a_cflags=-g -Da b_cflags=-g -Db test: test.o a.o b.o gcc -o $target $prereq %.o: %.c gcc $($stem^_cflags) -c -o $target $stem.c Or only filename-tag the object files: test: test.o a-debug.o b-opt.o c-prof.o %.o: %.c gcc -c -o $target $prereq %-opt.o: %.c gcc -O -c -o $target $prereq %-debug.o: %.c gcc -g -c -o $target $prereq %-prof.o: %.c gcc -p -c -o $target $prereq > * second, each file has a unique dependency graph -- for example > one `*.c` file might include other headers than another `*.c` file in > the same project; thus when updating a single header I want to be able > to build only those `*.c` files that actually depend on it; (this > observation is less important for C applications, but for other type > of programs -- like Java -- this fine grained dependency tracking > means a lot of saved computing power); Have you looked at cpp -M? Many cpps will generate make style dependencies for you, I think they'll work with mk as well. You can include them and the use meta rules for all the real work. It's still a large list of dependencies though, so it might not help you in this case. I'm no sure if erlang has somethings similar or not. > * third, in my brief experience with make files, meta-rules are > quite hard to get right... furthermore it is impossible to have two > patterns like: `%.%.x`; just imagine I have two types of images: > background and foreground and I want to superimpose them, then I would > like to be able to write `%{foreground}.%{background}.jpg : > %{foreground}.jpg %{background}.jpg ..."; (I know that I can resort > here to "<| generating command" but it seems just plain wrong...) Mk's meta rules are much easier to get right because they don't get messed up by all of GNU Make's automatically added meta rules. Also: default:V: circle-square.png (.*)-(.*).png:R: \1.png \2.png composite $prereq $target P.S. anyone know a better way to composite images using the plan9/plan9port image tools?