-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (43 loc) · 1.63 KB
/
Makefile
File metadata and controls
61 lines (43 loc) · 1.63 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
# SPDX-FileCopyrightText: Steven Ward
# SPDX-License-Identifier: MPL-2.0
# https://pracrand.sourceforge.net/installation.txt
# https://www.pcg-random.org/posts/how-to-test-with-practrand.html
# https://espadrine.github.io/blog/posts/a-primer-on-randomness.html
export LC_ALL = C
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
LIB_SRCS = $(wildcard src/*.cpp src/RNGs/*.cpp src/RNGs/other/*.cpp)
LIB_DEPS = $(LIB_SRCS:.cpp=.d)
LIB_OBJS = $(LIB_SRCS:.cpp=.o)
LIB = libPractRand.a
BIN_SRCS = $(wildcard tools/RNG_*.cpp)
BIN_DEPS = $(BIN_SRCS:.cpp=.d)
BINS = $(basename $(BIN_SRCS))
CPPFLAGS = -MMD -MP
CPPFLAGS += -I include
CXXFLAGS = -std=c++20
CXXFLAGS += -pipe -Wall -Wextra -Wpedantic -Wfatal-errors
CXXFLAGS += -O3 -flto=auto -march=native
#CXXFLAGS += -march=raptorlake
LDLIBS = -pthread
all: $(BINS)
$(LIB): $(LIB_OBJS)
ar rcs $@ $^
# The built-in recipe for the implicit rule uses $^ instead of $<
# https://www.gnu.org/software/make/manual/html_node/Static-Usage.html
# Static Pattern Rule
$(BINS): tools/RNG_% : tools/RNG_%.cpp $(LIB)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LIB)
install: $(BINS) | $(DESTDIR)$(BINDIR)
@cp -v -f --update -- $^ $(DESTDIR)$(BINDIR)
$(DESTDIR)$(BINDIR):
@mkdir -v -p -- $(DESTDIR)$(BINDIR)
clean:
@$(RM) --verbose -- $(LIB_DEPS) $(LIB_OBJS) $(LIB) $(BIN_DEPS) $(BINS)
lint:
-clang-tidy --quiet $(LIB_SRCS) $(BIN_SRCS) -- $(CPPFLAGS) $(CXXFLAGS)
# https://www.gnu.org/software/make/manual/make.html#Phony-Targets
.PHONY: all clean install lint
# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#index-removing-targets-on-failure
.DELETE_ON_ERROR:
-include $(LIB_DEPS) $(BIN_DEPS)