-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (62 loc) · 2.01 KB
/
Makefile
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
RAYLIBPATH = $(shell readlink -f raylib)
EMSDKPATH = $(shell readlink -f emsdk)
export PATH := $(EMSDKPATH):$(EMSDKPATH)/upstream/emscripten:$(EMSDKPATH)/node/16.20.0_64bit/bin:$(PATH)
export C_INCLUDE_PATH := $(RAYLIBPATH)/src:$(C_INCLUDE_PATH)
export LIBRARY_PATH := $(RAYLIBPATH)/src:$(RAYLIBPATH)/src/external:$(LIBRARY_PATH)
export LD_LIBRARY_PATH := $(RAYLIBPATH)/src:$(LD_LIBRARY_PATH)
.SUFFIXES:
TARGET=main
SRCS = $(wildcard *.c)
HEADERS = $(wildcard *.h)
OBJS = $(patsubst %.c,%.o,$(SRCS))
P ?= DESKTOP
ifeq ($(P),WEB)
PLATFORM = PLATFORM_WEB
else
PLATFORM = PLATFORM_DESKTOP
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
CC=emcc
LDFLAGS += --shell-file $(RAYLIBPATH)/src/shell.html -s USE_GLFW=3 -s ASYNCIFY -pthread $(RAYLIBPATH)/src/libraylib.a
OUT=main.html
else
CC=gcc
OUT=main
endif
RAYLIB_LIBTYPE ?= STATIC
UNAME_S := $(shell uname -s)
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(UNAME_S),Linux)
CCFLAGS += -D$(PLATFORM)
LDFLAGS += -lraylib -lGL -pthread -ldl -lrt -lX11
RAYLIB_LIBTYPE = SHARED
endif
ifeq ($(UNAME_S),Darwin)
LDFLAGS += $(shell pkg-config --libs --cflags raylib)
endif
endif
CCFLAGS += -Wall -std=c99 -pthread -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O2
LDFLAGS += -lm
.PHONY: raylib raylib-examples setup leaks run debug host emsdk
all: $(TARGET)
debug: CCFLAGS += -g -O0 -DPHYSAC_DEBUG
debug: clean $(TARGET) clean
clean:
rm -f *.o *.wasm *.html *.js $(OUT)
run : $(TARGET)
./$(OUT) $(ARGS)
host :
$(EMSDKPATH)/upstream/emscripten/emrun $(OUT)
leaks: $(TARGET)
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./$(OUT) $(ARGS)
raylib :
cd $(RAYLIBPATH)/src && $(MAKE) clean
cd $(RAYLIBPATH)/src && $(MAKE) PLATFORM=$(PLATFORM) RAYLIB_LIBTYPE=$(RAYLIB_LIBTYPE) CUSTOM_CFLAGS=-pthread
emsdk :
cd $(EMSDKPATH) && ./emsdk install latest && ./emsdk activate latest
raylib-examples : raylib
cd $(RAYLIBPATH)/examples && $(MAKE) PLATFORM=$(PLATFORM)
$(TARGET): $(OBJS)
$(CC) $(CCFLAGS) $(LDFLAGS) $^ -o $(OUT)
%.o: %.c %.h
$(CC) -c $(CCFLAGS) $< -o $@