-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathMakefile
70 lines (52 loc) · 1.49 KB
/
Makefile
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
# lsocket Makefile, works on Linux and Mac OS X, everywhere else roll your own.
#
# Gunnar Zötl <[email protected]>, 2013-2015.
# Released under the terms of the MIT license. See file LICENSE for details.
# swap the comments on the next 2 lines if you want the async resolver to be built and installed also
ALL=lsocket.so
#ALL=lsocket.so async_resolver.so
ifdef DEBUG
DBG=-g
OPT=
else
DBG=
OPT=-O2
endif
OS = $(shell uname -s)
CC=gcc
CFLAGS=-Wall -fPIC $(OPT) $(DBG)
# if this does not work, just set it to your version number
LUA_VERSION=$(shell lua -e "print((string.gsub(_VERSION, '^.+ ', '')))")
LUA_DIR = /usr/local
LUA_INCDIR=$(LUA_DIR)/include
INST_LIBDIR=$(LUA_DIR)/lib/lua/$(LUA_VERSION)
ifeq ($(OS),Darwin)
LIBFLAG=-bundle -undefined dynamic_lookup -all_load
else
LIBFLAG=-shared
endif
ifndef PTHRFLAG
PTHRFLAG=-pthread
endif
INCDIRS=-I$(LUA_INCDIR)
LDFLAGS=$(LIBFLAG) $(DBG)
all: $(ALL)
debug:; make DEBUG=1
install: all
mkdir -p $(INST_LIBDIR)
cp $(ALL) $(INST_LIBDIR)
lsocket.so: lsocket.o
$(CC) $(LDFLAGS) -o $@ $<
async_resolver.so: async_resolver.o gai_async.o
$(CC) $(LDFLAGS) -o $@ $^ $(PTHRFLAG)
%.o: %.c
$(CC) $(CFLAGS) $(INCDIRS) -c $< -o $@
async_resolver.o gai_async.o: gai_async.h
clean:
find . -name "*~" -exec rm {} \;
find . -name .DS_Store -exec rm {} \;
find . -name ._* -exec rm {} \;
rm -f *.o *.so core samples/testsocket
mingw: lsocket.dll
lsocket.dll : lsocket.c win_compat.c
$(CC) -o $@ -Wall $(OPT) $(DBG) $(INCDIRS) $^ $(LDFLAGS) -lws2_32 -L/usr/local/bin -llua53