Debian Codegraph @

src/GNUmakefile

raw
1 # non-recursive prologue
2 sp := $(sp).x
3 dirstack_$(sp) := $(d)
4 d := $(abspath $(lastword $(MAKEFILE_LIST))/..)
5
6 ifeq ($(origin GUARD_$(d)), undefined)
7 GUARD_$(d) := 1
8
9
10 #
11 # E N V I R O N M E N T C O N F I G U R A T I O N
12 #
13 include $(d)/../GNUmakefile
14
15 include $(d)/lib/GNUmakefile
16
17
18 #
19 # C O M P I L A T I O N F L A G S
20 #
21 VENDOR_$(d) = $(or $(CQUEUES_VENDOR),$(shell $(<D)/../mk/changelog author))
22 VERSION_$(d) = $(or $(CQUEUES_VERSION),$(shell $(<D)/../mk/changelog version))
23 COMMIT_$(d) = $(shell $(<D)/../mk/changelog commit)
24
25 CPPFLAGS_$(d) = $(ALL_CPPFLAGS) -DCOMPAT53_PREFIX=cqueues
26 CFLAGS_$(d) = $(ALL_CFLAGS)
27 SOFLAGS_$(d) = $(ALL_SOFLAGS)
28 LDFLAGS_$(d) = $(ALL_LDFLAGS)
29 LIBS_$(d) = $(ALL_LIBS)
30
31 CPPFLAGS_$(d) += $(and $(VENDOR_$(<D)),-DCQUEUES_VENDOR='"$(VENDOR_$(<D))"')
32 CPPFLAGS_$(d) += $(and $(VERSION_$(<D)),-DCQUEUES_VERSION=$(VERSION_$(<D))L)
33 CPPFLAGS_$(d) += $(and $(COMMIT_$(<D)),-DCQUEUES_COMMIT='"$(COMMIT_$(<D))"')
34
35 #
36 # C O M P I L A T I O N R U L E S
37 #
38 OBJS_$(d) = cqueues.o socket.o errno.o signal.o thread.o notify.o dns.o
39
40 # NOTE: M4 might fail so delay creating $@
41 $(d)/errno.c: $(d)/errno.c.m4
42 cd $(@D) && $(M4) $< >| [email protected]
43 mv [email protected] $@
44
45 $(d)/config.h: $(abspath $(d)/..)/config.h
46 $(CP) $< $@
47
48 define BUILD_$(d)
49
50 $$(d)/$(1)/cqueues.so: $$(addprefix $$(d)/$(1)/, $$(OBJS_$(d))) $$(d)/lib/libnonlua.a
51 $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LIBS_$$(abspath $$(@D)/..))
52
53 $$(d)/$(1)/%.o: $$(d)/%.c $$(d)/cqueues.h $$(d)/../vendor/compat53/c-api/compat-5.3.h $$(d)/config.h
54 $$(MKDIR) -p $$(@D)
55 $$(CC) $$(CFLAGS_$$(<D)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$$(<D)) -c -o $$@ $$<
56
57 $$(d)/$(1)/cqueues.o: $$(d)/lib/llrb.h
58
59 $$(d)/$(1)/socket.o: $$(d)/lib/socket.h $$(d)/lib/dns.h $$(d)/lib/fifo.h
60
61 $$(d)/$(1)/errno.o: $$(d)/lib/socket.h $$(d)/lib/dns.h
62
63 $$(d)/$(1)/dns.o: $$(d)/lib/dns.h
64
65 $$(d)/$(1)/thread.o: $$(d)/lib/llrb.h
66
67 $$(d)/$(1)/notify.o: $$(d)/lib/notify.h
68
69 ifneq ($(1), 5.3)
70 ifneq ($(1), 5.4)
71 $$(d)/$(1)/compat53.o: $$(d)/../vendor/compat53/c-api/compat-5.3.c $$(d)/../vendor/compat53/c-api/compat-5.3.h $$(d)/config.h
72 $$(MKDIR) -p $$(@D)
73 $$(CC) $$(CFLAGS_$(d)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$(d)) -c -o $$@ $$<
74
75 $$(d)/$(1)/cqueues.so: $$(d)/$(1)/compat53.o
76 endif
77 endif
78
79 .SECONDARY: liblua$(1)-cqueues cqueues$(1) cqueues
80
81 liblua$(1)-cqueues cqueues$(1) cqueues: $$(d)/$(1)/cqueues.so
82
83 endef # BUILD_$(d)
84
85 $(eval $(call BUILD_$(d),5.1))
86 $(eval $(call BUILD_$(d),5.2))
87 $(eval $(call BUILD_$(d),5.3))
88 $(eval $(call BUILD_$(d),5.4))
89
90 ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" ""
91 .SECONDARY: all all5.1 all5.2 all5.3 all5.4
92
93 all5.1: liblua5.1-cqueues
94 all5.2: liblua5.2-cqueues
95 all5.3: liblua5.3-cqueues
96 all5.4: liblua5.4-cqueues
97 all: $(foreach API,$(strip $(LUA_APIS)),all$(API))
98
99 endif
100
101
102 #
103 # I N S T A L L & U N I N S T A L L R U L E S
104 #
105 define INSTALL_$(d)
106
107 MODS$(1)_$(d) = \
108 $$(DESTDIR)$(2)/_cqueues.so \
109 $$(DESTDIR)$(3)/cqueues.lua \
110 $$(DESTDIR)$(3)/cqueues/socket.lua \
111 $$(DESTDIR)$(3)/cqueues/errno.lua \
112 $$(DESTDIR)$(3)/cqueues/signal.lua \
113 $$(DESTDIR)$(3)/cqueues/thread.lua \
114 $$(DESTDIR)$(3)/cqueues/notify.lua \
115 $$(DESTDIR)$(3)/cqueues/condition.lua \
116 $$(DESTDIR)$(3)/cqueues/promise.lua \
117 $$(DESTDIR)$(3)/cqueues/auxlib.lua \
118 $$(DESTDIR)$(3)/cqueues/dns.lua \
119 $$(DESTDIR)$(3)/cqueues/dns/resolver.lua \
120 $$(DESTDIR)$(3)/cqueues/dns/config.lua \
121 $$(DESTDIR)$(3)/cqueues/dns/hosts.lua \
122 $$(DESTDIR)$(3)/cqueues/dns/hints.lua \
123 $$(DESTDIR)$(3)/cqueues/dns/record.lua \
124 $$(DESTDIR)$(3)/cqueues/dns/packet.lua \
125 $$(DESTDIR)$(3)/cqueues/dns/resolvers.lua
126
127 .SECONDARY: liblua$(1)-cqueues-install cqueues$(1)-install
128
129 liblua$(1)-cqueues-install cqueues$(1)-install: $$(MODS$(1)_$$(d))
130
131 $$(DESTDIR)$(2)/_cqueues.so: $$(d)/$(1)/cqueues.so
132 $$(MKDIR) -p $$(@D)
133 cp -p $$< $$@
134
135 $$(DESTDIR)$(3)/%.lua: $$(d)/%.lua
136 $$(LUAC$(subst .,,$(1))) -p $$<
137 $$(MKDIR) -p $$(@D)
138 cp -p $$< $$@
139
140 $$(DESTDIR)$(3)/cqueues/%.lua: $$(d)/%.lua
141 $$(LUAC$(subst .,,$(1))) -p $$<
142 $$(MKDIR) -p $$(@D)
143 cp -p $$< $$@
144
145 $$(DESTDIR)$(3)/cqueues/dns/%.lua: $$(d)/dns.%.lua
146 $$(LUAC$(subst .,,$(1))) -p $$<
147 $$(MKDIR) -p $$(@D)
148 cp -p $$< $$@
149
150 .PHONY: liblua$(1)-cqueues-uninstall cqueues$(1)-uninstall
151
152 liblua$(1)-cqueues-uninstall cqueues$(1)-uninstall:
153 $$(RM) -f $$(MODS$(1)_$(d))
154 -$$(RMDIR) $$(DESTDIR)$(3)/cqueues/dns
155 -$$(RMDIR) $$(DESTDIR)$(3)/cqueues
156
157 endef # INSTALL_$(d)
158
159 $(eval $(call INSTALL_$(d),5.1,$$(lua51cpath),$$(lua51path)))
160 $(eval $(call INSTALL_$(d),5.2,$$(lua52cpath),$$(lua52path)))
161 $(eval $(call INSTALL_$(d),5.3,$$(lua53cpath),$$(lua53path)))
162 $(eval $(call INSTALL_$(d),5.4,$$(lua54cpath),$$(lua54path)))
163
164 ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" ""
165
166 .SECONDARY: install5.1 install5.2 install5.3 install5.4 install
167
168 install5.1: liblua5.1-cqueues-install
169 install5.2: liblua5.2-cqueues-install
170 install5.3: liblua5.3-cqueues-install
171 install5.4: liblua5.4-cqueues-install
172 install: $(foreach API,$(strip $(LUA_APIS)),install$(API))
173
174 .PHONY: uninstall5.1 uninstall5.2 uninstall5.3 uninstall
175
176 uninstall5.1: liblua5.1-cqueues-uninstall
177 uninstall5.2: liblua5.2-cqueues-uninstall
178 uninstall5.3: liblua5.3-cqueues-uninstall
179 uninstall5.4: liblua5.4-cqueues-uninstall
180 uninstall: $(foreach API,$(strip $(LUA_APIS)),uninstall$(API))
181
182 endif
183
184
185 #
186 # C L E A N R U L E S
187 #
188 .PHONY: $(d)/clean $(d)/clean~ clean clean~
189
190 $(d)/clean:
191 rm -rf $(@D)/errno.c $(@D)/errno.c.tmp $(@D)/config.h $(@D)/*.dSYM $(@D)/5.1 $(@D)/5.2 $(@D)/5.3
192
193 $(d)/clean~: $(d)/clean
194 rm -f $(@D)/*~
195
196 clean: $(d)/clean
197
198 clean~: $(d)/clean~
199
200
201 #
202 # H E L P R U L E S
203 #
204 .PHONY: $(d)/help help
205
206 $(d)/help:
207 @echo
208 @echo "src/ targets:"
209 @echo ""
210 @echo " all - build all API targets"
211 @echo " all5.1 - build 5.1/cqueues.so"
212 @echo " all5.2 - build 5.2/cqueues.so"
213 @echo " all5.3 - build 5.3/cqueues.so"
214 @echo " all5.4 - build 5.4/cqueues.so"
215 @echo " install - install all API targets"
216 @echo " install5.1 - install cqueues Lua 5.1 modules"
217 @echo " install5.2 - install cqueues Lua 5.2 modules"
218 @echo " install5.3 - install cqueues Lua 5.3 modules"
219 @echo " install5.4 - install cqueues Lua 5.4 modules"
220 @echo " uninstall - uninstall all API targets"
221 @echo "uninstall5.1 - uninstall cqueues Lua 5.1 modules"
222 @echo "uninstall5.2 - uninstall cqueues Lua 5.2 modules"
223 @echo "uninstall5.3 - uninstall cqueues Lua 5.3 modules"
224 @echo "uninstall5.4 - uninstall cqueues Lua 5.4 modules"
225 @echo " clean - rm binary targets, object files, debugging symbols, etc"
226 @echo " clean~ - clean + rm *~"
227 @echo " help - echo this help message"
228 @echo ""
229 @echo "Some important Make variables:"
230 @echo ""
231 @echo ' LUA_APIS - default Lua APIs to target ($(LUA_APIS))'
232 @echo " prefix - path to install root ($(value prefix))"
233 @echo ' lua51path - install path for Lua 5.1 modules ($(value lua51path))'
234 @echo 'lua51cpath - install path for Lua 5.1 C modules ($(value lua51cpath))'
235 @echo ' lua52path - install path for Lua 5.2 modules ($(value lua52path))'
236 @echo 'lua52cpath - install path for Lua 5.2 C modules ($(value lua52cpath))'
237 @echo ' lua53path - install path for Lua 5.3 modules ($(value lua53path))'
238 @echo 'lua53cpath - install path for Lua 5.3 C modules ($(value lua53cpath))'
239 @echo ' lua54path - install path for Lua 5.4 modules ($(value lua54path))'
240 @echo 'lua54cpath - install path for Lua 5.4 C modules ($(value lua54cpath))'
241 @echo ""
242 @echo 'LUA51_CPPFLAGS - cpp flags for Lua 5.1 headers ($(LUA51_CPPFLAGS))'
243 @echo 'LUA52_CPPFLAGS - cpp flags for Lua 5.2 headers ($(LUA52_CPPFLAGS))'
244 @echo 'LUA53_CPPFLAGS - cpp flags for Lua 5.3 headers ($(LUA53_CPPFLAGS))'
245 @echo 'LUA54_CPPFLAGS - cpp flags for Lua 5.4 headers ($(LUA54_CPPFLAGS))'
246 @echo ""
247 @echo "(NOTE: all the common GNU-style paths are supported, including"
248 @echo "prefix, bindir, libdir, datadir, includedir, and DESTDIR.)"
249 @echo ""
250 @echo "Report bugs to <[email protected]>"
251
252 help: $(d)/help
253
254
255 endif # include guard
256
257 # non-recursive epilogue
258 d := $(dirstack_$(sp))
259 sp := $(basename $(sp))