Debian Codegraph @

src/libraries/luasocket/libluasocket/makefile

raw
1 # luasocket src/makefile
2 #
3 # Definitions in this section can be overridden on the command line or in the
4 # environment.
5 #
6 # These are equivalent:
7 #
8 # export PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw
9 # make
10 #
11 # and
12 #
13 # make PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw
14
15 # PLAT: linux macosx win32 mingw
16 # platform to build for
17 PLAT?=linux
18
19 # LUAV: 5.1 5.2
20 # lua version to build against
21 LUAV?=5.1
22
23 # MYCFLAGS: to be set by user if needed
24 MYCFLAGS?=
25
26 # MYLDFLAGS: to be set by user if needed
27 MYLDFLAGS?=
28
29 # DEBUG: NODEBUG DEBUG
30 # debug mode causes luasocket to collect and returns timing information useful
31 # for testing and debugging luasocket itself
32 DEBUG?=NODEBUG
33
34 # where lua headers are found for macosx builds
35 # LUAINC_macosx:
36 # /opt/local/include
37 LUAINC_macosx_base?=/opt/local/include
38 LUAINC_macosx?=$(LUAINC_macosx_base)/lua/$(LUAV)
39 # FIXME default should this default to fink or to macports?
40 # What happens when more than one Lua version is installed?
41 LUAPREFIX_macosx?=/opt/local
42 CDIR_macosx?=lib/lua/$(LUAV)
43 LDIR_macosx?=share/lua/$(LUAV)
44
45 # LUAINC_linux:
46 # /usr/include/lua$(LUAV)
47 # /usr/local/include
48 # /usr/local/include/lua$(LUAV)
49 # where lua headers are found for linux builds
50 LUAINC_linux_base?=/usr/include
51 LUAINC_linux?=$(LUAINC_linux_base)/lua/$(LUAV)
52 LUAPREFIX_linux?=/usr/local
53 CDIR_linux?=lib/lua/$(LUAV)
54 LDIR_linux?=share/lua/$(LUAV)
55
56 # LUAINC_freebsd:
57 # /usr/local/include/lua$(LUAV)
58 # where lua headers are found for freebsd builds
59 LUAINC_freebsd_base?=/usr/local/include/
60 LUAINC_freebsd?=$(LUAINC_freebsd_base)/lua$(LUAV)
61 LUAPREFIX_freebsd?=/usr/local/
62 CDIR_freebsd?=lib/lua/$(LUAV)
63 LDIR_freebsd?=share/lua/$(LUAV)
64
65 # where lua headers are found for mingw builds
66 # LUAINC_mingw:
67 # /opt/local/include
68 LUAINC_mingw_base?=/usr/include
69 LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUAV)
70 LUALIB_mingw_base?=/usr/bin
71 LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUAV)/lua$(subst .,,$(LUAV)).dll
72 LUAPREFIX_mingw?=/usr
73 CDIR_mingw?=lua/$(LUAV)
74 LDIR_mingw?=lua/$(LUAV)/lua
75
76
77 # LUAINC_win32:
78 # LUALIB_win32:
79 # where lua headers and libraries are found for win32 builds
80 LUAPREFIX_win32?=
81 LUAINC_win32?=$(LUAPREFIX_win32)/include/lua/$(LUAV)
82 PLATFORM_win32?=Release
83 CDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)
84 LDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)/lua
85 LUALIB_win32?=$(LUAPREFIX_win32)/lib/lua/$(LUAV)/$(PLATFORM_win32)
86 LUALIBNAME_win32?=lua$(subst .,,$(LUAV)).lib
87
88
89 # LUAINC_solaris:
90 LUAINC_solaris_base?=/usr/include
91 LUAINC_solaris?=$(LUAINC_solaris_base)/lua/$(LUAV)
92 LUAPREFIX_solaris?=/usr/local
93 CDIR_solaris?=lib/lua/$(LUAV)
94 LDIR_solaris?=share/lua/$(LUAV)
95
96 # prefix: /usr/local /usr /opt/local /sw
97 # the top of the default install tree
98 prefix?=$(LUAPREFIX_$(PLAT))
99
100 CDIR?=$(CDIR_$(PLAT))
101 LDIR?=$(LDIR_$(PLAT))
102
103 # DESTDIR: (no default)
104 # used by package managers to install into a temporary destination
105 DESTDIR=
106
107 #------
108 # Definitions below can be overridden on the make command line, but
109 # shouldn't have to be.
110
111
112 #------
113 # Install directories
114 #
115
116 INSTALL_DIR=install -d
117 INSTALL_DATA=install -m644
118 INSTALL_EXEC=install
119 INSTALL_TOP=$(DESTDIR)$(prefix)
120
121 INSTALL_TOP_LDIR=$(INSTALL_TOP)/$(LDIR)
122 INSTALL_TOP_CDIR=$(INSTALL_TOP)/$(CDIR)
123
124 INSTALL_SOCKET_LDIR=$(INSTALL_TOP_LDIR)/socket
125 INSTALL_SOCKET_CDIR=$(INSTALL_TOP_CDIR)/socket
126 INSTALL_MIME_LDIR=$(INSTALL_TOP_LDIR)/mime
127 INSTALL_MIME_CDIR=$(INSTALL_TOP_CDIR)/mime
128
129 print:
130 @echo PLAT=$(PLAT)
131 @echo LUAV=$(LUAV)
132 @echo DEBUG=$(DEBUG)
133 @echo prefix=$(prefix)
134 @echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT))
135 @echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT))
136 @echo INSTALL_TOP_CDIR=$(INSTALL_TOP_CDIR)
137 @echo INSTALL_TOP_LDIR=$(INSTALL_TOP_LDIR)
138 @echo CFLAGS=$(CFLAGS)
139 @echo LDFLAGS=$(LDFLAGS)
140
141 #------
142 # Supported platforms
143 #
144 PLATS= macosx linux win32 mingw solaris
145
146 #------
147 # Compiler and linker settings
148 # for Mac OS X
149 SO_macosx=so
150 O_macosx=o
151 CC_macosx=gcc
152 DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN \
153 -DLUASOCKET_API='__attribute__((visibility("default")))' \
154 -DUNIX_API='__attribute__((visibility("default")))' \
155 -DMIME_API='__attribute__((visibility("default")))'
156 CFLAGS_macosx= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \
157 -fvisibility=hidden
158 LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o
159 LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
160 SOCKET_macosx=usocket.o
161
162 #------
163 # Compiler and linker settings
164 # for Linux
165 SO_linux=so
166 O_linux=o
167 CC_linux=gcc
168 DEF_linux=-DLUASOCKET_$(DEBUG) \
169 -DLUASOCKET_API='__attribute__((visibility("default")))' \
170 -DUNIX_API='__attribute__((visibility("default")))' \
171 -DMIME_API='__attribute__((visibility("default")))'
172 CFLAGS_linux= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \
173 -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden
174 LDFLAGS_linux=-O -shared -fpic -o
175 LD_linux=gcc
176 SOCKET_linux=usocket.o
177
178 #------
179 # Compiler and linker settings
180 # for FreeBSD
181 SO_freebsd=so
182 O_freebsd=o
183 CC_freebsd=gcc
184 DEF_freebsd=-DLUASOCKET_$(DEBUG) \
185 -DLUASOCKET_API='__attribute__((visibility("default")))' \
186 -DUNIX_API='__attribute__((visibility("default")))' \
187 -DMIME_API='__attribute__((visibility("default")))'
188 CFLAGS_freebsd= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \
189 -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden
190 LDFLAGS_freebsd=-O -shared -fpic -o
191 LD_freebsd=gcc
192 SOCKET_freebsd=usocket.o
193
194 #------
195 # Compiler and linker settings
196 # for Solaris
197 SO_solaris=so
198 O_solaris=o
199 CC_solaris=gcc
200 DEF_solaris=-DLUASOCKET_$(DEBUG) \
201 -DLUASOCKET_API='__attribute__((visibility("default")))' \
202 -DUNIX_API='__attribute__((visibility("default")))' \
203 -DMIME_API='__attribute__((visibility("default")))'
204 CFLAGS_solaris=-I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \
205 -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden
206 LDFLAGS_solaris=-lnsl -lsocket -lresolv -O -shared -fpic -o
207 LD_solaris=gcc
208 SOCKET_solaris=usocket.o
209
210 #------
211 # Compiler and linker settings
212 # for MingW
213 SO_mingw=dll
214 O_mingw=o
215 CC_mingw=gcc
216 DEF_mingw= -DLUASOCKET_INET_PTON -DLUASOCKET_$(DEBUG) \
217 -DWINVER=0x0501 -DLUASOCKET_API='__declspec(dllexport)' \
218 -DMIME_API='__declspec(dllexport)'
219 CFLAGS_mingw= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \
220 -fvisibility=hidden
221 LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o
222 LD_mingw=gcc
223 SOCKET_mingw=wsocket.o
224
225
226 #------
227 # Compiler and linker settings
228 # for Win32
229 SO_win32=dll
230 O_win32=obj
231 CC_win32=cl
232 DEF_win32= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \
233 //D "LUASOCKET_API=__declspec(dllexport)" //D "_CRT_SECURE_NO_WARNINGS" \
234 //D "_WINDLL" //D "MIME_API=__declspec(dllexport)" \
235 //D "LUASOCKET_$(DEBUG)"
236 CFLAGS_win32=//I "$(LUAINC)" $(DEF) //O2 //Ot //MD //W3 //nologo
237 LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \
238 //MANIFEST //MANIFESTFILE:"intermediate.manifest" \
239 //MANIFESTUAC:"level='asInvoker' uiAccess='false'" \
240 //SUBSYSTEM:WINDOWS //OPT:REF //OPT:ICF //DYNAMICBASE:NO \
241 //MACHINE:X86 /LIBPATH:"$(shell cmd //c echo $(LUALIB))" \
242 $(LUALIBNAME_win32) ws2_32.lib //OUT:
243 LD_win32=cl
244 SOCKET_win32=wsocket.obj
245
246 .SUFFIXES: .obj
247
248 .c.obj:
249 $(CC) $(CFLAGS) //Fo"$@" //c $<
250
251 #------
252 # Output file names
253 #
254 SO=$(SO_$(PLAT))
255 O=$(O_$(PLAT))
256 SOCKET_V=3.0-rc1
257 MIME_V=1.0.3
258 SOCKET_SO=socket-$(SOCKET_V).$(SO)
259 MIME_SO=mime-$(MIME_V).$(SO)
260 UNIX_SO=unix.$(SO)
261 SERIAL_SO=serial.$(SO)
262 SOCKET=$(SOCKET_$(PLAT))
263
264 #------
265 # Settings selected for platform
266 #
267 CC=$(CC_$(PLAT))
268 DEF=$(DEF_$(PLAT))
269 CFLAGS=$(MYCFLAGS) $(CFLAGS_$(PLAT))
270 LDFLAGS=$(MYLDFLAGS) $(LDFLAGS_$(PLAT))
271 LD=$(LD_$(PLAT))
272 LUAINC= $(LUAINC_$(PLAT))
273 LUALIB= $(LUALIB_$(PLAT))
274
275 #------
276 # Modules belonging to socket-core
277 #
278 SOCKET_OBJS= \
279 luasocket.$(O) \
280 timeout.$(O) \
281 buffer.$(O) \
282 io.$(O) \
283 auxiliar.$(O) \
284 compat.$(O) \
285 options.$(O) \
286 inet.$(O) \
287 $(SOCKET) \
288 except.$(O) \
289 select.$(O) \
290 tcp.$(O) \
291 udp.$(O)
292
293 #------
294 # Modules belonging mime-core
295 #
296 MIME_OBJS= \
297 mime.$(O) \
298 compat.$(O)
299
300 #------
301 # Modules belonging unix (local domain sockets)
302 #
303 UNIX_OBJS=\
304 buffer.$(O) \
305 auxiliar.$(O) \
306 options.$(O) \
307 timeout.$(O) \
308 io.$(O) \
309 usocket.$(O) \
310 unixtcp.$(O) \
311 unixudp.$(O) \
312 compat.$(O) \
313 unix.$(O)
314
315 #------
316 # Modules belonging to serial (device streams)
317 #
318 SERIAL_OBJS=\
319 buffer.$(O) \
320 auxiliar.$(O) \
321 options.$(O) \
322 timeout.$(O) \
323 io.$(O) \
324 usocket.$(O) \
325 serial.$(O)
326
327 #------
328 # Files to install
329 #
330 TO_SOCKET_LDIR= \
331 http.lua \
332 url.lua \
333 tp.lua \
334 ftp.lua \
335 headers.lua \
336 smtp.lua
337
338 TO_TOP_LDIR= \
339 ltn12.lua \
340 socket.lua \
341 mime.lua
342
343 #------
344 # Targets
345 #
346 default: $(PLAT)
347
348
349 freebsd:
350 $(MAKE) all-unix PLAT=freebsd
351
352 macosx:
353 $(MAKE) all-unix PLAT=macosx
354
355 win32:
356 $(MAKE) all PLAT=win32
357
358 linux:
359 $(MAKE) all-unix PLAT=linux
360
361 mingw:
362 $(MAKE) all PLAT=mingw
363
364 solaris:
365 $(MAKE) all-unix PLAT=solaris
366
367 none:
368 @echo "Please run"
369 @echo " make PLATFORM"
370 @echo "where PLATFORM is one of these:"
371 @echo " $(PLATS)"
372
373 all: $(SOCKET_SO) $(MIME_SO)
374
375 $(SOCKET_SO): $(SOCKET_OBJS)
376 $(LD) $(SOCKET_OBJS) $(LDFLAGS)$@
377
378 $(MIME_SO): $(MIME_OBJS)
379 $(LD) $(MIME_OBJS) $(LDFLAGS)$@
380
381 all-unix: all $(UNIX_SO) $(SERIAL_SO)
382
383 $(UNIX_SO): $(UNIX_OBJS)
384 $(LD) $(UNIX_OBJS) $(LDFLAGS)$@
385
386 $(SERIAL_SO): $(SERIAL_OBJS)
387 $(LD) $(SERIAL_OBJS) $(LDFLAGS)$@
388
389 install:
390 $(INSTALL_DIR) $(INSTALL_TOP_LDIR)
391 $(INSTALL_DATA) $(TO_TOP_LDIR) $(INSTALL_TOP_LDIR)
392 $(INSTALL_DIR) $(INSTALL_SOCKET_LDIR)
393 $(INSTALL_DATA) $(TO_SOCKET_LDIR) $(INSTALL_SOCKET_LDIR)
394 $(INSTALL_DIR) $(INSTALL_SOCKET_CDIR)
395 $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_CDIR)/core.$(SO)
396 $(INSTALL_DIR) $(INSTALL_MIME_CDIR)
397 $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_CDIR)/core.$(SO)
398
399 install-unix: install
400 $(INSTALL_EXEC) $(UNIX_SO) $(INSTALL_SOCKET_CDIR)/$(UNIX_SO)
401 $(INSTALL_EXEC) $(SERIAL_SO) $(INSTALL_SOCKET_CDIR)/$(SERIAL_SO)
402
403 local:
404 $(MAKE) install INSTALL_TOP_CDIR=.. INSTALL_TOP_LDIR=..
405
406 clean:
407 rm -f $(SOCKET_SO) $(SOCKET_OBJS) $(SERIAL_OBJS)
408 rm -f $(MIME_SO) $(UNIX_SO) $(SERIAL_SO) $(MIME_OBJS) $(UNIX_OBJS)
409
410 .PHONY: all $(PLATS) default clean echo none
411
412 #------
413 # List of dependencies
414 #
415 compat.$(O): compat.c compat.h
416 auxiliar.$(O): auxiliar.c auxiliar.h
417 buffer.$(O): buffer.c buffer.h io.h timeout.h
418 except.$(O): except.c except.h
419 inet.$(O): inet.c inet.h socket.h io.h timeout.h usocket.h
420 io.$(O): io.c io.h timeout.h
421 luasocket.$(O): luasocket.c luasocket.h auxiliar.h except.h \
422 timeout.h buffer.h io.h inet.h socket.h usocket.h tcp.h \
423 udp.h select.h
424 mime.$(O): mime.c mime.h
425 options.$(O): options.c auxiliar.h options.h socket.h io.h \
426 timeout.h usocket.h inet.h
427 select.$(O): select.c socket.h io.h timeout.h usocket.h select.h
428 serial.$(O): serial.c auxiliar.h socket.h io.h timeout.h usocket.h \
429 options.h unix.h buffer.h
430 tcp.$(O): tcp.c auxiliar.h socket.h io.h timeout.h usocket.h \
431 inet.h options.h tcp.h buffer.h
432 timeout.$(O): timeout.c auxiliar.h timeout.h
433 udp.$(O): udp.c auxiliar.h socket.h io.h timeout.h usocket.h \
434 inet.h options.h udp.h
435 unix.$(O): unix.c auxiliar.h socket.h io.h timeout.h usocket.h \
436 options.h unix.h buffer.h
437 usocket.$(O): usocket.c socket.h io.h timeout.h usocket.h
438 wsocket.$(O): wsocket.c socket.h io.h timeout.h usocket.h