source: trunk/softs/tsar_boot/Makefile @ 406

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

Introducing USE_DT (true by default) option in tsar_boot makefile

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