source: trunk/softs/tsar_boot/Makefile @ 759

Last change on this file since 759 was 759, checked in by cfuguet, 10 years ago

tsar_boot: preloader ldscript is automatically generated

  • Stack for processor 0 is allocated at the end of the cluster(0,0) ram segment:

SEG_RAM_BASE + SEG_RAM_SIZE - RESET_STACK_SIZE

  • code base is equal to the SEG_ROM_BASE constant defined in the hard_config.h file.
File size: 4.3 KB
RevLine 
[759]1# let the user have a default configuration (ie for HARD_CONFIG_PATH)
[411]2-include ./build.mk
3
[758]4USE_DT     ?= 1
5DTS        ?= platform.dts
6
[425]7MAKECMDGOALS ?= none
[293]8
[388]9ifneq ($(MAKECMDGOALS),$(filter $(MAKECMDGOALS),clean distclean clean-doc doc))
[759]10  ifndef HARD_CONFIG_PATH
11    $(error please define HARD_CONFIG_PATH 'make HARD_CONFIG_PATH=foo')
[388]12  else
[759]13    $(info Make for $(HARD_CONFIG_PATH))
[388]14  endif
15endif
16
[758]17# Platform clock frequency (in KHz)
18ifdef SYSTEM_CLK
19    DEFS   := "-DRESET_SYSTEM_CLK=$(SYSTEM_CLK)"
20endif
21
[653]22LD         := mipsel-unknown-elf-ld
23CC         := mipsel-unknown-elf-gcc
24AS         := mipsel-unknown-elf-as
25DU         := mipsel-unknown-elf-objdump
[758]26AR         := mipsel-unknown-elf-ar
[653]27RM         := rm -rf
[759]28SED        := sed
[653]29ECHO       := @echo
30MKDIR      := mkdir
31DTC        := dtc
32HEXDUMP    := hexdump
[388]33DOXYGEN    := doxygen
[293]34
35BUILD_DIR  := build
36
37# =============================================================================
38# Include files paths
39# =============================================================================
40
[759]41INCLUDE    += -I. -Iinclude -Idrivers -I$(HARD_CONFIG_PATH)
[293]42
43# =============================================================================
[758]44# Object files
[293]45# =============================================================================
46
[758]47VPATH      += src
[293]48
[586]49CFLAGS     := -Wall                \
50              -mno-gpopt           \
51              -ffreestanding       \
52              -fomit-frame-pointer \
[758]53              -march=mips32        \
[701]54              -O2                  \
[586]55              -Werror
[293]56
[653]57C_SRCS     := reset_elf_loader.c \
[758]58              reset_utils.c      \
59              reset_exception.c  \
[586]60              reset_ioc.c        \
[758]61              version.c
[406]62
[653]63S_SRCS     := reset.S
[293]64
[758]65OBJS       := $(addprefix $(BUILD_DIR)/,\
66                  $(subst .c,.o, $(notdir $(C_SRCS))) \
67                  $(subst .S,.o, $(notdir $(S_SRCS))))
[293]68
[586]69TARGET     := preloader.elf
[293]70
[758]71# =============================================================================
72# Drivers library
73# =============================================================================
[293]74
[758]75VPATH      += drivers
76
77DRV_SRCS   := reset_tty.c        \
78              reset_inval.c      \
79              reset_sdc.c        \
80              reset_bdv.c        \
81              reset_rdk.c        \
82              sdcard.c           \
83              spi.c
84
85DRV_OBJS   := $(addprefix $(BUILD_DIR)/,\
86                  $(subst .c,.o, $(notdir $(DRV_SRCS))))
87
88DRV_LIB    := libdrivers.a
89
90# =============================================================================
91# Makefile rules
92# =============================================================================
93
94VPATH      += $(BUILD_DIR)
95
[293]96all: $(TARGET)
97
[758]98$(BUILD_DIR)/$(DRV_LIB): $(BUILD_DIR) $(DRV_OBJS)
99        $(ECHO) "[   AR    ]     $(notdir $@)"
100        $(AR) rcs $@ $(DRV_OBJS)
101
102$(BUILD_DIR)/version.o: $(BUILD_DIR)/version.c
103        $(ECHO) "[   CC    ]     $(notdir $<)"
104        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
[587]105        $(DU) -D $@ > $@.txt
[502]106
[758]107$(BUILD_DIR)/version.c: $(BUILD_DIR) version.sh VERSION
108        $(ECHO) "[version.sh]"
109        ./version.sh > $@
110
[759]111$(BUILD_DIR)/preloader.ld: preloader.ld.in
112        $(ECHO) "[   CC    ]     $(notdir $<)"
113        $(CC) -x c $(INCLUDE) -E $< | $(SED) -e '/#/d' -e '/^[\s\t]*$$/d' > $@
114
115$(TARGET): $(BUILD_DIR) $(OBJS) $(BUILD_DIR)/preloader.ld $(BUILD_DIR)/platform.ld $(BUILD_DIR)/$(DRV_LIB)
[388]116        $(ECHO) "[   LD    ]     $@"
[759]117        $(LD) -o $@ -T $(BUILD_DIR)/preloader.ld $(OBJS) -L$(BUILD_DIR) -ldrivers
[293]118        $(DU) -D $@ > $@.txt
119
[425]120ifeq ($(USE_DT), 1)
[293]121$(BUILD_DIR)/platform.ld: $(BUILD_DIR)/platform.dtb
[388]122        $(ECHO) "[ HEXDUMP ]     $(notdir $<)"
[293]123        $(HEXDUMP) -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' $< > $@
[425]124else
125$(BUILD_DIR)/platform.ld:
126        $(ECHO) "[  TOUCH  ]     $(notdir $@)"
127        touch $@
128endif
[293]129
[759]130$(BUILD_DIR)/platform.dtb: $(HARD_CONFIG_PATH)/$(DTS)
[388]131        $(ECHO) "[   DTC   ]     $(notdir $<)"
[390]132        ${DTC} -O dtb -o $@ $< &> /dev/null
[293]133
134$(BUILD_DIR):
135        $(MKDIR) $@
136
[388]137doc: Doxyfile
138        $(DOXYGEN) Doxyfile
139
[293]140clean:
141        $(RM) $(TARGET).txt $(TARGET) *~ $(BUILD_DIR)
142
[388]143clean-doc:
144        $(RM) doc
[293]145
[388]146distclean: clean clean-doc
147
[293]148# =============================================================================
149# Implicit makefile rules
150
151$(BUILD_DIR)/%.o: %.c
[388]152        $(ECHO) "[   CC    ]     $(notdir $<)"
[293]153        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
154        $(DU) -D $@ > $@.txt
155
156$(BUILD_DIR)/%.o: %.S
[388]157        $(ECHO) "[   AS    ]     $(notdir $<)"
[293]158        $(CC) $(DEFS) ${INCLUDE} -g -mips32 -c -o $@ $<
159        $(DU) -D $@ > $@.txt
160
Note: See TracBrowser for help on using the repository browser.