-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
94 lines (74 loc) · 2.41 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
include Makefile.inc
PKG_CONFIG_PKGS = zlib
CFLAGS_EXTRA = $(shell pkg-config --cflags $(PKG_CONFIG_PKGS))
LIBS_EXTRA = $(shell pkg-config --libs $(PKG_CONFIG_PKGS))
DEFS = -Wall -Wextra -pedantic -std=c++11 $(CFLAGS_EXTRA)
CFLAGS = $(OPTIM_FLAGS) -c $(DEFS) -o $@ $<
DEPFLAGS = $(OPTIM_FLAGS) -E -MM $(DEFS) -o .dep/$*.d $<
LIBS = $(LIBS_EXTRA)
# -pthread
LFLAGS = $(OPTIM_FLAGS) -shared $(O) $(LIBS) -Wl,-soname,$@ -z defs -o $@
CCLDFLAGS = $(OPTIM_FLAGS) $(DEFS) $(LIBS) -L. -lAPNG -Wl,-rpath,\$$ORIGIN -o $@ $<
SED = sed -e 's:@LIBDIR@:$(LIBDIR):g' -e 's:@PREFIX@:$(PREFIX):g' -e 's:@VERSION@:$(VER):g'
CRUNCHMAKE = crunchMake $(shell pkg-config --cflags --libs crunch++ zlib)
ifeq ($(BUILD_VERBOSE), 0)
CRUNCHMAKE += -q
endif
ifeq ($(strip $(COVERAGE)), 1)
CRUNCHMAKE += --coverage
endif
CRUNCH = crunch++
PREFIX ?= /usr
LIBDIR ?= $(PREFIX)/lib
PKGDIR = $(LIBDIR)/pkgconfig
INCDIR = $(PREFIX)/include/APNG
O = crc32.o stream.o conversions.o reader.o
H = apng.hxx stream.hxx
VERMAJ = .0
VERMIN = $(VERMAJ).0
VERREV = $(VERMIN).1
VER = $(VERREV)
SO = libAPNG.so
PC = libAPNG.pc
TESTS = testAPNG.so
DEPS = .dep
quiet_cmd_crunchMake = -n
cmd_crunchMake = $(CRUNCHMAKE) $(2)
quiet_cmd_crunch = -n
cmd_crunch = $(CRUNCH) $(2)
default: all
all: $(DEPS) $(SO)
.dep $(LIBDIR) $(PKGDIR) $(INCDIR):
$(call run-cmd,install_dir,.dep)
install: all $(LIBDIR) $(PKGDIR) $(INCDIR) $(PC)
$(call run-cmd,install_file,$(addsuffix $(VER),$(SO)),$(LIBDIR))
$(call run-cmd,install_file,$(PC),$(PKGDIR))
#$(call run-cmd,install_file,$(H),$(INCDIR))
$(call run-cmd,ln,$(LIBDIR)/$(SO)$(VERREV),$(LIBDIR)/$(SO)$(VERMIN))
$(call run-cmd,ln,$(LIBDIR)/$(SO)$(VERMIN),$(LIBDIR)/$(SO)$(VERMAJ))
$(call run-cmd,ln,$(LIBDIR)/$(SO)$(VERMAJ),$(LIBDIR)/$(SO))
$(call ldconfig)
$(SO): $(O)
$(call run-cmd,ccld,$(LFLAGS))
$(call debug-strip,$(SO))
$(call run-cmd,ln,$@,$@$(VER))
%.pc: %.pc.in
$(call run-cmd,sed,$<,$@)
%.o: %.cxx | $(DEPS)
$(call makedep,$(CXX),$(DEPFLAGS))
$(call run-cmd,cxx,$(CFLAGS))
tests: $(O) $(TESTS)
testAPNG.so: CRUNCHMAKE += $(O)
$(TESTS): $(subst .so,.cxx,$@)
$(call run-cmd,crunchMake,$(subst .so,.cxx,$@))
testRead: testRead.cxx
$(call run-cmd,ccld,$(CCLDFLAGS))
check: tests
$(call run-cmd,crunch,$(subst .so,,$(TESTS)))
clean: $(DEPS)
$(call run-cmd,rm,APNG,$(O) $(SO))
$(call run-cmd,rm,tests,$(TESTS))
$(call run-cmd,rm,makedep,.dep/*.d)
.PHONY: default all clean tests check install
.SUFFIXES: .cxx .so .o
-include .dep/*.d