summaryrefslogtreecommitdiffhomepage
path: root/libs/nixio/Makefile
blob: ca22328aef52281b61ab48fe157b88c01549af12 (plain)
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
include ../../build/config.mk
include ../../build/module.mk
include ../../build/gccconfig.mk

AXTLS_VERSION = 1.2.1
AXTLS_DIR     = axTLS
AXTLS_FILE    = $(AXTLS_DIR)-$(AXTLS_VERSION).tar.gz
NIXIO_TLS    ?= openssl
NIXIO_LDFLAGS =

NIXIO_OBJ = src/nixio.o src/socket.o src/sockopt.o src/bind.o src/address.o \
	    src/poll.o src/io.o src/file.o src/splice.o src/process.o src/syslog.o \
	    src/tls-context.o src/tls-socket.o

ifeq ($(NIXIO_TLS),axtls)
	TLS_CFLAGS = -IaxTLS/ssl -IaxTLS/crypto -IaxTLS/config -include src/openssl-compat.h
	TLS_DEPENDS = src/openssl-compat.o
	NIXIO_OBJ += src/openssl-compat.o src/libaxtls.a
endif

ifeq ($(NIXIO_TLS),openssl)
	NIXIO_LDFLAGS += -lssl
endif


ifeq ($(OS),SunOS)
	NIXIO_LDFLAGS += -lsocket -lnsl -lsendfile
endif


%.o: %.c
	$(COMPILE) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) -c -o $@ $< 

src/tls-context.o: $(TLS_DEPENDS) src/tls-context.c
	$(COMPILE) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ src/tls-context.c
	
src/tls-socket.o: $(TLS_DEPENDS) src/tls-socket.c
	$(COMPILE) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ src/tls-socket.c
	
src/openssl-compat.o: src/libaxtls.a src/openssl-compat.c
	$(COMPILE) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ src/openssl-compat.c
	mkdir -p dist
	cp -pR axtls-root/* dist/
	

compile: $(NIXIO_OBJ)
	$(LINK) $(SHLIB_FLAGS) $(NIXIO_LDFLAGS) -o src/nixio.so $(NIXIO_OBJ)
	mkdir -p dist$(LUA_LIBRARYDIR)
	cp src/nixio.so dist$(LUA_LIBRARYDIR)/nixio.so

$(AXTLS_DIR)/.prepared:
	#rm -rf $(AXTLS_DIR)
	#tar xvfz $(AXTLS_FILE)
	cp axtls-config/.config axtls-config/config.h $(AXTLS_DIR)/config
	touch $@

src/libaxtls.a: $(AXTLS_DIR)/.prepared
	$(MAKE) -C $(AXTLS_DIR) CC=$(CC) CFLAGS="$(CFLAGS) $(EXTRA_CFLAGS) $(FPIC) '-Dalloca(size)=__builtin_alloca(size)' -Wall -pedantic -I../config -I../ssl -I../crypto" LDFLAGS="$(LDFLAGS)" OS="$(OS)" clean all
	cp -p $(AXTLS_DIR)/_stage/libaxtls.a src

clean: luaclean
	rm -f src/*.o src/*.so src/*.a
	rm -f $(AXTLS_DIR)/.prepared