help-make
[Top][All Lists]
Advanced

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

Re: simple help for makefile copy foo.pl to bin/foo only after foo.pl ha


From: Philip Guenther
Subject: Re: simple help for makefile copy foo.pl to bin/foo only after foo.pl has been touched
Date: Sat, 20 Oct 2007 04:24:21 -0600

On 10/19/07, Billy Patton <address@hidden> wrote:
> I'm trying to get the make file to handle files with suffixes but copy
> them to a bin directory without the suffix.  I can get the copy to work
> fine but the dependencies don't work.  I copies very time. takes less
> than a second but I'd rather not have it doing it every time.
>
> SCRIPTS := foo
> BINDIR := bin
>
> x : $(addprefix ${BIN_DIR}/,$(SCRIPTS))
>
> Here's what I have now
> ${BIN_DIR}/%.pl : %.pl
>   @$(PRINTF) "Copying $< to ${BIN_DIR}/$*\n"
>   @$(COPY) $< ${BIN_DIR}/$*
>   @$(CHMOD) 777 ${BIN_DIR}/$*

This rule violates the fundamental rule of makefiles: every non-phony
rule *MUST* create or update the *exact* file address@hidden  That is, the 
target
of a rule must match the target of the commands.  In the above., the
target of the rule ($@) is ${BIN_DIR}/whatever.pl, but the commands
create or update ${BIN_DIR}/whatever.  The solution is to change the
target of the rule to match what you want it to create:

${BIN_DIR}/%: %.pl
        @$(PRINTF) "Copying %s to %s\n" "$<" "$@"
        @$(COPY) $< $@
        @$(CHMOD) 777 $@


Having done that, you also need to update the dependency lists of any
other rules that claimed to require files in ${BIN_DIR} with the
suffix .pl.  Your sample makefile doesn't include any of those, so I
can't show how you need to change them.

(Indeed, I somehow suspect that your *real* makefile says
SCRIPTS=foo.pl instead of SCRIPTS=foo.  If not, then how is your
existing rule ever being triggered?  Please do not oversimplify when
asking questions!)


> Also how do I get the command for pulling from RCS to be quiet?

You write your own, overriding the built in.

(Or, you check out the sources once before hand so that the files
don't get removed and recreated all the time.  Are you really so short
on diskspace that you can't keep the files checked out?)


Philip Guenther




reply via email to

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