source: trunk/softs/tsar_boot/Makefile @ 281

Last change on this file since 281 was 281, checked in by bouyer, 11 years ago

Keep BEV bit set in STATUS register, and add an exception handler at
0xbfc0380. This handler just prints STATUS, CAUSE and EPC register and
stalls (does an infinite loop).

File size: 2.9 KB
Line 
1ifndef  PLATFORM_DIR
2$(error please define PLATFORM_DIR 'make PLATFORM_DIR=foo')
3else
4TOOLS    := tools
5
6ELF2MIF  := $(TOOLS)/elf_read/elf_utils.x
7LD             := mipsel-unknown-elf-ld
8CC             := mipsel-unknown-elf-gcc
9AS             := mipsel-unknown-elf-as
10DU             := mipsel-unknown-elf-objdump
11RM             := rm -rf
12ECHO           := echo
13MKDIR          := mkdir
14DTC            := dtc
15HEXDUMP        := hexdump
16
17OBJS_DIR       := objs
18MIF_DIR        := mifs
19
20# =============================================================================
21# Include files paths
22# =============================================================================
23
24INCLUDE    += -I. -Iio_drivers -I$(PLATFORM_DIR)
25
26# =============================================================================
27# Paths of sources in another directories
28# =============================================================================
29
30VPATH      += io_drivers
31VPATH      += $(PLATFORM_DIR)
32
33# =============================================================================
34# Object files
35# =============================================================================
36
37S_SRCS     += reset.s
38
39C_SRCS     += spi.c
40C_SRCS     += sdcard.c
41C_SRCS     += ioc.c
42C_SRCS     += boot_tty.c
43C_SRCS     += boot_loader_entry.c
44C_SRCS     += exceptions.c
45
46OBJS       := $(subst .s,.o,$(S_SRCS))
47OBJS       += $(subst .c,.o,$(C_SRCS))
48OBJS       := $(addprefix $(OBJS_DIR)/, $(OBJS))
49
50TARGET     := bin.soft
51
52ifdef   SOCLIB
53DEFS+= -DSOCLIB_IOC
54DTS=platform_soclib.dts
55$(info Making for $(PLATFORM_DIR), SocLib variant)
56else
57DTS=platform_fpga.dts
58$(info Making for $(PLATFORM_DIR), FPGA variant)
59endif
60
61CFLAGS   := -Wall -mno-gpopt -ffreestanding -fomit-frame-pointer -mips32 \
62                    -ggdb -mlong-calls
63# =============================================================================
64# ALL target. If the MIF variable is defined, the $(MIF) file is generated
65# using the $(basename $(MIF))_tab.txt file
66
67
68all: $(TARGET)
69        if [ ! -z $(MIF) ]; then\
70                if [ ! -e $(MIF_DIR) ]; then\
71                        $(MKDIR) $(MIF_DIR);\
72                fi;\
73                $(ECHO) "[   MIF  ]     $(MIF)";\
74                $(ELF2MIF) \
75                        -ELF_FILE $(TARGET) \
76                        -SEG_FILE $(basename $(MIF))_tab.txt \
77                        -MIF_FILE $(MIF_DIR)/$(MIF);\
78        fi;
79
80$(TARGET): $(OBJS_DIR) $(OBJS) ldscript $(OBJS_DIR)/platform.ld
81        @\
82        $(ECHO) "[   LD   ]     $@"
83        $(LD) -o $@ -T ldscript $(OBJS)
84        $(DU) -D $@ > $@.txt
85
86$(OBJS_DIR)/platform.ld: $(OBJS_DIR)/platform.dtb
87        $(HEXDUMP) -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' $< > $@
88
89$(OBJS_DIR)/platform.dtb: $(DTS)
90        ${DTC} -O dtb -o $@ $<
91
92$(OBJS_DIR):
93        $(MKDIR) $@
94
95clean:
96        $(RM) $(TARGET).txt $(TARGET) *~ $(OBJS_DIR)
97
98distclean: clean
99        $(RM) $(MIF_DIR)
100# =============================================================================
101# Implicit makefile rules
102
103$(OBJS_DIR)/%.o: %.c
104        @\
105        $(ECHO) "[   CC   ]     $(notdir $<)"
106        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
107        $(DU) -D $@ > $@.txt
108
109$(OBJS_DIR)/%.o: %.S
110        @\
111        $(ECHO) "[   AS   ]     $(notdir $<)"
112        $(CC) $(DEFS) ${INCLUDE} -g -mips32 -c -o $@ $<
113        $(DU) -D $@ > $@.txt
114
115
116.SILENT:
117endif
Note: See TracBrowser for help on using the repository browser.