-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (37 loc) · 1.49 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
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
src := $(call rwildcard,./,*.cpp)
obj = $(patsubst %.cpp,%.o,$(src))
LDFLAGS = -lsfml-graphics -lsfml-window -lsfml-system
OTHER_FLAGS = -g -Wall
INTELMAC_INCLUDE=-I/usr/local/include # Intel mac
APPLESILICON_INCLUDE=-I/opt/homebrew/include # Apple Silicon
UBUNTU_APPLESILICON_INCLUDE=-I/usr/include # Apple Silicon Ubuntu VM
UBUNTU_INTEL_INCLUDE=-I/usr/include # Intel Ubuntu VM
INTELMAC_LIB=-L/usr/local/lib # Intel mac
APPLESILICON_LIB=-L/opt/homebrew/lib # Apple Silicon
UBUNTU_APPLESILICON_LIB=-L/usr/lib/aarch64-linux-gnu # Apple Silicon Ubuntu VM
UBUNTU_INTEL_LIB=-L/usr/lib/x86_64-linux-gnu # Intel Ubuntu VM
MACOS_INCLUDE=$(APPLESILICON_INCLUDE)
MACOS_LIB=$(APPLESILICON_LIB)
UBUNTU_INCLUDE=$(UBUNTU_APPLESILICON_INCLUDE)
UBUNTU_LIB=$(UBUNTU_APPLESILICON_LIB)
MACOS_COMPILER=/usr/bin/clang++
UBUNTU_COMPILER=/usr/bin/g++
all: main
uname_s := $(shell uname -s)
main: $(obj)
ifeq ($(uname_s),Darwin)
$(MACOS_COMPILER) -std=c++17 -o $@ $^ $(LDFLAGS) $(OTHER_FLAGS) $(MACOS_LIB)
else ifeq ($(uname_s),Linux)
$(UBUNTU_COMPILER) -std=c++17 -o $@ $^ $(LDFLAGS) $(OTHER_FLAGS) $(UBUNTU_LIB)
endif
uname_s := $(shell uname -s)
%.o: %.cpp
ifeq ($(uname_s),Darwin)
$(MACOS_COMPILER) -std=c++17 -c $^ -o $@ $(OTHER_FLAGS)$(MACOS_INCLUDE)
else ifeq ($(uname_s),Linux)
$(UBUNTU_COMPILER) -std=c++17 -c $^ -o $@ $(OTHER_FLAGS) $(UBUNTU_INCLUDE)
endif
.PHONY: clean
clean:
rm -f $(obj) main