160 lines
5.4 KiB
Ruby
160 lines
5.4 KiB
Ruby
class LuaAT53 < Formula
|
|
desc "Powerful, lightweight programming language"
|
|
homepage "https://www.lua.org/"
|
|
url "https://www.lua.org/ftp/lua-5.3.6.tar.gz"
|
|
sha256 "fc5fd69bb8736323f026672b1b7235da613d7177e72558893a0bdcd320466d60"
|
|
license "MIT"
|
|
|
|
livecheck do
|
|
url "https://www.lua.org/ftp/"
|
|
regex(/href=.*?lua[._-]v?(5\.3(?:\.\d+)*)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
rebuild 1
|
|
sha256 cellar: :any, arm64_big_sur: "b354cab4cfe5a1e608752bc53c1887b9319078a1033305a7452f693edfc3e7f9"
|
|
sha256 cellar: :any, big_sur: "3fec7275812f0646dc113da036b77ab09af80421ae5ab2d90f8a122b5b225f1e"
|
|
sha256 cellar: :any, catalina: "1ba7031cba6c4b703e6ac2729ceb8bb23fb9ce12915888bcf395c9ebbfbb95b5"
|
|
sha256 cellar: :any, mojave: "180e59018eb294a00e41b426071ffbca0d3dc522569217064472e39aed359c0e"
|
|
end
|
|
|
|
keg_only :versioned_formula
|
|
|
|
uses_from_macos "unzip" => :build
|
|
|
|
on_linux do
|
|
depends_on "readline"
|
|
end
|
|
|
|
# Be sure to build a dylib, or else runtime modules will pull in another static copy of liblua = crashy
|
|
# See: https://github.com/Homebrew/legacy-homebrew/pull/5043
|
|
# ***Update me with each version bump!***
|
|
patch :DATA
|
|
|
|
def install
|
|
# Substitute formula prefix in `src/Makefile` for install name (dylib ID).
|
|
# Use our CC/CFLAGS to compile.
|
|
inreplace "src/Makefile" do |s|
|
|
s.gsub! "@LUA_PREFIX@", prefix
|
|
s.remove_make_var! "CC"
|
|
s.change_make_var! "CFLAGS", "#{ENV.cflags} -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)"
|
|
s.change_make_var! "MYLDFLAGS", ENV.ldflags
|
|
end
|
|
|
|
# Fix path in the config header
|
|
inreplace "src/luaconf.h", "/usr/local", HOMEBREW_PREFIX
|
|
|
|
# We ship our own pkg-config file as Lua no longer provide them upstream.
|
|
system "make", "macosx", "INSTALL_TOP=#{prefix}", "INSTALL_INC=#{include}/lua", "INSTALL_MAN=#{man1}"
|
|
system "make", "install", "INSTALL_TOP=#{prefix}", "INSTALL_INC=#{include}/lua", "INSTALL_MAN=#{man1}"
|
|
(lib/"pkgconfig/lua.pc").write pc_file
|
|
|
|
# Fix some software potentially hunting for different pc names.
|
|
bin.install_symlink "lua" => "lua#{version.major_minor}"
|
|
bin.install_symlink "lua" => "lua-#{version.major_minor}"
|
|
bin.install_symlink "luac" => "luac#{version.major_minor}"
|
|
bin.install_symlink "luac" => "luac-#{version.major_minor}"
|
|
(include/"lua#{version.major_minor}").install_symlink Dir[include/"lua/*"]
|
|
lib.install_symlink "liblua.#{version.major_minor}.dylib" => "liblua#{version.major_minor}.dylib"
|
|
(lib/"pkgconfig").install_symlink "lua.pc" => "lua#{version.major_minor}.pc"
|
|
(lib/"pkgconfig").install_symlink "lua.pc" => "lua-#{version.major_minor}.pc"
|
|
end
|
|
|
|
def pc_file
|
|
<<~EOS
|
|
V= #{version.major_minor}
|
|
R= #{version}
|
|
prefix=#{opt_prefix}
|
|
INSTALL_BIN= ${prefix}/bin
|
|
INSTALL_INC= ${prefix}/include/lua
|
|
INSTALL_LIB= ${prefix}/lib
|
|
INSTALL_MAN= ${prefix}/share/man/man1
|
|
INSTALL_LMOD= ${prefix}/share/lua/${V}
|
|
INSTALL_CMOD= ${prefix}/lib/lua/${V}
|
|
exec_prefix=${prefix}
|
|
libdir=${exec_prefix}/lib
|
|
includedir=${prefix}/include/lua
|
|
|
|
Name: Lua
|
|
Description: An Extensible Extension Language
|
|
Version: #{version}
|
|
Requires:
|
|
Libs: -L${libdir} -llua.#{version.major_minor} -lm
|
|
Cflags: -I${includedir}
|
|
EOS
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
You may also want luarocks:
|
|
brew install luarocks
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
assert_match "Ducks are terrifying.", shell_output("#{bin}/lua -e \"print ('Ducks are terrifying.')\"")
|
|
end
|
|
end
|
|
|
|
__END__
|
|
diff --git a/Makefile b/Makefile
|
|
index 7fa91c8..a825198 100644
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -41,7 +41,7 @@ PLATS= aix bsd c89 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.5.3.6.dylib
|
|
TO_MAN= lua.1 luac.1
|
|
|
|
# Lua version and release.
|
|
@@ -63,6 +63,8 @@ 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.5.3.6.dylib $(INSTALL_LIB)/liblua.5.3.dylib
|
|
+ ln -s -f liblua.5.3.dylib $(INSTALL_LIB)/liblua.dylib
|
|
|
|
uninstall:
|
|
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
|
|
diff --git a/src/Makefile b/src/Makefile
|
|
index 2e7a412..d0c4898 100644
|
|
--- a/src/Makefile
|
|
+++ b/src/Makefile
|
|
@@ -28,7 +28,7 @@ MYOBJS=
|
|
|
|
PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
|
|
|
|
-LUA_A= liblua.a
|
|
+LUA_A= liblua.5.3.6.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,12 @@ o: $(ALL_O)
|
|
a: $(ALL_A)
|
|
|
|
$(LUA_A): $(BASE_O)
|
|
- $(AR) $@ $(BASE_O)
|
|
- $(RANLIB) $@
|
|
+ $(CC) -dynamiclib -install_name @LUA_PREFIX@/lib/liblua.5.3.dylib \
|
|
+ -compatibility_version 5.3 -current_version 5.3.6 \
|
|
+ -o liblua.5.3.6.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.5.3.6 $(LIBS)
|
|
|
|
$(LUAC_T): $(LUAC_O) $(LUA_A)
|
|
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
|
|
@@ -110,7 +111,7 @@ linux:
|
|
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
|
|
|
|
macosx:
|
|
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline"
|
|
+ $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX -fno-common" SYSLIBS="-lreadline"
|
|
|
|
mingw:
|
|
$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \
|