-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (28 loc) · 984 Bytes
/
Copy pathMakefile
File metadata and controls
38 lines (28 loc) · 984 Bytes
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
CXX := g++
CXXFLAGS := -Wall -Wextra -Werror -pedantic -std=c++20 -fopenmp
RELEASEFLAGS := -O3
# List of source files
SRCS := main.cc io.cc
HEADERS := io.h collision.h sim_validator.h
# Object files
OBJS := $(SRCS:.cc=.o)
.PHONY: all clean
all: release
# List of executables (actual binary names)
EXECUTABLES := sim
PERF_EXECUTABLES := $(EXECUTABLES:%=%.perf)
TARGETS := $(EXECUTABLES)
PERF_TARGETS := $(PERF_EXECUTABLES)
release: $(TARGETS) $(PERF_TARGETS)
# How to compile .o and .o.perf object files
%.o: %.cc $(HEADERS)
$(CXX) $(CXXFLAGS) -DCHECK=1 $(RELEASEFLAGS) -c $< -o $@
%.o.perf: %.cc $(HEADERS)
$(CXX) $(CXXFLAGS) -DCHECK=0 $(RELEASEFLAGS) -c $< -o $@
# How to compile non-perf and perf executables
$(EXECUTABLES): %: %.o io.o sim_validator.a
$(CXX) $(CXXFLAGS) -DCHECK=1 $(RELEASEFLAGS) -o $@ $^
$(PERF_EXECUTABLES): %.perf: %.o.perf io.o
$(CXX) $(CXXFLAGS) -DCHECK=0 $(RELEASEFLAGS) -o $@ $^
clean:
$(RM) *.o *.o.perf $(EXECUTABLES) $(PERF_EXECUTABLES)