aboutsummaryrefslogtreecommitdiff
path: root/src/makefile
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2009-05-27 09:31:38 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2009-05-27 09:31:38 +0000
commitbce60be30fe8e9c1b0eb33128c23c93d7bca5303 (patch)
tree3927343c777fcb7764a0f2f89754a0ceab141c21 /src/makefile
parentd1a72435d5bd3528f3c334cd4d1da16dcead47bf (diff)
downloadluasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.tar.gz
luasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.tar.bz2
luasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.zip
Decent makefiles!
Diffstat (limited to 'src/makefile')
-rw-r--r--src/makefile156
1 files changed, 122 insertions, 34 deletions
diff --git a/src/makefile b/src/makefile
index b614f77..3351997 100644
--- a/src/makefile
+++ b/src/makefile
@@ -1,39 +1,86 @@
1PLAT = none
2INSTALL_DATA=cp
3INSTALL_EXEC=cp
4INSTALL_TOP= /opt/local
5LUAINC= $(LUAINC_$(PLAT))
6
1#------ 7#------
2# Load configuration 8# Install directories
3# 9#
4include ../config 10INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/5.1
11INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/5.1
12INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket
13INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket
14INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime
15INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime
5 16
6#------ 17#------
7# Hopefully no need to change anything below this line 18# Output file names
8# 19#
20EXT=so
21SOCKET_V=2.0.3
22MIME_V=1.0.3
23SOCKET_SO=socket.$(EXT).$(SOCKET_V)
24MIME_SO=mime.$(EXT).$(MIME_V)
25UNIX_SO=unix.$(EXT)
9 26
10#------ 27#------
11# Modules belonging to socket-core 28# Compiler and linker settings
12# 29# for Mac OS X
30LUAINC_macosx= -I/opt/local/include
31CC_macosx=gcc
32DEF_macosx= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN \
33 -DLUASOCKET_API='__attribute__((visibility("default")))' \
34 -DMIME_API='__attribute__((visibility("default")))'
35CFLAGS_macosx= $(LUAINC) $(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common \
36 -fvisibility=hidden
37LDFLAGS_macosx= -bundle -undefined dynamic_lookup
38LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
13 39
14#$(COMPAT)/compat-5.1.o \ 40#------
41# Compiler and linker settings
42# for Linux
43LUAINC_linux= -I/usr/local/include/lua5.1
44CC_linux=gcc
45DEF_linux=-DLUASOCKET_DEBUG \
46 -DLUASOCKET_API='__attribute__((visibility("default")))' \
47 -DMIME_API='__attribute__((visibility("default")))'
48CFLAGS_linux= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic \
49 -fvisibility=hidden
50LDFLAGS_linux=-O -shared -fpic
51LD_linux= gcc
15 52
16SOCKET_OBJS:= \ 53#------
54# Settings selected for platform
55#
56CC=$(CC_$(PLAT))
57DEF=$(DEF_$(PLAT))
58CFLAGS=$(CFLAGS_$(PLAT))
59LDFLAGS=$(LDFLAGS_$(PLAT))
60LD=$(LD_$(PLAT))
61
62#------
63# Modules belonging to socket-core
64#
65SOCKET_OBJS= \
17 luasocket.o \ 66 luasocket.o \
18 timeout.o \ 67 timeout.o \
19 buffer.o \ 68 buffer.o \
20 io.o \ 69 io.o \
21 auxiliar.o \ 70 auxiliar.o \
22 options.o \ 71 options.o \
23 inet.o \ 72 inet.o \
24 tcp.o \ 73 usocket.o \
25 udp.o \
26 except.o \ 74 except.o \
27 select.o \ 75 select.o \
28 usocket.o 76 tcp.o \
77 udp.o
29 78
30#------ 79#------
31# Modules belonging mime-core 80# Modules belonging mime-core
32# 81#
33#$(COMPAT)/compat-5.1.o \ 82MIME_OBJS= \
34 83 mime.o
35MIME_OBJS:=\
36 mime.o
37 84
38#------ 85#------
39# Modules belonging unix (local domain sockets) 86# Modules belonging unix (local domain sockets)
@@ -47,7 +94,35 @@ UNIX_OBJS:=\
47 usocket.o \ 94 usocket.o \
48 unix.o 95 unix.o
49 96
50all: $(SOCKET_SO) $(MIME_SO) 97#------
98# Files to install
99#
100TO_SOCKET_SHARE:= \
101 http.lua \
102 url.lua \
103 tp.lua \
104 ftp.lua \
105 headers.lua \
106 smtp.lua
107
108TO_TOP_SHARE:= \
109 ltn12.lua \
110 socket.lua \
111 mime.lua
112
113default: $(PLAT)
114
115macosx:
116 $(MAKE) all PLAT=macosx
117
118linux:
119 $(MAKE) all PLAT=linux
120
121none:
122 @echo "Please choose a platform:"
123 @echo " $(PLATS)"
124
125all: $(SOCKET_SO) $(MIME_SO)
51 126
52$(SOCKET_SO): $(SOCKET_OBJS) 127$(SOCKET_SO): $(SOCKET_OBJS)
53 $(LD) $(LDFLAGS) -o $@ $(SOCKET_OBJS) 128 $(LD) $(LDFLAGS) -o $@ $(SOCKET_OBJS)
@@ -58,6 +133,25 @@ $(MIME_SO): $(MIME_OBJS)
58$(UNIX_SO): $(UNIX_OBJS) 133$(UNIX_SO): $(UNIX_OBJS)
59 $(LD) $(LDFLAGS) -o $@ $(UNIX_OBJS) 134 $(LD) $(LDFLAGS) -o $@ $(UNIX_OBJS)
60 135
136install:
137 mkdir -p $(INSTALL_TOP_SHARE)
138 $(INSTALL_DATA) $(TO_TOP_SHARE) $(INSTALL_TOP_SHARE)
139 mkdir -p $(INSTALL_SOCKET_SHARE)
140 $(INSTALL_DATA) $(TO_SOCKET_SHARE) $(INSTALL_SOCKET_SHARE)
141 mkdir -p $(INSTALL_SOCKET_LIB)
142 $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_LIB)/core.$(EXT)
143 mkdir -p $(INSTALL_MIME_LIB)
144 $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(EXT)
145
146local:
147 $(MAKE) install INSTALL_TOP_LIB=.. INSTALL_TOP_SHARE=..
148
149clean:
150 rm -f $(SOCKET_SO) $(SOCKET_OBJS)
151 rm -f $(MIME_SO) $(UNIX_SO) $(MIME_OBJS) $(UNIX_OBJS)
152
153.PHONY: all $(PLATS) default clean echo none
154
61#------ 155#------
62# List of dependencies 156# List of dependencies
63# 157#
@@ -66,25 +160,19 @@ buffer.o: buffer.c buffer.h io.h timeout.h
66except.o: except.c except.h 160except.o: except.c except.h
67inet.o: inet.c inet.h socket.h io.h timeout.h usocket.h 161inet.o: inet.c inet.h socket.h io.h timeout.h usocket.h
68io.o: io.c io.h timeout.h 162io.o: io.c io.h timeout.h
69luasocket.o: luasocket.c luasocket.h auxiliar.h except.h timeout.h \ 163luasocket.o: luasocket.c luasocket.h auxiliar.h except.h \
70 buffer.h io.h inet.h socket.h usocket.h tcp.h udp.h select.h 164 timeout.h buffer.h io.h inet.h socket.h usocket.h tcp.h \
165 udp.h select.h
71mime.o: mime.c mime.h 166mime.o: mime.c mime.h
72options.o: options.c auxiliar.h options.h socket.h io.h timeout.h \ 167options.o: options.c auxiliar.h options.h socket.h io.h \
73 usocket.h inet.h 168 timeout.h usocket.h inet.h
74select.o: select.c socket.h io.h timeout.h usocket.h select.h 169select.o: select.c socket.h io.h timeout.h usocket.h select.h
75tcp.o: tcp.c auxiliar.h socket.h io.h timeout.h usocket.h inet.h \ 170tcp.o: tcp.c auxiliar.h socket.h io.h timeout.h usocket.h \
76 options.h tcp.h buffer.h 171 inet.h options.h tcp.h buffer.h
77timeout.o: timeout.c auxiliar.h timeout.h 172timeout.o: timeout.c auxiliar.h timeout.h
78udp.o: udp.c auxiliar.h socket.h io.h timeout.h usocket.h inet.h \ 173udp.o: udp.c auxiliar.h socket.h io.h timeout.h usocket.h \
79 options.h udp.h 174 inet.h options.h udp.h
80unix.o: unix.c auxiliar.h socket.h io.h timeout.h usocket.h options.h \ 175unix.o: unix.c auxiliar.h socket.h io.h timeout.h usocket.h \
81 unix.h buffer.h 176 options.h unix.h buffer.h
82usocket.o: usocket.c socket.h io.h timeout.h usocket.h 177usocket.o: usocket.c socket.h io.h timeout.h usocket.h
83 178wsocket.o: wsocket.c socket.h io.h timeout.h usocket.h
84clean:
85 rm -f $(SOCKET_SO) $(SOCKET_OBJS)
86 rm -f $(MIME_SO) $(UNIX_SO) $(MIME_OBJS) $(UNIX_OBJS)
87
88#------
89# End of makefile configuration
90#