-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (37 loc) · 1.04 KB
/
Copy pathMakefile
File metadata and controls
44 lines (37 loc) · 1.04 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
CXX = clang++
SOURCE = src/main.cpp
NAME = $(notdir $(basename $(SOURCE)))
BUILD_DIR = build
VERSION = $(shell git describe --tags --always --dirty="-dev" 2>/dev/null || echo "unknown")
MACHINE = $(shell $(CXX) -dumpmachine)
CXXFLAGS = -std=c++20 -O3 -Iinclude
ifeq ($(findstring linux,$(MACHINE)), linux)
EXE_EXT =
LDFLAGS =
else ifeq ($(findstring windows-msvc,$(MACHINE)), windows-msvc)
EXE_EXT = .exe
LDFLAGS =
else ifeq ($(findstring windows-gnu,$(MACHINE)), windows-gnu)
EXE_EXT = .exe
LDFLAGS =
else
$(error Unsupported platform: $(MACHINE))
endif
ifeq ($(DEBUG), 1)
CXXFLAGS += -g -fsanitize=address -fsanitize=undefined
VERSION := $(VERSION)-debug
endif
ifeq ($(USE_GMP), 1)
CXXFLAGS += -DUSE_GMP
LDFLAGS += -lgmp
TARGET = $(BUILD_DIR)/$(NAME)-$(VERSION)-$(MACHINE)-gmp$(EXE_EXT)
else
TARGET = $(BUILD_DIR)/$(NAME)-$(VERSION)-$(MACHINE)-nat$(EXE_EXT)
endif
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(SOURCE)
mkdir -p $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
clean:
rm -rf $(BUILD_DIR)