From d28c5fec1ad25ccf01c29a15cca4c4798dd3e359 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Wed, 7 Apr 2010 19:47:35 -0600 Subject: [PATCH] adapted link.sh; other small fixes --- arch/win32/makepackage.sh | 2 +- data/yoink.desktop | 2 +- link.sh | 257 ++++++++++++++++++++------------------ 3 files changed, 139 insertions(+), 122 deletions(-) diff --git a/arch/win32/makepackage.sh b/arch/win32/makepackage.sh index 793e435..390aa58 100755 --- a/arch/win32/makepackage.sh +++ b/arch/win32/makepackage.sh @@ -66,7 +66,7 @@ die() } ROOT="$PWD" -BUILD="$ROOT/tmp-$$" +BUILD=`mktemp -d "$ROOT/tmp-XXXXXXXX"` DIRECTORY="yoink-$VERSION" ARCHIVE="$BUILD/$DIRECTORY" diff --git a/data/yoink.desktop b/data/yoink.desktop index 2f301e2..fc9e68c 100644 --- a/data/yoink.desktop +++ b/data/yoink.desktop @@ -3,7 +3,7 @@ Encoding=UTF-8 Version=1.0 Name=Yoink Type=Application -Comment=Alien-stomping Entertainment +Comment=Alien-smashing action game Exec=yoink TryExec=yoink Icon=yoink diff --git a/link.sh b/link.sh index 3519d42..7db3de0 100755 --- a/link.sh +++ b/link.sh @@ -2,7 +2,7 @@ # # Yoink -# Execute this file to link the executable with fewer direct dependencies. +# Run this script to link the executable with fewer direct dependencies. # # You shouldn't call this directly; instead, use the configure script's # --enable-link-sh option and run make normally. This isn't enabled by @@ -10,133 +10,150 @@ # 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. # - -# link.sh -- try linking Vim with different sets of libraries, finding the -# minimal set for fastest startup. The problem is that configure adds a few -# libraries when they exist, but this doesn't mean they are needed for Vim. -# -# Author: Bram Moolenaar -# Last change: 2006 Sep 26 -# License: Public domain +# This script was adapted from some public domain code written by Bram +# Moolenaar for Vim. The only input needed is the link command in the +# variable LINK. It is expected that the linker will return an error code +# or this will not work. The script caches the test results in the +# `.link/link.sed' file; delete that file if you want to redetermine the +# required direct dependencies. # -# Warning: This fails miserably if the linker doesn't return an error code! -# -# Otherwise this script is fail-safe, falling back to the original full link -# command if anything fails. -echo "$LINK " >link.cmd -exit_value=0 -# -# If .link/link.sed already exists, use it. We assume a previous run of -# link.sh has found the correct set of libraries. -# -if test -f .link/link.sed; then - echo "link.sh: The file '.link/link.sed' exists, which is going to be used now." - echo "link.sh: If linking fails, try deleting the .link/link.sed file." - echo "link.sh: If this fails too, try creating an empty .link/link.sed file." -else +# 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 \ + $THE_END" -# If linking works with the full link command, try removing some libraries, -# that are known not to be needed on at least one system. -# Remove .link/pathdef.c if there is a new link command and compile it again. -# There is a loop to remove libraries that appear several times. -# -# Notes: -# - Can't remove Xext; It links fine but will give an error when running gvim -# with Motif. -# - Don't remove the last -lm: On HP-UX Vim links OK but crashes when the GTK -# GUI is started, because the "floor" symbol could not be resolved. -# - cat link.cmd - if sh link.cmd; then - mkdir -p .link - touch .link/link.sed - cp link.cmd linkit.sh - for libname in 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 vorbis; do - cont=yes - while test -n "$cont"; do - if grep "l$libname " linkit.sh >/dev/null; then - if test ! -f link1.sed; then - echo "link.sh: OK, linking works, let's try removing a few libraries." - echo "link.sh: See .link/link.log for details." - rm -f .link/link.log - fi - echo "s/-l$libname *//" >link1.sed - sed -f .link/link.sed linkit2.sh - sed -f link1.sed linkit.sh - # keep the last -lm - if test $libname != "m" || grep "lm " linkit.sh >/dev/null; then - echo "link.sh: Trying to remove the $libname library..." - cat linkit.sh >>.link/link.log - # Redirect this link output, it may contain error messages which - # should be ignored. - if sh linkit.sh >>.link/link.log 2>&1; then - echo "link.sh: We don't need the $libname library!" - cat link1.sed >>.link/link.sed - else - echo "link.sh: We DO need the $libname library." - cont= - cp link.cmd linkit.sh - fi - else - cont= - cp link.cmd linkit.sh - fi - else - cont= - cp link.cmd linkit.sh - fi - done - done - if test ! -f link1.sed; then - echo "link.sh: Linked fine, no libraries can be removed" - touch link3.sed - fi - else - exit_value=$? - fi + +linkdir=".link" +logfile="$linkdir/link.log" +sedfile="$linkdir/link.sed" + +workdir=$(mktemp -d tmp.XXXXXXXX) +cmdfile="$workdir/link.cmd" +runfile="$workdir/link.run" + +tmpfile1="$workdir/link.tmp1" +tmpfile2="$workdir/link.tmp2" +tmpfile3="$workdir/link.tmp3" + + +printlog() +{ + echo "link.sh: $@" +} + +echo "$LINK " >$cmdfile +exitcode=0 + + +if test -f $sedfile +then + printlog "The file $sedfile exists, which is now going to be used." + printlog "If linking fails, try deleting the $sedfile file." + printlog "If that fails, try creating an empty $sedfile file." + printlog "If that fails, configure the package with --disable-link-sh." +else + cat $cmdfile + if sh $cmdfile + then + mkdir -p $linkdir + touch $sedfile + cp $cmdfile $runfile + for libname in $libraries + do + cont=yes + while test -n "$cont" + do + if grep "l$libname " $runfile >/dev/null + then + if test ! -f $tmpfile1 + then + printlog "Full linking works; now the fun begins." + printlog "See $logfile for details." + rm -f $logfile + fi + echo "s/-l$libname *//" >$tmpfile1 + sed -f $sedfile <$cmdfile | sed -f $tmpfile1 >$runfile + # keep the last -lm; this is supposedly needed by HP-UX + if test $libname != "m" || grep "lm " $runfile >/dev/null + then + printlog "Trying to remove the $libname library..." + cat $runfile >>$logfile + if sh $runfile >>$logfile 2>&1 + then + printlog "We don't need the $libname library!" + cat $tmpfile1 >>$sedfile + continue + else + printlog "We DO need the $libname library." + fi + fi + fi + cont= + cp $cmdfile $runfile + done + done + if test ! -f $tmpfile1 + then + printlog "Linked fine, no libraries can be removed." + touch $tmpfile3 + fi + else + exitcode=$? + fi fi -# -# Now do the real linking. -# -if test -s .link/link.sed; then - echo "link.sh: Using .link/link.sed file to remove a few libraries" - sed -f .link/link.sed linkit.sh - cat linkit.sh - if sh linkit.sh; then - exit_value=0 - echo "link.sh: Linked fine with a few libraries removed" - else - exit_value=$? - echo "link.sh: Linking failed, making .link/link.sed empty and trying again" - mv -f .link/link.sed link2.sed - touch .link/link.sed - fi + +if test -s $sedfile +then + printlog "Using $sedfile file to remove a few libraries." + sed -f $sedfile <$cmdfile >$runfile + cat $runfile + if sh $runfile + then + exitcode=0 + printlog "Linked fine with a few libraries removed." + else + exitcode=$? + printlog "Linking failed, making $sedfile empty and trying again." + mv -f $sedfile $tmpfile2 + touch $sedfile + fi fi -if test -f .link/link.sed -a ! -s .link/link.sed -a ! -f link3.sed; then - echo "link.sh: Using unmodified link command" - cat link.cmd - if sh link.cmd; then - exit_value=0 - echo "link.sh: Linked OK" - else - exit_value=$? - if test -f link2.sed; then - echo "link.sh: Linking doesn't work at all, removing .link/link.sed" - rm -f .link/link.sed - fi - fi + +if test -f $sedfile -a ! -s $sedfile -a ! -f $tmpfile3 +then + printlog "Using unmodified link command." + cat $cmdfile + if sh $cmdfile + then + exitcode=0 + printlog "Linked OK." + else + exitcode=$? + if test -f $tmpfile2 + then + printlog "Linking doesn't work at all, removing $sedfile." + rm -f $sedfile + fi + fi fi -# -# cleanup -# -rm -f link.cmd linkit.sh link1.sed link2.sed link3.sed linkit2.sh -# -# return an error code if something went wrong -# -exit $exit_value +rm -rf "$workdir" +exit $exitcode -- 2.43.0