Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CXX ?= g++
- # path #
- SRC_PATH = src
- BUILD_PATH = build
- BIN_PATH = $(BUILD_PATH)/bin
- # executable #
- BIN_NAME = AA02
- # extensions #
- SRC_EXT = cpp
- # code lists #
- # Find all source files in the source directory, sorted by
- # most recently modified
- # SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' | sort -k 1nr | cut -f2-)
- SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' -printf '%T@ %p\n' | sort -k 1nr | cut -d ' ' -f 2)
- # Set the object file names, with the source directory stripped
- # from the path, and the build path prepended in its place
- OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o)
- # Set the dependency files that will be used to add header dependencies
- DEPS = $(OBJECTS:.o=.d)
- # flags #
- COMPILE_FLAGS = -std=c++17 -Wall -Wextra -g
- # Space-separated pkg-config libraries used by this project
- LIBS = `pkg-config --cflags --libs sdl2 vulkan`
- INCLUDES = -I include/ -I /usr/local/include -I$(VULKAN_SDK)/include
- .PHONY: default_target
- default_target: release
- .PHONY: release
- release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS)
- release: dirs
- @$(MAKE) all
- .PHONY: dirs
- dirs:
- @mkdir -p $(dir $(OBJECTS))
- @mkdir -p $(BIN_PATH)
- # @echo "Deleting directories and $(BIN_NAME) symlink"
- .PHONY: clean
- clean:
- @$(RM) $(BIN_NAME)
- @$(RM) -r $(BUILD_PATH)
- @$(RM) -r $(BIN_PATH)
- # checks the executable and symlinks to the output
- # @echo "Making symlink: $(BIN_NAME) -> $<"
- .PHONY: all
- all: $(BIN_PATH)/$(BIN_NAME)
- @$(RM) $(BIN_NAME)
- @ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME)
- # Creation of the executable
- # @echo "Linking: $@"
- $(BIN_PATH)/$(BIN_NAME): $(OBJECTS)
- $(CXX) $(OBJECTS) $(LIBS) -o $@
- # Add dependency files, if they exist
- -include $(DEPS)
- # Source file rules
- # After the first compilation they will be joined with the rules from the
- # dependency files to provide header dependencies
- # @echo "Compiling: $< -> $@"
- $(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT)
- $(CXX) $(CXXFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@
- run:
- $(MAKE) clean
- +$(MAKE) -j
- ./AA02
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement