incorporated vim's link.sh; -i arg reports commit
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 7 Apr 2010 20:37:26 +0000 (14:37 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 7 Apr 2010 20:37:26 +0000 (14:37 -0600)
configure.ac
link.sh [new file with mode: 0755]
src/Main.cc
src/Makefile.am

index d4be8382f66cae1066bf012a2b2c13f677d9e649..a05e8236a4bc2301b40a19d1249420b10cc1e733 100644 (file)
@@ -36,44 +36,52 @@ AM_CONDITIONAL([NETBSD], [test x$NETBSD = xyes])
 #
 
 AC_ARG_ENABLE([debug],
-                         [  --enable-debug          include debugging symbols and features],
+                         [AS_HELP_STRING([--enable-debug],
+                                                         [include debugging symbols and code paths])],
                          [debug=$enableval],
                          [debug=no])
 
 AC_ARG_ENABLE([double-precision],
-                         [  --enable-double-precision      use doubles instead of floats],
+                         [AS_HELP_STRING([--enable-double-precision],
+                                                         [use doubles instead of floats])],
                          [double_precision=$enableval],
                          [double_precision=no])
 
 AC_ARG_ENABLE([profile],
-                         [  --enable-profile        make a binary with code profiling instructions],
+                         [AS_HELP_STRING([--enable-profile],
+                                                         [make a binary with code profiling instructions])],
                          [profile=$enableval],
                          [profile=no])
 
 AC_ARG_ENABLE([extra-warnings],
-                         [  --enable-extra-warnings make the gcc compiler give more warnings],
+                         [AS_HELP_STRING([--enable-extra-warnings],
+                                                         [make the gcc compiler give more warnings])],
                          [extra_warnings=$enableval],
                          [extra_warnings=no])
 
+AC_ARG_ENABLE([link-sh],
+                         [AS_HELP_STRING([--enable-link-sh],
+                                                         [give the executable fewer direct dependencies])],
+                         [link_sh=$enableval],
+                         [link_sh=no])
+
 AC_ARG_ENABLE([clock_gettime],
-                         [  --enable-clock_gettime  use clock_gettime() instead of SDL_GetTicks()],
+                         [AS_HELP_STRING([--enable-clock_gettime],
+                                                         [use clock_gettime() instead of SDL_GetTicks()])],
                          [clock_gettime=$enableval],
                          [clock_gettime=no])
 
 AC_ARG_ENABLE([threads],
-                         [  --enable-threads        use threads for concurrency where appropriate],
+                         [AS_HELP_STRING([--enable-threads],
+                                                         [use threads for concurrency where appropriate])],
                          [threads=$enableval],
                          [threads=no])
 
-AC_ARG_ENABLE([gtk],
-                         [  --enable-gtk            enable GTK+ modal dialogs],
-                         [gtk=$enableval],
-                         [gtk=no])
-
-AC_ARG_ENABLE([qt4],
-                         [  --enable-qt4            enable QT modal dialogs],
-                         [qt4=$enableval],
-                         [qt4=no])
+AC_ARG_WITH([gui-toolkit],
+                       [AS_HELP_STRING([--with-gui-toolkit=ARG],
+                                                       [possible values: none (default), gtk, qt4])],
+                       [gui_toolkit=$withval],
+                       [gui_toolkit=none])
 
 
 if test x$debug = xyes
@@ -105,17 +113,19 @@ then
        CXXFLAGS="$CXXFLAGS -Wextra -Wno-unused-parameter"
 fi
 
+AM_CONDITIONAL([LINK_SH], [test x$link_sh = xyes])
+
 if test x$threads = xyes
 then
        AC_DEFINE([USE_THREADS], 1,
                          [Define to 1 if you want to use threads when applicable.])
 fi
 
-if test x$gtk = xyes
+if test x$gui_toolkit = xgtk
 then
        AC_DEFINE([USE_GTK], 1,
                          [Define to 1 if you want to use GTK+ modal dialogs.])
-elif test x$qt4 = xyes
+elif test x$gui_toolkit = xqt4
 then
        AC_DEFINE([USE_QT4], 1,
                          [Define to 1 if you want to use QT4 modal dialogs.])
@@ -255,7 +265,7 @@ PKG_CHECK_MODULES([LUA], [lua],
                                   AC_MSG_WARN([Missing liblua ($website)])])
 
 ##### GTK+ 2.0 #####
