Advertisement
Guest User

Untitled

a guest
Nov 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 2.38 KB | None | 0 0
  1. CXX ?= g++
  2.  
  3. # path #
  4. SRC_PATH = $(shell pwd)
  5. BUILD_PATH = Build
  6. BIN_PATH = Application
  7.  
  8. # executable #
  9. BIN_NAME = MyGame
  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. # Set the object file names, with the source directory stripped
  19. # from the path, and the build path prepended in its place
  20. OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o)
  21. # Set the dependency files that will be used to add header dependencies
  22. DEPS = $(OBJECTS:.o=.d)
  23.  
  24. # flags #
  25. COMPILE_FLAGS = -std=c++11 -Wall -Wextra -g
  26. INCLUDES = -I $(SRC_PATH)/TrikytaEngine/libs/includes/ -I $(SRC_PATH)/TrikytaEngine/src/ -I $(SRC_PATH)/PhysicsEngine/ -I $(SRC_PATH)/PhysicsEngine/PhysicsEngine/Core/ -I $(SRC_PATH)/Libraries/src/ -I $(SRC_PATH)/Libraries/src/TinyXML -I $(SRC_PATH)/Libraries/src/zlib -I $(SRC_PATH)/LuaBinds/src/ -I $(SRC_PATH)/LuaBinds/lua/include/ -I $(SRC_PATH)/Game/src/
  27. # Space-separated pkg-config libraries used by this project
  28. LIBS = -LLinuxLibs/ -lSDL2 -LLinuxLibs/ -lSDL2_image -LLinuxLibs/ -lSDL2_ttf -LLinuxLibs/ -llua -LLinuxLibs/ -lz -lm
  29. #`sdl2-config --libs --cflags` -LLinuxLibs/ -lSDL2main -LLinuxLibs/ -lSDL_ttf -LLinuxLibs/ -lSDL2_image
  30. .PHONY: default_target
  31. default_target: release
  32.  
  33. .PHONY: release
  34. release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS)
  35. release: dirs
  36.     @$(MAKE) all
  37.  
  38. .PHONY: dirs
  39. dirs:
  40.     @echo "Creating directories"
  41.     @mkdir -p $(dir $(OBJECTS))
  42.     @mkdir -p $(BIN_PATH)
  43.  
  44. .PHONY: clean
  45. clean:
  46.     @echo "Deleting $(BIN_NAME) symlink"
  47.     @$(RM) $(BIN_NAME)
  48.     @echo "Deleting directories"
  49.     @$(RM) -r $(BUILD_PATH)
  50.     @$(RM) -r $(BIN_PATH)
  51.  
  52. # checks the executable and symlinks to the output
  53. .PHONY: all
  54. all: $(BIN_PATH)/$(BIN_NAME)
  55.     @echo "Making symlink: $(BIN_NAME) -> $<"
  56.     @$(RM) $(BIN_NAME)
  57.     @ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME)
  58.  
  59. # Creation of the executable
  60. $(BIN_PATH)/$(BIN_NAME): $(OBJECTS)
  61.     @echo "Linking: $@"
  62.     $(CXX) $(OBJECTS) -o $@ $(LIBS)
  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. $(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT)
  71.     @echo "Compiling: $< -> $@"
  72.     $(CXX) $(CXXFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement