help-make
[Top][All Lists]
Advanced

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

Not sure how to phrase subject, compiles, copies, implicit and eval


From: PATTON, BILLY \(SBCSI\)
Subject: Not sure how to phrase subject, compiles, copies, implicit and eval
Date: Wed, 24 May 2006 05:56:48 -0500

Here is an example. 
__BEGIN__
PROJECTS := ldb
bb+ldb := infgn
topic+ldb+infgn := err
targets+ldb+infgn+err := /ldb/infgn/err/bin/a /ldb/infgn/err/bin/b
target+ldb+infgn+err+a := /some_path/a.sh
target+ldb+infgn+err+b := b.c c.c d.c

COMP_CXX = @$$(CXX) $$(CXXFLAGS) $$(INCLUDE) -o $$@ -c $$<
CP_BIN_CMD = @$(CP) $$< $$(@D)/$$(basename $$(<F)) ; \
             $$(CHMOD) $$(@D)/$$(basename $$(<F))

# shortcut :)  Normally been created with foreach loops
.PHONY : all
all : ldb+infgn+err

define pbt
$(1)+$(2)+$(3) : $(targets+$(1)+$(2)+$(3))
endef
$(foreach proj,$(PROJECTS),\
  $(foreach bb,$(bb+$(proj)),\
    $(foreach topic,$(topic+$(proj)+$(bb)),\
      $(eval $(call pbt,$(proj),$(bb),$(topic))))))

define do_pbt
/ldb/infgn/err/bin/%.o : /ldb/infgn/err/src/%.c ; $(COMP_CC)
/ldb/infgn/err/bin/%   : /ldb/infgn/err/src/%.sh ; $(CP_BIN_CMD)
endef
$(foreach proj,$(PROJECTS),\
  $(foreach bb,$(bb+$(proj)),\
    $(foreach topic,$(topic+$(proj)+$(bb)),\
      $(eval $(call do_pbt,$(proj),$(bb),$(topic))))))
__END__

I built the do_pbt that will handle many extentions.  Mostly those that
are just copies and removing the extentions, a.sh to a.  It handles all
the compiling of the .c (not shown .cpp .cxx .pc) and archives them.
Now I get to the variable target+ldb+infgn+err+b.  Assume that *.c has
already been compiled and stored in an archive.  Also assume that I
cannot hardcode the pattern rule to create 'b'.
I tried the following
##
## build the targets
##
#target+$(1)+$(2)+$(3)+$(4) : $(addprefix
$(PRD_TREE)/$(1)/$(2)/,$(notdir $(target+$(1)+$(2)+$(3)+$(4):.c=.o)))
define build_target
$(4) : $(addprefix $(PRD_TREE)/$(1)/$(2)/,$(notdir
$(target+$(1)+$(2)+$(3)+$(4):.c=.o)))
  echo "CC -o $@ $<"
endef
$(foreach proj,$(PROJECTS),\
 $(foreach bb,$(bb+$(proj)),\
   $(foreach topic,$(topic+$(proj)+$(bb)), \
     $(foreach target,$(targets+$(proj)+$(bb)+$(topic)),\
       $(if $(target+$(proj)+$(bb)+$(topic)+$(notdir $(target))),\
         $(warning $(call
build_target,$(proj),$(bb),$(topic),$(target))))))))

This worked to create b but it also gave a lot of warnings of override's
from having duplicate rules.  One created by do_ptb and the other
created by build_target.

Is there a way that I can combine these?

perhaps
define build_target
$(4) : $(addprefix $(PRD_TREE)/$(1)/$(2)/,$(notdir
$(target+$(1)+$(2)+$(3)+$(4):.c=.o)))
  echo "CC -o $@ $<"
$(4) : /$(1)/$(2)/$(3)/src/%.sh ; $(CP_BIN_CMD)
endef
blablabla




reply via email to

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