4 AXTLS_FILE = $(AXTLS_DIR)-$(AXTLS_VERSION).tar.gz
6 NIXIO_SHADOW ?= $(shell echo 'int main(void){ return !getspnam("root"); }' | $(CC) $(CFLAGS) -include shadow.h -xc -o/dev/null - 2>/dev/null && echo yes)
8 NIXIO_LDFLAGS = -llua -lm -ldl
11 ifeq (,$(findstring Darwin,$(OS)))
12 NIXIO_LDFLAGS += -lcrypt -shared
14 NIXIO_LDFLAGS += -bundle -undefined dynamic_lookup
15 EXTRA_CFLAGS += -D__DARWIN__
18 NIXIO_OBJ = nixio.o socket.o sockopt.o bind.o address.o \
19 protoent.o poll.o io.o file.o splice.o process.o \
20 syslog.o bit.o binary.o fs.o user.o \
21 $(if $(NIXIO_TLS),tls-crypto.o tls-context.o tls-socket.o,)
23 ifeq ($(NIXIO_TLS),axtls)
24 TLS_CFLAGS = -IaxTLS/ssl -IaxTLS/crypto -IaxTLS/config -include axtls-compat.h
25 TLS_DEPENDS = axtls-compat.o
26 NIXIO_OBJ += axtls-compat.o libaxtls.a
29 ifeq ($(NIXIO_TLS),openssl)
30 NIXIO_LDFLAGS += -lssl -lcrypto
33 ifeq ($(NIXIO_TLS),cyassl)
34 NIXIO_LDFLAGS += -lcyassl
35 TLS_DEPENDS = cyassl-compat.o
36 TLS_CFLAGS = -include cyassl-compat.h
37 NIXIO_OBJ += cyassl-compat.o
41 NIXIO_CFLAGS += -DNO_TLS
44 ifneq ($(NIXIO_SHADOW),yes)
45 NIXIO_CFLAGS += -DNO_SHADOW
50 NIXIO_LDFLAGS += -lsocket -lnsl -lsendfile
53 ifneq (,$(findstring MINGW,$(OS))$(findstring mingw,$(OS))$(findstring Windows,$(OS)))
54 NIXIO_CROSS_CC:=$(shell which i586-mingw32msvc-cc)
55 ifneq (,$(NIXIO_CROSS_CC))
58 NIXIO_OBJ += mingw-compat.o
59 NIXIO_LDFLAGS_POST:=-llua -lssl -lcrypto -lws2_32 -lgdi32
61 EXTRA_CFLAGS += -D_WIN32_WINNT=0x0501
69 $(CC) $(CPPFLAGS) $(CFLAGS) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) -c -o $@ $<
72 tls-crypto.o: $(TLS_DEPENDS) tls-crypto.c
73 $(CC) $(CPPFLAGS) $(CFLAGS) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ tls-crypto.c
75 tls-context.o: $(TLS_DEPENDS) tls-context.c
76 $(CC) $(CPPFLAGS) $(CFLAGS) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ tls-context.c
78 tls-socket.o: $(TLS_DEPENDS) tls-socket.c
79 $(CC) $(CPPFLAGS) $(CFLAGS) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ tls-socket.c
81 axtls-compat.o: libaxtls.a axtls-compat.c
82 $(CC) $(CPPFLAGS) $(CFLAGS) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ axtls-compat.c
84 cp -pR axtls-root/* dist/
88 $(CC) $(LDFLAGS) $(SHLIB_FLAGS) -o $(NIXIO_SO) $(NIXIO_OBJ) $(NIXIO_LDFLAGS) $(NIXIO_LDFLAGS_POST)
89 mkdir -p dist/usr/lib/lua
90 cp $(NIXIO_SO) dist/usr/lib/lua/$(NIXIO_SO)
92 $(AXTLS_DIR)/.prepared:
94 #tar xvfz $(AXTLS_FILE)
95 cp axtls-config/.config axtls-config/config.h $(AXTLS_DIR)/config
98 libaxtls.a: $(AXTLS_DIR)/.prepared
99 $(MAKE) -C $(AXTLS_DIR) CC="$(CC)" CFLAGS="$(CFLAGS) $(EXTRA_CFLAGS) $(FPIC) -Wall -pedantic -I../config -I../ssl -I../crypto" LDFLAGS="$(LDFLAGS)" OS="$(OS)" clean all
100 cp -p $(AXTLS_DIR)/_stage/libaxtls.a src
101 # *************************************************************************
106 # The use of the axTLS cryptographical provider is discouraged!
107 # Please switch to either CyaSSL or OpenSSL.
108 # Support for axTLS might be removed in the near future.
112 #**************************************************************************
115 rm -f *.o *.so *.a *.dll
116 rm -f $(AXTLS_DIR)/.prepared
120 cp -pR dist/* $(DESTDIR)/