-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
56 lines (45 loc) · 1.26 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
#### MAKEFILE
#### Generated by myself.
#### Currently support two platforms:
#### - MacOS
#### - Windows
## Compiler settings.
CC := g++
CLANG := clang++
CFLAGS := -std=c++17 -O3 # -Og -Wall -Wextra
## Basic settings.
TARGET := bricks
BUILDDIR := build
ICDDIR := src
SRCDIR := src
## Add your *.cpp file here, make sure they are under SRCDIR folder.
SOURCES := $(wildcard $(addprefix $(SRCDIR)/, *.cpp))
INCLUDES := $(wildcard $(addprefix $(ICDDIR)/, *.h))
OBJECTS := $(addprefix $(BUILDDIR)/, $(notdir $(SOURCES:.cpp=.o)))
ifeq ($(OS),Windows_NT)
MKDIR := if not exist $(BUILDDIR) mkdir $(BUILDDIR)
RUN :=
PLATFORM := win32
CLEAN := if exist $(BUILDDIR) rmdir /s /q $(BUILDDIR)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
MKDIR := mkdir -p $(BUILDDIR)
RUN := ./
PLATFORM := macos
CLEAN := rm -rf $(BUILDDIR)
endif
endif
all: $(PLATFORM)
prepare:
@$(MKDIR)
macos: prepare $(OBJECTS)
@$(CLANG) -o $(TARGET) -framework Cocoa $(CFLAGS) platform/macos.mm $(OBJECTS)
win32: prepare $(OBJECTS)
@$(CC) -o $(TARGET).exe $(CFLAGS) platform/win32.cpp $(OBJECTS) -lgdi32
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp $(INCLUDES)
@$(CC) $(CFLAGS) -I$(ICDDIR) -o $@ -c $<
clean:
@$(CLEAN)
run: $(PLATFORM)
@$(RUN)$(TARGET)