source: trunk/softs/tsar_boot/Makefile @ 412

Last change on this file since 412 was 411, checked in by porquet, 11 years ago

tsar_boot: let the user have a custom conf file to avoid repeating
arguments on command line

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