]> Dogcows Code - chaz/yoink/blob - tools/link.lua
use only triangles; no quads
[chaz/yoink] / tools / link.lua
1 #!/usr/bin/env lua
2
3 --
4 -- Yoink
5 -- Run this script to link the executable with fewer direct dependencies.
6 --
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.
13 --
14
15
16 -- List here any libraries that are known to not be needed on some
17 -- platform.
18 libraries = {
19 "atk-1.0",
20 "cairo",
21 "fontconfig",
22 "freetype",
23 "gdk-x11-2.0",
24 "gio-2.0",
25 "glib-2.0",
26 "gmodule-2.0",
27 "ogg",
28 "pango-1.0",
29 "pangocairo-1.0",
30 "pangoft2-1.0",
31 "pthread",
32 "vorbis"
33 }
34
35
36 -- We want to print only if verbose is set to true.
37 do
38 local verbose = os.getenv("verbose") == "true"
39 local oldprint = print
40
41 print = function(...) if verbose then oldprint(unpack(arg)) end end
42 end
43
44
45 command = arg[1]
46 removed = {}
47
48 -- Get the link command as passed on the command-line.
49 for i,arg in ipairs(arg) do
50 if i ~= 1 then
51 command = string.format("%s %q", command, arg)
52 end
53 end
54
55 original = command
56
57
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)
65 command = new_command
66 else
67 print("We DO need "..library)
68 end
69 end
70 end
71
72
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.")
79 else
80 print("The link failed. :-(")
81 os.exit(1)
82 end
83
This page took 0.037404 seconds and 4 git commands to generate.