Advertisement
dominus

Untitled

Apr 27th, 2025
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.15 KB | None | 0 0
  1. # Compiler and flags
  2. CC = gcc
  3. CXX = g++
  4. CFLAGS = -w -std=c++20
  5. CXXFLAGS = $(CFLAGS)
  6.  
  7. # Find SDL3 packages using pkg-config
  8. PKGS = sdl3 sdl3-image sdl3-ttf libxml-2.0
  9. CFLAGS += $(shell pkg-config --cflags $(PKGS))
  10. CXXFLAGS += $(shell pkg-config --cflags $(PKGS))
  11. LIBS = $(shell pkg-config --libs $(PKGS))
  12.  
  13. # Directories
  14. SRC_DIR = SDL3Test
  15. OBJ_DIR = obj
  16. BIN_DIR = bin
  17.  
  18. # Find all source files
  19. SRCS = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*.cpp)
  20. OBJS = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(filter %.c,$(SRCS))) \
  21.     $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter %.cpp,$(SRCS)))
  22.  
  23. # Target executable name
  24. TARGET = $(BIN_DIR)/LairwareSDL3
  25.  
  26. # Default target
  27. all: dirs $(TARGET)
  28.  
  29. # Create necessary directories
  30. dirs:
  31.     @mkdir -p $(OBJ_DIR) $(BIN_DIR)
  32.  
  33. # Link object files
  34. $(TARGET): $(OBJS)
  35.     $(CXX) -o $@ $^ $(LIBS)
  36.  
  37. # Compile C source files
  38. $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
  39.     $(CC) $(CFLAGS) -c $< -o $@
  40.  
  41. # Compile C++ source files
  42. $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
  43.     $(CXX) $(CXXFLAGS) -c $< -o $@
  44.  
  45. # Clean up
  46. clean:
  47.     rm -rf $(OBJ_DIR) $(BIN_DIR)
  48.  
  49. # Run the application
  50. run: all
  51.     $(TARGET)
  52.  
  53. .PHONY: all dirs clean run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement