-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (80 loc) · 2.48 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Set the windows path you want to move the game inorder to run it (use /mnt/ befor the path so you can access you disk)
WIN_PATH := /mnt/c/Users/Georg/Desktop/
# Set the name of the output
EXEC := index
# paths
LIB := libs
INCLUDE := ./include -I ./include/raylib
SRC := ./src
BUILD := ./build
#Program args
ARGS := 3
#Default compiler
CC := gcc
CXX := g++
#Debug mode
DEBUG := false
#Exta libs
LIBS := -lraylib
EXTRA :=
#For web emcc path
EMCC_ARGS := -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=10
EMCC_PATH := /home/george/Documents/emsdk
EMCC_TEMPLATE := $(LIB)/web/template.html
################################### DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ###################################
# Makefile options
PLATFORM = LINUX
#compiler options
CFLAGS = -I$(INCLUDE)
CXXFLAGS = -I$(INCLUDE)
LDFLAGS = -lm
SRCS := $(shell find $(SRC) -name '*.c')
OBJS := $(SRCS:$(SRC)/%.c=$(SRC)/%.o)
OBJPATH := $(addprefix $(BUILD)/,$(notdir $(OBJS)))
SRCS_CXX := $(shell find $(SRC) -name '*.cpp')
OBJS_CXX := $(SRCS_CXX:$(SRC)/%.cpp=$(SRC)/%.opp)
OBJPATH_CXX := $(addprefix $(BUILD)/,$(notdir $(OBJS_CXX)))
ifneq ($(PLATFORM),WEB)
ifeq ($(DEBUG),true)
CFLAGS += -ggdb -Wall -Werror
else
CFLAGS += -O3 -Werror
endif
endif
ifeq ($(PLATFORM),WIN)
LDFLAGS += -L$(LIB)/windows/ $(LIBS) -lgdi32 -lwinmm -lopengl32 -lpthread
CC = x86_64-w64-mingw32-gcc
CXX = x86_64-w64-mingw32-g++
EXEC :=$(EXEC).exe
else ifeq ($(PLATFORM),LINUX)
LDFLAGS += -L$(LIB)/linux $(LIBS) -lGL -lpthread -ldl -lrt -lX11
WIN_PATH = ./
else ifeq ($(PLATFORM),WEB)
CC := emcc
CXX := em++
CFLAGS += -DWASM
LDFLAGS += -L$(LIB)/web $(LIBS) -s ASYNCIFY -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 $(EMCC_ARGS) --shell-file $(EMCC_TEMPLATE)
# SHELL := /bin/bash
EXEC := $(EXEC).html
ifneq (,$(wildcard assets))
LDFLAGS += --preload-file=assets
endif
endif
$(SRC)/%.opp: $(SRC)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@ && mv $@ $(BUILD)
$(SRC)/%.o: $(SRC)/%.c
$(CC) $(CFLAGS) -c $< -o $@ && mv $@ $(BUILD)
$(EXEC):$(OBJS) $(OBJS_CXX) $(EXTRA)
$(CXX) $(OBJPATH) $(OBJPATH_CXX) $(EXTRA) -o $(EXEC) $(LDFLAGS)
EMCC:
$(EMCC_PATH)/emsdk activate latest
source $(EMCC_PATH)/emsdk_env.sh
#Cleaning
PHONY clean:
rm -f $(BUILD)/*.o $(BUILD)/*.opp $(EXTRA) $(EXEC).exe $(EXEC) $(EXEC).html $(EXEC).js $(EXEC).wasm $(EXEC).data *.js
valgrind:
$(MAKE) clean
$(MAKE) $(EXEC) DEBUG=true
valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./$(EXEC) $(ARGS)
run: $(EXEC)
./$(EXEC) $(ARGS)