-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (81 loc) · 3.89 KB
/
Makefile
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
# C++20 #
# | | #
# __| __| | | __| | #
# ( ( | | | | #
# \___| \___| \__,_| \__| _| #
# #
# ccutl Core Utilities #
# #
# [ccutl]: a C++ utilities library focused on flexibility and expressibility #
# Copyright (C) 2020, 2021 Justin Collier #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the internalied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# make the include dir by default
all: include
PREFIX ?= /usr/local
CXX = clang++
CXXFLAGS += -std=c++20 \
-g \
-I. \
-Iinclude \
-Itest/libs \
-Ilibs/pputl/include \
-Weverything \
-Wno-padded \
-Wno-c++98-compat \
-Wno-c++98-compat-pedantic \
-Wno-global-constructors \
-Wno-exit-time-destructors \
-Wno-documentation-unknown-command
# all of the input headers in the source directory
SRC_HEADERS = $(shell find src/ -type f -name '*.h')
# all of the tests. each input header must have an associated test source
TEST_SOURCES = $(patsubst src/%.h, test/src/%.cc, ${SRC_HEADERS}) test/src/main.cc
# all of the test objects
TEST_OBJECTS = $(patsubst test/%.cc, test/.o/%.o, ${TEST_SOURCES})
# rule to make the include directory and everything within it
include: bs/build.ts ${SRC_HEADERS} libs/pputl/include README.md
bs/node_modules/.bin/ts-node -s $<
# test sources depend on the include dir to be generated
${TEST_SOURCES}: include
# cache directories for test objects
test/.o/src/ctl/detail:
mkdir -p $@
# make sure the object dirs exist
${TEST_OBJECTS}: test/.o/src/ctl/detail
# create all of the test objects
test/.o/%.o: test/%.cc
${CXX} ${CXXFLAGS} -c $< -o $@
# create the test executable using all of the test objects
test/test: ${TEST_OBJECTS}
${CXX} ${CXXFLAGS} $^ -o $@
# `make test` functionality
test: test/test
@./$<
# install include/ctl to ${DESTDIR}${PREFIX}/include/
install: ${DESTDIR}${PREFIX}/include include
install -d 644 $</ctl
install -m 644 include/ctl/* -t $</ctl
# removes ${DESTDIR}${PREFIX}/include/ctl
uninstall: ${DESTDIR}${PREFIX}/include/ctl
${RM} -r $<
# clean up testing
clean-test:
${RM} test/test
${RM} -r test/.o
# clean up everything. THIS DELETES THE INCLUDE DIR!
clean: libs/pputl/include # adding this dependency to prevent accidental clean
${RM} -r include
${MAKE} clean-test
.PHONY: all test install uninstall clean-test clean