2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-08-31 22:31:54 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Lua < Formula
|
2009-11-21 17:06:11 +00:00
|
|
|
homepage 'http://www.lua.org/'
|
2012-03-08 14:09:30 +00:00
|
|
|
url 'http://www.lua.org/ftp/lua-5.1.4.tar.gz'
|
2009-11-21 17:06:11 +00:00
|
|
|
md5 'd0870f2de55d59c1c8419f36e8fac150'
|
2010-06-19 00:07:32 +00:00
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
|
|
|
build 2326
|
|
|
|
cause "Lua itself compiles with LLVM, but may fail when other software tries to link."
|
|
|
|
end
|
2011-03-21 21:24:22 +00:00
|
|
|
|
2010-06-29 20:15:10 +00:00
|
|
|
# Skip cleaning both empty folders and bin/libs so external symbols still work.
|
2010-04-07 05:58:35 +00:00
|
|
|
skip_clean :all
|
2009-08-31 22:31:54 +00:00
|
|
|
|
2012-03-08 14:09:30 +00:00
|
|
|
def options
|
|
|
|
[['--completion', 'Enables advanced readline support']]
|
|
|
|
end
|
|
|
|
|
2011-04-05 07:21:20 +00:00
|
|
|
# Be sure to build a dylib, or else runtime modules will pull in another static copy of liblua = crashy
|
|
|
|
# See: https://github.com/mxcl/homebrew/pull/5043
|
|
|
|
def patches
|
2012-03-08 14:09:30 +00:00
|
|
|
p = [DATA]
|
2011-12-23 17:14:28 +00:00
|
|
|
# completion provided by advanced readline power patch from
|
|
|
|
# http://lua-users.org/wiki/LuaPowerPatches
|
|
|
|
if ARGV.include? '--completion'
|
2012-03-08 14:09:30 +00:00
|
|
|
p << 'http://luajit.org/patches/lua-5.1.4-advanced_readline.patch'
|
2011-12-23 17:14:28 +00:00
|
|
|
end
|
2012-03-08 14:09:30 +00:00
|
|
|
p
|
2011-12-23 17:14:28 +00:00
|
|
|
end
|
2011-04-05 07:21:20 +00:00
|
|
|
|
2009-08-31 22:31:54 +00:00
|
|
|
def install
|
2010-07-16 21:19:14 +00:00
|
|
|
# Apply patch-level 2
|
2012-03-08 14:09:30 +00:00
|
|
|
curl "https://trac.macports.org/export/90538/trunk/dports/lang/lua/files/patch-lua-5.1.4-3", "-O"
|
2011-03-19 04:18:15 +00:00
|
|
|
safe_system '/usr/bin/patch', '-d', 'src', '-i', '../patch-lua-5.1.4-3'
|
2010-12-21 03:40:11 +00:00
|
|
|
# we could use the patches method if it supported additional arguments (-d in our case)
|
2010-07-16 21:19:14 +00:00
|
|
|
|
2010-06-19 00:07:32 +00:00
|
|
|
# Use our CC/CFLAGS to compile.
|
|
|
|
inreplace 'src/Makefile' do |s|
|
|
|
|
s.remove_make_var! 'CC'
|
2010-08-10 15:05:31 +00:00
|
|
|
s.change_make_var! 'CFLAGS', "#{ENV.cflags} $(MYCFLAGS)"
|
2010-06-19 00:07:32 +00:00
|
|
|
end
|
2010-02-19 19:19:01 +00:00
|
|
|
|
2010-06-19 00:07:32 +00:00
|
|
|
# Fix path in the config header
|
2009-09-15 09:23:24 +00:00
|
|
|
inreplace 'src/luaconf.h', '/usr/local', HOMEBREW_PREFIX
|
2009-09-05 03:05:08 +00:00
|
|
|
|
2010-06-19 00:07:32 +00:00
|
|
|
# Fix paths in the .pc
|
|
|
|
inreplace 'etc/lua.pc' do |s|
|
|
|
|
s.gsub! "prefix= /usr/local", "prefix=#{HOMEBREW_PREFIX}"
|
2010-07-16 21:19:14 +00:00
|
|
|
s.gsub! "INSTALL_MAN= ${prefix}/man/man1", "INSTALL_MAN= ${prefix}/share/man/man1"
|
2010-06-19 00:07:32 +00:00
|
|
|
end
|
|
|
|
|
2011-08-04 11:47:53 +00:00
|
|
|
# this ensures that this symlinking for lua starts at lib/lua/5.1 and not
|
|
|
|
# below that, thus making luarocks work
|
|
|
|
(HOMEBREW_PREFIX/"lib/lua"/version.split('.')[0..1].join('.')).mkpath
|
|
|
|
|
2010-06-19 00:07:32 +00:00
|
|
|
system "make", "macosx", "INSTALL_TOP=#{prefix}", "INSTALL_MAN=#{man1}"
|
|
|
|
system "make", "install", "INSTALL_TOP=#{prefix}", "INSTALL_MAN=#{man1}"
|
2009-09-05 03:05:08 +00:00
|
|
|
|
2009-12-11 17:53:27 +00:00
|
|
|
(lib+"pkgconfig").install 'etc/lua.pc'
|
2009-08-31 22:31:54 +00:00
|
|
|
end
|
|
|
|
end
|
2011-04-05 07:21:20 +00:00
|
|
|
|
|
|
|
__END__
|
|
|
|
diff --git a/Makefile b/Makefile
|
|
|
|
index 6e78f66..6b48d2b 100644
|
|
|
|
--- a/Makefile
|
|
|
|
+++ b/Makefile
|
|
|
|
@@ -43,7 +43,7 @@ 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 ../etc/lua.hpp
|
|
|
|
-TO_LIB= liblua.a
|
|
|
|
+TO_LIB= liblua.5.1.4.dylib
|
|
|
|
TO_MAN= lua.1 luac.1
|
|
|
|
|
|
|
|
# Lua version and release.
|
2011-09-08 21:02:07 +00:00
|
|
|
@@ -64,6 +64,8 @@ install: dummy
|
2011-04-05 07:21:20 +00:00
|
|
|
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.5.1.4.dylib $(INSTALL_LIB)/liblua.5.1.dylib
|
2011-09-08 21:02:07 +00:00
|
|
|
+ ln -s -f liblua.5.1.dylib $(INSTALL_LIB)/liblua.dylib
|
2011-04-05 07:21:20 +00:00
|
|
|
|
|
|
|
ranlib:
|
|
|
|
cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
|
|
|
|
diff --git a/src/Makefile b/src/Makefile
|
|
|
|
index e4a3cd6..e35a1b5 100644
|
|
|
|
--- a/src/Makefile
|
|
|
|
+++ b/src/Makefile
|
|
|
|
@@ -22,7 +22,7 @@ MYLIBS=
|
|
|
|
|
|
|
|
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
|
|
|
|
|
|
|
|
-LUA_A= liblua.a
|
|
|
|
+LUA_A= liblua.5.1.4.dylib
|
|
|
|
CORE_O= lapi.o lcode.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
|
|
|
|
@@ -48,11 +48,13 @@ o: $(ALL_O)
|
|
|
|
a: $(ALL_A)
|
|
|
|
|
|
|
|
$(LUA_A): $(CORE_O) $(LIB_O)
|
|
|
|
- $(AR) $@ $?
|
|
|
|
- $(RANLIB) $@
|
2011-12-09 23:21:43 +00:00
|
|
|
+ $(CC) -dynamiclib -install_name HOMEBREW_PREFIX/lib/liblua.5.1.dylib \
|
2011-04-05 07:21:20 +00:00
|
|
|
+ -compatibility_version 5.1 -current_version 5.1.4 \
|
|
|
|
+ -o liblua.5.1.4.dylib $^
|
|
|
|
|
|
|
|
$(LUA_T): $(LUA_O) $(LUA_A)
|
|
|
|
- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
|
|
|
|
+ $(CC) -fno-common $(MYLDFLAGS) \
|
|
|
|
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.5.1.4 $(LIBS)
|
|
|
|
|
|
|
|
$(LUAC_T): $(LUAC_O) $(LUA_A)
|
|
|
|
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
|
|
|
|
@@ -99,7 +101,7 @@ linux:
|
|
|
|
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
|
|
|
|
|
|
|
|
macosx:
|
|
|
|
- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
|
|
|
|
+ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX -fno-common" MYLIBS="-lreadline"
|
|
|
|
# use this on Mac OS X 10.3-
|
|
|
|
# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
|
|
|
|
|