-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (48 loc) · 1.33 KB
/
Makefile
File metadata and controls
58 lines (48 loc) · 1.33 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
# Detect OS
ifeq ($(OS),Windows_NT)
OUTPUT := main.exe
else
OUTPUT := main
endif
# Recursive wildcard to collect source files using relative paths.
# This avoids issues with spaces in absolute paths on Windows.
rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
SRCS := $(call rwildcard,src/,*.cpp)
SRCS := $(filter-out \
src/libs/value/pyBool.cpp \
src/libs/value/pyClass.cpp \
src/libs/value/pyFloat.cpp \
src/libs/value/pyInstance.cpp \
src/libs/value/pyInt.cpp \
src/libs/value/pyNone.cpp \
src/libs/value/pyStr.cpp, \
$(SRCS))
# Set the compiler and compiler flags
CC := g++
CFLAGS := -std=c++20 -Wno-unused-parameter
# Release tuning (was #pragma GCC in main.cpp); skipped for DEBUG. Needs CPU with AVX2/FMA.
ifndef DEBUG
CFLAGS += -Ofast -mavx -mavx2 -mfma
endif
# Add DEBUG macro to CFLAGS
ifdef DEBUG
CFLAGS += -DDEBUG -Wall -Wextra -g
CFLAGS += -Wno-unused-variable -Wno-reorder
endif
# Build rule
build: $(OUTPUT)
# Linking rule
$(OUTPUT):
$(CC) $(CFLAGS) $(SRCS) -o $(OUTPUT)
# Test rule with optional TEST variable
# Usage: make test TEST=<test_name>
test:
chmod +x test.sh
./test.sh $(TEST)
# Clean rule
clean:
ifeq ($(OS),Windows_NT)
@powershell -Command "Remove-Item -Force -ErrorAction SilentlyContinue $(OUTPUT)"
else
@rm -f $(OUTPUT)
endif