-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
47 lines (39 loc) · 1.17 KB
/
Copy pathmakefile
File metadata and controls
47 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Detect OS
UNAME := $(shell uname)
# Source and output
SRC := ./src/main.cpp
OUT_DIR := ./build
OUT := $(OUT_DIR)/main
ifeq ($(UNAME), Windows_NT)
OUT := $(OUT).exe
endif
# Optional: user override for raylib paths
RAYLIB_DIR ?= ./raylib # Default relative location
RAYLIB_INCLUDE ?= $(RAYLIB_DIR)
RAYLIB_EXTERNAL ?= $(RAYLIB_DIR)
# Ensure build dir exists
$(shell mkdir -p $(OUT_DIR))
# Compiler and flags
CXX := g++
CXXFLAGS := -std=c++17 -g -O2 -Wall -Wno-narrowing -Wno-missing-braces
CPPFLAGS := -I. -I$(RAYLIB_INCLUDE) -I$(RAYLIB_EXTERNAL)
ifeq ($(UNAME), Linux)
LIBS := -L$(RAYLIB_DIR) -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -latomic
DEFINES := -DPLATFORM_DESKTOP -DPLATFORM_DESKTOP_GLFW -D_DEFAULT_SOURCE
else ifeq ($(UNAME), Darwin)
LIBS := -L$(RAYLIB_DIR) -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
DEFINES := -DPLATFORM_DESKTOP
else
CPPFLAGS += -I$(RAYLIB_DIR)
LIBS := -L$(RAYLIB_DIR) -lraylib -lgdi32 -lwinmm
DEFINES := -DPLATFORM_DESKTOP
endif
# Build target
main: $(SRC)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DEFINES) -o $(OUT) $^ $(LIBS)
# Run target
run: main
$(OUT)
# Clean build artifacts
clean:
rm -rf $(OUT_DIR)/*