source: trunk/softs/tsar_boot/Makefile @ 662

Last change on this file since 662 was 662, checked in by cfuguet, 10 years ago

Bugfix in tsar_boot makefile:

  • when defining makefile parameters (SOCLIB, RAMDISK, USE_DT), the assigned value is used instead of only their definition.

Example: make PLATFORM_DIR=<path> SOCLIB=1 RAMDISK=1

make PLATFORM_DIR=<path> SOCLIB=1 RAMDISK=0

In the former example, the preloader sould be compiled for
SOCLIB using RAMDISK.
In the latter the preloader should be compiled for SOCLIB
without using RAMDISK.

Before modifications in this commit, the two invocations examples
would result on SOCLIB using RAMDISK because the value was not
used but only the definition.

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