Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 2.15 KB | None | 0 0
  1. CXX ?= g++
  2.  
  3. # path #
  4. SRC_PATH = src
  5. BUILD_PATH = build
  6. BIN_PATH = $(BUILD_PATH)/bin
  7.  
  8. # executable #
  9. BIN_NAME = AA02
  10.  
  11. # extensions #
  12. SRC_EXT = cpp
  13.  
  14. # code lists #
  15. # Find all source files in the source directory, sorted by
  16. # most recently modified
  17. # SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' | sort -k 1nr | cut -f2-)
  18. SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' -printf '%T@ %p\n' | sort -k 1nr | cut -d ' ' -f 2)
  19.  
  20. # Set the object file names, with the source directory stripped
  21. # from the path, and the build path prepended in its place
  22. OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o)
  23. # Set the dependency files that will be used to add header dependencies
  24. DEPS = $(OBJECTS:.o=.d)
  25.  
  26. # flags #
  27. COMPILE_FLAGS = -std=c++17 -Wall -Wextra -g
  28. # Space-separated pkg-config libraries used by this project
  29. LIBS = `pkg-config --cflags --libs sdl2 vulkan`
  30. INCLUDES = -I include/ -I /usr/local/include -I$(VULKAN_SDK)/include
  31.  
  32. .PHONY: default_target
  33. default_target: release
  34.  
  35. .PHONY: release
  36. release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS)
  37. release: dirs
  38.         @$(MAKE) all
  39.  
  40. .PHONY: dirs
  41. dirs:
  42.         @mkdir -p $(dir $(OBJECTS))
  43.         @mkdir -p $(BIN_PATH)
  44.  
  45. #       @echo "Deleting directories and $(BIN_NAME) symlink"
  46. .PHONY: clean
  47. clean:
  48.         @$(RM) $(BIN_NAME)
  49.         @$(RM) -r $(BUILD_PATH)
  50.         @$(RM) -r $(BIN_PATH)
  51.  
  52. # checks the executable and symlinks to the output
  53. # @echo "Making symlink: $(BIN_NAME) -> $<"
  54. .PHONY: all
  55. all: $(BIN_PATH)/$(BIN_NAME)
  56.         @$(RM) $(BIN_NAME)
  57.         @ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME)
  58.  
  59. # Creation of the executable
  60. # @echo "Linking: $@"
  61. $(BIN_PATH)/$(BIN_NAME): $(OBJECTS)
  62.         $(CXX) $(OBJECTS) $(LIBS) -o $@
  63.  
  64. # Add dependency files, if they exist
  65. -include $(DEPS)
  66.  
  67. # Source file rules
  68. # After the first compilation they will be joined with the rules from the
  69. # dependency files to provide header dependencies
  70.  
  71. #       @echo "Compiling: $< -> $@"
  72. $(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT)
  73.         $(CXX) $(CXXFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@
  74.  
  75. run:
  76.         $(MAKE) clean
  77.         +$(MAKE) -j
  78.         ./AA02
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement