source: trunk/softs/tsar_boot/Makefile @ 276

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

A boot loader to be stored in ROM of a TSAR platform.
Based on Cesar FUGUET's work.
Platform-specific files are in a subdirectory, e.g. platform_fpga_de2-115,
so the same code can be targetted to different platforms.
The platform is selected with the PLATFORM_DIR environnement variable.
The supported variant are soclib and fpga, the later being the default
and the former selected by defining the SOCLIB environnement variable.
The boot loader embeds a binary device tree describing the platform,
to be used by the loaded software.

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
44
45OBJS       := $(subst .s,.o,$(S_SRCS))
46OBJS       += $(subst .c,.o,$(C_SRCS))
47OBJS       := $(addprefix $(OBJS_DIR)/, $(OBJS))
48
49TARGET     := bin.soft
50
51ifdef   SOCLIB
52DEFS+= -DSOCLIB_IOC
53DTS=platform_soclib.dts
54$(info Making for $(PLATFORM_DIR), SocLib variant)
55else
56DTS=platform_fpga.dts
57$(info Making for $(PLATFORM_DIR), FPGA variant)
58endif
59
60CFLAGS   := -Wall -mno-gpopt -ffreestanding -fomit-frame-pointer -mips32 \
61                    -ggdb -mlong-calls
62# =============================================================================
63# ALL target. If the MIF variable is defined, the $(MIF) file is generated
64# using the $(basename $(MIF))_tab.txt file
65
66
67all: $(TARGET)
68        if [ ! -z $(MIF) ]; then\
69                if [ ! -e $(MIF_DIR) ]; then\
70                        $(MKDIR) $(MIF_DIR);\
71                fi;\
72                $(ECHO) "[   MIF  ]     $(MIF)";\
73                $(ELF2MIF) \
74                        -ELF_FILE $(TARGET) \
75                        -SEG_FILE $(basename $(MIF))_tab.txt \
76                        -MIF_FILE $(MIF_DIR)/$(MIF);\
77        fi;
78
79$(TARGET): $(OBJS_DIR) $(OBJS) ldscript $(OBJS_DIR)/platform.ld
80        @\
81        $(ECHO) "[   LD   ]     $@"
82        $(LD) -o $@ -T ldscript $(OBJS)
83        $(DU) -D $@ > $@.txt
84
85$(OBJS_DIR)/platform.ld: $(OBJS_DIR)/platform.dtb
86        $(HEXDUMP) -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' $< > $@
87
88$(OBJS_DIR)/platform.dtb: $(DTS)
89        ${DTC} -O dtb -o $@ $<
90
91$(OBJS_DIR):
92        $(MKDIR) $@
93
94clean:
95        $(RM) $(TARGET).txt $(TARGET) *~ $(OBJS_DIR)
96
97distclean: clean
98        $(RM) $(MIF_DIR)
99# =============================================================================
100# Implicit makefile rules
101
102$(OBJS_DIR)/%.o: %.c
103        @\
104        $(ECHO) "[   CC   ]     $(notdir $<)"
105        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
106        $(DU) -D $@ > $@.txt
107
108$(OBJS_DIR)/%.o: %.S
109        @\
110        $(ECHO) "[   AS   ]     $(notdir $<)"
111        $(CC) $(DEFS) ${INCLUDE} -g -mips32 -c -o $@ $<
112        $(DU) -D $@ > $@.txt
113
114
115.SILENT:
116endif
Note: See TracBrowser for help on using the repository browser.