-if test x$gtk = xyes
+if test x$gui_toolkit = xgtk
 then
        website="http://www.gtk.org/"
        PKG_CHECK_MODULES([GTK], [gtk+-2.0],
@@ -267,15 +277,15 @@ then
 fi
 
 ##### QT4 #####
-if test x$qt4 = xyes
+if test x$gui_toolkit = xqt4
 then
        website="http://qt.nokia.com/"
-       PKG_CHECK_MODULES([QT], [QtGui],
-                                         [LIBS="$LIBS $QT_LIBS"
-                                          CFLAGS="$CFLAGS $QT_CFLAGS"
-                                          CXXFLAGS="$CXXFLAGS $QT_CFLAGS"],
+       PKG_CHECK_MODULES([QT4], [QtGui],
+                                         [LIBS="$LIBS $QT4_LIBS"
+                                          CFLAGS="$CFLAGS $QT4_CFLAGS"
+                                          CXXFLAGS="$CXXFLAGS $QT4_CFLAGS"],
                                          [missing=yes
-                                          AC_MSG_WARN([Missing QT ($website)])])
+                                          AC_MSG_WARN([Missing QT4 ($website)])])
 fi
 
 if test x$missing = xyes
@@ -372,6 +382,12 @@ AC_DEFINE_UNQUOTED([VERSION_REVISION], [${VERSION_REVISION:-0}],
 PVERSION="${VERSION_MAJOR:-0}.${VERSION_MINOR:-0}.${VERSION_REVISION:-0}.0"
 AC_SUBST([PVERSION])
 
+if githead=$(git log -n1 --date=short --pretty=format:"%h (%ad)")
+then
+       AC_DEFINE_UNQUOTED([YOINK_GITHEAD], ["$githead"],
+                                          [Define to the git commit currently checked out.])
+fi
+
 
 #
 # Create the build files.
diff --git a/link.sh b/link.sh
new file mode 100755 (executable)
index 0000000..3519d42
--- /dev/null
+++ b/link.sh
@@ -0,0 +1,142 @@
+#!/bin/sh
+
+#
+# Yoink
+# Execute this file 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
+# default because there is the potential for runtime linking problems.  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.
+#
+
+# 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
+#
+# 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
+
+# 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 <link.cmd >linkit2.sh
+          sed -f link1.sed <linkit2.sh >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
+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 <link.cmd >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
+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
+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
+
index 835f3d06bc099c6cc3595e6193ab462d9aa308e8..8554c7fb854dff128875dbaf78dea33df717fc19 100644 (file)
@@ -221,6 +221,9 @@ void Main::printInfo(int argc, char* argv[])
        }
 
        std::cout << "   Executable: " << argv[0] << std::endl
+#ifdef YOINK_GITHEAD
+                         << "       Commit: "YOINK_GITHEAD << std::endl
+#endif
                          << "      Version: "VERSION << std::endl
                          << "        Built: " << COMPILE_TIME << std::endl
                          << "     Compiler: "COMPILER_STRING << std::endl
index 98cf9b91e804e3ae52377c093b9a13719352fa8c..9bbd7e8282833bf4674252f583e11a8430f208dd 100644 (file)
@@ -114,21 +114,25 @@ yoink_SOURCES = \
                                $(ENDLIST)
 
 if WIN32
-
 yoink_SOURCES += yoink.rc
-
 .rc.o:
        $(WINDRES) -o $@ -i $<
-
 else
-
 YOINK_ENVIRONMENT = YOINK_DATADIR="$(top_srcdir)/data"
-
 run: all
        $(YOINK_ENVIRONMENT) ./yoink $(YOINK_OPTS)
 
 debug: all
        $(YOINK_ENVIRONMENT) gdb ./yoink
+endif
+
+if LINK_SH
+yoink$(EXEEXT): $(yoink_OBJECTS) $(yoink_DEPENDENCIES)
+       @rm -f yoink$(EXEEXT)
+       @LINK="$(CXXLINK) $(yoink_OBJECTS) $(yoink_LDADD) $(LIBS)"\
+               sh $(top_srcdir)/link.sh
 
+clean-local:
+       rm -rf .link
 endif
 
This page took 0.026502 seconds and 4 git commands to generate.