[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Prime Mover v0.1
- From: David Given <dg@...>
- Date: Mon, 16 Oct 2006 22:38:34 +0100
Sam Roberts wrote:
[...]
> make doesn't care what directory your files are in, you haven't figured
> out how to use the tool yet if that is causing you trouble.
All right, try this: I have fifty files in directory A, all with .c
extensions, that need to be built with one particular set of compilation
options. I also have fifty files in directory B, all with .c extensions, that
need to be built with *another* set of compilation options. How do you write a
single makefile that deals with this cleanly?
The answer is, you can't. make automatically determines what rule to apply to
each file based on the file extension. (Actually, a file pattern. It might be
possible to use patterns of the form 'A/%.c' and 'B/%.c', but I'd be hesitant
to use it.) However, it only allows you to specify a *single* rule for each
pattern. In order to solve the above problem, you have two options: firstly,
you can specify manually which files each rule should apply to --- which
rather defeats the purpose of make's automatic rule mechanism --- or else you
write two makefiles, which is much less effort, but which blows a big hole in
the dependency management.
It gets even worse when your two sets of files are all in *one* directory. It
gets an order of magnitude worse when you try to bolt in automatic C
dependency management. It gets *another* order of magnitude worse when you try
to add support for cross-compilation. And if you try to add support for
multi-stage compilation, make curls up in a corner and cries.
Here's a real-world example I had to cope with in my day job: I'm building
fifty different Special Objects. Each Special Object is made up of several
source files (.cc files). Each .cc file needs to be preprocessed via a custom
program before compilation, where the preprocessor flags vary according to the
Special Object --- and the *first* source file of each Special Object, when
preprocessed, produces an extra .o file that needs to be passed directly to
the linker. This all has to handle C dependencies correctly, and it would be
nice if we could build parallel debug and optimisation versions.
(If you're interested, I solved that one by writing a Lua makefile generator,
where the makefile specified absolutely everything explicitly. Prime Mover
actually developed from that program.)
Trust me. I know how to use make.
--
+- David Given --McQ-+ "Gaping from its single obling socket was
| dg@cowlark.com | scintillating, many fauceted scarlet emerald..."
| (dg@tao-group.com) | --- Jim Theis, _The Eye of Argon_ (spelling
+- www.cowlark.com --+ original)
Attachment:
signature.asc
Description: OpenPGP digital signature