Patch lua52 to build on Darwin

This commit is contained in:
John Wiegley 2014-04-15 04:46:14 -05:00
parent abdd87da3c
commit b18dc38dc1
2 changed files with 59 additions and 2 deletions

View File

@ -0,0 +1,52 @@
diff --git a/Makefile b/Makefile
index 209a132..9387b09 100644
--- a/Makefile
+++ b/Makefile
@@ -43,5 +43,5 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
# What to install.
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.${version}.dylib
TO_MAN= lua.1 luac.1
# Lua version and release.
@@ -64,3 +64,5 @@ install: dummy
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+ ln -s -f liblua.${version}.dylib $(INSTALL_LIB)/liblua.${majorVersion}.dylib
+ ln -s -f liblua.${majorVersion}.dylib $(INSTALL_LIB)/liblua.dylib
ranlib:
cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
diff --git a/src/Makefile b/src/Makefile
index fea895b..d9146d0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -28,7 +28,7 @@ MYOBJS=
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
-LUA_A= liblua.a
+LUA_A= liblua.${version}.dylib
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
ltm.o lundump.o lvm.o lzio.o
@@ -56,11 +56,13 @@ o: $(ALL_O)
a: $(ALL_A)
$(LUA_A): $(BASE_O)
- $(AR) $@ $(BASE_O)
- $(RANLIB) $@
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${version}.dylib \
+ -compatibility_version ${version} -current_version ${version} \
+ -o liblua.${version}.dylib $^
$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+ $(CC) -fno-common $(MYLDFLAGS) \
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${version} $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)

View File

@ -19,9 +19,14 @@ stdenv.mkDerivation rec {
buildInputs = [ readline ];
patches = [ dsoPatch ];
patches = if stdenv.isDarwin then [ ./5.2.darwin.patch ] else [ dsoPatch ];
configurePhase = ''
configurePhase =
if stdenv.isDarwin
then ''
makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDLAGS="-fPIC" V=${majorVersion} R=${version} )
installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.${version}.dylib" INSTALL_DATA='cp -d' )
'' else ''
makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDLAGS="-fPIC" V=${majorVersion} R=${version} )
installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.a liblua.so liblua.so.${majorVersion} liblua.so.${version}" INSTALL_DATA='cp -d' )
'';