-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile.base
More file actions
83 lines (57 loc) · 1.96 KB
/
Makefile.base
File metadata and controls
83 lines (57 loc) · 1.96 KB
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
DOCKERMAKE=buildtools/docker-make
JOBS := $(shell nproc)
PUID := $(shell id -u)
PGID := $(shell id -g)
OUTPUT = build/$(EXE)
CC = $(COMPILER_PREFIX)-gcc
CXX = $(COMPILER_PREFIX)-g++
STRIP = $(COMPILER_PREFIX)-strip
ifeq ($(NOLTO),1)
LTO :=
else
LTO := -flto
endif
ifeq ($(NDEBUG),1)
OPT := -O3 $(LTO) -static
else
OPT := -Og -ggdb
endif
ifeq ($(SANITIZE),1)
OPT += -fsanitize=address
endif
CFLAGS = $(OPT) -Wall
CXXFLAGS = $(OPT) -Wall -std=c++17
CPPFLAGS ?= -MMD -MP
SRCS_C := $(wildcard src/*.c)
SRCS_CXX := $(wildcard src/*.cpp)
BUILDDIR = build/$(PLATFORM)
OBJS := $(SRCS_C:src/%.c=$(BUILDDIR)/%.c.o)
OBJS += $(SRCS_CXX:src/%.cpp=$(BUILDDIR)/%.cpp.o)
DEPS = $(OBJS:.o=.d)
all: $(OUTPUT)
$(OUTPUT): builddir $(OBJS)
$(CXX) $(CXXFLAGS) -o $(OUTPUT) $(OBJS) $(LDFLAGS)
strip: $(OUTPUT)
$(STRIP) --strip-all $(OUTPUT) || true
llvm-strip -x --strip-unneeded $(OUTPUT) || true
$(BUILDDIR)/%.c.o: src/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BUILDDIR)/%.cpp.o: src/%.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
clean:
rm -rfv build/
builddir:
mkdir -p $(BUILDDIR)
x64-linux:
$(DOCKERMAKE) NDEBUG=1 -j$(JOBS) strip CXX="zig c++ -target x86_64-linux-musl" TARGET="x86_64-linux-musl" EXE="3it-x64-linux" PLATFORM="x86_64-linux-musl"
x64-windows:
$(DOCKERMAKE) NDEBUG=1 -j$(JOBS) strip CXX="zig c++ -target x86_64-windows-gnu" TARGET="x86_64-windows-gnu.exe" EXE="3it-x64-windows.exe" PLATFORM="x86_64-windows-gnu"
aarch64-linux:
$(DOCKERMAKE) NDEBUG=1 -j$(JOBS) strip CXX="zig c++ -target aarch64-linux-musl" TARGET="x86_64-linux-musl" EXE="3it-aarch64-linux" PLATFORM="aarch64-linux-musl"
aarch64-macos:
$(DOCKERMAKE) NDEBUG=1 -j$(JOBS) NOLTO=1 strip CXX="zig c++ -target aarch64-macos-none" TARGET="x86_64-linux-musl" EXE="3it-aarch64-macos" PLATFORM="aarch64-macos-none"
builder:
buildtools/build-builder
release: build-builder x64-linux x64-windows aarch64-linux aarch64-macos
.PHONY: clean builddir release docker-release build-builder
-include $(DEPS)