aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: c26fd2d3319cc57e371e0827548a4b9f1d84384b (plain) (blame)
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
prefix = /usr/local/lua52
libdir = $(prefix)/lib
datadir = $(prefix)/share
includedir = $(prefix)/include
luainclude = $(includedir)/lua/5.2
luapath = $(datadir)/lua/5.2
luacpath = $(libdir)/lua/5.2

LUAC = $(prefix)/bin/luac

VENDOR.OS = $(shell ../mk/vendor.os)
VENDOR.CC = $(shell env CC="${CC}" ../mk/vendor.cc)


CPPFLAGS = -I$(luainclude)

ifeq ($(VENDOR.CC), sunpro)
DFLAGS = -g
CFLAGS = -xcode=pic13 $(DFLAGS)
CPPFLAGS += -DOPENSSL_NO_EC
else
DFLAGS = -g -Wall -Wextra -Wno-deprecated-declarations -Wno-unused
CFLAGS = -fPIC $(DFLAGS)
endif

LDFLAGS = -lssl -lcrypto

ifeq ($(VENDOR.OS), Darwin)
SOFLAGS = -bundle -undefined dynamic_lookup
else
SOFLAGS = -shared
endif


all: openssl.so

openssl.so: openssl.o
	$(CC) -o $@ $^ $(SOFLAGS) $(LDFLAGS)

openssl.o: openssl.c compat52.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<


install: $(DESTDIR)$(luacpath)/_openssl.so \
         $(DESTDIR)$(luapath)/openssl/bignum.lua \
         $(DESTDIR)$(luapath)/openssl/pubkey.lua \
         $(DESTDIR)$(luapath)/openssl/x509.lua \
         $(DESTDIR)$(luapath)/openssl/x509/name.lua \
         $(DESTDIR)$(luapath)/openssl/x509/altname.lua \
         $(DESTDIR)$(luapath)/openssl/x509/chain.lua \
         $(DESTDIR)$(luapath)/openssl/x509/store.lua \
         $(DESTDIR)$(luapath)/openssl/ssl/context.lua \
         $(DESTDIR)$(luapath)/openssl/ssl.lua \
         $(DESTDIR)$(luapath)/openssl/digest.lua \
         $(DESTDIR)$(luapath)/openssl/hmac.lua

$(DESTDIR)$(luacpath)/_openssl.so: openssl.so
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/bignum.lua: openssl.bignum.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/pubkey.lua: openssl.pubkey.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/x509.lua: openssl.x509.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/x509/name.lua: openssl.x509.name.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/x509/altname.lua: openssl.x509.altname.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/x509/chain.lua: openssl.x509.chain.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/x509/store.lua: openssl.x509.store.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/ssl/context.lua: openssl.ssl.context.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/ssl.lua: openssl.ssl.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/digest.lua: openssl.digest.lua
	mkdir -p $(@D)
	cp -p $< $@

$(DESTDIR)$(luapath)/openssl/hmac.lua: openssl.hmac.lua
	mkdir -p $(@D)
	cp -p $< $@


.PHONY: clean clean~ help

clean:
	rm -f *.so *.o

clean~: clean
	rm -f *~

help:
	@echo "Available targets:"
	@echo ""
	@echo "       all - build all binary targets"
	@echo "openssl.so - build openssl.so module"
	@echo "   install - install openssl modules"
	@echo "     clean - rm binary targets, object files, debugging symbols, etc"
	@echo "    clean~ - clean + rm *~"
	@echo "      help - echo this help message"
	@echo ""
	@echo "Some important Make variables:"
	@echo ""
	@echo "    prefix - path to install root"
	@echo 'luainclude - path to Lua headers ($$(prefix)/include/lua/5.2)'
	@echo '   luapath - install path for Lua modules ($$(prefix)/share/lua/5.2)'
	@echo '  luacpath - install path for Lua C modules ($$(prefix)/lib/lua/5.2)'
	@echo '      LUAC - path to luac utility ($$(prefix)/bin/luac)'
	@echo ""
	@echo "Report bugs to <william@25thandClement.com>"