-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (55 loc) · 1.91 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
.POSIX:
.SUFFIXES:
.SUFFIXES: .cpp .o .unittest .profraw .profdata .coverage
VERSION = 1.0.0
CXX = clang++
LD = ld
XCRUN = xcrun
CPROF = $(XCRUN) llvm-profdata
CCOV = $(XCRUN) llvm-cov
PREFIX = /opt/local
LIBDIR = $(PREFIX)/lib
INCLUDEDIR = $(PREFIX)/include
SANITIZE = -fsanitize=address -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error
COVERAGE = -fprofile-instr-generate -fcoverage-mapping
OPTS = -std=c++17 -Werror -Weverything -Wno-c++98-compat -Wno-padded -Wno-poison-system-directories -Wno-global-constructors -Wno-exit-time-destructors
.PHONY: all
all: libargparse.a argparse.coverage
libargparse.a: argparse.o
$(LD) -r $^ -o $@
.cpp.o:
$(CXX) $(OPTS) -c $^ -o $@
libargparse.pc:
printf 'prefix=%s\n' "$(PREFIX)" > $@
printf 'exec_prefix=$${prefix}\n' >> $@
printf 'includedir=$${prefix}/include\n' >> $@
printf 'libdir=$${prefix}/lib\n' >> $@
printf 'Name: libargparse\n' >> $@
printf 'Version: %s\n' "$(VERSION)" >> $@
printf 'Description: Command Line Argument Parser\n' >> $@
argparse.unittest: test_argparse.cpp
.profdata.coverage:
$(CCOV) show $*.unittest -instr-profile=$< $*.cpp > $@
! grep " 0|" $@
echo PASS $@
.profraw.profdata:
$(CPROF) merge -sparse $< -o $@
.unittest.profraw:
LLVM_PROFILE_FILE=$@ ./$<
.cpp.unittest:
$(CXX) $(SANITIZE) $(COVERAGE) $(OPTS) $^ -o $@
.PHONY: install
install: argparse.hpp libargparse.a libargparse.pc
mkdir -p $(INCLUDEDIR)/libargparse
mkdir -p $(LIBDIR)/pkgconfig
install -m644 argparse.hpp $(INCLUDEDIR)/libargparse/argparse.hpp
install -m644 libargparse.a $(LIBDIR)/libargparse.a
install -m644 libargparse.pc $(LIBDIR)/pkgconfig/libargparse.pc
.PHONY: uninstall
uninstall:
rm -f $(INCLUDEDIR)/libargparse/argparse.hpp
rm -f $(LIBDIR)/libargparse.a
rm -f $(LIBDIR)/pkgconfig/libargparse.pc
.PHONY: clean
clean:
rm -rf libargparse.a libargparse.pc *.o *.coverage *.profdata *.profraw *.unittest*