]>
Dogcows Code - chaz/yoink/blob - link.lua
d0eed0c0c1d5c9960184e12763d880cfb4cadc42
5 -- Run this script to link the executable with fewer direct dependencies.
7 -- You shouldn't call this directly; instead, use the configure script's
8 -- --enable-asneeded option and run make normally. This isn't enabled by
9 -- default because there is the potential for runtime linking problems on
10 -- some platforms. If you have a newer version of GCC, you should prefer
11 -- the --as-needed linker flag over this method, though they both should
12 -- accomplish the same thing.
16 -- List here any libraries that are known to not be needed on some
36 -- We want to print only if verbose is set to true.
38 local verbose
= os
.getenv("verbose") == "true"
39 local oldprint
= print
41 print = function(...) if verbose
then oldprint(unpack(arg
)) end end
48 -- Get the link command as passed on the command-line.
49 for i
,arg
in ipairs(arg
) do
51 command
= string.format("%s %q", command
, arg
)
58 -- Check for libraries which aren't needed for successful linking.
59 for i
,library
in ipairs(libraries
) do
60 local new_command
= command
:gsub("%s\"%-l"..library
.."+\"%s", " ")
61 if new_command
~= command
then
62 if os
.execute(new_command
.." >/dev/null 2>&1") == 0 then
63 print("We DON'T need "..library
)
64 table.insert(removed
, library
)
67 print("We DO need "..library
)
73 -- Perform the final link.
74 if 0 < #removed
and os
.execute(command
.." >/dev/null 2>&1") == 0 then
75 local removed
= table.concat(removed
, ", ")
76 print("Linked fine without some libraries: "..removed
)
77 elseif os
.execute(original
.." >/dev/null 2>&1") == 0 then
78 print("Linked with the original link command.")
80 print("The link failed. :-(")
This page took 0.038852 seconds and 3 git commands to generate.