source: trunk/softs/tsar_boot/Makefile @ 513

Last change on this file since 513 was 502, checked in by bouyer, 11 years ago

Print a version string at execution, dynamically computed at link time.
The version string includes: content of ./version, builder and date,
and svn revision.
This helps to know which version we're really executing ...

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