source: trunk/softs/tsar_boot/Makefile

Last change on this file was 1049, checked in by alain, 9 years ago

Cosmetic change in the hard_config.h file : XCU -> ICU , TTY -> TXT

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