sbsv2/raptor/lib/flm/gnumakefile.flm
changeset 0 044383f39525
child 3 e1eecf4d390d
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 # Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Gnumakefile FLM -> Knows how to run gnumakefiles
       
    15 # Will only work on Windows
       
    16 # 
       
    17 #
       
    18 
       
    19 TMPROOT:=$(subst \,/,$(EPOCROOT))
       
    20 OLD_EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/
       
    21 OLDSTYLE_EPOCROOT:=$(subst /,\,$(OLD_EPOCROOT))
       
    22 
       
    23 # Set up the correct make to be invoked
       
    24 MAKEVAR:=
       
    25 ifeq ($(USENMAKE),1)
       
    26 MAKEVAR:=$(NMAKE) $(NMAKEFLAGS)
       
    27 else
       
    28 MAKEVAR:="$(SBSV1MAKE)"
       
    29 endif
       
    30 
       
    31 ################################# FLM Parameter description ##
       
    32 # Parameters:
       
    33 #   EPOCROOT:=
       
    34 #   PLATFORM:=$(VARIANTPLATFORM)
       
    35 # The current configuration either UREL or UDEB:
       
    36 #   CFG:=$(VARIANTTYPE)
       
    37 # Relative path to EPOCROOT. (to where?):
       
    38 #   TO_ROOT:=
       
    39 # The path to the top-level bld.inf.
       
    40 # Note: if a bld.inf file #includes another bld.inf, this variable will
       
    41 # always contain the directory of that top-level file. If you require
       
    42 # the directory of the bld.inf which actually references the makefile,
       
    43 # use $(EXTENSION_ROOT) instead.
       
    44 #   TO_BLDINF:=
       
    45 # The project's working build directory under \epoc32\build\..
       
    46 #   EPOCBLD:=
       
    47 
       
    48 
       
    49 ################################ Standard Variables ##
       
    50 # We may set the following 
       
    51 # for the sake of gnumakefiles which
       
    52 # need to know them:
       
    53 
       
    54 ## Path element separator.
       
    55 /:=/
       
    56 ## PATH environment variable separator.
       
    57 ;:=:
       
    58 
       
    59 ####
       
    60 # Various file and directory manipulation tools.
       
    61 # We are using the standard GNU coretools.
       
    62 # On Windows these are supplied by CYGWIN
       
    63 RMDIR:=$(GNURMDIR)
       
    64 RM:=$(GNURM)
       
    65 ERASE:=$(GNURM)
       
    66 MKDIR:=$(GNUMKDIR)
       
    67 CP:=$(GNUCP)
       
    68 
       
    69 # Targets:
       
    70 # We need to hook the BLD, LIB, ..., targets in the gnumakefile into the
       
    71 # global phony TARGET, LIBRARY, ..., targets in the overall Makefile.
       
    72 #
       
    73 # Additionally we need a specific name for each gnumakefile's targets so
       
    74 # that we can create dependencies between, say, the FINAL target of one
       
    75 # extension and the FINAL target of another. Ideally this name would be
       
    76 # unique but that would require the full path to be used so we compromise
       
    77 # and use a unique name and a portable reference that is relatively "unique".
       
    78 
       
    79 UNIQ:=$(DIRECTORY)$(EXTMAKEFILENAME)$(TO_ROOT)$(EPOCBLD)$(TO_BLDINF)$(PLATFORM)$(CFG)$(MAKEVAR)
       
    80 UNIQ:=$(word 1,$(shell echo $(UNIQ) | $(GNUMD5SUM)))
       
    81 gmake_$(notdir $(EXTMAKEFILENAME))_$(PLATFORM)_$(CFG):=$(UNIQ)
       
    82 CFG_uppercase:=$(call uppercase,$(CFG))
       
    83 
       
    84 RVCT22BIN:=$(RVCTBIN)
       
    85 RVCT22LIB:=$(RVCTLIB)
       
    86 RVCT22INC:=$(RVCTINC)
       
    87 
       
    88 EXTMAKEFILEPARAMETERS:= \
       
    89 	EPOCROOT PLATFORM TO_ROOT TO_BLDINF \
       
    90 	EPOCBLD CFG RMDIR RM ERASE MKDIR CP  \
       
    91 	MAKEFILENAME DIRECTORY EXTMAKEFILENAME            \
       
    92 	DEPENDENCIES TOOL RVCT22LIB RVCT22INC RVCT22BIN MAKEVAR
       
    93 
       
    94 # The standard gnumakefile Targets
       
    95 # These will be implemented in terms of double colon
       
    96 # rules - such that make FREEZE will cause all FREEZE 
       
    97 # targets to be evaluated.
       
    98 # For each call of this FLM we also need
       
    99 # to create unique versions of each of these targets
       
   100 # so that there is something to attach
       
   101 # the current FLM parameters to using target-specific 
       
   102 # variable declarations.
       
   103 
       
   104 EXTMAKETARGETS:= \
       
   105 	MAKMAKE     \
       
   106 	BLD         \
       
   107 	FREEZE      \
       
   108 	LIB         \
       
   109 	CLEANLIB    \
       
   110 	RESOURCE    \
       
   111 	CLEAN       \
       
   112 	RELEASABLES \
       
   113 	FINAL
       
   114 #	DO_NOTHING  
       
   115 
       
   116 # Hook into global targets
       
   117 #
       
   118 MAKEFILE::    $(UNIQ)_MAKMAKE
       
   119 BITMAP::      $(UNIQ)_MAKMAKE
       
   120 TARGET::      $(UNIQ)_BLD
       
   121 FREEZE::      $(UNIQ)_FREEZE
       
   122 LIBRARY::     $(UNIQ)_LIB
       
   123 CLEAN::       $(UNIQ)_CLEAN $(UNIQ)_CLEANLIB
       
   124 RESOURCE::    $(UNIQ)_RESOURCE
       
   125 FINAL::       $(UNIQ)_FINAL
       
   126 RELEASABLES:: $(UNIQ)_RELEASABLES
       
   127 
       
   128 # make sure gnumakefiles happen at the right stages
       
   129 MAKMAKE_DEPS:=EXPORT
       
   130 RESOURCE_DEPS:=BITMAP 
       
   131 LIB_DEPS:=RESOURCE
       
   132 BLD_DEPS:=LIBRARY
       
   133 FINAL_DEPS:=TARGET
       
   134 
       
   135 export /
       
   136 export ;
       
   137 
       
   138 #################################### Global Targets ##
       
   139 ## All the global targets for the gnumakefiles
       
   140 # gnumakes are called as sub-makes, using make 3.79 from abld (passed through $(SBSV1MAKE)). 
       
   141 # makefile and nmakefile are called using nmake.
       
   142 
       
   143 define callgnumake
       
   144 .PHONY:: $(UNIQ)_$(1)
       
   145 
       
   146 $(EPOCROOT)/epoc32/build/TEM_$(1):: $(UNIQ)_$(1)
       
   147 
       
   148 $(UNIQ)_$(1): $($(1)_DEPS)
       
   149 	$(call startrule,extension_makefile,FORCESUCCESS) \
       
   150 	$(foreach V,$(EXTMAKEFILEPARAMETERS),$(V)='$($(V))') EXTMAKEFILETARGET='$(1)' \
       
   151 	$(if $(USENMAKE),export MAKEFLAGS="";cd "$(subst /,\,$(DIRECTORY))";,) export EPOCROOT="$(strip $(OLDSTYLE_EPOCROOT))\"; export CFG=$(CFG_uppercase); \
       
   152 	$(MAKEVAR) $(if $(USENMAKE),,-C "$(subst /,\,$(DIRECTORY))") -f "$(EXTMAKEFILENAME)" \
       
   153 	CFG=$(CFG_uppercase) EPOCBLD="$(subst /,\,$(EPOCBLD))" TO_BLDINF="$(subst /,\,$(TO_BLDINF))" PLATFORM=$(PLATFORM) $(if $(SAVESPACE),$(subst BLD,SAVESPACE,$(1)),$(1)) \
       
   154 	$(call endrule,extension_makefile) 
       
   155 ifneq ($(call isoneof,$(1),RELEASABLES FINAL),)
       
   156 	$(call startrawoutput) \
       
   157 	echo "$(call whatLogOpen)" ; \
       
   158 	$(foreach V,$(EXTMAKEFILEPARAMETERS),$(V)='$($(V))') EXTMAKEFILETARGET='RELEASABLES' \
       
   159 	$(if $(USENMAKE),export MAKEFLAGS="";cd "$(subst /,\,$(DIRECTORY))";,) export EPOCROOT="$(strip $(OLDSTYLE_EPOCROOT))\"; export CFG=$(CFG_uppercase); \
       
   160 	$(MAKEVAR) $(if $(USENMAKE),-C -S,-C "$(subst /,\,$(DIRECTORY))" --no-print-directory) -f "$(EXTMAKEFILENAME)" \
       
   161 	CFG=$(CFG_uppercase) EPOCBLD="$(subst /,\,$(EPOCBLD))" TO_BLDINF="$(subst /,\,$(TO_BLDINF))" PLATFORM=$(PLATFORM) RELEASABLES | \
       
   162 	(read -r LINE; while [ $$$$? -eq 0 ]; do \
       
   163 	if [[ ! $$$$LINE =~ "Nothing to be done for"  ]] ; then echo "$(call whatLogItem,EM,$$$$LINE)"; fi; \
       
   164 	read -r LINE; done; ); \
       
   165 	echo "$(call whatLogClose)" \
       
   166 	$(call endrawoutput)
       
   167 
       
   168 
       
   169 WHATGNUEM:: $(UNIQ)_RELEASABLES
       
   170 
       
   171 endif
       
   172 endef
       
   173 
       
   174 DO_NOTHING:: $(UNIQ)_DO_NOTHING 
       
   175 $(UNIQ)_DO_NOTHING: ;
       
   176 
       
   177 $(foreach EXTTRG,$(EXTMAKETARGETS),$(eval $(call callgnumake,$(EXTTRG))))
       
   178 
       
   179 ## Do ROMFILE target in romstuff.mke
       
   180 ifeq ($(ROMFILE_$(call sanitise,$(EXTMAKEFILENAME))),)
       
   181 ROMFILE_$(call sanitise,$(EXTMAKEFILENAME)):=1
       
   182 
       
   183 ROMDIR:=$(subst $(OLD_EPOCROOT),$(OLD_EPOCROOT)epoc32/rom/,$(TO_BLDINF))
       
   184 
       
   185 define RomfileRomstuff
       
   186 ROMFILE::
       
   187 	@$(MAKEVAR) --no-print-directory $(if $(USENMAKE),,-C "$(subst /,\,$(DIRECTORY))") -f "$(EXTMAKEFILENAME)" ROMFILE >> $(ROMDIR)/ARMV5TEST.IBY
       
   188 endef
       
   189 
       
   190 $(eval $(call RomfileRomstuff))
       
   191 endif