sbsv1/buildsystem/extension/base/bootstrap.flm
changeset 607 378360dbbdba
parent 599 fa7a3cc6effd
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
       
     1 # Copyright (c) 2009-2010 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 "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 #
       
    15 
       
    16 ifeq ($($(NAME)_$(PLATFORM_PATH)_bootstrap_flm),)
       
    17 $(NAME)_$(PLATFORM_PATH)_bootstrap_flm := 1 
       
    18 
       
    19 E32PATH := $(EXTENSION_ROOT)/$(E32PATH)
       
    20 SOURCES := $(foreach S,$(SOURCES),$(addprefix $(EXTENSION_ROOT)/,$(S)))
       
    21 INCLUDES2:=$(addprefix $(EXTENSION_ROOT)/,$(INCLUDES))
       
    22 EXTRA_INC_PATH := $(foreach S,$(EXTRA_INC_PATH),$(addprefix $(EXTENSION_ROOT)/,$(S)))
       
    23 GENINCLUDES_HEADERS := $(foreach H,$(GENINCLUDES_HEADERS),$(addprefix $(EXTENSION_ROOT)/,$(H)))
       
    24 
       
    25 ifndef LINKBASE
       
    26 LINKBASE := 0x00000000
       
    27 endif
       
    28 
       
    29 UNIQ:=$(E32PATH)$(PLATFORM_PATH)$(NAME)$(MEMMODEL)$(SOURCES)$(ASM_MACROS)
       
    30 UNIQ:=$(word 1,$(shell echo $(UNIQ) | $(GNUMD5SUM)))
       
    31 
       
    32 # Make the output build directory name unique, starting with NAME of the binary being built
       
    33 EPOCBLDABS := $(EPOCBLD)/$(NAME)_$(UNIQ)
       
    34 
       
    35 EPOCINC := $(EPOCROOT)/epoc32/include
       
    36 EPOCKERNINC := $(EPOCINC)/kernel
       
    37 EPOCCPUINC := $(EPOCKERNINC)/$(CPU)
       
    38 EPOCTRG := $(EPOCROOT)/epoc32/release/$(PLATFORM_PATH)
       
    39 TRG := $(EPOCTRG)/$(NAME).bin
       
    40 TEMPTRG := $(EPOCBLDABS)/$(NAME).bin
       
    41 ASMINCPATH := 
       
    42 ASM_MACROS :=
       
    43 CLEANTARGETS :=
       
    44 
       
    45 CLEANTARGETS := $(CLEANTARGETS) $(TRG) $(TEMPTRG) $(join $(basename $(TRG)),.sym)
       
    46 
       
    47 ifneq ($(EXTRA_INC_PATH),)
       
    48 ASMINCPATH := $(EXTRA_INC_PATH)
       
    49 endif
       
    50 
       
    51 ASMINCPATH := . $(EPOCBLDABS) $(ASMINCPATH) $(EXTENSION_ROOT) $(EPOCCPUINC) $(EXTRA_EPOC32_INC_PATH) $(E32PATH)/eka/include/kernel/$(CPU)
       
    52 
       
    53 ifeq ($(MEMMODEL),)
       
    54 $(error MEMMODEL parameter not specified)
       
    55 endif
       
    56 
       
    57 # Convert MEMMODEL parameter to lower case
       
    58 MEMMODEL := $(shell echo $(MEMMODEL) | tr A-Z a-z)
       
    59 
       
    60 ifeq ($(MEMMODEL),direct)
       
    61 CFG_MM := CFG_MMDirect
       
    62 HEADERS_MM :=
       
    63 endif
       
    64 ifeq ($(MEMMODEL),flexible)
       
    65 CFG_MM := CFG_MMFlexible
       
    66 HEADERS_MM := $(E32PATH)/eka/include/memmodel/epoc/flexible/$(CPU)/mmboot.h
       
    67 endif
       
    68 ifeq ($(MEMMODEL),moving)
       
    69 CFG_MM := CFG_MMMoving
       
    70 HEADERS_MM := $(E32PATH)/eka/include/memmodel/epoc/moving/$(CPU)/mmboot.h
       
    71 endif
       
    72 ifeq ($(MEMMODEL),multiple)
       
    73 CFG_MM := CFG_MMMultiple
       
    74 HEADERS_MM := $(E32PATH)/eka/include/memmodel/epoc/multiple/$(CPU)/mmboot.h
       
    75 endif
       
    76 ifndef CFG_MM
       
    77 $(error '$(MEMMODEL)' memory model unknown)
       
    78 endif
       
    79 
       
    80 ASM_MACROS := $(ASM_MACROS) $(CFG_MM)
       
    81 ifneq ($(SMP),)
       
    82 ASM_MACROS := $(ASM_MACROS) SMP
       
    83 endif
       
    84 
       
    85 ASMINCPATHCMD := $(foreach dir,$(ASMINCPATH),$(join -I ,$(dir)))
       
    86 ASM_MACROS := $(ASM_MACROS) USE_CXSF
       
    87       
       
    88 INCEXT := inc
       
    89 ASM_MACRO_CMD := $(foreach macro,$(ASM_MACROS),--predefine "$(macro) SETL {TRUE}")
       
    90 AFLAGS := -g --keep $(ASM_MACRO_CMD) $(ASMINCPATHCMD)
       
    91 LFLAGS := --ro-base $(LINKBASE) --entry $(LINKBASE) --map
       
    92 SYMOPT := --symdefs
       
    93 
       
    94 define bootstrap_asm
       
    95 $(1) : $(2) : $(3)
       
    96 	$(call startrule,bootstrap_rvct_asm) \
       
    97 	$(ASM) $(AFLAGS) -o $$@ --LIST $$(join $$(basename $$@),.lst) $$< \
       
    98 	$(call endrule,bootstrap_rvct_asm)
       
    99 endef
       
   100 
       
   101 define bootstrap_link
       
   102 $(EPOCBLDABS)/$(NAME).in : $(LINKOBJECTS) $(LINKFILE) | $(EPOCBLDABS)
       
   103 	$(call startrule,bootstrap_rvct_link) \
       
   104 	$(LD) $(LFLAGS) $(SYMOPT) $$(join $$(basename $$@),.sym) -o $$@ $$(filter %.o,$$^); \
       
   105 	$(GNUCP) $$@ $$(join $$(basename $(TRG)),.sym) \
       
   106 	$(call endrule,bootstrap_rvct_link)	
       
   107 endef
       
   108 
       
   109 define bootstrap_strip
       
   110 $(TRG) : $(EPOCBLDABS)/$(NAME).in
       
   111 	$(call startrule,bootstrap_strip) \
       
   112 	$(FROMELF) --bin --output $$@ $$< \
       
   113 	$(call endrule,bootstrap_rvct_strip)
       
   114 endef
       
   115 
       
   116 define bootstrap_h2inc
       
   117 # How to translate the .h files to .inc
       
   118 $(1) : $(2)
       
   119 	$(call startrule,bootstrap_h2inc) \
       
   120 	$(PERL) $(EPOCROOT)/epoc32/tools/h2inc.pl $$< $$@ ARMASM \
       
   121 	$(call endrule, bootsrap_h2inc)
       
   122 endef
       
   123 
       
   124 # Joins two lists with a 1:1 mapping, separated by a ->
       
   125 # $(call bootstrap_joinlists,a b c,d e f) returns a->d b->e c->f
       
   126 define bootstrap_joinlists
       
   127 $(join $(1),$(addprefix ->,$(2)))
       
   128 endef
       
   129 
       
   130 # Path for generic source files
       
   131 BASESRCPATH := $(E32PATH)/eka/kernel/$(CPU)
       
   132 
       
   133 # Generic source files
       
   134 BASESOURCES := $(foreach S,$(BASESOURCES_NAMES),$(addprefix $(BASESRCPATH)/,$(S)))
       
   135 
       
   136 HEADERS:= $(E32PATH)/eka/include/kernel/kernboot.h $(E32PATH)/eka/include/kernel/arm/bootdefs.h $(E32PATH)/eka/include/e32rom.h $(GENINCLUDES_HEADERS) $(HEADERS_MM)
       
   137 
       
   138 # Generated include files
       
   139 BOOTSTRAP_GENINCLUDES := $(foreach f,$(HEADERS),$(basename $(notdir $(f))).$(INCEXT))
       
   140 
       
   141 # Non-generated generic include files
       
   142 ifeq ($(BASEINCLUDES),)
       
   143 BASEINCLUDES := $(E32PATH)/eka/include/kernel/$(CPU)/bootcpu.inc $(E32PATH)/eka/include/kernel/$(CPU)/bootmacro.inc
       
   144 endif
       
   145 INCLUDES2 := $(foreach f,$(INCLUDES2),$(basename $(f)).$(INCEXT))
       
   146 
       
   147 # Generic object files
       
   148 FULLBASEOBJECTS := $(foreach src, $(BASESOURCES_NAMES), $(addprefix $(EPOCBLDABS)/,$(basename $(src)).o))
       
   149 
       
   150 # Platform specific object files
       
   151 FULLOBJECTS := $(foreach src, $(SOURCES), $(addprefix $(EPOCBLDABS)/,$(basename $(notdir $(src))).o))
       
   152 
       
   153 LINKOBJECTS := $(FULLBASEOBJECTS) $(FULLOBJECTS)
       
   154 
       
   155 # Generated include files with paths
       
   156 FULLGENINCLUDES := $(addprefix $(EPOCBLDABS)/,$(BOOTSTRAP_GENINCLUDES))
       
   157 
       
   158 CLEANTARGETS := $(CLEANTARGETS) $(FULLBASEOBJECTS) $(FULLOBJECTS) $(LINKOBJECTS) $(FULLGENINCLUDES) 
       
   159 
       
   160 CLEANTARGETS := $(CLEANTARGETS) $(EPOCBLDABS)/$(NAME).in $(join $(basename $(EPOCBLDABS)/$(NAME).in),.sym)
       
   161 
       
   162 JOINED_INC := $(call bootstrap_joinlists,$(FULLGENINCLUDES),$(HEADERS))
       
   163 $(foreach J,$(JOINED_INC),$(eval $(call bootstrap_h2inc,$(word 1,$(subst ->, ,$(J))),$(word 2,$(subst ->, ,$(J))) | $(EPOCBLDABS))))
       
   164 
       
   165 # How to strip linked object to binary
       
   166 $(eval $(call bootstrap_strip,$(TRG),$(EPOCBLDABS)/$(NAME).in))
       
   167 
       
   168 LISTFILE := $(foreach f,$(FULLBASEOBJECTS),$(join $(basename $(f)),.lst)) $(foreach f,$(FULLOBJECTS),$(join $(basename $(f)),.lst))
       
   169 CLEANTARGETS := $(CLEANTARGETS) $(LISTFILE)
       
   170 
       
   171 JOINED_BASEOBJECTS := $(call bootstrap_joinlists,$(FULLBASEOBJECTS),$(BASESOURCES))
       
   172 
       
   173 $(foreach J,$(JOINED_BASEOBJECTS),$(eval $(call bootstrap_asm,$(word 1,$(subst ->, ,$(J))),$(EPOCBLDABS)/%.o,$(word 2,$(subst ->, ,$(J))) $(BASEINCLUDES) $(FULLGENINCLUDES) $(INCLUDES2) | $(EPOCBLDABS))))
       
   174 
       
   175 JOINED_OBJECTS := $(call bootstrap_joinlists,$(FULLOBJECTS),$(SOURCES))
       
   176 
       
   177 $(foreach J,$(JOINED_OBJECTS),$(eval $(call bootstrap_asm,$(word 1,$(subst ->, ,$(J))),$(EPOCBLDABS)/%.o,$(word 2,$(subst ->, ,$(J))) $(BASEINCLUDES) $(FULLGENINCLUDES) $(INCLUDES2) |$(EPOCBLDABS))))
       
   178 
       
   179 # How to link the object files
       
   180 $(eval $(bootstrap_link))
       
   181 
       
   182 # Hook into global targets
       
   183 TARGET :: $(TRG)
       
   184 
       
   185 #############################################
       
   186 
       
   187 # --what to show releasables
       
   188 $(eval $(call whatmacro,$(TRG),USERFLM))
       
   189 # create directory
       
   190 CREATABLEPATHS := $(EPOCBLDABS) $(EPOCTRG)
       
   191 $(call makepath,$(CREATABLEPATHS))
       
   192 # clean up
       
   193 $(eval $(call GenerateStandardCleanTarget,$(CLEANTARGETS),$(BUILDLOC)))
       
   194 
       
   195 endif