blob: b21747e65b2ef25cc170c8b81bdd6a2b2efdfe18 (
plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
.DEFAULT_GOAL=all
_DEPS=$(addprefix .deps/, $(OBJ:.o=.d))
_PCHDRS=$(shell [ -z "$(PCPKGS)" ] || pkg-config --cflags $(PCPKGS))
_PCLIBS=$(shell [ -z "$(PCPKGS)" ] ||pkg-config --libs $(PCPKGS))
_LIBSRCHPATHS=$(addprefix -L, $(dir $(DEPS)))
_LIBINCPATHS=$(addprefix -I, $(dir $(DEPS))) $(_PCHDRS)
_LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(DEPS)))) $(_PCLIBS)
# yeah, I should probably remove -Werror, but it's nice for developing alone.
CFLAGS += -Wall -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-char-subscripts -g -O0
CFLAGS += -MMD -MP -MF .deps/$(subst /,-,$*).d
LIB ?= $(INSTLIB)
BIN ?= $(INSTBIN)
# disable implicit rules.
.SUFFIXES:
.SECONDARY:
.PHONY: clean clean-gen clean-bin clean-obj clean-misc clean-backups
.PHONY: all _modversions
all: _modversions subdirs $(BIN) $(LIB) $(EXTRA)
$(LIB): $(OBJ) $(EXTRADEP) $(DEPS)
$(AR) -rcs $@ $(OBJ)
$(BIN): $(OBJ) $(EXTRADEP) $(DEPS)
$(CC) -o $@ $(OBJ) $(_LIBSRCHPATHS) $(_LIBPATHS) $(LDFLAGS)
$(DEPS):
@cd $(dir $@) && $(MAKE)
subdirs:
@for i in $(SUB); do (\
cd $$i && \
$(MAKE) || \
exit 1 \
) || exit 1; done
subdirs-clean:
@for i in $(SUB); do (\
cd $$i && \
$(MAKE) clean|| \
exit 1 \
); done
subdirs-install:
@for i in $(SUB); do (\
cd $$i && \
$(MAKE) install|| \
exit 1 \
); done
clean: subdirs-clean $(EXTRACLEAN)
rm -f ${BIN} ${OBJ} ${CLEAN} ${LIB}
rm -rf .deps/
install: subdirs-install $(INSTBIN) $(INSTLIB) $(INSTHDR) $(INSTPKG) $(EXTRAINSTALL)
@for i in $(INSTBIN); do \
echo install $(abspath $$i $(DESTDIR)/$(INST_ROOT)/bin); \
mkdir -p $(abspath $(DESTDIR)/$(INST_ROOT)/bin); \
install $$i $(abspath $(DESTDIR)/$(INST_ROOT)/bin); \
done
@for i in $(INSTLIB); do \
echo install -m 644 $$i $(abspath $(DESTDIR)/$(INST_ROOT)/lib); \
mkdir -p $(abspath $(DESTDIR)/$(INST_ROOT)/lib); \
install -m 644 $$i $(abspath $(DESTDIR)/$(INST_ROOT)/lib); \
done
@for i in $(INSTHDR); do \
echo install $$i $(abspath $(DESTDIR)/$(INST_ROOT)/include); \
mkdir -p $(abspath $(DESTDIR)/$(INST_ROOT)/include); \
install $$i $(abspath $(DESTDIR)/$(INST_ROOT)/include); \
done
@for i in $(INSTPKG); do \
echo install $(abspath $$i $(DESTDIR)/$(INST_ROOT)/lib/pkgconfig); \
mkdir -p $(abspath $(DESTDIR)/$(INST_ROOT)/lib/pkgconfig); \
install $(abspath $$i $(DESTDIR)/$(INST_ROOT)/lib/pkgconfig); \
done
@for i in $(INSTMAN); do \
sect="$${i##*.}"; \
echo install -m 644 $$i $(abspath $(DESTDIR)/$(INST_MAN)$${sect}); \
mkdir -p $(abspath $(DESTDIR)/$(INST_MAN)$${sect}); \
install -m 644 $$i $(abspath $(DESTDIR)/$(INST_MAN)$${sect}); \
done
subdirs-uninstall:
@for i in $(SUB); do (\
cd $$i && \
$(MAKE) uninstall|| \
exit 1 \
); done
uninstall: subdirs-uninstall $(EXTRAUNINSTALL)
@for i in $(INSTBIN); do \
echo rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/bin/$$i); \
rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/bin/$$i); \
done
@for i in $(INSTLIB); do \
echo rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/lib/$$i); \
rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/lib/$$i); \
done
@for i in $(INSTHDR); do \
echo rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/include/$$i); \
rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/include/$$i); \
done
@for i in $(INSTPKG); do \
echo rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/lib/pkgconfig/$$i); \
rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/lib/pkgconfig/$$i); \
done
@for i in $(INSTMAN); do \
sect="$${i##*.}" \
echo rm -f $$i $(abspath $(DESTDIR)/$(INST_MAN)$${sect}/$$i); \
rm -f $(abspath $(DESTDIR)/$(INST_MAN)$${sect}/$$i); \
done
%.o: %.c $(GENHDR) .deps/stamp
$(CC) -c $(CFLAGS) $(_LIBINCPATHS) $<
%.o: %.cpp $(GENHDR) .deps/stamp
$(CXX) -c $(CFLAGS) $(_LIBINCPATHS) $<
%.o: %.cc $(GENHDR) .deps/stamp
$(CXX) -c $(CFLAGS) $(_LIBINCPATHS) $<
.deps/stamp:
mkdir -p .deps && touch .deps/stamp
config.mk: configure
./configure --redo
_modversions:
@[ -z "$(PCPKGS)" ] || pkg-config --modversion $(PCPKGS) > /dev/null
-include $(_DEPS)
|