help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Manipulating source files


From: Greg Chicares
Subject: Re: Manipulating source files
Date: Tue, 22 Jun 2010 11:17:23 +0000
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

On 2010-06-22 06:46Z, Gary wrote:
> Before I use my "compiler" on the source file(s) it should act on, using
> suffix rules, I need to manipulate them a little (using sed) but I don't
> want to actually change the original file on disk. What are my options?
> I was looking to just pipe the sed output to the compiler, then
> realised, as someone pointed out to me the other day, the makefile isn't
> a shell script.

Yes, but its recipes are shell invocations. I'd most likely write an
intermediate file, e.g. [untested]:

%.o : %.c
        $(SED) -e'some sed command' $< >$(@:.o=.manipulated.c)
        $(CC)  -c $(CFLAGS) $(CPPFLAGS) $(@:.o=.manipulated.c) -o $@

If your compiler supports piping, you could combine those steps into
a single line. Maybe you could even insert 'sed' into the compiler's
preprocessing step. Or you could write a program or script to invoke
in place of the compiler, and it can do anything you like. But those
ideas seem brittle or weird, whereas writing an intermediate file is
simple and robust.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]