delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/22/13:47:57

From: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How do I do this with make?
Date: 22 Jan 1998 17:37:51 GMT
Organization: Oxford University, England
Lines: 52
Message-ID: <6a805f$dij$1@news.ox.ac.uk>
References: <69nuae$492$1 AT star DOT cs DOT vu DOT nl>
NNTP-Posting-Host: sable.ox.ac.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 16 Jan 1998 15:28:14 GMT in comp.os.msdos.djgpp Ruiter de M
<mdruiter AT cs DOT vu DOT nl> wrote:

: I want to do, in a makefile:

: # -*- makefile -*-
: 10/%.enc: 10/%.jpg
: 	same commands
: 20/%.enc: 20/%.jpg
: 	same commands
: ...
: 90/%.enc: 90/%.jpg
: 	same commands

: Any ideas?

I'm sorry for the delayed reply, I thought you'd already been answered
satisfactorily.  Anyway, I think this might point you in the right
direction:

:TARGETS = $(patsubst %.b,%.a,$(wildcard */*.b))
:
:.PHONY: all
:
:all: $(TARGETS)
:
:%.a: %.b
:        @echo "wibble $< $@"
:        @touch $@

With directories 10 and 20 and input files 10/foo.b, 10/bar.b,
20/foo.b the output was:

wibble 10/bar.b 10/bar.a
wibble 10/foo.b 10/foo.a
wibble 20/foo.b 20/foo.a

The effect, then, is to pick out the names of all *.b files one
directory level lower than the current directory, change the
extensions to `.a', put them in the variable TARGETS.  Make these
dependencies of `all', the first rule in the file, so that they all
become goals.  Then define a pattern rule telling Make how to create
a %.a file from %.b.

I think this is pretty much what you wanted; you'll have to tweak of
course.  This was running on a DEC Alpha, but it ought to work on
djgpp too AFAICS.

Remember, with GNU Make [almost] anything is possible... ;)

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019