source: trunk/softs/tsar_boot/Makefile @ 758

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

tsar_boot: improving configuration infrastructure

  • Using hard_config.h which respects the same sintax that the hard_config.h file of all TSAR platforms. This file can be then generated by the GIET-VM genmap tool or written manually.
  • All peripheral drivers have been moved to a drivers directory and they are compiled as a static library. This allows GCC to only include in the final .ELF the object files of used peripherals and not all of them.
  • Example hard_config.h and ldscripts have been introduced in the conf directory.
  • Improving comments in all files
File size: 4.1 KB
RevLine 
[758]1# let the user have a default configuration (ie for PLATFORM_DIR)
[411]2-include ./build.mk
3
[758]4USE_DT     ?= 1
5DTS        ?= platform.dts
6
[425]7MAKECMDGOALS ?= none
[293]8
[388]9ifneq ($(MAKECMDGOALS),$(filter $(MAKECMDGOALS),clean distclean clean-doc doc))
10  ifndef PLATFORM_DIR
11    $(error please define PLATFORM_DIR 'make PLATFORM_DIR=foo')
12  else
[758]13    $(info Make for $(PLATFORM_DIR))
[388]14  endif
15endif
16
[758]17# Platform clock frequency (in KHz)
18ifdef SYSTEM_CLK
19    DEFS   := "-DRESET_SYSTEM_CLK=$(SYSTEM_CLK)"
20endif
21
[653]22LD         := mipsel-unknown-elf-ld
23CC         := mipsel-unknown-elf-gcc
24AS         := mipsel-unknown-elf-as
25DU         := mipsel-unknown-elf-objdump
[758]26AR         := mipsel-unknown-elf-ar
[653]27RM         := rm -rf
28ECHO       := @echo
29MKDIR      := mkdir
30DTC        := dtc
31HEXDUMP    := hexdump
[388]32DOXYGEN    := doxygen
[293]33
34BUILD_DIR  := build
35
36# =============================================================================
37# Include files paths
38# =============================================================================
39
[758]40INCLUDE    += -I. -Iinclude -Idrivers -I$(PLATFORM_DIR)
[293]41
42# =============================================================================
[758]43# Object files
[293]44# =============================================================================
45
[758]46VPATH      += src
[293]47
[586]48CFLAGS     := -Wall                \
49              -mno-gpopt           \
50              -ffreestanding       \
51              -fomit-frame-pointer \
[758]52              -march=mips32        \
[701]53              -O2                  \
[586]54              -Werror
[293]55
[653]56C_SRCS     := reset_elf_loader.c \
[758]57              reset_utils.c      \
58              reset_exception.c  \
[586]59              reset_ioc.c        \
[758]60              version.c
[406]61
[653]62S_SRCS     := reset.S
[293]63
[758]64OBJS       := $(addprefix $(BUILD_DIR)/,\
65                  $(subst .c,.o, $(notdir $(C_SRCS))) \
66                  $(subst .S,.o, $(notdir $(S_SRCS))))
[293]67
[586]68TARGET     := preloader.elf
[293]69
[758]70# =============================================================================
71# Drivers library
72# =============================================================================
[293]73
[758]74VPATH      += drivers
75
76DRV_SRCS   := reset_tty.c        \
77              reset_inval.c      \
78              reset_sdc.c        \
79              reset_bdv.c        \
80              reset_rdk.c        \
81              sdcard.c           \
82              spi.c
83
84DRV_OBJS   := $(addprefix $(BUILD_DIR)/,\
85                  $(subst .c,.o, $(notdir $(DRV_SRCS))))
86
87DRV_LIB    := libdrivers.a
88
89# =============================================================================
90# Makefile rules
91# =============================================================================
92
93VPATH      += $(BUILD_DIR)
94
[293]95all: $(TARGET)
96
[758]97$(BUILD_DIR)/$(DRV_LIB): $(BUILD_DIR) $(DRV_OBJS)
98        $(ECHO) "[   AR    ]     $(notdir $@)"
99        $(AR) rcs $@ $(DRV_OBJS)
100
101$(BUILD_DIR)/version.o: $(BUILD_DIR)/version.c
102        $(ECHO) "[   CC    ]     $(notdir $<)"
103        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
[587]104        $(DU) -D $@ > $@.txt
[502]105
[758]106$(BUILD_DIR)/version.c: $(BUILD_DIR) version.sh VERSION
107        $(ECHO) "[version.sh]"
108        ./version.sh > $@
109
110$(TARGET): $(BUILD_DIR) $(OBJS) $(PLATFORM_DIR)/ldscript $(BUILD_DIR)/platform.ld $(BUILD_DIR)/$(DRV_LIB)
[388]111        $(ECHO) "[   LD    ]     $@"
[758]112        $(LD) -o $@ -T $(PLATFORM_DIR)/ldscript $(OBJS) -L$(BUILD_DIR) -ldrivers
[293]113        $(DU) -D $@ > $@.txt
114
[425]115ifeq ($(USE_DT), 1)
[293]116$(BUILD_DIR)/platform.ld: $(BUILD_DIR)/platform.dtb
[388]117        $(ECHO) "[ HEXDUMP ]     $(notdir $<)"
[293]118        $(HEXDUMP) -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' $< > $@
[425]119else
120$(BUILD_DIR)/platform.ld:
121        $(ECHO) "[  TOUCH  ]     $(notdir $@)"
122        touch $@
123endif
[293]124
[758]125$(BUILD_DIR)/platform.dtb: $(PLATFORM_DIR)/$(DTS)
[388]126        $(ECHO) "[   DTC   ]     $(notdir $<)"
[390]127        ${DTC} -O dtb -o $@ $< &> /dev/null
[293]128
129$(BUILD_DIR):
130        $(MKDIR) $@
131
[388]132doc: Doxyfile
133        $(DOXYGEN) Doxyfile
134
[293]135clean:
136        $(RM) $(TARGET).txt $(TARGET) *~ $(BUILD_DIR)
137
[388]138clean-doc:
139        $(RM) doc
[293]140
[388]141distclean: clean clean-doc
142
[293]143# =============================================================================
144# Implicit makefile rules
145
146$(BUILD_DIR)/%.o: %.c
[388]147        $(ECHO) "[   CC    ]     $(notdir $<)"
[293]148        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
149        $(DU) -D $@ > $@.txt
150
151$(BUILD_DIR)/%.o: %.S
[388]152        $(ECHO) "[   AS    ]     $(notdir $<)"
[293]153        $(CC) $(DEFS) ${INCLUDE} -g -mips32 -c -o $@ $<
154        $(DU) -D $@ > $@.txt
155
Note: See TracBrowser for help on using the repository browser.