source: trunk/softs/tsar_boot/Makefile @ 653

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

Introducing a RAMDISK driver in the preloader.

When using RAMDISK, execute the make command with the flags
SOCLIB=1 and RAMDISK=1. The RDK_PADDR_BASE variable must
also be set on the conf/<platform>/defs_platform.h

These modifications are backward compatibles. Therefore,
when no using RAMDISK, none modifications applied on the
platform configuration file.

File size: 3.7 KB
Line 
1# let the user have a default configuration (ie for PLATFORM_DIR and SOCLIB)
2-include ./build.mk
3
4MAKECMDGOALS ?= none
5
6ifneq ($(MAKECMDGOALS),$(filter $(MAKECMDGOALS),clean distclean clean-doc doc))
7  ifndef PLATFORM_DIR
8    $(error please define PLATFORM_DIR 'make PLATFORM_DIR=foo')
9  else
10    ifdef SOCLIB
11      ifdef RAMDISK
12        DEFS+= -DUSE_RDK
13      else
14        DEFS+= -DUSE_BDV
15      endif
16      DTS=platform_soclib.dts
17      $(info Make for $(PLATFORM_DIR), SocLib variant)
18    else
19      DEFS+= -DUSE_SPI
20      DTS=platform_fpga.dts
21      $(info Make for $(PLATFORM_DIR), FPGA variant)
22    endif
23  endif
24endif
25
26LD         := mipsel-unknown-elf-ld
27CC         := mipsel-unknown-elf-gcc
28AS         := mipsel-unknown-elf-as
29DU         := mipsel-unknown-elf-objdump
30RM         := rm -rf
31ECHO       := @echo
32MKDIR      := mkdir
33DTC        := dtc
34HEXDUMP    := hexdump
35DOXYGEN    := doxygen
36
37BUILD_DIR  := build
38SRCS_DIR   := src
39INCS_DIR   := include
40
41# =============================================================================
42# Include files paths
43# =============================================================================
44
45INCLUDE    += -I. -I$(INCS_DIR) -I$(PLATFORM_DIR)
46
47# =============================================================================
48# Paths of sources in another directories
49# =============================================================================
50
51VPATH      += $(SRCS_DIR)
52VPATH      += $(PLATFORM_DIR)
53
54# =============================================================================
55# Object files
56# =============================================================================
57
58CFLAGS     := -Wall                \
59              -mno-gpopt           \
60              -ffreestanding       \
61              -fomit-frame-pointer \
62              -mips32              \
63              -ggdb                \
64              -mlong-calls         \
65              -Werror
66
67C_SRCS     := reset_elf_loader.c \
68              reset_ioc.c        \
69              reset_utils.c      \
70              reset_tty.c        \
71              reset_exception.c
72
73ifndef SOCLIB
74  C_SRCS   += sdcard.c spi.c
75endif
76
77S_SRCS     := reset.S
78
79OBJS       := $(subst .c,.o, $(notdir $(C_SRCS)))
80OBJS       += $(subst .S,.o, $(notdir $(S_SRCS)))
81OBJS       := $(addprefix $(BUILD_DIR)/, $(OBJS))
82
83TARGET     := preloader.elf
84
85USE_DT     ?= 1
86
87all: $(TARGET)
88
89 $(BUILD_DIR)/version.o: $(BUILD_DIR) $(OBJS) version version.sh
90        $(ECHO) "[version.sh]"
91        ./version.sh > $(BUILD_DIR)/version.c
92        $(ECHO) "[   CC    ]     $(BUILD_DIR)/version.c"
93        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $(BUILD_DIR)/version.c
94        $(DU) -D $@ > $@.txt
95
96$(TARGET): $(BUILD_DIR) $(BUILD_DIR)/version.o $(OBJS) $(PLATFORM_DIR)/ldscript $(BUILD_DIR)/platform.ld
97        $(ECHO) "[   LD    ]     $@"
98        $(LD) -o $@ -T $(PLATFORM_DIR)/ldscript $(OBJS) $(BUILD_DIR)/version.o
99        $(DU) -D $@ > $@.txt
100
101ifeq ($(USE_DT), 1)
102$(BUILD_DIR)/platform.ld: $(BUILD_DIR)/platform.dtb
103        $(ECHO) "[ HEXDUMP ]     $(notdir $<)"
104        $(HEXDUMP) -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' $< > $@
105else
106$(BUILD_DIR)/platform.ld:
107        $(ECHO) "[  TOUCH  ]     $(notdir $@)"
108        touch $@
109endif
110
111$(BUILD_DIR)/platform.dtb: $(DTS)
112        $(ECHO) "[   DTC   ]     $(notdir $<)"
113        ${DTC} -O dtb -o $@ $< &> /dev/null
114
115$(BUILD_DIR):
116        $(MKDIR) $@
117
118doc: Doxyfile
119        $(DOXYGEN) Doxyfile
120
121clean:
122        $(RM) $(TARGET).txt $(TARGET) *~ $(BUILD_DIR)
123
124clean-doc:
125        $(RM) doc
126
127distclean: clean clean-doc
128
129# =============================================================================
130# Implicit makefile rules
131
132$(BUILD_DIR)/%.o: %.c
133        $(ECHO) "[   CC    ]     $(notdir $<)"
134        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
135        $(DU) -D $@ > $@.txt
136
137$(BUILD_DIR)/%.o: %.S
138        $(ECHO) "[   AS    ]     $(notdir $<)"
139        $(CC) $(DEFS) ${INCLUDE} -g -mips32 -c -o $@ $<
140        $(DU) -D $@ > $@.txt
141
142#.SILENT:
Note: See TracBrowser for help on using the repository browser.