Formula/lua@5.1.rb
# 5.3 is not fully backwards compatible so we must retain 2 Luas for now.
5.3 is not fully backwards compatible so we must retain 2 Luas for now.
5 . 3 is not fully backwards compatible so we must retain 2 Luas for now .
def install
    ENV.append_to_cflags "-fPIC" unless OS.mac?
    inreplace "src/Makefile" do |s|
      s.gsub! "@LUA_PREFIX@", prefix if OS.mac?
      s.remove_make_var! "CC"
      s.change_make_var! "CFLAGS", "#{ENV.cflags} $(MYCFLAGS)"
      s.change_make_var! "MYLDFLAGS", ENV.ldflags
      s.sub! "MYCFLAGS_VAL", "-fno-common -DLUA_USE_LINUX" if OS.mac?
    end
    inreplace "src/luaconf.h", "/usr/local", HOMEBREW_PREFIX
    inreplace "etc/lua.pc" do |s|
      s.gsub! "prefix= /usr/local", "prefix=#{HOMEBREW_PREFIX}"
      s.gsub! "INSTALL_MAN= ${prefix}/man/man1", "INSTALL_MAN= ${prefix}/share/man/man1"
      s.gsub! "INSTALL_INC= ${prefix}/include", "INSTALL_INC= ${prefix}/include/lua-5.1"
      s.gsub! "includedir=${prefix}/include", "includedir=${prefix}/include/lua-5.1"
      s.gsub! "Libs: -L${libdir} -llua -lm", "Libs: -L${libdir} -llua.5.1 -lm"
    end
    arch = OS.mac? ? "macosx" : "linux"
    system "make", arch, "INSTALL_TOP=#{prefix}", "INSTALL_MAN=#{man1}", "INSTALL_INC=#{include}/lua-5.1"
    system "make",
           "install",
           "INSTALL_TOP=#{prefix}",
           "INSTALL_MAN=#{man1}",
           "INSTALL_INC=#{include}/lua-5.1",
           *("TO_LIB=liblua.so.5.1 liblua.so.5.1.5" unless OS.mac?)
    (lib/"pkgconfig").install "etc/lua.pc"
    mv bin/"lua", bin/"lua-5.1"
    mv bin/"luac", bin/"luac-5.1"
    mv man1/"lua.1", man1/"lua-5.1.1"
    mv man1/"luac.1", man1/"luac-5.1.1"
    mv lib/"pkgconfig/lua.pc", lib/"pkgconfig/lua-5.1.pc"
    bin.install_symlink "lua-5.1" => "lua5.1"
    bin.install_symlink "luac-5.1" => "luac5.1"
    include.install_symlink "lua-5.1" => "lua5.1"
    (lib/"pkgconfig").install_symlink "lua-5.1.pc" => "lua5.1.pc"
    (libexec/"lib/pkgconfig").install_symlink lib/"pkgconfig/lua-5.1.pc" => "lua.pc"
    unless OS.mac?
      lib.install_symlink "liblua.so.5.1.5" => "liblua.5.1.5.so"
      lib.install_symlink "liblua.so.5.1" => "liblua.5.1.so"
    end
  end
def install ENV . append_to_cflags "-fPIC" unless OS . mac? inreplace "src/Makefile" do | s | s . gsub! "@LUA_PREFIX@" , prefix if OS . mac? s . remove_make_var! "CC" s . change_make_var! "CFLAGS" , "#{ENV.cflags} $(MYCFLAGS)" s . change_make_var! "MYLDFLAGS" , ENV . ldflags s . sub! "MYCFLAGS_VAL" , "-fno-common -DLUA_USE_LINUX" if OS . mac? end inreplace "src/luaconf.h" , "/usr/local" , HOMEBREW_PREFIX inreplace "etc/lua.pc" do | s | s . gsub! "prefix= /usr/local" , "prefix=#{HOMEBREW_PREFIX}" s . gsub! "INSTALL_MAN= ${prefix}/man/man1" , "INSTALL_MAN= ${prefix}/share/man/man1" s . gsub! "INSTALL_INC= ${prefix}/include" , "INSTALL_INC= ${prefix}/include/lua-5.1" s . gsub! "includedir=${prefix}/include" , "includedir=${prefix}/include/lua-5.1" s . gsub! "Libs: -L${libdir} -llua -lm" , "Libs: -L${libdir} -llua.5.1 -lm" end arch = OS . mac? ? "macosx" : "linux" system "make" , arch , "INSTALL_TOP=#{prefix}" , "INSTALL_MAN=#{man1}" , "INSTALL_INC=#{include}/lua-5.1" system "make" , "install" , "INSTALL_TOP=#{prefix}" , "INSTALL_MAN=#{man1}" , "INSTALL_INC=#{include}/lua-5.1" , * ( "TO_LIB=liblua.so.5.1 liblua.so.5.1.5" unless OS . mac? ) ( lib / "pkgconfig" ) . install "etc/lua.pc" mv bin / "lua" , bin / "lua-5.1" mv bin / "luac" , bin / "luac-5.1" mv man1 / "lua.1" , man1 / "lua-5.1.1" mv man1 / "luac.1" , man1 / "luac-5.1.1" mv lib / "pkgconfig/lua.pc" , lib / "pkgconfig/lua-5.1.pc" bin . install_symlink "lua-5.1" => "lua5.1" bin . install_symlink "luac-5.1" => "luac5.1" include . install_symlink "lua-5.1" => "lua5.1" ( lib / "pkgconfig" ) . install_symlink "lua-5.1.pc" => "lua5.1.pc" ( libexec / "lib/pkgconfig" ) . install_symlink lib / "pkgconfig/lua-5.1.pc" => "lua.pc" unless OS . mac? lib . install_symlink "liblua.so.5.1.5" => "liblua.5.1.5.so" lib . install_symlink "liblua.so.5.1" => "liblua.5.1.so" end end
5.3 is not fully backwards compatible so we must retain 2 Luas for now.
5 . 3 is not fully backwards compatible so we must retain 2 Luas for now .
# Fix: /usr/bin/ld: lapi.o: relocation R_X86_64_32 against `luaO_nilobject_' can not be used # when making a shared object; recompile with -fPIC # See http://www.linuxfromscratch.org/blfs/view/cvs/general/lua.html # Use our CC/CFLAGS to compile. # Fix path in the config header # Fix paths in the .pc # Renaming from Lua to Lua51. # Note that the naming must be both lua-version & lua.version. # Software can't find the libraries without supporting both the # hyphen and full stop. # Hack around wrong .so file naming