/
Makefile
87 lines (70 loc) · 2.21 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
# Copyright 2021 Google LLC
# Copyright 2008-2021 Alexander Galanin <al@galanin.nnov.ru>
# http://galanin.nnov.ru/~al
#
# 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 implied 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/>.
DEST = mount-zip
prefix = /usr
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
PKG_CONFIG ?= pkg-config
DEPS = fuse libzip icu-uc icu-i18n
LIBS += -Llib -lmountzip
LIBS += $(shell $(PKG_CONFIG) --libs $(DEPS))
CXXFLAGS += $(shell $(PKG_CONFIG) --cflags $(DEPS))
CXXFLAGS += -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -pedantic -std=c++20
ifeq ($(DEBUG), 1)
CXXFLAGS += -O0 -g
else
CXXFLAGS += -O2 -DNDEBUG
endif
LIB = lib/libmountzip.a
SOURCES = main.cc
OBJECTS = $(SOURCES:.cc=.o)
MAN = $(DEST).1
MANDIR = $(prefix)/share/man/man1
CLEANFILES = $(OBJECTS) $(DEST)
INSTALL = install
INSTALL_PROGRAM = $(INSTALL) -D
INSTALL_DATA = $(INSTALL) -D -m 644
all: $(DEST)
doc: $(MAN)
man -l $(MAN)
$(DEST): $(OBJECTS) $(LIB)
$(CXX) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
main.o: main.cc
$(CXX) -Ilib -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
$(LIB):
$(MAKE) -C lib
lib-clean:
$(MAKE) -C lib clean
check-clean:
$(MAKE) -C tests clean
clean: lib-clean all-clean check-clean
all-clean:
rm -f $(CLEANFILES)
$(MAN): README.md
pandoc $< -s -t man -o $@
install: $(DEST)
$(INSTALL_PROGRAM) "$(DEST)" "$(DESTDIR)$(bindir)/$(DEST)"
$(INSTALL_DATA) $(MAN) "$(DESTDIR)$(MANDIR)/$(MAN)"
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
uninstall:
rm "$(DESTDIR)$(bindir)/$(DEST)" "$(DESTDIR)$(MANDIR)/$(MAN)"
debug:
$(MAKE) DEBUG=1 all
check: debug
$(MAKE) -C tests
.PHONY: all doc debug clean all-clean lib-clean check-clean install uninstall check $(LIB)