aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 481174e02084b94d4878dcf7e6959abaaff07127 (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
prefix = /usr/local/lua52
libdir = $(prefix)/lib
datadir = $(prefix)/share
includedir = $(prefix)/include
lua52include = $(includedir)/lua/5.2
lua52path = $(datadir)/lua/5.2
lua52cpath = $(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$(DESTDIR)$(lua52include)
DFLAGS = -Wall -Wextra -Wno-deprecated-declarations -Wno-unused
CFLAGS = -fPIC $(DFLAGS)
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
	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<


install: $(lua52cpath)/_openssl.so

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


.PHONY: clean clean~

clean:
	rm -f *.so *.o

clean~: clean
	rm -f *~