source: trunk/softs/tsar_boot/Makefile @ 390

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

Reactivating commented command in the Makefile of the tsar_boot

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