Last active
December 18, 2015 19:19
-
-
Save gvvaughan/5832054 to your computer and use it in GitHub Desktop.
Patch upstream lua-5.2.2 for building on Mac OS X by Homebrew.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Patch upstream lua-5.2.2 for building on Mac OS X by Homebrew. | |
1. An extension of my earlier in-formula shared library compilation patch for earlier | |
releases. | |
2. Install binaries, headers, manual pages and library with 5.2 suffixes to enable | |
parallel installation with other versions of lua. | |
diff --git a/Makefile b/Makefile | |
index bd9515f..81daea5 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -12,7 +12,8 @@ PLAT= none | |
# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h. | |
INSTALL_TOP= /usr/local | |
INSTALL_BIN= $(INSTALL_TOP)/bin | |
-INSTALL_INC= $(INSTALL_TOP)/include | |
+INSTALL_INC= $(INSTALL_TOP)/include/lua-$V | |
INSTALL_LIB= $(INSTALL_TOP)/lib | |
+INSTALL_LIBEXEC= $(INSTALL_TOP)/libexec | |
INSTALL_MAN= $(INSTALL_TOP)/man/man1 | |
INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V | |
@@ -39,30 +40,35 @@ RM= rm -f | |
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris | |
# What to install. | |
-TO_BIN= lua luac | |
+TO_LIBEXEC= lua$V luac$V | |
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp | |
-TO_LIB= liblua.a | |
-TO_MAN= lua.1 luac.1 | |
+TO_LIB= liblua.$R.dylib | |
+TO_MAN= lua-$V.1 luac-$V.1 | |
# Lua version and release. | |
V= 5.2 | |
-R= $V.1 | |
+R= $V.2 | |
# Targets start here. | |
all: $(PLAT) | |
$(PLATS) clean: | |
- cd src && $(MAKE) $@ | |
+ cd src && $(MAKE) $@ V=$V R=$R | |
test: dummy | |
src/lua -v | |
install: dummy | |
- cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) | |
+ cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_LIBEXEC) $(INSTALL_LIB)/pkgconfig $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) | |
- cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) | |
+ cd src && $(INSTALL_EXEC) $(TO_LIBEXEC) $(INSTALL_LIBEXEC) | |
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) | |
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) | |
- cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) | |
+ cd doc && $(INSTALL_DATA) lua.1 $(INSTALL_MAN)/lua-$V.1 | |
+ cd doc && $(INSTALL_DATA) luac.1 $(INSTALL_MAN)/luac-$V.1 | |
+ ln -s -f liblua.$R.dylib $(INSTALL_LIB)/liblua.$V.dylib | |
+ ln -s -f liblua.$V.dylib $(INSTALL_LIB)/liblua.dylib | |
+ ln -s -f lua.1 $(INSTALL_MAN)/lua-$V.1 | |
+ ln -s -f luac.1 $(INSTALL_MAN)/luac-$V.1 | |
uninstall: | |
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN) | |
diff --git a/src/Makefile b/src/Makefile | |
index 8c9ee67..7f92407 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.$R.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 | |
@@ -36,10 +36,10 @@ LIB_O= lauxlib.o lbaselib.o lbitlib.o lc | |
lmathlib.o loslib.o lstrlib.o ltablib.o loadlib.o linit.o | |
BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS) | |
-LUA_T= lua | |
+LUA_T= lua$V | |
LUA_O= lua.o | |
-LUAC_T= luac | |
+LUAC_T= luac$V | |
LUAC_O= luac.o | |
ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) | |
@@ -56,11 +56,12 @@ o: $(ALL_O) | |
a: $(ALL_A) | |
$(LUA_A): $(BASE_O) | |
- $(AR) $@ $(BASE_O) | |
- $(RANLIB) $@ | |
+ $(CC) -dynamiclib -install_name /usr/local/lib/liblua.$V.dylib \ | |
+ -compatibility_version $V -current_version $R \ | |
+ -o liblua.$R.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.$R $(LIBS) | |
$(LUAC_T): $(LUAC_O) $(LUA_A) | |
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) | |
@@ -89,36 +90,36 @@ none: | |
@echo " $(PLATS)" | |
aix: | |
- $(MAKE) $(ALL) CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" SYSLDFLAGS="-brtl -bexpall" | |
+ $(MAKE) $(ALL) V="$V" R="$R" CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" SYSLDFLAGS="-brtl -bexpall" | |
ansi: | |
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_ANSI" | |
+ $(MAKE) $(ALL) V="$V" R="$R" SYSCFLAGS="-DLUA_ANSI" | |
bsd: | |
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-Wl,-E" | |
+ $(MAKE) $(ALL) V="$V" R="$R" SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-Wl,-E" | |
freebsd: | |
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -lreadline" | |
+ $(MAKE) $(ALL) V="$V" R="$R" SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -lreadline" | |
generic: $(ALL) | |
linux: | |
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" | |
+ $(MAKE) $(ALL) V="$V" R="$R" SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" | |
macosx: | |
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline" | |
+ $(MAKE) $(ALL) V="$V" R="$R" SYSCFLAGS="-DLUA_USE_MACOSX -fno-common" SYSLIBS="-lreadline" | |
mingw: | |
- $(MAKE) "LUA_A=lua52.dll" "LUA_T=lua.exe" \ | |
+ $(MAKE) V="$V" R="$R" "LUA_A=lua52.dll" "LUA_T=lua.exe" \ | |
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ | |
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe | |
$(MAKE) "LUAC_T=luac.exe" luac.exe | |
posix: | |
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX" | |
+ $(MAKE) $(ALL) V="$V" R="$R" SYSCFLAGS="-DLUA_USE_POSIX" | |
solaris: | |
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" | |
+ $(MAKE) $(ALL) V="$V" R="$R" SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" | |
# list targets that do not create files (but not all makes understand .PHONY) | |
.PHONY: all $(PLATS) default o a clean depend echo none |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment