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