Advertisement
kiwidog

liborbis/bigboss SDL2 makefile port

Jan 29th, 2020
1,215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 2.70 KB | None | 0 0
  1. # Project name
  2. PROJ_NAME := BIGBOSS_SDL2
  3.  
  4. # C++ compiler
  5. CPPC    :=  clang++
  6.  
  7. # Linker
  8. LNK     := ld
  9.  
  10. # C compiler
  11. CC      :=  clang
  12.  
  13. # Archiver
  14. AS      :=  llvm-ar
  15.  
  16. # Objcopy
  17. OBJCOPY :=  objcopy
  18.  
  19. # Output directory, by default is build
  20. ifeq ($(OUT_DIR),)
  21. OUT_DIR :=  Build
  22. endif
  23.  
  24. # Source directory
  25. SRC_DIR :=  source
  26.  
  27. # Include directory paths
  28. I_DIRS  :=  -I$(OO_PS4_TOOLCHAIN)/include -Iinclude
  29.  
  30. # Library directory paths
  31. L_DIRS  :=  -L. -L$(OO_PS4_TOOLCHAIN)/lib
  32.  
  33. # Included libraries
  34. LIBS    := -lc -lm
  35.  
  36. # Orbis flags
  37. ORB_VER := -D_DEBUG -D__ORBIS__ -D__PS4__
  38.  
  39. # C++ Flags
  40. CFLAGS  := $(I_DIRS) $(ORB_VER) -g -std=c11 -O0 -msse2 -mavx -target x86_64-scei-ps4 -Wall -Werror -Wno-unknown-pragmas
  41.  
  42. # Assembly flags
  43. SFLAGS  :=
  44.  
  45. # Linker flags
  46. LFLAGS  := -v $(L_DIRS) -nostdlib
  47.  
  48. # Calculate the listing of all file paths
  49. CFILES  :=  $(wildcard $(SRC_DIR)/*.c)
  50. CPPFILES := $(wildcard $(SRC_DIR)/*.cpp)
  51. SFILES  :=  $(wildcard $(SRC_DIR)/*.s)
  52. OBJS    :=  $(patsubst $(SRC_DIR)/%.s, $(OUT_DIR)/$(SRC_DIR)/%.o, $(SFILES)) $(patsubst $(SRC_DIR)/%.c, $(OUT_DIR)/$(SRC_DIR)/%.o, $(CFILES)) $(patsubst $(SRC_DIR)/%.cpp, $(OUT_DIR)/$(SRC_DIR)/%.o, $(CPPFILES))
  53.  
  54. ALL_CPP := $(shell find $(SRC_DIR)/ -type f -name '*.cpp')
  55. ALL_C   := $(shell find $(SRC_DIR)/ -type f -name '*.c')
  56. ALL_S   := $(shell find $(SRC_DIR)/ -type f -name '*.s')
  57.  
  58. ALL_SOURCES :=  $(ALL_S) $(ALL_C) $(ALL_CPP)
  59. TO_BUILD := $(ALL_S:$(SRC_DIR)%=$(OUT_DIR)/$(SRC_DIR)%) $(ALL_C:$(SRC_DIR)%=$(OUT_DIR)/$(SRC_DIR)%) $(ALL_CPP:$(SRC_DIR)%=$(OUT_DIR)/$(SRC_DIR)%)
  60. ALL_OBJ_CPP := $(TO_BUILD:.cpp=.o)
  61. ALL_OBJ_C := $(ALL_OBJ_CPP:.c=.o)
  62. ALL_OBJ := $(ALL_OBJ_C:.s=.o)
  63.  
  64. # Target elf name
  65. TARGET = "$(PROJ_NAME).elf"
  66.  
  67. # Target payload name (data + text only, no elf)
  68. PAYLOAD = "$(PROJ_NAME).bin"
  69.  
  70. $(TARGET): $(ALL_OBJ)
  71.     @echo Compiling $(PROJ_NAME)...
  72.     @$(CC) $(ALL_OBJ) -o $(OUT_DIR)/$(TARGET) $(LFLAGS) $(LIBS)
  73.  
  74. $(OUT_DIR)/$(SRC_DIR)/%.o: $(SRC_DIR)/%.c
  75.     @echo "Compiling $< ..."
  76.     @clang-tidy -checks=clang-analyzer-*,bugprone-*,portability-*,cert-* $< -- $(I_DIRS) $(C_DEFS)
  77.     @$(CC) $(CFLAGS) $(IDIRS) -c $< -o $@
  78.  
  79. $(OUT_DIR)/$(SRC_DIR)/%.o: $(SRC_DIR)/%.cpp
  80.     @echo "Compiling $< ..."
  81.     @clang-tidy -checks=clang-analyzer-*,bugprone-*,portability-*,cert-* $< -- $(I_DIRS) $(C_DEFS)
  82.     @$(CPPC) $(CFLAGS) $(IDIRS) -c $< -o $@
  83.  
  84. $(OUT_DIR)/$(SRC_DIR)/%.o: $(SRC_DIR)/%.s
  85.     @echo "Compiling $< ..."
  86.     @$(CC) -c -o $@ $< $(SFLAGS)
  87.  
  88. .PHONY: clean
  89.  
  90. clean:
  91.     @echo "Cleaning project..."
  92.     @rm -f $(TARGET) $(PAYLOAD) $(shell find $(OUT_DIR)/ -type f -name '*.o') $(shell find $(OUT_DIR)/ -type f -name '*.bin') $(shell find $(OUT_DIR)/ -type f -name '*.elf')
  93.  
  94. create:
  95.     @echo "Creating directories..."
  96.     @mkdir -p $(shell find '$(SRC_DIR)/' -type d -printf '$(OUT_DIR)/%p\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement