-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (66 loc) · 1.52 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
# Setup the Windows Compiler (In this cross-compiling using mingw64)
MINGW64 = x86_64-w64-mingw32-gcc-10-win32
# Setup the basic compilation flags
# Warn all, extra and compile for c2x
CFLAGS := -Wall -Wextra -Iinclude/
CFLAGS += `sdl2-config --cflags`
SDLFLAGS = `sdl2-config --libs`
LDFLAGS = -lm
ifdef USE_GCC
# Use GNU's GCC Compiler
CC = gcc
CFLAGS += -DUSE_GCC -DPREC23
else
# Use LLVM's frontend CLANG
ifdef CODEQL
CC = clang-15
CFLAGS += -DCODEQL
else
CC = clang
endif
endif
ifdef DBG_OPCODE
CFLAGS += -DOPCODE_DEBUG
endif
ifdef DGB
CFLAGS += -g
endif
ifdef ASAN
CFLAGS += -fsanitize=address
endif
ifdef PREC23
CFLAGS += -DPREC23
else
CFLAGS += -std=c2x
endif
ifeq ($(OS),Windows_NT)
BINARY := gamegirl.exe
HOST := Windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
HOST := Linux
BINARY := gamegirl
SOURCES := $(shell find . -name '*.c')
OBJECTS = $(SOURCES:.c=.o)
endif
endif
.PHONY: clean all
all: clean $(BINARY)
$(BINARY): $(OBJECTS)
@echo " 🚧 Linking..."
ifeq ($(HOST), Linux)
@echo " \033[0;36mLD \033[0mgamegirl"
@$(CC) $(CFLAGS) $(SDLFLAGS) $^ -o $@ $(SDLFLAGS) $(LDFLAGS)
endif
ifeq ($(HOST), Windows)
$(MINGW64) $(CFLAGS) -I$(Win32SDL2Headers) -L$(Win32SDL2Libs) $^ -o $@ -lmingw32 -lSDL2main -lSDL2
endif
%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@
@echo " \033[0;35mCC\033[0m $<"
clean:
@echo "🧹 Cleaning..."
ifeq ($(filter $(BINARY), $(MAKECMDGOALS)),)
$(shell find . -name '*.o' -exec rm {} \;)
endif