source: trunk/softs/tsar_boot/Makefile @ 293

Last change on this file since 293 was 293, checked in by cfuguet, 11 years ago

Including Makefile for tsar boot loader

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