Skip to content

Commit

Permalink
Rework makefiles to simplify setting and choosing build options.
Browse files Browse the repository at this point in the history
Includes documentation for common build settings, reasonable
defaults, and ability to set common build options in the
environment.
  • Loading branch information
sam-github committed May 8, 2012
1 parent 04be61f commit c291383
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 22 deletions.
20 changes: 15 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
PLAT?= macosx
# luasocket makefile
#
# see src/makefile for description of how to customize the build
#
# Targets:
# install install system independent support
# install-unix also install unix-only support
# install-both install both lua5.1 and lua5.2 socket support
# print print the build settings

PLAT?= linux
PLATS= macosx linux win32

#------
# Hopefully no need to change anything below this line
#
all: $(PLAT)

$(PLATS) none install install-unix local clean:
@cd src; $(MAKE) $@
$(MAKE) -C src $@

print:
$(MAKE) -C src $@

test:
lua test/hello.lua
Expand Down
78 changes: 61 additions & 17 deletions src/makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,65 @@
PLAT?=macosx
# luasocket src/makefile
#
# Definitions in this section can be overriden on the command line or in the
# environment.
#
# These are equivalent:
#
# export PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw
# make
#
# and
#
# make PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw

# PLAT: linux macosx win32
# platform to build for
PLAT?=linux

# LUAV: 5.1 5.2
# lua version to build against
LUAV?=5.1
prefix=../../../build/lua/$(LUAV)
#prefix=/usr/local
#prefix=/opt/local
#prefix=.

LUAINC_macosx=../../../build/lua/$(LUAV)/include
#LUAINC_macosx=/opt/local/include
#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.2.0-beta/src
#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.1.4/src
# DEBUG: NODEBUG DEBUG
# debug mode causes luasocket to collect and returns timing information useful
# for testing and debugging luasocket itself
DEBUG?=NODEBUG

#LUAINC_linux=/usr/local/include/lua$(LUAV)
LUAINC_linux=/usr/include/lua$(LUAV)
#LUAINC_linux=/usr/local/include
# prefix: /usr/local /usr /opt/local /sw
# the top of the default install tree
prefix?=/usr/local

# where lua headers are found for macosx builds
# LUAINC_macosx: /opt/local/include
LUAINC_macosx?=/opt/local/include
# FIXME default should be where fink puts lua

# LUAINC_linux: /usr/include/lua$(LUAV) /usr/local/include /usr/local/include/lua$(LUAV)
# where lua headers are found for linux builds
LUAINC_linux?=/usr/include/lua$(LUAV)

# LUAINC_win32:
# LUALIB_win32:
# where lua headers and libraries are found for win32 builds
LUAINC_win32?="../../lua-5.1.3/src"
LUALIB_win32?="../../lua-5.1.3"
# FIXME default should be where lua-for-windows puts lua

# DESTDIR: (no default)
# used by package managers to install into a temporary destination
DESTDIR=

#------
# Definitions below can be overridden on the make command line, but
# shouldn't have to be.

LUAINC_win32="../../lua-5.1.3/src"
LUALIB_win32="../../lua-5.1.3"
print:
@echo PLAT=$(PLAT)
@echo LUAV=$(LUAV)
@echo DEBUG=$(DEBUG)
@echo prefix=$(prefix)
@echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT))
@echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT))

#------
# Install directories
Expand Down Expand Up @@ -44,7 +88,7 @@ PLATS= macosx linux win32
SO_macosx=so
O_macosx=o
CC_macosx=gcc
DEF_macosx= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN -DLUA_COMPAT_MODULE \
DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN -DLUA_COMPAT_MODULE \
-DLUASOCKET_API='__attribute__((visibility("default")))' \
-DMIME_API='__attribute__((visibility("default")))'
CFLAGS_macosx= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \
Expand All @@ -59,7 +103,7 @@ SOCKET_macosx=usocket.o
SO_linux=so
O_linux=o
CC_linux=gcc
DEF_linux=-DLUASOCKET_DEBUG \
DEF_linux=-DLUASOCKET_$(DEBUG) \
-DLUASOCKET_API='__attribute__((visibility("default")))' \
-DMIME_API='__attribute__((visibility("default")))'
CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \
Expand All @@ -75,7 +119,7 @@ SO_win32=dll
O_win32=obj
CC_win32=cl
DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \
/D "LUASOCKET_API=__declspec(dllexport)" /D "LUASOCKET_DEBUG" \
/D "LUASOCKET_API=__declspec(dllexport)" /D "LUASOCKET_$(DEBUG)" \
/D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL"
CFLAGS_win32=/I$(LUAINC) $(DEF) /O2 /Ot /MD /W3 /nologo
LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \
Expand Down

0 comments on commit c291383

Please sign in to comment.