Rework makefiles to simplify setting and choosing build options.

Includes documentation for common build settings, reasonable
defaults, and ability to set common build options in the
environment.
This commit is contained in:
Sam Roberts 2012-04-26 13:33:01 -07:00
parent 04be61f88d
commit c291383ce2
2 changed files with 76 additions and 22 deletions

View File

@ -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 PLATS= macosx linux win32
#------
# Hopefully no need to change anything below this line
#
all: $(PLAT) all: $(PLAT)
$(PLATS) none install install-unix local clean: $(PLATS) none install install-unix local clean:
@cd src; $(MAKE) $@ $(MAKE) -C src $@
print:
$(MAKE) -C src $@
test: test:
lua test/hello.lua lua test/hello.lua

View File

@ -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 LUAV?=5.1
prefix=../../../build/lua/$(LUAV)
#prefix=/usr/local
#prefix=/opt/local
#prefix=.
LUAINC_macosx=../../../build/lua/$(LUAV)/include # DEBUG: NODEBUG DEBUG
#LUAINC_macosx=/opt/local/include # debug mode causes luasocket to collect and returns timing information useful
#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.2.0-beta/src # for testing and debugging luasocket itself
#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.1.4/src DEBUG?=NODEBUG
#LUAINC_linux=/usr/local/include/lua$(LUAV) # prefix: /usr/local /usr /opt/local /sw
LUAINC_linux=/usr/include/lua$(LUAV) # the top of the default install tree
#LUAINC_linux=/usr/local/include prefix?=/usr/local
LUAINC_win32="../../lua-5.1.3/src" # where lua headers are found for macosx builds
LUALIB_win32="../../lua-5.1.3" # 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.
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 # Install directories
@ -44,7 +88,7 @@ PLATS= macosx linux win32
SO_macosx=so SO_macosx=so
O_macosx=o O_macosx=o
CC_macosx=gcc 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")))' \ -DLUASOCKET_API='__attribute__((visibility("default")))' \
-DMIME_API='__attribute__((visibility("default")))' -DMIME_API='__attribute__((visibility("default")))'
CFLAGS_macosx= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \ CFLAGS_macosx= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \
@ -59,7 +103,7 @@ SOCKET_macosx=usocket.o
SO_linux=so SO_linux=so
O_linux=o O_linux=o
CC_linux=gcc CC_linux=gcc
DEF_linux=-DLUASOCKET_DEBUG \ DEF_linux=-DLUASOCKET_$(DEBUG) \
-DLUASOCKET_API='__attribute__((visibility("default")))' \ -DLUASOCKET_API='__attribute__((visibility("default")))' \
-DMIME_API='__attribute__((visibility("default")))' -DMIME_API='__attribute__((visibility("default")))'
CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \ CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \
@ -75,7 +119,7 @@ SO_win32=dll
O_win32=obj O_win32=obj
CC_win32=cl CC_win32=cl
DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \ 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" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL"
CFLAGS_win32=/I$(LUAINC) $(DEF) /O2 /Ot /MD /W3 /nologo CFLAGS_win32=/I$(LUAINC) $(DEF) /O2 /Ot /MD /W3 /nologo
LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \ LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \