toolsandutils/buildsystem/extension/base/integrator_lmnand2_miniboot.mk
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 # Copyright (c) 2006-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 "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 # To guarantee there is a slash at the end of EPOCROOT in case there is not.
       
    17 # This is needed to ensure compatibility with SBSv1. 
       
    18 TMPROOT:=$(subst \,/,$(EPOCROOT))
       
    19 EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/
       
    20 
       
    21 include $(EPOCROOT)epoc32/tools/shell/$(notdir $(basename $(SHELL))).mk
       
    22 
       
    23 
       
    24 ## Set the source directory
       
    25 BLDINFDIR := ../../../unref/orphan/cedgen/base/integrator/.
       
    26 SRCDIR = $(EXTENSION_ROOT)/nandboot/miniboot
       
    27 SPECSRCDIR = $(EXTENSION_ROOT)/../integratormotherboard/nandboot/miniboot
       
    28 TARGETDIR = $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)
       
    29 EPOCINCDIR = $(EPOCROOT)epoc32/include/integrator/logic/lmnand2
       
    30 
       
    31 #Rules
       
    32 vpath %.s . $(SPECSRCDIR) $(SRCDIR)
       
    33 vpath %.inc . $(SRCDIR) $(SPECSRCDIR) $(EPOCINCDIR)
       
    34 vpath %.ginc . $(BUILDLOC)
       
    35 
       
    36 
       
    37 # Build directory (EPOCBLD too long)
       
    38 #BUILDLOC = $(EPOCROOT)epoc32/build/integrator/logic/lmnand2/nandboot/miniboot/$(PLATFORM_PATH)/$(CFG_PATH)
       
    39 BUILDLOC = $(EPOCBLD)/$(PLATFORM_PATH)/$(CFG_PATH)
       
    40 
       
    41 ## Set the target name
       
    42 INCLUDES := nand.inc
       
    43 SPECINCLUDES := arm.inc
       
    44 EPOCINCLUDES := nand_fbr_offset.inc
       
    45 
       
    46 SRC := miniboot.s arm.s
       
    47 TARGET = $(TARGETDIR)/_lmnand2_miniboot.bin
       
    48 TMPTARGET = $(BUILDLOC)/miniboot.exe
       
    49 
       
    50 # Set the code and data base addresses 
       
    51 LINKBASE = 0x0000000
       
    52 
       
    53 ARMASM_OUT := $(shell armasm 2>&1)
       
    54 ARMASM_OUT_4 := $(word 4,$(ARMASM_OUT))
       
    55 # Use GCC toolchain if no other is available
       
    56 TOOLVER := GCC
       
    57 RVCTSTR := $(strip $(findstring RVCT, $(ARMASM_OUT_4)))
       
    58 ifeq "$(RVCTSTR)" "RVCT"
       
    59         TOOLVER := RVCT
       
    60         OP := --
       
    61         OB := o
       
    62 endif 
       
    63 
       
    64 ifeq "$(TOOLVER)" "RVCT"
       
    65         ASM_MACROS += USE_CXSF
       
    66 
       
    67         ASM := armasm
       
    68         LINK := armlink
       
    69         FROMELF := fromelf
       
    70         OBJEXT := o
       
    71         INCEXT := inc
       
    72 
       
    73         ASMINCPATHCMD := $(foreach dir,$(SRCDIR),$(join -I ,$(dir))) $(foreach dir,$(EPOCINCDIR),$(join -I ,$(dir)))
       
    74         SPECASMINCPATHCMD := $(foreach dir,$(SPECSRCDIR),$(join -I ,$(dir)))
       
    75         ASM_MACRO_CMD := $(foreach macro,$(ASM_MACROS),$(OP)predefine "$(macro) SETL {TRUE}")
       
    76         AFLAGS := -g $(OP)keep $(ASM_MACRO_CMD) $(ASMINCPATHCMD) $(SPECASMINCPATHCMD)
       
    77         
       
    78         SYMOPT := $(OP)symdefs
       
    79         ASMTYP := ARMASM
       
    80         LINKFILE :=
       
    81         define do_asm
       
    82                 $(ASM) $(AFLAGS) -$(OB) $@ $(OP)LIST $(join $(basename $@),.lst) $<
       
    83         endef
       
    84         
       
    85         LFLAGS := $(OP)ro-base $(LINKBASE) $(OP)entry $(LINKBASE) $(OP)map
       
    86 
       
    87         define do_link
       
    88                 $(LINK) $(LFLAGS) -$(OB) $@ $(filter %.$(OBJEXT),$^)
       
    89         endef
       
    90 
       
    91         define do_strip
       
    92                 $(FROMELF) $(OP)bin $(OP)output $@ $<
       
    93         endef
       
    94 endif
       
    95 
       
    96 
       
    97 #GCC build options
       
    98 ifeq "$(TOOLVER)" "GCC"
       
    99         ASM := as
       
   100         AFLAGS := -mapcs-32 -R -n -I$(BUILDLOC)
       
   101 
       
   102         LINKFLAGS = -n -x --section-alignment 4 --file-alignment 2 -no-whole-archive
       
   103         OBJEXT := o
       
   104         INCEXT := ginc
       
   105         LINKFILE = $(SRCDIR)/miniboot.lnk
       
   106         define do_includes
       
   107                 perl $(EPOCROOT)epoc32/tools/armasm2as.pl $< $@
       
   108         endef
       
   109         define do_asm
       
   110                 perl $(EPOCROOT)epoc32/tools/armasm2as.pl $< $(join $(basename $@),.s) 
       
   111                 $(AS) $(AFLAGS) -o $@ $(join $(basename $@),.s)
       
   112         endef
       
   113         define do_link
       
   114                 ld -o "$(TMPTARGET)"  --start $(FULLOBJECTS) --script=$(LINKFILE)
       
   115         endef
       
   116         define do_strip
       
   117                 strip -O binary -o "$(TARGET)" "$(TMPTARGET)"
       
   118                 $(ERASE) $(call slash2generic,"$(TMPTARGET)") 
       
   119 	#	$(ERASE) "$(TMPTARGET)"
       
   120                 echo Built $(TARGET)
       
   121         endef
       
   122         PROCESS_INCLUDES := 1
       
   123 endif
       
   124 
       
   125 
       
   126 OBJECTS := $(foreach f,$(SRC),$(basename $(f)).$(OBJEXT))
       
   127 
       
   128 FULLOBJECTS := $(addprefix $(BUILDLOC)/,$(OBJECTS))
       
   129 
       
   130 
       
   131 #Include processing
       
   132 
       
   133 
       
   134 ifdef PROCESS_INCLUDES
       
   135 
       
   136 GCCSRC := $(addprefix $(BUILDLOC)/,$(SRC))
       
   137 
       
   138 FULLINCLUDES := $(foreach f,$(INCLUDES),$(basename $(f)).$(INCEXT))
       
   139 FULLINCLUDES := $(addprefix $(BUILDLOC)/,$(FULLINCLUDES))
       
   140 
       
   141 SPECFULLINCLUDES := $(foreach f,$(SPECINCLUDES),$(basename $(f)).$(INCEXT))
       
   142 SPECFULLINCLUDES := $(addprefix $(BUILDLOC)/,$(SPECFULLINCLUDES))
       
   143 
       
   144 EPOCFULLINCLUDES := $(foreach f,$(EPOCINCLUDES),$(basename $(f)).$(INCEXT))
       
   145 EPOCFULLINCLUDES := $(addprefix $(BUILDLOC)/,$(EPOCFULLINCLUDES))
       
   146 
       
   147 #Creation of headers
       
   148 $(FULLINCLUDES) : $(BUILDLOC)/%.$(INCEXT) : %.inc
       
   149 	$(do_includes)
       
   150 $(SPECFULLINCLUDES) : $(BUILDLOC)/%.$(INCEXT) : %.inc
       
   151 	$(do_includes)
       
   152 $(EPOCFULLINCLUDES) : $(BUILDLOC)/%.$(INCEXT) : %.inc
       
   153 	$(do_includes)
       
   154 
       
   155 else
       
   156 
       
   157 #Armasm sytax specifc asm rule goes here
       
   158 FULLINCLUDES := $(addprefix $(SRCDIR)/,$(INCLUDES))
       
   159 SPECFULLINCLUDES:= $(addprefix $(SPECSRCDIR)/,$(SPECINCLUDES))
       
   160 EPOCFULLINCLUDES:= $(addprefix $(EPOCINCDIR)/,$(EPOCINCLUDES))
       
   161 
       
   162 endif
       
   163  
       
   164 
       
   165 #Strip
       
   166 $(TARGET) : $(TMPTARGET)
       
   167 	$(do_strip)
       
   168 
       
   169 #Link	
       
   170 $(TMPTARGET) : $(FULLOBJECTS)
       
   171 	$(do_link)
       
   172 
       
   173 #Objects
       
   174 $(FULLOBJECTS): $(BUILDLOC)/%.$(OBJEXT): %.s $(FULLINCLUDES) $(SPECFULLINCLUDES)  $(EPOCFULLINCLUDES)
       
   175 	$(do_asm)
       
   176 
       
   177 # make directories
       
   178 $(TARGETDIR):
       
   179 	$(call ifnotexistd,"$(TARGETDIR)")
       
   180 
       
   181 $(BUILDLOC):
       
   182 	$(call ifnotexistd,"$(BUILDLOC)")
       
   183 
       
   184 
       
   185 MAKMAKE :
       
   186 	echo Nothing to do
       
   187 
       
   188 FREEZE :
       
   189 	echo Nothing to do
       
   190 
       
   191 LIB :
       
   192 	echo Nothing to do
       
   193 
       
   194 CLEANLIB :
       
   195 	echo Nothing to do
       
   196 
       
   197 RESOURCE :
       
   198 	echo Nothing to do
       
   199 
       
   200 FINAL :
       
   201 	echo Nothing to do
       
   202 
       
   203 
       
   204 
       
   205 BLD SAVESPACE : $(TARGETDIR) $(BUILDLOC) $(TARGET)
       
   206 
       
   207 RELEASABLES :
       
   208 	@echo "$(TARGET)"
       
   209 
       
   210 CLEAN :
       
   211 	-$(ERASE) $(call slash2generic,"$(TARGET)") 
       
   212 	-$(ERASE) $(call slash2generic,"$(BUILDLOC)/*.*") 
       
   213 #	-$(ERASE) "$(TARGET)"
       
   214 #	-$(ERASE) "$(BUILDLOC)/*.*"
       
   215