Merge pull request #3 from msva/master

DESTDIR compatibility + *FLAGs/utils configurability + ld -fpic error fix + #1 fix
This commit is contained in:
Matthew Wild 2013-05-15 04:02:47 -07:00
commit f77fb40033
3 changed files with 28 additions and 21 deletions

View File

@ -1,17 +1,19 @@
# Inform the location to intall the modules # Inform the location to intall the modules
LUAPATH=/usr/local/share/lua/5.1 LUAPATH ?= /usr/share/lua/5.1
LUACPATH=/usr/local/lib/lua/5.1 LUACPATH ?= /usr/lib/lua/5.1
# Compile with build-in LuaSocket's help files. # Compile with build-in LuaSocket's help files.
# Comment this lines if you will link with non-internal LuaSocket's help files # Comment this lines if you will link with non-internal LuaSocket's help files
# and edit INCDIR and LIBDIR properly. # and edit INCDIR and LIBDIR properly.
EXTRA=luasocket EXTRA = luasocket
DEFS=-DWITH_LUASOCKET DEFS = -DWITH_LUASOCKET
# Edit the lines below to inform new path, if necessary. # Edit the lines below to inform new path, if necessary.
# Path below points to internal LuaSocket's help files. # Path below points to internal LuaSocket's help files.
INCDIR=-I. INC_PATH ?= -I/usr/include
LIBDIR=-L./luasocket LIB_PATH ?= -L/usr/lib
INCDIR = -I. $(INC_PATH)
LIBDIR = -L./luasocket $(LIB_PATH)
# For Mac OS X: set the system version # For Mac OS X: set the system version
MACOSX_VERSION=10.4 MACOSX_VERSION=10.4

View File

@ -10,29 +10,32 @@ LIBS=-lssl -lcrypto -lluasocket
WARN=-Wall -pedantic WARN=-Wall -pedantic
BSD_CFLAGS=-O2 -fpic $(WARN) $(INCDIR) $(DEFS) BSD_CFLAGS=-O2 -fPIC $(WARN) $(INCDIR) $(DEFS)
BSD_LDFLAGS=-O -shared -fpic $(LIBDIR) BSD_LDFLAGS=-O -fPIC -shared $(LIBDIR)
LNX_CFLAGS=-O2 -fpic $(WARN) $(INCDIR) $(DEFS) LNX_CFLAGS=-O2 -fPIC $(WARN) $(INCDIR) $(DEFS)
LNX_LDFLAGS=-O -shared -fpic $(LIBDIR) LNX_LDFLAGS=-O -fPIC -shared $(LIBDIR)
MAC_ENV=env MACOSX_DEPLOYMENT_TARGET='$(MACVER)' MAC_ENV=env MACOSX_DEPLOYMENT_TARGET='$(MACVER)'
MAC_CFLAGS=-O2 -fno-common $(WARN) $(INCDIR) $(DEFS) MAC_CFLAGS=-O2 -fno-common $(WARN) $(INCDIR) $(DEFS)
MAC_LDFLAGS=-bundle -undefined dynamic_lookup $(LIBDIR) MAC_LDFLAGS=-bundle -undefined dynamic_lookup $(LIBDIR)
CC=gcc INSTALL ?= install
LD=$(MYENV) gcc CC ?= cc
CFLAGS=$(MYCFLAGS) LD ?= $(MYENV) cc
LDFLAGS=$(MYLDFLAGS) CFLAGS += $(MYCFLAGS)
LDFLAGS += $(MYLDFLAGS)
DESTDIR ?= /
.PHONY: all clean install none linux bsd macosx luasocket .PHONY: all clean install none linux bsd macosx luasocket
all: all:
install: $(CMOD) $(LMOD) install: $(CMOD) $(LMOD)
install -m644 -D $(CMOD) $(LUACPATH) $(INSTALL) -d $(DESTDIR)$(LUAPATH)/ssl $(DESTDIR)$(LUACPATH)
install -m644 -D $(LMOD) $(LUAPATH) $(INSTALL) -D $(CMOD) $(DESTDIR)$(LUACPATH)
install -m644 -D https.lua $(LUAPATH)/ssl $(INSTALL) -m644 -D $(LMOD) $(DESTDIR)$(LUAPATH)
$(INSTALL) -m644 -D https.lua $(DESTDIR)$(LUAPATH)/ssl
linux: linux:
@$(MAKE) $(CMOD) MYCFLAGS="$(LNX_CFLAGS)" MYLDFLAGS="$(LNX_LDFLAGS)" EXTRA="$(EXTRA)" @$(MAKE) $(CMOD) MYCFLAGS="$(LNX_CFLAGS)" MYLDFLAGS="$(LNX_LDFLAGS)" EXTRA="$(EXTRA)"

View File

@ -4,16 +4,18 @@ OBJS= \
timeout.o \ timeout.o \
usocket.o usocket.o
CC=gcc CC ?= cc
CFLAGS=$(MYCFLAGS) -DLUASOCKET_DEBUG CFLAGS += $(MYCFLAGS) -DLUASOCKET_DEBUG
AR := ar rcu
RANLIB ?= ranlib
.PHONY: all clean .PHONY: all clean
all: libluasocket.a all: libluasocket.a
libluasocket.a: $(OBJS) libluasocket.a: $(OBJS)
ar rcu $@ $(OBJS) $(AR) $@ $(OBJS)
ranlib $@ $(RANLIB) $@
clean: clean:
rm -f $(OBJS) libluasocket.a rm -f $(OBJS) libluasocket.a