dragonbane

MakeFile

Mar 31st, 2021 (edited)
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 KB | None | 0 0
  1. #---------------------------------------------------------------------------------
  2. # Clear the implicit built in rules
  3. #---------------------------------------------------------------------------------
  4. .SUFFIXES:
  5. #---------------------------------------------------------------------------------
  6. ifeq ($(strip $(DEVKITPPC)),)
  7. $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
  8. endif
  9. ifeq ($(strip $(DEVKITPRO)),)
  10. $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
  11. endif
  12.  
  13. PREFIX := powerpc-eabi-
  14.  
  15. export AS := $(PREFIX)as
  16. export CC := $(PREFIX)gcc
  17. export CXX := $(PREFIX)g++
  18. export AR := $(PREFIX)ar
  19. export OBJCOPY := $(PREFIX)objcopy
  20.  
  21. #---------------------------------------------------------------------------------
  22. # TARGET is the name of the output
  23. # BUILD is the directory where object files & intermediate files will be placed
  24. # SOURCES is a list of directories containing source code
  25. # INCLUDES is a list of directories containing extra header files
  26. #---------------------------------------------------------------------------------
  27. TARGET := build/lib
  28. BUILD := build
  29. BUILD_DBG := $(TARGET)_dbg
  30. SOURCES := source \
  31. source/common \
  32. source/imports \
  33. source/network \
  34. source/memory \
  35. source/watcher \
  36. source/watcher/Common \
  37. source/watcher/EmuProcess \
  38. source/utils
  39. DATA :=
  40.  
  41. INCLUDES := source
  42.  
  43. #---------------------------------------------------------------------------------
  44. # options for code generation
  45. # DB: if the C++ .eh_frame sections are problematic, remove them from CXXFLAGS via -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
  46. # DB: -fno-common: Disable common section allowing uninitialized variables to reserve space and work with the RomHack compiler
  47. #---------------------------------------------------------------------------------
  48. CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math -G 0 \
  49. -ffunction-sections -fdata-sections \
  50. -fno-common \
  51. -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-unused-label -Wno-strict-aliasing \
  52. -O3 $(INCLUDE)
  53. CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math -G 0 \
  54. -ffunction-sections -fdata-sections \
  55. -fno-common \
  56. -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-unused-label -Wno-strict-aliasing \
  57. -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables \
  58. -O3 $(INCLUDE)
  59. ASFLAGS := -mregnames
  60. LDFLAGS := -nostartfiles -Wl,-Map,$(notdir $@).map,--gc-sections
  61.  
  62. #---------------------------------------------------------------------------------
  63. Q := @
  64. MAKEFLAGS += --no-print-directory
  65.  
  66. #---------------------------------------------------------------------------------
  67. # no real need to edit anything past this point unless you need to add additional
  68. # rules for different file extensions
  69. #---------------------------------------------------------------------------------
  70. ifneq ($(BUILD),$(notdir $(CURDIR)))
  71. #---------------------------------------------------------------------------------
  72. export PROJECTDIR := $(CURDIR)
  73. export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
  74. export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  75. $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  76. export DEPSDIR := $(CURDIR)/$(BUILD)
  77.  
  78. #---------------------------------------------------------------------------------
  79. # automatically build a list of object files for our project
  80. #---------------------------------------------------------------------------------
  81. CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  82. CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  83. sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  84. SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
  85.  
  86. #---------------------------------------------------------------------------------
  87. # use CXX for linking C++ projects, CC for standard C
  88. #---------------------------------------------------------------------------------
  89. ifeq ($(strip $(CPPFILES)),)
  90. export LD := $(CC)
  91. else
  92. export LD := $(CXX)
  93. endif
  94.  
  95. export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
  96. $(sFILES:.s=.o) $(SFILES:.S=.o)
  97.  
  98. #---------------------------------------------------------------------------------
  99. # build a list of include paths
  100. #---------------------------------------------------------------------------------
  101. export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir))
  102.  
  103.  
  104. export OUTPUT := $(CURDIR)/$(TARGET)
  105. .PHONY: $(BUILD) clean install
  106.  
  107. #---------------------------------------------------------------------------------
  108. $(BUILD):
  109. @[ -d $@ ] || mkdir -p $@
  110. @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
  111.  
  112. #---------------------------------------------------------------------------------
  113. clean:
  114. @echo clean ...
  115. @rm -fr $(BUILD)
  116.  
  117. #---------------------------------------------------------------------------------
  118. else
  119.  
  120. DEPENDS := $(OFILES:.o=.d)
  121.  
  122. #---------------------------------------------------------------------------------
  123. # main targets
  124. #---------------------------------------------------------------------------------
  125. $(OUTPUT).a: $(OFILES)
  126.  
  127. #---------------------------------------------------------------------------------
  128. %.a:
  129. #---------------------------------------------------------------------------------
  130. @echo $(notdir $@)
  131. @rm -f $@
  132. @$(AR) -rc $@ $^
  133.  
  134. #---------------------------------------------------------------------------------
  135. %.o: %.cpp
  136. @echo $(notdir $<)
  137. @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER)
  138.  
  139. #---------------------------------------------------------------------------------
  140. %.o: %.c
  141. @echo $(notdir $<)
  142. @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER)
  143.  
  144. #---------------------------------------------------------------------------------
  145. %.o: %.S
  146. @echo $(notdir $<)
  147. @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
  148.  
  149.  
  150. -include $(DEPENDS)
  151.  
  152. #---------------------------------------------------------------------------------
  153. endif
  154. #---------------------------------------------------------------------------------
  155.  
Add Comment
Please, Sign In to add comment