Makefile 2.3 KB

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