X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=tools%2Flink.lua;fp=tools%2Flink.lua;h=0000000000000000000000000000000000000000;hp=d0eed0c0c1d5c9960184e12763d880cfb4cadc42;hb=6c9943707d4f33035830eba0587a61a34eaecbc2;hpb=af88821a172c4dfd138b91b2a5148ae50b502fa2 diff --git a/tools/link.lua b/tools/link.lua deleted file mode 100755 index d0eed0c..0000000 --- a/tools/link.lua +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env lua - --- --- Yoink --- Run this script to link the executable with fewer direct dependencies. --- --- You shouldn't call this directly; instead, use the configure script's --- --enable-asneeded option and run make normally. This isn't enabled by --- default because there is the potential for runtime linking problems on --- some platforms. If you have a newer version of GCC, you should prefer --- the --as-needed linker flag over this method, though they both should --- accomplish the same thing. --- - - --- List here any libraries that are known to not be needed on some --- platform. -libraries = { - "atk-1.0", - "cairo", - "fontconfig", - "freetype", - "gdk-x11-2.0", - "gio-2.0", - "glib-2.0", - "gmodule-2.0", - "ogg", - "pango-1.0", - "pangocairo-1.0", - "pangoft2-1.0", - "pthread", - "vorbis" -} - - --- We want to print only if verbose is set to true. -do - local verbose = os.getenv("verbose") == "true" - local oldprint = print - - print = function(...) if verbose then oldprint(unpack(arg)) end end -end - - -command = arg[1] -removed = {} - --- Get the link command as passed on the command-line. -for i,arg in ipairs(arg) do - if i ~= 1 then - command = string.format("%s %q", command, arg) - end -end - -original = command - - --- Check for libraries which aren't needed for successful linking. -for i,library in ipairs(libraries) do - local new_command = command:gsub("%s\"%-l"..library.."+\"%s", " ") - if new_command ~= command then - if os.execute(new_command.." >/dev/null 2>&1") == 0 then - print("We DON'T need "..library) - table.insert(removed, library) - command = new_command - else - print("We DO need "..library) - end - end -end - - --- Perform the final link. -if 0 < #removed and os.execute(command.." >/dev/null 2>&1") == 0 then - local removed = table.concat(removed, ", ") - print("Linked fine without some libraries: "..removed) -elseif os.execute(original.." >/dev/null 2>&1") == 0 then - print("Linked with the original link command.") -else - print("The link failed. :-(") - os.exit(1) -end -