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: Billy Patton
Subject: Re: simple help for makefile copy foo.pl to bin/foo only after foo.pl has been touched
Date: Sat, 20 Oct 2007 06:41:00 -0500
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Philip Guenther wrote:
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
Philip,
Thanks for your response, I made the changes you had but that resulted in an error : make: *** No rule to make target `/home/bpatton/tool_box/bin/diffFiles.pl', needed by `x'. Stop.

Here is the makefile (shortened)

SCRIPTS := diffFiles.pl
x : $(addprefix ${BIN_DIR}/,$(SCRIPTS))
${BIN_DIR}/% : %.pl
 @$(PRINTF) "Copying %s to %s\n" "$<" "$@"
 @$(COPY) $< $@
 @$(CHMOD) 777 $@



I have these rules for .csh, .tcsh,.sh,.bash, and .pm
.pm differs slightly but the concept is the same.

--
   ___  _ ____       ___       __  __
  / _ )(_) / /_ __  / _ \___ _/ /_/ /____  ___
 / _  / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/   \_,_/\__/\__/\___/_//_/
           /___/
Dallas, Texas, 214-480-1965,  address@hidden






reply via email to

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