aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego.nehab@gmail.com>2012-05-08 11:51:25 -0700
committerDiego Nehab <diego.nehab@gmail.com>2012-05-08 11:51:25 -0700
commit1bb586d655ebb1d39ad29d45ec520f2ccfbf8e86 (patch)
treed583e64eaff558bc601179ea4127d2aa720cf312
parentee7c53c3e58350c51e5c622e1b9ff8acf02c0e59 (diff)
parentc291383ce26d975648ac110bf7c8ba04c65de116 (diff)
downloadluasocket-1bb586d655ebb1d39ad29d45ec520f2ccfbf8e86.tar.gz
luasocket-1bb586d655ebb1d39ad29d45ec520f2ccfbf8e86.tar.bz2
luasocket-1bb586d655ebb1d39ad29d45ec520f2ccfbf8e86.zip
Merge pull request #7 from sam-github/fix-makefiles
Rework makefiles to simplify setting and choosing build options.
-rw-r--r--makefile20
-rw-r--r--src/makefile78
2 files changed, 76 insertions, 22 deletions
diff --git a/makefile b/makefile
index 8e9e967..934485b 100644
--- a/makefile
+++ b/makefile
@@ -1,13 +1,23 @@
1PLAT?= macosx 1# luasocket makefile
2#
3# see src/makefile for description of how to customize the build
4#
5# Targets:
6# install install system independent support
7# install-unix also install unix-only support
8# install-both install both lua5.1 and lua5.2 socket support
9# print print the build settings
10
11PLAT?= linux
2PLATS= macosx linux win32 12PLATS= macosx linux win32
3 13
4#------
5# Hopefully no need to change anything below this line
6#
7all: $(PLAT) 14all: $(PLAT)
8 15
9$(PLATS) none install install-unix local clean: 16$(PLATS) none install install-unix local clean:
10 @cd src; $(MAKE) $@ 17 $(MAKE) -C src $@
18
19print:
20 $(MAKE) -C src $@
11 21
12test: 22test:
13 lua test/hello.lua 23 lua test/hello.lua
diff --git a/src/makefile b/src/makefile
index 6225ce4..4df62bd 100644
--- a/src/makefile
+++ b/src/makefile
@@ -1,21 +1,65 @@
1PLAT?=macosx 1# luasocket src/makefile
2#
3# Definitions in this section can be overriden 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
16# platform to build for
17PLAT?=linux
18
19# LUAV: 5.1 5.2
20# lua version to build against
2LUAV?=5.1 21LUAV?=5.1
3prefix=../../../build/lua/$(LUAV)
4#prefix=/usr/local
5#prefix=/opt/local
6#prefix=.
7 22
8LUAINC_macosx=../../../build/lua/$(LUAV)/include 23# DEBUG: NODEBUG DEBUG
9#LUAINC_macosx=/opt/local/include 24# debug mode causes luasocket to collect and returns timing information useful
10#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.2.0-beta/src 25# for testing and debugging luasocket itself
11#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.1.4/src 26DEBUG?=NODEBUG
12 27
13#LUAINC_linux=/usr/local/include/lua$(LUAV) 28# prefix: /usr/local /usr /opt/local /sw
14LUAINC_linux=/usr/include/lua$(LUAV) 29# the top of the default install tree
15#LUAINC_linux=/usr/local/include 30prefix?=/usr/local
31
32# where lua headers are found for macosx builds
33# LUAINC_macosx: /opt/local/include
34LUAINC_macosx?=/opt/local/include
35# FIXME default should be where fink puts lua
36
37# LUAINC_linux: /usr/include/lua$(LUAV) /usr/local/include /usr/local/include/lua$(LUAV)
38# where lua headers are found for linux builds
39LUAINC_linux?=/usr/include/lua$(LUAV)
40
41# LUAINC_win32:
42# LUALIB_win32:
43# where lua headers and libraries are found for win32 builds
44LUAINC_win32?="../../lua-5.1.3/src"
45LUALIB_win32?="../../lua-5.1.3"
46# FIXME default should be where lua-for-windows puts lua
47
48# DESTDIR: (no default)
49# used by package managers to install into a temporary destination
50DESTDIR=
51
52#------
53# Definitions below can be overridden on the make command line, but
54# shouldn't have to be.
16 55
17LUAINC_win32="../../lua-5.1.3/src" 56print:
18LUALIB_win32="../../lua-5.1.3" 57 @echo PLAT=$(PLAT)
58 @echo LUAV=$(LUAV)
59 @echo DEBUG=$(DEBUG)
60 @echo prefix=$(prefix)
61 @echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT))
62 @echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT))
19 63
20#------ 64#------
21# Install directories 65# Install directories
@@ -44,7 +88,7 @@ PLATS= macosx linux win32
44SO_macosx=so 88SO_macosx=so
45O_macosx=o 89O_macosx=o
46CC_macosx=gcc 90CC_macosx=gcc
47DEF_macosx= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN -DLUA_COMPAT_MODULE \ 91DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN -DLUA_COMPAT_MODULE \
48 -DLUASOCKET_API='__attribute__((visibility("default")))' \ 92 -DLUASOCKET_API='__attribute__((visibility("default")))' \
49 -DMIME_API='__attribute__((visibility("default")))' 93 -DMIME_API='__attribute__((visibility("default")))'
50CFLAGS_macosx= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \ 94CFLAGS_macosx= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \
@@ -59,7 +103,7 @@ SOCKET_macosx=usocket.o
59SO_linux=so 103SO_linux=so
60O_linux=o 104O_linux=o
61CC_linux=gcc 105CC_linux=gcc
62DEF_linux=-DLUASOCKET_DEBUG \ 106DEF_linux=-DLUASOCKET_$(DEBUG) \
63 -DLUASOCKET_API='__attribute__((visibility("default")))' \ 107 -DLUASOCKET_API='__attribute__((visibility("default")))' \
64 -DMIME_API='__attribute__((visibility("default")))' 108 -DMIME_API='__attribute__((visibility("default")))'
65CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \ 109CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \
@@ -75,7 +119,7 @@ SO_win32=dll
75O_win32=obj 119O_win32=obj
76CC_win32=cl 120CC_win32=cl
77DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \ 121DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \
78 /D "LUASOCKET_API=__declspec(dllexport)" /D "LUASOCKET_DEBUG" \ 122 /D "LUASOCKET_API=__declspec(dllexport)" /D "LUASOCKET_$(DEBUG)" \
79 /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" 123 /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL"
80CFLAGS_win32=/I$(LUAINC) $(DEF) /O2 /Ot /MD /W3 /nologo 124CFLAGS_win32=/I$(LUAINC) $(DEF) /O2 /Ot /MD /W3 /nologo
81LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \ 125LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \