-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
170 lines (151 loc) · 4.64 KB
/
Makefile
File metadata and controls
170 lines (151 loc) · 4.64 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
.PHONY: build
.PHONY: fftw
.PHONY: nasm
.PHONY: nasmfmt
.PHONY: onekpaq
.PHONY: pre-commit
.PHONY: venv
.PHONY: clang-tidy
.PHONY: clang-tidy-fix
.PHONY: clang-tidy-check
GO_CHECK := $(shell which go 2> /dev/null)
INSTALL_NASM_FMT := GO111MODULE=on go install github.com/yamnikov-oleg/nasmfmt@latest
NASMFMT_INSTALLED := $(shell which nasmfmt 2> /dev/null)
REQUIREMENTS_FILE = scripts/requirements.txt
TOOLS_DIR = tools
VENV_DIR = venv
NUM_PROCESSORS = 4
MAKEFLAGS += --no-print-directory
ifeq ($(OS),Windows_NT)
PYTHON = python
VENV_BIN = $(VENV_DIR)/Scripts
VENV_PYTHON = $(VENV_BIN)/python.exe
VENV_PIP = $(VENV_BIN)/pip.exe
ACTIVATE_SCRIPT = $(VENV_BIN)/activate.bat
else
PYTHON = python3
VENV_BIN = $(VENV_DIR)/bin
VENV_PYTHON = $(VENV_BIN)/python
VENV_PIP = $(VENV_BIN)/pip
ACTIVATE_SCRIPT = $(VENV_BIN)/activate
endif
build:
@echo "Building the project..."
ifeq ($(OS),Windows_NT)
@cmake -S . -B build -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug
else
@cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
endif
@cmake --build build --config Debug -- --no-print-directory -j ${NUM_PROCESSORS}
clean:
@echo "Cleaning the project..."
@if exist build (cmake --build build --target clean) || (echo No build directory.)
install:
@echo "Downloading dependencies..."
@git submodule update --init --recursive
@echo "Installing tools..."
@$(MAKE) nasm
@$(MAKE) nasmfmt
@$(MAKE) onekpaq
@$(MAKE) crinkler
@$(MAKE) fftw
@$(MAKE) venv
@$(MAKE) activate
consts:
@echo "Generating constants..."
@$(VENV_PYTHON) scripts/constants.py
nasmfmt:
ifeq ($(GO_CHECK),)
@echo "Go is not installed. Installation of nasmfmt is skipped."
else
ifeq ($(NASMFMT_INSTALLED),)
@echo "Installing nasmfmt..."
@$(INSTALL_NASM_FMT)
@which nasmfmt > /dev/null || echo "nasmfmt not found in PATH. Add \$GOPATH/bin to your PATH."
else
@echo "nasmfmt is already installed."
endif
endif
onekpaq:
@echo "Installing oneKpaq..."
@if [ ! -d $(TOOLS_DIR)/oneKpaq ]; then \
mkdir -p $(TOOLS_DIR); \
cd $(TOOLS_DIR) && git clone https://github.com/temisu/oneKpaq.git; \
fi
@cd $(TOOLS_DIR)/oneKpaq && $(MAKE)
@rm -rf $(TOOLS_DIR)/oneKpaq/.git 2>/dev/null || true
crinkler:
@echo "Installing Crinkler..."
@if [ ! -d "$(TOOLS_DIR)/crinkler" ]; then \
mkdir -p $(TOOLS_DIR) && \
echo "Downloading Crinkler 2.3..." && \
curl -L -o crinkler23.zip https://github.com/runestubbe/Crinkler/releases/download/v2.3/crinkler23.zip && \
echo "Extracting Crinkler..." && \
powershell -Command "Expand-Archive -Path crinkler23.zip -DestinationPath $(TOOLS_DIR)\crinkler -Force" && \
rm crinkler23.zip && \
echo "Crinkler installed to $(TOOLS_DIR)/crinkler"; \
else \
echo "Crinkler directory already exists"; \
fi
pre-commit:
@echo "Installing pre-commit..."
@$(VENV_PIP) install pre-commit
@$(VENV_PYTHON) -m pre_commit install
@$(VENV_PYTHON) -m pre_commit autoupdate
venv:
@echo "Creating virtual environment..."
@if [ ! -d "$(VENV_DIR)" ]; then \
$(PYTHON) -m venv $(VENV_DIR) && \
echo "Virtual environment created at $(VENV_DIR)"; \
else \
echo "Virtual environment already exists at $(VENV_DIR)"; \
fi
@if [ -f "$(REQUIREMENTS_FILE)" ]; then \
echo "Installing Python dependencies..." && \
$(VENV_PIP) install -r $(REQUIREMENTS_FILE); \
else \
echo "No requirements.txt found, skipping Python dependencies"; \
fi
activate:
@echo "To activate the virtual environment, run:"
ifeq ($(OS),Windows_NT)
@echo " $(ACTIVATE_SCRIPT)"
else
@echo " source $(ACTIVATE_SCRIPT)"
endif
fftw:
@echo "Installing FFTW..."
ifeq ($(OS),Windows_NT)
@if [ ! -d "fftw" ]; then \
mkdir -p fftw && \
echo "Downloading FFTW 3.3.5 for Windows..." && \
curl -L -o fftw-3.3.5-dll32.zip https://fftw.org/pub/fftw/fftw-3.3.5-dll32.zip && \
echo "Extracting FFTW..." && \
powershell -Command "Expand-Archive -Path fftw-3.3.5-dll32.zip -DestinationPath fftw -Force" && \
rm fftw-3.3.5-dll32.zip && \
echo "FFTW installed to fftw directory"; \
else \
echo "FFTW directory already exists"; \
fi
else
@if [ ! -d "fftw" ]; then \
mkdir -p fftw && \
echo "Downloading FFTW 3.3.10 for Linux..." && \
curl -L -o fftw-3.3.10.tar.gz https://www.fftw.org/fftw-3.3.10.tar.gz && \
echo "Extracting FFTW..." && \
tar -xzf fftw-3.3.10.tar.gz -C fftw --strip-components=1 && \
rm fftw-3.3.10.tar.gz && \
echo "FFTW source installed to fftw directory"; \
else \
echo "FFTW directory already exists"; \
fi
endif
clang-tidy:
@echo "Running clang-tidy..."
@cmake --build build --target clang-tidy
clang-tidy-fix:
@echo "Running clang-tidy with --fix..."
@cmake --build build --target clang-tidy-fix
clang-tidy-check:
@echo "Listing clang-tidy checks..."
@cmake --build build --target clang-tidy-check