Guest User

Untitled

a guest
Jul 16th, 2022
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.63 KB | None | 0 0
  1. #---------------------------------------------------------------------------------
  2. # Clear the implicit built in rules
  3. #---------------------------------------------------------------------------------
  4. .SUFFIXES:
  5. #---------------------------------------------------------------------------------
  6. # Set toolchain location in an environment var for future use, this will change
  7. # to use a system environment var in the future.
  8. #---------------------------------------------------------------------------------
  9. ifeq ($(strip $(FXCGSDK)),)
  10. export FXCGSDK := $(abspath ../../../)
  11. endif
  12.  
  13. include $(FXCGSDK)/toolchain/prizm_rules
  14.  
  15.  
  16. #---------------------------------------------------------------------------------
  17. # TARGET is the name of the output
  18. # BUILD is the directory where object files & intermediate files will be placed
  19. # SOURCES is a list of directories containing source code
  20. # INCLUDES is a list of directories containing extra header files
  21. #---------------------------------------------------------------------------------
  22. TARGET := $(notdir $(CURDIR))
  23. BUILD := build
  24. SOURCES := src
  25. DATA := data
  26. INCLUDES :=
  27.  
  28. #---------------------------------------------------------------------------------
  29. # options for code and add-in generation
  30. #---------------------------------------------------------------------------------
  31.  
  32. MKG3AFLAGS := -n basic:heythere -i uns:../unselected.bmp -i sel:../selected.bmp
  33.  
  34. # Optional: add -flto to CFLAGS and LDFLAGS to enable link-time optimization
  35. # (LTO). Doing so will usually allow the compiler to generate much better code
  36. # (smaller and/or faster), but may expose bugs in your code that don't cause
  37. # any trouble without LTO enabled.
  38. CFLAGS = -Os -Wall $(MACHDEP) $(INCLUDE) -ffunction-sections -fdata-sections
  39. CXXFLAGS = $(CFLAGS) -fno-exceptions
  40.  
  41. LDFLAGS = $(MACHDEP) -T$(FXCGSDK)/toolchain/prizm.x -Wl,-static -Wl,-gc-sections
  42.  
  43. #---------------------------------------------------------------------------------
  44. # any extra libraries we wish to link with the project
  45. #---------------------------------------------------------------------------------
  46. LIBS := -lc -lfxcg -lgcc
  47.  
  48. #---------------------------------------------------------------------------------
  49. # list of directories containing libraries, this must be the top level containing
  50. # include and lib
  51. #---------------------------------------------------------------------------------
  52. LIBDIRS :=
  53.  
  54. #---------------------------------------------------------------------------------
  55. # no real need to edit anything past this point unless you need to add additional
  56. # rules for different file extensions
  57. #---------------------------------------------------------------------------------
  58. ifneq ($(BUILD),$(notdir $(CURDIR)))
  59. #---------------------------------------------------------------------------------
  60.  
  61. export OUTPUT := $(CURDIR)/$(TARGET)
  62.  
  63. export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  64. $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  65.  
  66. export DEPSDIR := $(CURDIR)/$(BUILD)
  67.  
  68. #---------------------------------------------------------------------------------
  69. # automatically build a list of object files for our project
  70. #---------------------------------------------------------------------------------
  71. CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  72. CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  73. sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  74. SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
  75. BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  76.  
  77. #---------------------------------------------------------------------------------
  78. # use CXX for linking C++ projects, CC for standard C
  79. #---------------------------------------------------------------------------------
  80. ifeq ($(strip $(CPPFILES)),)
  81. export LD := $(CC)
  82. else
  83. export LD := $(CXX)
  84. endif
  85.  
  86. export OFILES := $(addsuffix .o,$(BINFILES)) \
  87. $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
  88. $(sFILES:.s=.o) $(SFILES:.S=.o)
  89.  
  90. #---------------------------------------------------------------------------------
  91. # build a list of include paths
  92. #---------------------------------------------------------------------------------
  93. export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
  94. $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  95. -I$(CURDIR)/$(BUILD) -I$(LIBFXCG_INC)
  96.  
  97. #---------------------------------------------------------------------------------
  98. # build a list of library paths
  99. #---------------------------------------------------------------------------------
  100. export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
  101. -L$(LIBFXCG_LIB)
  102.  
  103. export OUTPUT := $(CURDIR)/$(TARGET)
  104. .PHONY: all clean
  105.  
  106. #---------------------------------------------------------------------------------
  107. all: $(BUILD)
  108. @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
  109.  
  110. $(BUILD):
  111. @mkdir $@
  112.  
  113. #---------------------------------------------------------------------------------
  114. export CYGWIN := nodosfilewarning
  115. clean:
  116. $(call rmdir,$(BUILD))
  117. $(call rm,$(OUTPUT).bin)
  118. $(call rm,$(OUTPUT).g3a)
  119.  
  120. #---------------------------------------------------------------------------------
  121. else
  122.  
  123. DEPENDS := $(OFILES:.o=.d)
  124.  
  125. #---------------------------------------------------------------------------------
  126. # main targets
  127. #---------------------------------------------------------------------------------
  128. $(OUTPUT).g3a: $(OUTPUT).bin
  129. $(OUTPUT).bin: $(OFILES)
  130.  
  131.  
  132. -include $(DEPENDS)
  133.  
  134. #---------------------------------------------------------------------------------
  135. endif
  136. #---------------------------------------------------------------------------------
  137.  
Advertisement
Add Comment
Please, Sign In to add comment