source: trunk/softs/tsar_boot/Makefile @ 408

Last change on this file since 408 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
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
[406]20ifeq ($(USE_DT), 0)
21        DTS=
22endif
23
[293]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
[388]33DOXYGEN    := doxygen
[293]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
[406]60
[293]61ifndef SOCLIB
[406]62  C_SRCS   += sdcard.c spi.c
[293]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
[406]73ifndef USE_DT
74  USE_DT := 1
75else
76  USE_DT := $(USE_DT)
77endif
[293]78
79ifdef SYSCLK_FREQ
[406]80  DEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ)
[293]81endif
82
83all: $(TARGET)
84
[368]85$(TARGET): $(BUILD_DIR) $(OBJS) $(PLATFORM_DIR)/ldscript $(BUILD_DIR)/platform.ld
[388]86        $(ECHO) "[   LD    ]     $@"
[368]87        $(LD) -o $@ -T $(PLATFORM_DIR)/ldscript $(OBJS)
[293]88        $(DU) -D $@ > $@.txt
89
90$(BUILD_DIR)/platform.ld: $(BUILD_DIR)/platform.dtb
[388]91        $(ECHO) "[ HEXDUMP ]     $(notdir $<)"
[293]92        $(HEXDUMP) -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' $< > $@
93
94$(BUILD_DIR)/platform.dtb: $(DTS)
[406]95ifeq ($(USE_DT), 1)
[388]96        $(ECHO) "[   DTC   ]     $(notdir $<)"
[390]97        ${DTC} -O dtb -o $@ $< &> /dev/null
[406]98else
99        touch $@
100endif
[293]101
102$(BUILD_DIR):
103        $(MKDIR) $@
104
[388]105doc: Doxyfile
106        $(DOXYGEN) Doxyfile
107
[293]108clean:
109        $(RM) $(TARGET).txt $(TARGET) *~ $(BUILD_DIR)
110
[388]111clean-doc:
112        $(RM) doc
[293]113
[388]114distclean: clean clean-doc
115
[293]116# =============================================================================
117# Implicit makefile rules
118
119$(BUILD_DIR)/%.o: %.c
[388]120        $(ECHO) "[   CC    ]     $(notdir $<)"
[293]121        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
122        $(DU) -D $@ > $@.txt
123
124$(BUILD_DIR)/%.o: %.S
[388]125        $(ECHO) "[   AS    ]     $(notdir $<)"
[293]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.