sbsv2/raptor/lib/flm/resource.mk
changeset 630 31ef8a13d4f4
parent 625 a1925fb7753a
equal deleted inserted replaced
629:541af5ee3ed9 630:31ef8a13d4f4
    29     # could  force deps to be generated always - debatable.
    29     # could  force deps to be generated always - debatable.
    30     # .PHONY: $3
    30     # .PHONY: $3
    31 
    31 
    32     $3: $(SOURCE)
    32     $3: $(SOURCE)
    33 	$(call startrule,resourcedependencies,FORCESUCCESS) \
    33 	$(call startrule,resourcedependencies,FORCESUCCESS) \
    34 	$(GNUCPP) -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\
    34 	$(GNUCPP) -DLANGUAGE_$(2) -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\
    35 	$(CPPOPT) $(SOURCE) -M -MG -MT"$1" | \
    35 	$(CPPOPT) $(SOURCE) -M -MG -MT"$1" | \
    36 	$$(DEPENDENCY_CORRECTOR) >$3 \
    36 	$$(DEPENDENCY_CORRECTOR) >$3 \
    37 	$(call endrule,resourcedependencies)
    37 	$(call endrule,resourcedependencies)
    38 
    38 
    39     SOURCETARGET_$(call sanitise,$(SOURCE)): $3
    39     SOURCETARGET_$(call sanitise,$(SOURCE)): $3
    41     CLEANTARGETS:=$$(CLEANTARGETS) $3
    41     CLEANTARGETS:=$$(CLEANTARGETS) $3
    42 
    42 
    43 endef # resource.deps #
    43 endef # resource.deps #
    44 
    44 
    45 ###############################################################################
    45 ###############################################################################
    46 # $1 is the name of the intermediate RESOURCEFILE
       
    47 # $2 is the LANGUAGE		(eg. sc or 01 or 02 ...)
       
    48 # Uses $(RESOURCEHEADER),$(SOURCE),$(HEADLANG),$(MMPDEFS) apart from some tools
       
    49 define resource.build
       
    50     $(if $(FLMDEBUG),$$(info <debug>resource.build: $1 LANG:$2 </debug>))
       
    51 
    46 
       
    47 # Must be a separate macro since we 
       
    48 define resource.decideheader
    52       DOHEADER:=
    49       DOHEADER:=
    53       ifeq ($(HEADLANG),$2)
    50       ifeq ($(HEADLANG),$2)
    54         ifneq ($(RESOURCEHEADER),)
    51         ifneq ($(RESOURCEHEADER),)
    55           RESOURCE:: $(RESOURCEHEADER)
    52           RESOURCE:: $(RESOURCEHEADER)
    56 
    53 
    57           DOHEADER:=-h$(RESOURCEHEADER)
    54           DOHEADER:=-h$(RESOURCEHEADER)
    58           # strictly speaking if $1 is made then the header file should be there too
       
    59           # but suppose someone adds a header statement to their MMP after doing a build?
       
    60           # so here we recreate the resource header if its missing even if the intermediate resource
       
    61           # has actually been built.  The problem is: what if the rpp file is not there (oops)? 
       
    62           # So this is not perfect but I think that the situation is fairly unlikely.
       
    63           # We can afford to put in an if statement for the rsg file - it's not a race condition because
       
    64           # $1 is done and the build engine guarantees that it's there so no resource header
       
    65           # can be attempted while we're trying to test.
       
    66           $(RESOURCEHEADER) : $1
       
    67 	    $(call startrule,resourcecompile.headerfill,FORCESUCCESS) \
       
    68 	    if [ ! -f "$(RESOURCEHEADER)" ]; then $(GNUCPP)  -DLANGUAGE_$2 \
       
    69 	      -DLANGUAGE_$(subst sc,SC,$(2)) $(call makemacrodef,-D,$(MMPDEFS))\
       
    70 	      $(CPPOPT) $(SOURCE) -o $1.rpp; fi && \
       
    71 	    if [ ! -f "$(RESOURCEHEADER)" ]; then $(RCOMP) -m045,046,047 -u -h$$@ -s$1.rpp; fi \
       
    72 	    $(call endrule,resourcecompile.headerfill)
       
    73 
    55 
    74           # we will add the resourceheader to RELEASABLES globally
    56           # we will add the resourceheader to RELEASABLES globally
    75         endif
    57         endif
    76 
    58 
    77       else
    59       else
    78         # Use the headlang resource (in primaryfile) as the dependency 
    60         # Use the headlang resource (in primaryfile) as the dependency 
    79         # "leader" for this resource
    61         # "leader" for this resource
    80         $1: $(PRIMARYFILE)
    62         $1: $(PRIMARYFILE)
    81       endif
    63       endif
       
    64 endef
       
    65 
       
    66 # $1 is the name of the intermediate RESOURCEFILE
       
    67 # $2 is the LANGUAGE		(eg. sc or 01 or 02 ...)
       
    68 # Uses $(RESOURCEHEADER),$(SOURCE),$(HEADLANG),$(MMPDEFS) apart from some tools
       
    69 define resource.build
       
    70     $(if $(FLMDEBUG),$$(info <debug>resource.build: $1 LANG:$2 </debug>))
       
    71 
       
    72     $(eval $(resource.decideheader))
       
    73 
       
    74     ifneq ($(DOHEADER),)
       
    75         # Strictly speaking if $1 is made then the header file should be there too
       
    76         # but suppose someone adds a header statement to their MMP after doing a build?
       
    77         # so here we recreate the resource header if its missing even if the intermediate resource
       
    78         # has actually been built.  The problem is: what if the rpp file is not there (oops)? 
       
    79         # So this is not perfect but I think that the situation is fairly unlikely.
       
    80         # We can afford to put in an if statement for the rsg file - it's not a race condition because
       
    81         # $1 is done and the build engine guarantees that it's there so no resource header
       
    82         # can be attempted while we're trying to test.
       
    83         $(RESOURCEHEADER) : $1
       
    84 	    $(call startrule,resourcecompile.headerfill,FORCESUCCESS) \
       
    85 	    if [ ! -f "$(RESOURCEHEADER)" ]; then $(GNUCPP)  -DLANGUAGE_$2 \
       
    86 	      -DLANGUAGE_$(subst sc,SC,$(2)) $(call makemacrodef,-D,$(MMPDEFS))\
       
    87 	      $(CPPOPT) $(SOURCE) -o $1.rpp; fi && \
       
    88 	    if [ ! -f "$(RESOURCEHEADER)" ]; then $(RCOMP) -m045,046,047 -u -h$$@ -s$1.rpp; fi \
       
    89 	    $(call endrule,resourcecompile.headerfill)
       
    90     endif
    82 
    91 
    83 
    92 
    84       RESOURCE:: $1
       
    85 
    93 
    86       $1: $(SOURCE)
    94     RESOURCE:: $1
    87 	  $(call startrule,resourcecompile,FORCESUCCESS) \
    95     
    88 	  $(GNUCPP)  -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$(2)) $(call makemacrodef,-D,$(MMPDEFS))\
    96     $1: $(SOURCE)
    89 	  $(CPPOPT) $(SOURCE) -o $1.rpp && \
    97 	$(call startrule,resourcecompile,FORCESUCCESS) \
    90 	  $(RCOMP) -m045,046,047 -u $$(DOHEADER) -o$$@ -s$1.rpp \
    98 	$(GNUCPP)  -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$(2)) $(call makemacrodef,-D,$(MMPDEFS))\
    91 	  $(call endrule,resourcecompile)
    99 	$(CPPOPT) $(SOURCE) -o $1.rpp && \
       
   100 	$(RCOMP) -m045,046,047 -u $(DOHEADER) -o$$@ -s$1.rpp \
       
   101 	$(call endrule,resourcecompile)
    92 
   102 
    93     SOURCETARGET_$(call sanitise,$(SOURCE)): $1
   103     SOURCETARGET_$(call sanitise,$(SOURCE)): $1
    94     CLEANTARGETS:=$$(CLEANTARGETS) $1 $1.rpp 
   104     CLEANTARGETS:=$$(CLEANTARGETS) $1 $1.rpp 
    95 endef # resource.build
   105 endef # resource.build
    96 
   106