summaryrefslogtreecommitdiff
path: root/GNUmakefile
diff options
context:
space:
mode:
authorWilliam Ahern <william@server.local>2013-09-09 13:59:31 -0700
committerWilliam Ahern <william@server.local>2013-09-09 13:59:31 -0700
commit6e6b301ceee052ffd4187d9024c09520e4378de3 (patch)
tree4711d0e9a4868dda93a6168329e5ee9e4cc2781e /GNUmakefile
parent709e7fde568d3808089d92114632e4f273ba924b (diff)
downloadluaossl-6e6b301ceee052ffd4187d9024c09520e4378de3.tar.gz
luaossl-6e6b301ceee052ffd4187d9024c09520e4378de3.tar.bz2
luaossl-6e6b301ceee052ffd4187d9024c09520e4378de3.zip
-n
update openssl modules to new build
Diffstat (limited to 'GNUmakefile')
-rw-r--r--GNUmakefile283
1 files changed, 133 insertions, 150 deletions
diff --git a/GNUmakefile b/GNUmakefile
index d484ff5..c895dd1 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,163 +1,146 @@
1prefix = /usr/local 1# non-recursive prologue
2bindir = $(prefix)/bin 2sp := $(sp).x
3libdir = $(prefix)/lib 3dirstack_$(sp) := $(d)
4datadir = $(prefix)/share 4d := $(abspath $(lastword $(MAKEFILE_LIST))/..)
5includedir = $(prefix)/include
6luainclude =
7luapath =
8luacpath =
9LUAC =
10
11# backwards compatible install paths
12ifneq ($(origin lua52include), undefined)
13luainclude = $(lua52include)
14endif
15 5
16ifneq ($(origin lua52path), undefined) 6ifeq ($(origin GUARD_$(d)), undefined)
17luapath = $(lua52path) 7GUARD_$(d) := 1
18endif
19 8
20ifneq ($(origin lua52cpath), undefined)
21luacpath = $(lua52cpath)
22endif
23 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#
13include $(d)/../GNUmakefile
24 14
25# call helper to derive our Lua paths
26ENV = CC CPPFLAGS prefix bindir libdir datadir includedir \
27 luainclude luapath luacpath LUAC
28$(shell env $(foreach V, $(ENV), $(V)="$(call $(V))") ../mk/lua.path make > .config)
29include .config
30 15
16#
17# C O M P I L A T I O N F L A G S
18#
19OS_$(d) = $(shell $(d)/../mk/vendor.os)
20CC_$(d) = $(shell $(d)/../mk/vendor.cc)
21LUAPATH_$(d) = $(shell env CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(<D)/../mk/lua.path -krxm3 -I$(DESTDIR)$(includedir) -I/usr/include -I/usr/local/include -P$(DESTDIR)$(bindir) -P$(bindir) -L$(DESTDIR)$(libdir) -L$(libdir) -v$(1) $(2))
31 22
32VENDOR.OS = $(shell ../mk/vendor.os) 23CPPFLAGS_$(d) = $(CPPFLAGS_$(abspath $(@D)/../..))
33VENDOR.CC = $(shell env CC="${CC}" ../mk/vendor.cc) 24CFLAGS_$(d) = $(CFLAGS_$(abspath $(@D)/../..))
25LDFLAGS_$(d) = $(LDFLAGS_$(abspath $(@D)/../..))
26SOFLAGS_$(d) = $(SOFLAGS_$(abspath $(@D)/../..))
34 27
35ifneq ($(luainclude),) 28ifeq ($(CC_$(d)), sunpro)
36CPPFLAGS = -I$(luainclude) 29CPPFLAGS_$(d) += -DOPENSSL_NO_EC
37endif 30endif
38 31
39ifeq ($(VENDOR.CC), sunpro) 32LDFLAGS_$(d) += -lssl -lcrypto
40DFLAGS = -g
41CFLAGS = -xcode=pic13 $(DFLAGS)
42CPPFLAGS += -DOPENSSL_NO_EC
43else
44DFLAGS = -g -Wall -Wextra -Wno-deprecated-declarations -Wno-unused
45CFLAGS = -fPIC $(DFLAGS)
46endif
47 33
48LDFLAGS = -lssl -lcrypto 34#
35# C O M P I L A T I O N R U L E S
36#
37#all: $(d)/openssl.so
38
39define BUILD_$(d)
40
41.INTERMEDIATE: liblua$(1)-openssl
42
43$$(d)/$(1)/openssl.so: $$(d)/$(1)/openssl.o
44 $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(SOFLAGS) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS)
45
46$$(d)/$(1)/openssl.o: $$(d)/openssl.c $$(d)/compat52.h
47 test "$$(notdir $$(@D))" = "$$(call LUAPATH_$$(<D), $$(notdir $$(@D)), version)"
48 $$(MKDIR) -p $$(@D)
49 $$(CC) $$(CFLAGS_$$(<D)) $$(CFLAGS) $$(call LUAPATH_$$(<D), $$(notdir $$(@D)), cppflags) $$(CPPFLAGS_$$(<D)) $$(CPPFLAGS) -c -o $$@ $$<
50
51liblua$(1)-openssl: $$(d)/$(1)/openssl.so
52
53all: liblua$(1)-openssl
54
55endef # BUILD_$(d)
56
57$(eval $(call BUILD_$(d),5.1))
58
59$(eval $(call BUILD_$(d),5.2))
60
61
62#
63# I N S T A L L & U N I N S T A L L R U L E S
64#
65define INSTALL_$(d)
66
67LUAC$(1)_$(d) = $$(or $$(call LUAPATH_$(d), $(1), luac), true)
68
69MODS$(1)_$(d) = \
70 $$(DESTDIR)$(2)/_openssl.so \
71 $$(DESTDIR)$(3)/openssl/bignum.lua \
72 $$(DESTDIR)$(3)/openssl/pubkey.lua \
73 $$(DESTDIR)$(3)/openssl/x509.lua \
74 $$(DESTDIR)$(3)/openssl/x509/name.lua \
75 $$(DESTDIR)$(3)/openssl/x509/altname.lua \
76 $$(DESTDIR)$(3)/openssl/x509/chain.lua \
77 $$(DESTDIR)$(3)/openssl/x509/store.lua \
78 $$(DESTDIR)$(3)/openssl/ssl/context.lua \
79 $$(DESTDIR)$(3)/openssl/ssl.lua \
80 $$(DESTDIR)$(3)/openssl/digest.lua \
81 $$(DESTDIR)$(3)/openssl/hmac.lua \
82 $$(DESTDIR)$(3)/openssl/cipher.lua
83
84.INTERMEDIATE: liblua$(1)-openssl-install
85
86$$(DESTDIR)$(2)/_openssl.so: $$(d)/$(1)/openssl.so
87 $$(MKDIR) -p $$(@D)
88 $$(CP) -p $$< $$@
89
90$$(DESTDIR)$(3)/openssl/%.lua: $$(d)/openssl.%.lua
91 $$(MKDIR) -p $$(@D)
92 $$(CP) -p $$< $$@
93
94$$(DESTDIR)$(3)/openssl/x509/%.lua: $$(d)/openssl.x509.%.lua
95 $$(MKDIR) -p $$(@D)
96 $$(CP) -p $$< $$@
97
98$$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/openssl.ssl.%.lua
99 $$(MKDIR) -p $$(@D)
100 $$(CP) -p $$< $$@
101
102$$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/openssl.ssl.%.lua
103 $$(MKDIR) -p $$(@D)
104 $$(CP) -p $$< $$@
105
106liblua$(1)-openssl-install: $$(MODS$(1)_$$(d))
107
108.PHONY: liblua$(1)-openssl-uninstall uninstall
109
110liblua$(1)-openssl-uninstall:
111 $$(RM) -f $$(MODS$(1)_$(d))
112 -$$(RMDIR) $$(DESTDIR)$(3)/openssl/x509
113 -$$(RMDIR) $$(DESTDIR)$(3)/openssl/ssl
114 -$$(RMDIR) $$(DESTDIR)$(3)/openssl
115
116uninstall: liblua$(1)-openssl-uninstall
117
118endef # INSTALL_$(d)
119
120
121$(eval $(call INSTALL_$(d),5.1,$$(lua51cpath),$$(lua51path)))
122
123$(eval $(call INSTALL_$(d),5.2,$$(lua52cpath),$$(lua52path)))
124
125
126#
127# C L E A N R U L E S
128#
129.PHONY: $(d)/clean $(d)/clean~ clean clean~
130
131$(d)/clean:
132 $(RM) -fr $(@D)/*.so $(@D)/*.o $(@D)/*.dSYM $(@D)/5.1 $(@D)/5.2
133
134$(d)/clean~: $(d)/clean
135 $(RM) -f $(@D)/*~
136
137clean: $(d)/clean
138
139clean~: $(d)/clean~
49 140
50ifeq ($(VENDOR.OS), Darwin)
51SOFLAGS = -bundle -undefined dynamic_lookup
52else
53SOFLAGS = -shared
54endif
55 141
142endif # include guard
56 143
57all: openssl.so 144# non-recursive epilogue
58 145d := $(dirstack_$(sp))
59openssl.so: openssl.o 146sp := $(basename $(sp))
60 $(CC) -o $@ $^ $(SOFLAGS) $(LDFLAGS)
61
62openssl.o: openssl.c compat52.h
63 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
64
65
66install: $(DESTDIR)$(luacpath)/_openssl.so \
67 $(DESTDIR)$(luapath)/openssl/bignum.lua \
68 $(DESTDIR)$(luapath)/openssl/pubkey.lua \
69 $(DESTDIR)$(luapath)/openssl/x509.lua \
70 $(DESTDIR)$(luapath)/openssl/x509/name.lua \
71 $(DESTDIR)$(luapath)/openssl/x509/altname.lua \
72 $(DESTDIR)$(luapath)/openssl/x509/chain.lua \
73 $(DESTDIR)$(luapath)/openssl/x509/store.lua \
74 $(DESTDIR)$(luapath)/openssl/ssl/context.lua \
75 $(DESTDIR)$(luapath)/openssl/ssl.lua \
76 $(DESTDIR)$(luapath)/openssl/digest.lua \
77 $(DESTDIR)$(luapath)/openssl/hmac.lua \
78 $(DESTDIR)$(luapath)/openssl/cipher.lua
79
80$(DESTDIR)$(luacpath)/_openssl.so: openssl.so
81 mkdir -p $(@D)
82 cp -p $< $@
83
84$(DESTDIR)$(luapath)/openssl/bignum.lua: openssl.bignum.lua
85 mkdir -p $(@D)
86 cp -p $< $@
87
88$(DESTDIR)$(luapath)/openssl/pubkey.lua: openssl.pubkey.lua
89 mkdir -p $(@D)
90 cp -p $< $@
91
92$(DESTDIR)$(luapath)/openssl/x509.lua: openssl.x509.lua
93 mkdir -p $(@D)
94 cp -p $< $@
95
96$(DESTDIR)$(luapath)/openssl/x509/name.lua: openssl.x509.name.lua
97 mkdir -p $(@D)
98 cp -p $< $@
99
100$(DESTDIR)$(luapath)/openssl/x509/altname.lua: openssl.x509.altname.lua
101 mkdir -p $(@D)
102 cp -p $< $@
103
104$(DESTDIR)$(luapath)/openssl/x509/chain.lua: openssl.x509.chain.lua
105 mkdir -p $(@D)
106 cp -p $< $@
107
108$(DESTDIR)$(luapath)/openssl/x509/store.lua: openssl.x509.store.lua
109 mkdir -p $(@D)
110 cp -p $< $@
111
112$(DESTDIR)$(luapath)/openssl/ssl/context.lua: openssl.ssl.context.lua
113 mkdir -p $(@D)
114 cp -p $< $@
115
116$(DESTDIR)$(luapath)/openssl/ssl.lua: openssl.ssl.lua
117 mkdir -p $(@D)
118 cp -p $< $@
119
120$(DESTDIR)$(luapath)/openssl/digest.lua: openssl.digest.lua
121 mkdir -p $(@D)
122 cp -p $< $@
123
124$(DESTDIR)$(luapath)/openssl/hmac.lua: openssl.hmac.lua
125 mkdir -p $(@D)
126 cp -p $< $@
127
128$(DESTDIR)$(luapath)/openssl/cipher.lua: openssl.cipher.lua
129 mkdir -p $(@D)
130 cp -p $< $@
131
132
133.PHONY: clean clean~ help
134
135clean:
136 rm -f *.so *.o
137 rm -f .config
138
139clean~: clean
140 rm -f *~
141
142help:
143 @echo "Available targets:"
144 @echo ""
145 @echo " all - build all binary targets"
146 @echo "openssl.so - build openssl.so module"
147 @echo " install - install openssl modules"
148 @echo " clean - rm binary targets, object files, debugging symbols, etc"
149 @echo " clean~ - clean + rm *~"
150 @echo " help - echo this help message"
151 @echo ""
152 @echo "Some important Make variables:"
153 @echo ""
154 @echo " prefix - path to install root"
155 @echo 'luainclude - path to Lua headers ($$(prefix)/include/lua/5.2)'
156 @echo ' luapath - install path for Lua modules ($$(prefix)/share/lua/5.2)'
157 @echo ' luacpath - install path for Lua C modules ($$(prefix)/lib/lua/5.2)'
158 @echo ' LUAC - path to luac utility ($$(bindir)/luac)'
159 @echo ""
160 @echo "(NOTE: all the common GNU-style paths are supported, including"
161 @echo "prefix, bindir, libdir, datadir, includedir, and DESTDIR.)"
162 @echo ""
163 @echo "Report bugs to <william@25thandClement.com>"