summaryrefslogtreecommitdiff
path: root/src/GNUmakefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/GNUmakefile')
-rw-r--r--src/GNUmakefile136
1 files changed, 53 insertions, 83 deletions
diff --git a/src/GNUmakefile b/src/GNUmakefile
index 015a93c..e257ba6 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -16,66 +16,46 @@ include $(d)/../GNUmakefile
16# 16#
17# C O M P I L A T I O N F L A G S 17# C O M P I L A T I O N F L A G S
18# 18#
19OS_$(d) = $(shell $(d)/../mk/vendor.os) 19CPPFLAGS_$(d) = $(ALL_CPPFLAGS) -DHAVE_CONFIG_H -DCOMPAT53_PREFIX=luaossl
20CC_$(d) = $(shell env CC="$(CC) "$(d)/../mk/vendor.cc) 20CFLAGS_$(d) = $(ALL_CFLAGS)
21LUAPATH_$(d) = $(shell env CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(<D)/../mk/luapath -krxm3 -I$(DESTDIR)$(includedir) -I/usr/include -I/usr/local/include -P$(DESTDIR)$(bindir) -P$(bindir) -L$(DESTDIR)$(libdir) -L$(libdir) -v$(1) $(2)) 21SOFLAGS_$(d) = $(ALL_SOFLAGS)
22 22LDFLAGS_$(d) = $(ALL_LDFLAGS)
23CPPFLAGS_$(d) = $(CPPFLAGS_$(abspath $(@D)/../..)) -DLUA_COMPAT_APIINTCASTS -DHAVE_CONFIG_H 23LIBS_$(d) = $(ALL_LIBS)
24CFLAGS_$(d) = $(CFLAGS_$(abspath $(@D)/../..))
25LDFLAGS_$(d) = $(LDFLAGS_$(abspath $(@D)/../..))
26SOFLAGS_$(d) = $(SOFLAGS_$(abspath $(@D)/../..))
27
28ifeq ($(CC_$(d)), sunpro)
29CPPFLAGS_$(d) += -DOPENSSL_NO_EC
30endif
31
32LDFLAGS_$(d) += -lssl -lcrypto -lpthread -lm
33
34# NetBSD, FreeBSD, OpenBSD (and presumably descendants) lack any libdl;
35# dlopen, et al are part of libc.
36ifneq ($(patsubst %BSD,BSD,$(OS_$(d))), BSD)
37LDFLAGS_$(d) += -ldl
38endif
39
40 24
41# 25#
42# C O M P I L A T I O N R U L E S 26# C O M P I L A T I O N R U L E S
43# 27#
28OBJS_$(d) = openssl.o ../vendor/compat53/c-api/compat-5.3.o
29
44$(d)/config.h: $(abspath $(d)/..)/config.h 30$(d)/config.h: $(abspath $(d)/..)/config.h
45 $(CP) $< $@ 31 $(CP) $< $@
46 32
47define BUILD_$(d) 33define BUILD_$(d)
48 34
49.SECONDARY: liblua$(1)-openssl openssl$(1) 35$$(d)/$(1)/openssl.so: $$(addprefix $$(d)/$(1)/, $$(OBJS_$(d)))
36 $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LIBS_$$(abspath $$(@D)/..))
50 37
51$$(d)/$(1)/openssl.so: $$(d)/$(1)/openssl.o 38$$(d)/$(1)/%.o: $$(d)/%.c $$(d)/../vendor/compat53/c-api/compat-5.3.h $$(d)/config.h
52 $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(SOFLAGS) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS)
53
54$$(d)/$(1)/openssl.o: $$(d)/openssl.c $$(d)/compat52.h $$(d)/config.h
55 test "$$(notdir $$(@D))" = "$$(call LUAPATH_$$(<D), $$(notdir $$(@D)), version)"
56 $$(MKDIR) -p $$(@D) 39 $$(MKDIR) -p $$(@D)
57 $$(CC) $$(CFLAGS_$$(<D)) $$(CFLAGS) $$(call LUAPATH_$$(<D), $$(notdir $$(@D)), cppflags) $$(CPPFLAGS_$$(<D)) $$(CPPFLAGS) -c -o $$@ $$< 40 $$(CC) $$(CFLAGS_$$(<D)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$$(<D)) -c -o $$@ $$<
41
42.SECONDARY: liblua$(1)-openssl openssl$(1) openssl
58 43
59liblua$(1)-openssl openssl$(1): $$(d)/$(1)/openssl.so 44liblua$(1)-openssl openssl$(1) openssl: $$(d)/$(1)/openssl.so
60 45
61endef # BUILD_$(d) 46endef # BUILD_$(d)
62 47
63$(eval $(call BUILD_$(d),5.1)) 48$(eval $(call BUILD_$(d),5.1))
64
65$(eval $(call BUILD_$(d),5.2)) 49$(eval $(call BUILD_$(d),5.2))
66
67$(eval $(call BUILD_$(d),5.3)) 50$(eval $(call BUILD_$(d),5.3))
68 51
69ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" "" 52ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" ""
70.SECONDARY: all5.1 all5.2 all 53.SECONDARY: all all5.1 all5.2 all5.3
71 54
72all5.1: liblua5.1-openssl 55all5.1: liblua5.1-openssl
73
74all5.2: liblua5.2-openssl 56all5.2: liblua5.2-openssl
75
76all5.3: liblua5.3-openssl 57all5.3: liblua5.3-openssl
77 58all: $(foreach API,$(strip $(LUA_APIS)),all$(API))
78all: all5.1 all5.2
79 59
80endif 60endif
81 61
@@ -85,13 +65,13 @@ endif
85# 65#
86define INSTALL_$(d) 66define INSTALL_$(d)
87 67
88LUAC$(1)_$(d) = $$(or $$(call LUAPATH_$(d), $(1), luac), true)
89
90MODS$(1)_$(d) = \ 68MODS$(1)_$(d) = \
91 $$(DESTDIR)$(2)/_openssl.so \ 69 $$(DESTDIR)$(2)/_openssl.so \
92 $$(DESTDIR)$(3)/openssl.lua \ 70 $$(DESTDIR)$(3)/openssl.lua \
93 $$(DESTDIR)$(3)/openssl/auxlib.lua \ 71 $$(DESTDIR)$(3)/openssl/auxlib.lua \
94 $$(DESTDIR)$(3)/openssl/bignum.lua \ 72 $$(DESTDIR)$(3)/openssl/bignum.lua \
73 $$(DESTDIR)$(3)/openssl/ocsp/basic.lua \
74 $$(DESTDIR)$(3)/openssl/ocsp/response.lua \
95 $$(DESTDIR)$(3)/openssl/pkey.lua \ 75 $$(DESTDIR)$(3)/openssl/pkey.lua \
96 $$(DESTDIR)$(3)/openssl/pubkey.lua \ 76 $$(DESTDIR)$(3)/openssl/pubkey.lua \
97 $$(DESTDIR)$(3)/openssl/x509.lua \ 77 $$(DESTDIR)$(3)/openssl/x509.lua \
@@ -114,42 +94,34 @@ MODS$(1)_$(d) = \
114 94
115.SECONDARY: liblua$(1)-openssl-install openssl$(1)-install 95.SECONDARY: liblua$(1)-openssl-install openssl$(1)-install
116 96
117$$(DESTDIR)$(2)/_openssl.so: $$(d)/$(1)/openssl.so 97liblua$(1)-openssl-install openssl$(1)-install: $$(MODS$(1)_$$(d))
118 $$(MKDIR) -p $$(@D)
119 $$(CP) -fp $$< $$@
120 98
121$$(DESTDIR)$(3)/openssl.lua: $$(d)/openssl.lua 99$$(DESTDIR)$(2)/_openssl.so: $$(d)/$(1)/openssl.so
122 $$(LUAC$(1)_$(d)) -p $$<
123 $$(MKDIR) -p $$(@D) 100 $$(MKDIR) -p $$(@D)
124 $$(CP) -p $$< $$@ 101 $$(CP) -p $$< $$@
125 102
126$$(DESTDIR)$(3)/openssl/%.lua: $$(d)/openssl.%.lua 103$$(DESTDIR)$(3)/%.lua: $$(d)/%.lua
127 $$(LUAC$(1)_$(d)) -p $$< 104 $$(LUAC$(subst .,,$(1))) -p $$<
128 $$(MKDIR) -p $$(@D) 105 $$(MKDIR) -p $$(@D)
129 $$(CP) -p $$< $$@ 106 $$(CP) -p $$< $$@
130 107
131# pubkey.lua used to be symbolic link to pkey.lua, but that caused packaging 108$$(DESTDIR)$(3)/openssl/%.lua: $$(d)/openssl.%.lua
132# headaches. Now it's a stub, but the cp -p in the inference rule will copy 109 $$(LUAC$(subst .,,$(1))) -p $$<
133# to the target of the symbolic link, so we need a special install rule to
134# clean up the mess.
135$$(DESTDIR)$(3)/openssl/pubkey.lua: $$(d)/openssl.pubkey.lua
136 $$(LUAC$(1)_$(d)) -p $$<
137 $$(MKDIR) -p $$(@D) 110 $$(MKDIR) -p $$(@D)
138 $$(RM) -f $$@
139 $$(CP) -p $$< $$@ 111 $$(CP) -p $$< $$@
140 112
141$$(DESTDIR)$(3)/openssl/x509/%.lua: $$(d)/openssl.x509.%.lua 113$$(DESTDIR)$(3)/openssl/ocsp/%.lua: $$(d)/ocsp.%.lua
142 $$(LUAC$(1)_$(d)) -p $$< 114 $$(LUAC$(subst .,,$(1))) -p $$<
143 $$(MKDIR) -p $$(@D) 115 $$(MKDIR) -p $$(@D)
144 $$(CP) -p $$< $$@ 116 $$(CP) -p $$< $$@
145 117
146$$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/openssl.ssl.%.lua 118$$(DESTDIR)$(3)/openssl/x509/%.lua: $$(d)/x509.%.lua
147 $$(LUAC$(1)_$(d)) -p $$< 119 $$(LUAC$(subst .,,$(1))) -p $$<
148 $$(MKDIR) -p $$(@D) 120 $$(MKDIR) -p $$(@D)
149 $$(CP) -p $$< $$@ 121 $$(CP) -p $$< $$@
150 122
151$$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/openssl.ssl.%.lua 123$$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/ssl.%.lua
152 $$(LUAC$(1)_$(d)) -p $$< 124 $$(LUAC$(subst .,,$(1))) -p $$<
153 $$(MKDIR) -p $$(@D) 125 $$(MKDIR) -p $$(@D)
154 $$(CP) -p $$< $$@ 126 $$(CP) -p $$< $$@
155 127
@@ -159,6 +131,7 @@ liblua$(1)-openssl-install openssl$(1)-install: $$(MODS$(1)_$$(d))
159 131
160liblua$(1)-openssl-uninstall openssl$(1)-uninstall: 132liblua$(1)-openssl-uninstall openssl$(1)-uninstall:
161 $$(RM) -f $$(MODS$(1)_$(d)) 133 $$(RM) -f $$(MODS$(1)_$(d))
134 -$$(RMDIR) $$(DESTDIR)$(3)/openssl/ocsp
162 -$$(RMDIR) $$(DESTDIR)$(3)/openssl/x509 135 -$$(RMDIR) $$(DESTDIR)$(3)/openssl/x509
163 -$$(RMDIR) $$(DESTDIR)$(3)/openssl/ssl 136 -$$(RMDIR) $$(DESTDIR)$(3)/openssl/ssl
164 -$$(RMDIR) $$(DESTDIR)$(3)/openssl 137 -$$(RMDIR) $$(DESTDIR)$(3)/openssl
@@ -166,31 +139,24 @@ liblua$(1)-openssl-uninstall openssl$(1)-uninstall:
166endef # INSTALL_$(d) 139endef # INSTALL_$(d)
167 140
168$(eval $(call INSTALL_$(d),5.1,$$(lua51cpath),$$(lua51path))) 141$(eval $(call INSTALL_$(d),5.1,$$(lua51cpath),$$(lua51path)))
169
170$(eval $(call INSTALL_$(d),5.2,$$(lua52cpath),$$(lua52path))) 142$(eval $(call INSTALL_$(d),5.2,$$(lua52cpath),$$(lua52path)))
171
172$(eval $(call INSTALL_$(d),5.3,$$(lua53cpath),$$(lua53path))) 143$(eval $(call INSTALL_$(d),5.3,$$(lua53cpath),$$(lua53path)))
173 144
174ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" "" 145ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" ""
146
175.SECONDARY: install5.1 install5.2 install5.3 install 147.SECONDARY: install5.1 install5.2 install5.3 install
176 148
177install5.1: liblua5.1-openssl-install 149install5.1: liblua5.1-openssl-install
178
179install5.2: liblua5.2-openssl-install 150install5.2: liblua5.2-openssl-install
180
181install5.3: liblua5.3-openssl-install 151install5.3: liblua5.3-openssl-install
182 152install: $(foreach API,$(strip $(LUA_APIS)),install$(API))
183install: install5.1 install5.2
184 153
185.PHONY: uninstall5.1 uninstall5.2 uninstall5.3 uninstall 154.PHONY: uninstall5.1 uninstall5.2 uninstall5.3 uninstall
186 155
187uninstall5.1: liblua5.1-openssl-uninstall 156uninstall5.1: liblua5.1-openssl-uninstall
188
189uninstall5.2: liblua5.2-openssl-uninstall 157uninstall5.2: liblua5.2-openssl-uninstall
190
191uninstall5.3: liblua5.3-openssl-uninstall 158uninstall5.3: liblua5.3-openssl-uninstall
192 159uninstall: $(foreach API,$(strip $(LUA_APIS)),uninstall$(API))
193uninstall: uninstall5.1 uninstall5.2
194 160
195endif 161endif
196 162
@@ -201,7 +167,7 @@ endif
201.PHONY: $(d)/clean $(d)/clean~ clean clean~ 167.PHONY: $(d)/clean $(d)/clean~ clean clean~
202 168
203$(d)/clean: 169$(d)/clean:
204 $(RM) -fr $(@D)/*.so $(@D)/*.o $(@D)/*.dSYM $(@D)/5.1 $(@D)/5.2 $(@D)/5.3 170 $(RM) -fr $(@D)/config.h $(@D)/*.dSYM $(@D)/5.1 $(@D)/5.2 $(@D)/5.3
205 171
206$(d)/clean~: $(d)/clean 172$(d)/clean~: $(d)/clean
207 $(RM) -f $(@D)/*~ 173 $(RM) -f $(@D)/*~
@@ -218,27 +184,27 @@ clean~: $(d)/clean~
218 184
219$(d)/help: 185$(d)/help:
220 @echo 186 @echo
221 @echo "ext/ targets:" 187 @echo "src/ targets:"
222 @echo "" 188 @echo ""
223 @echo " all - build all binary targets" 189 @echo " all - build all API targets"
224 @echo "openssl - invokes openssl5.1 and openssl5.2" 190 @echo " all5.1 - build 5.1/openssl.so"
225 @echo "openssl5.1 - build 5.1/openssl.so" 191 @echo " all5.2 - build 5.2/openssl.so"
226 @echo "openssl5.2 - build 5.2/openssl.so" 192 @echo " all5.3 - build 5.3/openssl.so"
227 @echo "openssl5.3 - build 5.3/openssl.so" 193 @echo " install - install all API targets"
228 @echo "install - invokes install5.1 and install5.2" 194 @echo " install5.1 - install openssl Lua 5.1 modules"
229 @echo "install5.1 - install openssl Lua 5.1 modules" 195 @echo " install5.2 - install openssl Lua 5.2 modules"
230 @echo "install5.2 - install openssl Lua 5.2 modules" 196 @echo " install5.3 - install openssl Lua 5.3 modules"
231 @echo "install5.3 - install openssl Lua 5.3 modules" 197 @echo " uninstall - uninstall all API targets"
232 @echo "uninstall - invokes uninstall5.1 and uninstall5.2"
233 @echo "uninstall5.1 - uninstall openssl Lua 5.1 modules" 198 @echo "uninstall5.1 - uninstall openssl Lua 5.1 modules"
234 @echo "uninstall5.2 - uninstall openssl Lua 5.2 modules" 199 @echo "uninstall5.2 - uninstall openssl Lua 5.2 modules"
235 @echo "uninstall5.3 - uninstall openssl Lua 5.3 modules" 200 @echo "uninstall5.3 - uninstall openssl Lua 5.3 modules"
236 @echo " clean - rm binary targets, object files, debugging symbols, etc" 201 @echo " clean - rm binary targets, object files, debugging symbols, etc"
237 @echo " clean~ - clean + rm *~" 202 @echo " clean~ - clean + rm *~"
238 @echo " help - echo this help message" 203 @echo " help - echo this help message"
239 @echo "" 204 @echo ""
240 @echo "Some important Make variables:" 205 @echo "Some important Make variables:"
241 @echo "" 206 @echo ""
207 @echo ' LUA_APIS - default Lua APIs to target ($(LUA_APIS))'
242 @echo " prefix - path to install root ($(value prefix))" 208 @echo " prefix - path to install root ($(value prefix))"
243 @echo ' lua51path - install path for Lua 5.1 modules ($(value lua51path))' 209 @echo ' lua51path - install path for Lua 5.1 modules ($(value lua51path))'
244 @echo 'lua51cpath - install path for Lua 5.1 C modules ($(value lua51cpath))' 210 @echo 'lua51cpath - install path for Lua 5.1 C modules ($(value lua51cpath))'
@@ -247,6 +213,10 @@ $(d)/help:
247 @echo ' lua53path - install path for Lua 5.3 modules ($(value lua53path))' 213 @echo ' lua53path - install path for Lua 5.3 modules ($(value lua53path))'
248 @echo 'lua53cpath - install path for Lua 5.3 C modules ($(value lua53cpath))' 214 @echo 'lua53cpath - install path for Lua 5.3 C modules ($(value lua53cpath))'
249 @echo "" 215 @echo ""
216 @echo 'LUA51_CPPFLAGS - cpp flags for Lua 5.1 headers ($(LUA51_CPPFLAGS))'
217 @echo 'LUA52_CPPFLAGS - cpp flags for Lua 5.2 headers ($(LUA52_CPPFLAGS))'
218 @echo 'LUA53_CPPFLAGS - cpp flags for Lua 5.3 headers ($(LUA53_CPPFLAGS))'
219 @echo ""
250 @echo "(NOTE: all the common GNU-style paths are supported, including" 220 @echo "(NOTE: all the common GNU-style paths are supported, including"
251 @echo "prefix, bindir, libdir, datadir, includedir, and DESTDIR.)" 221 @echo "prefix, bindir, libdir, datadir, includedir, and DESTDIR.)"
252 @echo "" 222 @echo ""