From fceef56dceaa603322f871787751c8901afcd31a Mon Sep 17 00:00:00 2001 From: "Vadim A. Misbakh-Soloviov" Date: Tue, 14 May 2013 04:23:57 +0700 Subject: [PATCH] DESTDIR compatibility + *FLAGs/utils configurability + ld -fpic error fix. Also fixes #1 Signed-off-by: Vadim A. Misbakh-Soloviov --- Makefile | 14 ++++++++------ src/Makefile | 25 ++++++++++++++----------- src/luasocket/Makefile | 10 ++++++---- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 93fbe77..c8aa90f 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,19 @@ # Inform the location to intall the modules -LUAPATH=/usr/local/share/lua/5.1 -LUACPATH=/usr/local/lib/lua/5.1 +LUAPATH ?= /usr/share/lua/5.1 +LUACPATH ?= /usr/lib/lua/5.1 # Compile with build-in LuaSocket's help files. # Comment this lines if you will link with non-internal LuaSocket's help files # and edit INCDIR and LIBDIR properly. -EXTRA=luasocket -DEFS=-DWITH_LUASOCKET +EXTRA = luasocket +DEFS = -DWITH_LUASOCKET # Edit the lines below to inform new path, if necessary. # Path below points to internal LuaSocket's help files. -INCDIR=-I. -LIBDIR=-L./luasocket +INC_PATH ?= -I/usr/include +LIB_PATH ?= -L/usr/lib +INCDIR = -I. $(INC_PATH) +LIBDIR = -L./luasocket $(LIB_PATH) # For Mac OS X: set the system version MACOSX_VERSION=10.4 diff --git a/src/Makefile b/src/Makefile index 0358f00..7c94870 100644 --- a/src/Makefile +++ b/src/Makefile @@ -10,29 +10,32 @@ LIBS=-lssl -lcrypto -lluasocket WARN=-Wall -pedantic -BSD_CFLAGS=-O2 -fpic $(WARN) $(INCDIR) $(DEFS) -BSD_LDFLAGS=-O -shared -fpic $(LIBDIR) +BSD_CFLAGS=-O2 -fPIC $(WARN) $(INCDIR) $(DEFS) +BSD_LDFLAGS=-O -fPIC -shared $(LIBDIR) -LNX_CFLAGS=-O2 -fpic $(WARN) $(INCDIR) $(DEFS) -LNX_LDFLAGS=-O -shared -fpic $(LIBDIR) +LNX_CFLAGS=-O2 -fPIC $(WARN) $(INCDIR) $(DEFS) +LNX_LDFLAGS=-O -fPIC -shared $(LIBDIR) MAC_ENV=env MACOSX_DEPLOYMENT_TARGET='$(MACVER)' MAC_CFLAGS=-O2 -fno-common $(WARN) $(INCDIR) $(DEFS) MAC_LDFLAGS=-bundle -undefined dynamic_lookup $(LIBDIR) -CC=gcc -LD=$(MYENV) gcc -CFLAGS=$(MYCFLAGS) -LDFLAGS=$(MYLDFLAGS) +INSTALL ?= install +CC ?= cc +LD ?= $(MYENV) cc +CFLAGS += $(MYCFLAGS) +LDFLAGS += $(MYLDFLAGS) +DESTDIR ?= / .PHONY: all clean install none linux bsd macosx luasocket all: install: $(CMOD) $(LMOD) - install -m644 -D $(CMOD) $(LUACPATH) - install -m644 -D $(LMOD) $(LUAPATH) - install -m644 -D https.lua $(LUAPATH)/ssl + $(INSTALL) -d $(DESTDIR)$(LUAPATH)/ssl $(DESTDIR)$(LUACPATH) + $(INSTALL) -D $(CMOD) $(DESTDIR)$(LUACPATH) + $(INSTALL) -m644 -D $(LMOD) $(DESTDIR)$(LUAPATH) + $(INSTALL) -m644 -D https.lua $(DESTDIR)$(LUAPATH)/ssl linux: @$(MAKE) $(CMOD) MYCFLAGS="$(LNX_CFLAGS)" MYLDFLAGS="$(LNX_LDFLAGS)" EXTRA="$(EXTRA)" diff --git a/src/luasocket/Makefile b/src/luasocket/Makefile index 901c678..5d845d4 100644 --- a/src/luasocket/Makefile +++ b/src/luasocket/Makefile @@ -4,16 +4,18 @@ OBJS= \ timeout.o \ usocket.o -CC=gcc -CFLAGS=$(MYCFLAGS) -DLUASOCKET_DEBUG +CC ?= cc +CFLAGS += $(MYCFLAGS) -DLUASOCKET_DEBUG +AR := ar rcu +RANLIB ?= ranlib .PHONY: all clean all: libluasocket.a libluasocket.a: $(OBJS) - ar rcu $@ $(OBJS) - ranlib $@ + $(AR) $@ $(OBJS) + $(RANLIB) $@ clean: rm -f $(OBJS) libluasocket.a