Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2025
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.60 KB | Source Code | 0 0
  1. # to compile and run in one command type:
  2. # make run
  3.  
  4. # define which compiler to use
  5. CXX     := g++
  6. OUTPUT  := sfmlgame
  7. OS      := $(shell uname)
  8. SRC_DIR := ./src
  9.  
  10. # linux compiler / linker flags
  11. ifeq ($(OS), Linux)
  12.     CXX_FLAGS := -O3 -std=c++20 -Wno-unused-result -Wno-deprecated-declarations
  13.     INCLUDES  := -I$(SRC_DIR) -I$(SRC_DIR)/imgui
  14.     LDFLAGS   := -O3 -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lGL
  15. endif
  16.  
  17. # mac osx compiler / linker flags
  18. ifeq ($(OS), Darwin)
  19.     SFML_DIR  := /opt/homebrew/Cellar/sfml/2.6.1
  20.     CXX_FLAGS := -O3 -std=c++20 -Wno-unused-result -Wno-deprecated-declarations
  21.     INCLUDES  := -I$(SRC_DIR) -I$(SRC_DIR)/imgui -I$(SFML_DIR)/include
  22.     LDFLAGS   := -O3 -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -L$(SFML_DIR)/lib -framework OpenGL
  23. endif
  24.  
  25. # the source files for the ecs game engine
  26. SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp $(SRC_DIR)/imgui/*.cpp)
  27. OBJ_FILES := $(SRC_FILES:.cpp=.o)
  28.  
  29. # Include dependency files
  30. DEP_FILES := $(OBJ_FILES:.o=.d)
  31. -include $(DEP_FILES)
  32.  
  33. # all of these targets will be made if you just type make
  34. all: $(OUTPUT)
  35.  
  36. # define the main executable requirements / command
  37. $(OUTPUT): $(OBJ_FILES) Makefile
  38.     $(CXX) $(OBJ_FILES) $(LDFLAGS) -o ./bin/$@
  39.  
  40. # specifies how the object files are compiled from cpp files
  41. %.o: %.cpp
  42.     $(CXX) -MMD -MP -c $(CXX_FLAGS) $(INCLUDES) $< -o $@
  43.  
  44. # typing 'make clean' will remove all intermediate build files
  45. clean:
  46.     rm -f $(OBJ_FILES) $(DEP_FILES) ./bin/$(OUTPUT)
  47.  
  48. # typing 'make run' will compile and run the program
  49. run: $(OUTPUT)
  50.     cd bin && ./$(OUTPUT) && cd ..
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement