1### Makefile to build the FreeRTOS library ### 2 3# Build target (options: sim, board) 4 5TARGET = sim 6SMALL = 7 8# Tools 9 10CC = xt-xcc 11AS = xt-xcc 12AR = xt-ar 13XT_CORE = $(patsubst %-params,%,$(notdir $(shell xt-xcc --show-config=core))) 14CONFIGDIR = $(shell xt-xcc --show-config=config) 15 16# For platform-specific commands 17 18include $(CONFIGDIR)/misc/hostenv.mk 19 20# Source code and build locations 21 22SRCROOT = $(subst /,$(S),$(CURDIR)) 23TSTROOT = $(abspath $(SRCROOT)$(S)..$(S)..$(S)..$(S)..$(S)..$(S)demos$(S)cadence$(S)sim$(SMALL)) 24BLDROOT = $(TSTROOT)$(S)build 25BLDDIR = $(BLDROOT)$(S)$(XT_CORE) 26 27FR_SRCDIR = $(abspath $(SRCROOT)$(S)..$(S)..$(S)..) 28FR_SRCDIR2 = $(FR_SRCDIR)$(S)portable$(S)MemMang 29XT_SRCDIR = $(SRCROOT) 30 31vpath %.c $(FR_SRCDIR) $(FR_SRCDIR2) $(XT_SRCDIR) 32vpath %.S $(XT_SRCDIR) 33 34# File lists 35 36FR_C_FILES = $(notdir $(wildcard $(FR_SRCDIR)/*.c)) $(notdir $(wildcard $(FR_SRCDIR2)/*.c)) 37XT_C_FILES = $(notdir $(wildcard $(XT_SRCDIR)/*.c)) 38XT_S_FILES = $(notdir $(wildcard $(XT_SRCDIR)/*.S)) 39 40# List of all .o files that will go into the library 41 42LIB_C_O = $(patsubst %.c,%.o,$(XT_C_FILES) $(FR_C_FILES)) 43LIB_S_O = $(patsubst %.S,%.o,$(XT_S_FILES)) 44LIB_O_LIST = $(addprefix $(BLDDIR)/,$(LIB_C_O) $(LIB_S_O)) 45 46# Output files 47 48OSLIB = $(BLDDIR)$(S)libfreertos.a 49 50# Build options 51 52ifeq ($(TARGET),sim) 53DFLAGS = -DXT_SIMULATOR 54endif 55ifeq ($(TARGET),board) 56DFLAGS = -DXT_BOARD 57endif 58 59IFLAGS = \ 60 -I$(FR_SRCDIR)$(S)..$(S)include -I$(FR_SRCDIR)$(S)..$(S)include$(S)private \ 61 -I$(XT_SRCDIR) -I$(TSTROOT)$(S)common$(S)config_files -I$(BLDDIR) 62 63CFLAGS = -O2 -g 64CCFLAGS = $(CFLAGS) -Wall -mno-coproc -mlongcalls -ffunction-sections -mno-l32r-flix $(DFLAGS) 65ASFLAGS = $(CCFLAGS) 66 67# Include dependency rules (generated using -MD) 68 69-include $(wildcard $(BLDDIR)/*.d) 70 71# Targets 72 73all : mkdir $(OSLIB) 74 75mkdir : $(BLDDIR)/.mkdir 76 77$(BLDDIR)/.mkdir : 78 @$(MKPATH) $(BLDDIR) 79 @echo "" > $@ 80 -$(CP) $(CONFIGDIR)/xtensa-elf/include/sys/reent.h $(BLDDIR)/reent.h 81 82$(OSLIB) : $(LIB_O_LIST) 83 $(AR) -rs $@ $^ 84 85$(BLDDIR)/%.o : %.c 86 $(CC) $(CCFLAGS) $(IFLAGS) -MD -MF $(subst .o,.d,$@) -c -o $@ $< 87 88$(BLDDIR)/%.o : %.S 89 $(CC) $(ASFLAGS) $(IFLAGS) -MD -MF $(subst .o,.d,$@) -c -o $@ $< 90 91clean : 92 $(RM_R) $(BLDDIR) 93 94clean_all : 95 $(RM_R) $(BLDROOT) 96 97.PHONY : all mkdir clean clean_all 98