diff --git a/Portfile b/Portfile
index f5292ef..3863177 100644
--- a/Portfile
+++ b/Portfile
@@ -5,7 +5,7 @@ PortSystem                  1.0
 PortGroup                   xcodeversion 1.0
 
 name                        gnuplot
-version                     4.4.4
+version                     4.6.0
 categories                  math science
 # the license has some inconvenient requirements that we're not meeting
 # to be allowed to distribute binaries
@@ -31,11 +31,11 @@ dist_subdir                 ${name}/${version}
 distfiles-append            ${name}.pdf
 extract.only                ${distname}.tar.gz
 checksums                   ${distname}.tar.gz \
-                            rmd160  7e1d039c05c46fa38b53a3c4afbd328509da901d \
-                            sha256  d228599d08d5f87bcb79af8af8bb432c77d942802b1643f920c7baaeaf1ddbfd \
+                            rmd160  2c06500f45fb81850b45713a2cd0e38f0021b065 \
+                            sha256  6e60adb5039a3541f407c2ade670004178b376754c424c13f0be24c7960c17be \
                             ${name}.pdf \
-                            rmd160  f8bd424418bbf87e405c0f3d7eb2bf759c4770d5 \
-                            sha256  3495b65604239d78cdad5ac3b34864572382c09ddf8ea202bddafce9133a1adf
+                            rmd160  374614145a7b78e263b0cfbb695eb22d07dede9a \
+                            sha256  57bd4d88e1321968ba06f29dfa322b4cd9e6beb4e0f42e1a4775d9c9a41af170
 
 depends_lib                 port:expat \
                             port:fontconfig \
@@ -49,11 +49,13 @@ depends_lib                 port:expat \
                             port:xpm \
                             port:zlib
 
-patchfiles                  patch-src-variable_c.diff
+patchfiles                  patch-src-variable_c.diff \
+                            patch-upstream-wxt-scroll.diff \
+                            patch-upstream-qt.diff \
+                            patch-configure-qt.diff
 
 platform darwin {
     depends_lib-append      port:aquaterm
-    configure.cflags-append -DDEFAULTTERM='"aqua"'
 }
 
 minimum_xcodeversions       {9 3.1}
@@ -81,7 +83,22 @@ variant no_x11 {
     configure.args-append   --without-x
 }
 
-variant wxwidgets description "Enable wxWidgets front-end" {
+variant luaterm description "Enable lua-based terminals" {
+    depends_lib-append      port:lua
+    configure.args-delete   --without-lua
+    configure.args-append   --with-lua
+}
+
+variant pangocairo description "Enable cairo-based terminals" {
+    depends_lib-append      path:lib/pkgconfig/pango.pc:pango
+    configure.args-delete   --without-cairo
+}
+
+# One can in principle choose between wxWidgets and wxWidgets-devel,
+# but only 2.9 allows building 64-bit binaries.
+# If it is acceptable to depend on wxWidgets-devel only,
+# one could delete the variant that depends on wxWidgets 2.8.
+variant wxwidgets conflicts wxwidgets_devel description "Enable wxt terminal (wxWidgets 2.8, 32-bit only)" {
     depends_lib-append      port:wxWidgets
     configure.args-delete   --disable-wxwidgets
     configure.args-append   --with-wx-config=${prefix}/bin/wx-config
@@ -92,15 +109,21 @@ if {[variant_isset wxwidgets]} {
     supported_archs         i386 ppc
 }
 
-variant luaterm description "Enable Lua terminal" {
-    depends_lib-append      port:lua
-    configure.args-delete   --without-lua
-    configure.args-append   --with-lua
+variant wxwidgets_devel conflicts wxwidgets description "Enable wxt terminal (using wxWidgets 2.9, supports 64-bit)" {
+    depends_lib-append      port:wxWidgets-devel
+    configure.args-delete   --disable-wxwidgets
+    configure.args-append   --with-wx-config=${prefix}/bin/wx-config
+}
+if {[variant_isset wxwidgets_devel]} {
+    # http://trac.wxwidgets.org/ticket/13565
+    if {${configure.compiler} == "clang"} {
+        configure.compiler llvm-gcc-4.2
+    }
 }
 
-variant pangocairo description "Enable cairo-based terminals" {
-    depends_lib-append      path:lib/pkgconfig/pango.pc:pango
-    configure.args-delete   --without-cairo
+variant qt description "Enable qt terminal" {
+    depends_lib-append      port:qt4-mac
+    configure.args-append   --enable-qt
 }
 
 variant tutorial description "Build the tutorial (requires a tex install)" {
diff --git a/files/patch-configure-qt.diff b/files/patch-configure-qt.diff
new file mode 100644
index 0000000..a21b679
--- /dev/null
+++ b/files/patch-configure-qt.diff
@@ -0,0 +1,993 @@
+--- Makefile.in.orig
++++ Makefile.in
+@@ -166,6 +166,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -211,6 +214,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- config/Makefile.in.orig
++++ config/Makefile.in
+@@ -110,6 +110,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -155,6 +158,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- configure.orig
++++ configure
+@@ -610,6 +610,8 @@ subdirs
+ DIST_CONTACT
+ HAVE_LRELEASE_FALSE
+ HAVE_LRELEASE_TRUE
++BUILD_ON_APPLE_FALSE
++BUILD_ON_APPLE_TRUE
+ BUILD_QT_FALSE
+ BUILD_QT_TRUE
+ LRELEASE
+@@ -674,6 +676,12 @@ PLAINTEX
+ EMACS
+ CC_FOR_BUILD
+ LN_S
++am__fastdepOBJC_FALSE
++am__fastdepOBJC_TRUE
++OBJCDEPMODE
++ac_ct_OBJC
++OBJCFLAGS
++OBJC
+ ANSI2KNR
+ U
+ EGREP
+@@ -810,6 +818,8 @@ LDFLAGS
+ LIBS
+ CPPFLAGS
+ CPP
++OBJC
++OBJCFLAGS
+ XMKMF
+ PKG_CONFIG
+ LUA_CFLAGS
+@@ -1518,6 +1528,8 @@ Some influential environment variables:
+   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+               you have headers in a nonstandard directory <include dir>
+   CPP         C preprocessor
++  OBJC        Objective C compiler command
++  OBJCFLAGS   Objective C compiler flags
+   XMKMF       Path to xmkmf, Makefile generator for X Window System
+   PKG_CONFIG  path to pkg-config utility
+   LUA_CFLAGS  C compiler flags for LUA, overriding pkg-config
+@@ -1867,6 +1879,44 @@ $as_echo "$ac_res" >&6; }
+ 
+ } # ac_fn_c_check_header_compile
+ 
++# ac_fn_objc_try_compile LINENO
++# -----------------------------
++# Try to compile conftest.$ac_ext, and return whether this succeeded.
++ac_fn_objc_try_compile ()
++{
++  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
++  rm -f conftest.$ac_objext
++  if { { ac_try="$ac_compile"
++case "(($ac_try" in
++  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++  *) ac_try_echo=$ac_try;;
++esac
++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
++$as_echo "$ac_try_echo"; } >&5
++  (eval "$ac_compile") 2>conftest.err
++  ac_status=$?
++  if test -s conftest.err; then
++    grep -v '^ *+' conftest.err >conftest.er1
++    cat conftest.er1 >&5
++    mv -f conftest.er1 conftest.err
++  fi
++  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++  test $ac_status = 0; } && {
++	 test -z "$ac_objc_werror_flag" ||
++	 test ! -s conftest.err
++       } && test -s conftest.$ac_objext; then :
++  ac_retval=0
++else
++  $as_echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++	ac_retval=1
++fi
++  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
++  as_fn_set_status $ac_retval
++
++} # ac_fn_objc_try_compile
++
+ # ac_fn_c_try_link LINENO
+ # -----------------------
+ # Try to link conftest.$ac_ext, and return whether this succeeded.
+@@ -5314,6 +5364,382 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ 
++ac_ext=m
++ac_cpp='$OBJCPP $CPPFLAGS'
++ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_objc_compiler_gnu
++if test -n "$ac_tool_prefix"; then
++  for ac_prog in gcc objcc objc cc CC
++  do
++    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
++set dummy $ac_tool_prefix$ac_prog; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if test "${ac_cv_prog_OBJC+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  if test -n "$OBJC"; then
++  ac_cv_prog_OBJC="$OBJC" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++  IFS=$as_save_IFS
++  test -z "$as_dir" && as_dir=.
++    for ac_exec_ext in '' $ac_executable_extensions; do
++  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++    ac_cv_prog_OBJC="$ac_tool_prefix$ac_prog"
++    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++    break 2
++  fi
++done
++  done
++IFS=$as_save_IFS
++
++fi
++fi
++OBJC=$ac_cv_prog_OBJC
++if test -n "$OBJC"; then
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJC" >&5
++$as_echo "$OBJC" >&6; }
++else
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++
++    test -n "$OBJC" && break
++  done
++fi
++if test -z "$OBJC"; then
++  ac_ct_OBJC=$OBJC
++  for ac_prog in gcc objcc objc cc CC
++do
++  # Extract the first word of "$ac_prog", so it can be a program name with args.
++set dummy $ac_prog; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  if test -n "$ac_ct_OBJC"; then
++  ac_cv_prog_ac_ct_OBJC="$ac_ct_OBJC" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++  IFS=$as_save_IFS
++  test -z "$as_dir" && as_dir=.
++    for ac_exec_ext in '' $ac_executable_extensions; do
++  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++    ac_cv_prog_ac_ct_OBJC="$ac_prog"
++    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++    break 2
++  fi
++done
++  done
++IFS=$as_save_IFS
++
++fi
++fi
++ac_ct_OBJC=$ac_cv_prog_ac_ct_OBJC
++if test -n "$ac_ct_OBJC"; then
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJC" >&5
++$as_echo "$ac_ct_OBJC" >&6; }
++else
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++
++  test -n "$ac_ct_OBJC" && break
++done
++
++  if test "x$ac_ct_OBJC" = x; then
++    OBJC="gcc"
++  else
++    case $cross_compiling:$ac_tool_warned in
++yes:)
++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
++ac_tool_warned=yes ;;
++esac
++    OBJC=$ac_ct_OBJC
++  fi
++fi
++
++# Provide some information about the compiler.
++$as_echo "$as_me:${as_lineno-$LINENO}: checking for Objective C compiler version" >&5
++set X $ac_compile
++ac_compiler=$2
++for ac_option in --version -v -V -qversion; do
++  { { ac_try="$ac_compiler $ac_option >&5"
++case "(($ac_try" in
++  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++  *) ac_try_echo=$ac_try;;
++esac
++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
++$as_echo "$ac_try_echo"; } >&5
++  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
++  ac_status=$?
++  if test -s conftest.err; then
++    sed '10a\
++... rest of stderr output deleted ...
++         10q' conftest.err >conftest.er1
++    cat conftest.er1 >&5
++  fi
++  rm -f conftest.er1 conftest.err
++  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++  test $ac_status = 0; }
++done
++
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5
++$as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; }
++if test "${ac_cv_objc_compiler_gnu+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
++int
++main ()
++{
++#ifndef __GNUC__
++       choke me
++#endif
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_objc_try_compile "$LINENO"; then :
++  ac_compiler_gnu=yes
++else
++  ac_compiler_gnu=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ac_cv_objc_compiler_gnu=$ac_compiler_gnu
++
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objc_compiler_gnu" >&5
++$as_echo "$ac_cv_objc_compiler_gnu" >&6; }
++if test $ac_compiler_gnu = yes; then
++  GOBJC=yes
++else
++  GOBJC=
++fi
++ac_test_OBJCFLAGS=${OBJCFLAGS+set}
++ac_save_OBJCFLAGS=$OBJCFLAGS
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5
++$as_echo_n "checking whether $OBJC accepts -g... " >&6; }
++if test "${ac_cv_prog_objc_g+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  ac_save_objc_werror_flag=$ac_objc_werror_flag
++   ac_objc_werror_flag=yes
++   ac_cv_prog_objc_g=no
++   OBJCFLAGS="-g"
++   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
++int
++main ()
++{
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_objc_try_compile "$LINENO"; then :
++  ac_cv_prog_objc_g=yes
++else
++  OBJCFLAGS=""
++      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
++int
++main ()
++{
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_objc_try_compile "$LINENO"; then :
++
++else
++  ac_objc_werror_flag=$ac_save_objc_werror_flag
++	 OBJCFLAGS="-g"
++	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
++int
++main ()
++{
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_objc_try_compile "$LINENO"; then :
++  ac_cv_prog_objc_g=yes
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++   ac_objc_werror_flag=$ac_save_objc_werror_flag
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_objc_g" >&5
++$as_echo "$ac_cv_prog_objc_g" >&6; }
++if test "$ac_test_OBJCFLAGS" = set; then
++  OBJCFLAGS=$ac_save_OBJCFLAGS
++elif test $ac_cv_prog_objc_g = yes; then
++  if test "$GOBJC" = yes; then
++    OBJCFLAGS="-g -O2"
++  else
++    OBJCFLAGS="-g"
++  fi
++else
++  if test "$GOBJC" = yes; then
++    OBJCFLAGS="-O2"
++  else
++    OBJCFLAGS=
++  fi
++fi
++ac_ext=c
++ac_cpp='$CPP $CPPFLAGS'
++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_c_compiler_gnu
++
++depcc="$OBJC" am_compiler_list='gcc3 gcc'
++
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
++$as_echo_n "checking dependency style of $depcc... " >&6; }
++if test "${am_cv_OBJC_dependencies_compiler_type+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
++  # We make a subdir and do the tests there.  Otherwise we can end up
++  # making bogus files that we don't know about and never remove.  For
++  # instance it was reported that on HP-UX the gcc test will end up
++  # making a dummy file named `D' -- because `-MD' means `put the output
++  # in D'.
++  mkdir conftest.dir
++  # Copy depcomp to subdir because otherwise we won't find it if we're
++  # using a relative directory.
++  cp "$am_depcomp" conftest.dir
++  cd conftest.dir
++  # We will build objects and dependencies in a subdirectory because
++  # it helps to detect inapplicable dependency modes.  For instance
++  # both Tru64's cc and ICC support -MD to output dependencies as a
++  # side effect of compilation, but ICC will put the dependencies in
++  # the current directory while Tru64 will put them in the object
++  # directory.
++  mkdir sub
++
++  am_cv_OBJC_dependencies_compiler_type=none
++  if test "$am_compiler_list" = ""; then
++     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
++  fi
++  am__universal=false
++
++
++  for depmode in $am_compiler_list; do
++    # Setup a source with many dependencies, because some compilers
++    # like to wrap large dependency lists on column 80 (with \), and
++    # we should not choose a depcomp mode which is confused by this.
++    #
++    # We need to recreate these files for each test, as the compiler may
++    # overwrite some of them when testing with obscure command lines.
++    # This happens at least with the AIX C compiler.
++    : > sub/conftest.c
++    for i in 1 2 3 4 5 6; do
++      echo '#include "conftst'$i'.h"' >> sub/conftest.c
++      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
++      # Solaris 8's {/usr,}/bin/sh.
++      touch sub/conftst$i.h
++    done
++    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
++
++    # We check with `-c' and `-o' for the sake of the "dashmstdout"
++    # mode.  It turns out that the SunPro C++ compiler does not properly
++    # handle `-M -o', and we need to detect this.  Also, some Intel
++    # versions had trouble with output in subdirs
++    am__obj=sub/conftest.${OBJEXT-o}
++    am__minus_obj="-o $am__obj"
++    case $depmode in
++    gcc)
++      # This depmode causes a compiler race in universal mode.
++      test "$am__universal" = false || continue
++      ;;
++    nosideeffect)
++      # after this tag, mechanisms are not by side-effect, so they'll
++      # only be used when explicitly requested
++      if test "x$enable_dependency_tracking" = xyes; then
++	continue
++      else
++	break
++      fi
++      ;;
++    msvisualcpp | msvcmsys)
++      # This compiler won't grok `-c -o', but also, the minuso test has
++      # not run yet.  These depmodes are late enough in the game, and
++      # so weak that their functioning should not be impacted.
++      am__obj=conftest.${OBJEXT-o}
++      am__minus_obj=
++      ;;
++    none) break ;;
++    esac
++    if depmode=$depmode \
++       source=sub/conftest.c object=$am__obj \
++       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
++       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
++         >/dev/null 2>conftest.err &&
++       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
++       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
++       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
++       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
++      # icc doesn't choke on unknown options, it will just issue warnings
++      # or remarks (even with -Werror).  So we grep stderr for any message
++      # that says an option was ignored or not supported.
++      # When given -MP, icc 7.0 and 7.1 complain thusly:
++      #   icc: Command line warning: ignoring option '-M'; no argument required
++      # The diagnosis changed in icc 8.0:
++      #   icc: Command line remark: option '-MP' not supported
++      if (grep 'ignoring option' conftest.err ||
++          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
++        am_cv_OBJC_dependencies_compiler_type=$depmode
++        break
++      fi
++    fi
++  done
++
++  cd ..
++  rm -rf conftest.dir
++else
++  am_cv_OBJC_dependencies_compiler_type=none
++fi
++
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_OBJC_dependencies_compiler_type" >&5
++$as_echo "$am_cv_OBJC_dependencies_compiler_type" >&6; }
++OBJCDEPMODE=depmode=$am_cv_OBJC_dependencies_compiler_type
++
++ if
++  test "x$enable_dependency_tracking" != xno \
++  && test "$am_cv_OBJC_dependencies_compiler_type" = gcc3; then
++  am__fastdepOBJC_TRUE=
++  am__fastdepOBJC_FALSE='#'
++else
++  am__fastdepOBJC_TRUE='#'
++  am__fastdepOBJC_FALSE=
++fi
++
++
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
+ $as_echo_n "checking for an ANSI C-conforming const... " >&6; }
+ if test "${ac_cv_c_const+set}" = set; then :
+@@ -7828,7 +8254,7 @@ else
+ 	char b[false == 0 ? 1 : -1];
+ 	char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+ 	char d[(bool) 0.5 == true ? 1 : -1];
+-	bool e = &s;
++	/* See body of main program for 'e'.  */
+ 	char f[(_Bool) 0.0 == false ? 1 : -1];
+ 	char g[true];
+ 	char h[sizeof (_Bool)];
+@@ -7839,25 +8265,6 @@ else
+ 	_Bool n[m];
+ 	char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+ 	char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+-#	if defined __xlc__ || defined __GNUC__
+-	 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+-	    reported by James Lemley on 2005-10-05; see
+-	    http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+-	    This test is not quite right, since xlc is allowed to
+-	    reject this program, as the initializer for xlcbug is
+-	    not one of the forms that C requires support for.
+-	    However, doing the test right would require a runtime
+-	    test, and that would make cross-compilation harder.
+-	    Let us hope that IBM fixes the xlc bug, and also adds
+-	    support for this kind of constant expression.  In the
+-	    meantime, this test will reject xlc, which is OK, since
+-	    our stdbool.h substitute should suffice.  We also test
+-	    this with GCC, where it should work, to detect more
+-	    quickly whether someone messes up the test in the
+-	    future.  */
+-	 char digs[] = "0123456789";
+-	 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+-#	endif
+ 	/* Catch a bug in an HP-UX C compiler.  See
+ 	   http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ 	   http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+@@ -7869,6 +8276,7 @@ int
+ main ()
+ {
+ 
++	bool e = &s;
+ 	*pq |= q;
+ 	*pq |= ! q;
+ 	/* Refer to every declared value, to avoid compiler optimizations.  */
+@@ -13010,7 +13418,7 @@ fi
+   CXXFLAGS="$CXXFLAGS $QT_CXXFLAGS"
+ 
+     if test "$is_apple" = yes; then
+-    CXXFLAGS="$CXXFLAGS -ObjC"
++    LIBS="$LIBS -framework Cocoa"
+   fi
+ 
+   QT4LOC=`$PKG_CONFIG --variable=exec_prefix QtCore`
+@@ -13056,6 +13464,15 @@ else
+ fi
+ 
+ 
++ if test "${is_apple}" = yes; then
++  BUILD_ON_APPLE_TRUE=
++  BUILD_ON_APPLE_FALSE='#'
++else
++  BUILD_ON_APPLE_TRUE='#'
++  BUILD_ON_APPLE_FALSE=
++fi
++
++
+  if test "${LRELEASE}" != no; then
+   HAVE_LRELEASE_TRUE=
+   HAVE_LRELEASE_FALSE='#'
+@@ -13222,6 +13639,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+   as_fn_error "conditional \"am__fastdepCC\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${am__fastdepOBJC_TRUE}" && test -z "${am__fastdepOBJC_FALSE}"; then
++  as_fn_error "conditional \"am__fastdepOBJC\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+   as_fn_error "conditional \"am__fastdepCC\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+@@ -13262,6 +13683,10 @@ if test -z "${BUILD_QT_TRUE}" && test -z "${BUILD_QT_FALSE}"; then
+   as_fn_error "conditional \"BUILD_QT\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${BUILD_ON_APPLE_TRUE}" && test -z "${BUILD_ON_APPLE_FALSE}"; then
++  as_fn_error "conditional \"BUILD_ON_APPLE\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${HAVE_LRELEASE_TRUE}" && test -z "${HAVE_LRELEASE_FALSE}"; then
+   as_fn_error "conditional \"HAVE_LRELEASE\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+--- configure.in.orig
++++ configure.in
+@@ -26,6 +26,7 @@ AC_GNU_SOURCE
+ AC_PROG_CC
+ AM_C_PROTOTYPES
+ AC_PROG_CPP
++AC_PROG_OBJC
+ AC_C_CONST
+ AC_C_INLINE
+ AC_C_STRINGIZE
+@@ -1146,7 +1147,7 @@ if test "${enable_qt_ok}" = yes ; then
+ 
+   dnl Compile Objective C Cocoa headers on Mac to hide the gnuplot icon from the dock
+   if test "$is_apple" = yes; then
+-    CXXFLAGS="$CXXFLAGS -ObjC"
++    LIBS="$LIBS -framework Cocoa"
+   fi
+ 
+   QT4LOC=`$PKG_CONFIG --variable=exec_prefix QtCore`
+@@ -1183,6 +1184,8 @@ if test "${enable_qt_ok}" = yes ; then
+ fi
+ AM_CONDITIONAL(BUILD_QT, test "${enable_qt_ok}" = yes)
+ 
++AM_CONDITIONAL(BUILD_ON_APPLE, test "${is_apple}" = yes)
++
+ dnl translation tools
+ AM_CONDITIONAL(HAVE_LRELEASE, test "${LRELEASE}" != no)
+ 
+--- demo/Makefile.in.orig
++++ demo/Makefile.in
+@@ -110,6 +110,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -155,6 +158,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- m4/Makefile.in.orig
++++ m4/Makefile.in
+@@ -110,6 +110,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -155,6 +158,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- man/Makefile.in.orig
++++ man/Makefile.in
+@@ -135,6 +135,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -180,6 +183,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- share/LaTeX/Makefile.in.orig
++++ share/LaTeX/Makefile.in
+@@ -134,6 +134,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -179,6 +182,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- share/Makefile.in.orig
++++ share/Makefile.in
+@@ -174,6 +174,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -219,6 +222,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- src/Makefile.am.orig
++++ src/Makefile.am
+@@ -143,6 +143,10 @@ clean-local: clean-qt-extra clean-demo
+ 
+ gnuplot_SOURCES += qtterminal/qt_term.cpp
+ 
++if BUILD_ON_APPLE
++gnuplot_SOURCES += qtterminal/qt_term_mac.m
++endif
++
+ pkglibexec_PROGRAMS += gnuplot_qt
+ 
+ $(gnuplot_qt_OBJECTS) : ui_QtGnuplotSettings.h
+--- src/Makefile.in.orig
++++ src/Makefile.in
+@@ -45,7 +45,8 @@ pkglibexec_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
+ 
+ # Qt terminal sources
+ @BUILD_QT_TRUE@am__append_6 = qtterminal/qt_term.cpp
+-@BUILD_QT_TRUE@am__append_7 = gnuplot_qt
++@BUILD_ON_APPLE_TRUE@@BUILD_QT_TRUE@am__append_7 = qtterminal/qt_term_mac.m
++@BUILD_QT_TRUE@am__append_8 = gnuplot_qt
+ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+ 	$(srcdir)/makefile.all ansi2knr.1 ansi2knr.c
+ subdir = src
+@@ -86,12 +87,14 @@ am__gnuplot_SOURCES_DIST = alloc.c alloc.h ansichek.h axis.c axis.h \
+ 	util.c util.h util3d.c util3d.h variable.c variable.h \
+ 	version.c version.h wxterminal/wxt_gui.cpp \
+ 	wxterminal/gp_cairo.c wxterminal/gp_cairo_helpers.c bitmap.c \
+-	qtterminal/qt_term.cpp
++	qtterminal/qt_term.cpp qtterminal/qt_term_mac.m
+ @BUILD_WXWIDGETS_TRUE@am__objects_1 = wxt_gui.$(OBJEXT)
+ @BUILD_GPCAIRO_TRUE@am__objects_2 = gp_cairo$U.$(OBJEXT) \
+ @BUILD_GPCAIRO_TRUE@	gp_cairo_helpers$U.$(OBJEXT)
+ @BUILD_BITMAP_TRUE@am__objects_3 = bitmap$U.$(OBJEXT)
+ @BUILD_QT_TRUE@am__objects_4 = qt_term.$(OBJEXT)
++@BUILD_ON_APPLE_TRUE@@BUILD_QT_TRUE@am__objects_5 =  \
++@BUILD_ON_APPLE_TRUE@@BUILD_QT_TRUE@	qt_term_mac.$(OBJEXT)
+ am_gnuplot_OBJECTS = alloc$U.$(OBJEXT) axis$U.$(OBJEXT) \
+ 	binary$U.$(OBJEXT) breaders$U.$(OBJEXT) color$U.$(OBJEXT) \
+ 	command$U.$(OBJEXT) contour$U.$(OBJEXT) datafile$U.$(OBJEXT) \
+@@ -108,7 +111,8 @@ am_gnuplot_OBJECTS = alloc$U.$(OBJEXT) axis$U.$(OBJEXT) \
+ 	tabulate$U.$(OBJEXT) term$U.$(OBJEXT) time$U.$(OBJEXT) \
+ 	unset$U.$(OBJEXT) util$U.$(OBJEXT) util3d$U.$(OBJEXT) \
+ 	variable$U.$(OBJEXT) version$U.$(OBJEXT) $(am__objects_1) \
+-	$(am__objects_2) $(am__objects_3) $(am__objects_4)
++	$(am__objects_2) $(am__objects_3) $(am__objects_4) \
++	$(am__objects_5)
+ gnuplot_OBJECTS = $(am_gnuplot_OBJECTS)
+ am__DEPENDENCIES_1 =
+ gnuplot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@@ -156,6 +160,11 @@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ CXXLD = $(CXX)
+ CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+ 	-o $@
++OBJCCOMPILE = $(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
++	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)
++OBJCLD = $(OBJC)
++OBJCLINK = $(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) \
++	$(LDFLAGS) -o $@
+ SOURCES = $(bf_test_SOURCES) $(gnuplot_SOURCES) \
+ 	$(EXTRA_gnuplot_SOURCES) $(gnuplot_qt_SOURCES) \
+ 	$(nodist_gnuplot_qt_SOURCES) $(gnuplot_x11_SOURCES)
+@@ -292,6 +301,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -337,6 +349,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+@@ -430,7 +443,7 @@ gnuplot_SOURCES = alloc.c alloc.h ansichek.h axis.c axis.h binary.c \
+ 	tabulate.h template.h term_api.h term.c term.h time.c unset.c \
+ 	util.c util.h util3d.c util3d.h variable.c variable.h \
+ 	version.c version.h $(am__append_2) $(am__append_3) \
+-	$(am__append_4) $(am__append_6)
++	$(am__append_4) $(am__append_6) $(am__append_7)
+ gnuplot_LDADD = $(TERMLIBS) $(TERMXLIBS) $(WX_LIBS) $(QT_LIBS)
+ @BUILD_GNUPLOT_X11_TRUE@gnuplot_x11_SOURCES = gplt_x11.c gplt_x11.h gpexecute.c gpexecute.h mousecmn.h version.c version.h
+ @BUILD_GNUPLOT_X11_TRUE@XLIBS = @LIBRARIES_FOR_X@
+@@ -510,7 +523,7 @@ $(T)vws.trm $(T)win.trm $(T)wxt.trm $(T)x11.trm $(T)xlib.trm
+ all: all-recursive
+ 
+ .SUFFIXES:
+-.SUFFIXES: .c .cpp .o .obj
++.SUFFIXES: .c .cpp .m .o .obj
+ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/makefile.all $(am__configure_deps)
+ 	@for dep in $?; do \
+ 	  case '$(am__configure_deps)' in \
+@@ -696,6 +709,7 @@ mostlyclean-kr:
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pm3d$U.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qrc_QtGnuplotResource.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qt_term.Po@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qt_term_mac.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readline$U.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/save$U.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scanner$U.Po@am__quote@
+@@ -1056,6 +1070,34 @@ QtGnuplotEvent.obj: qtterminal/QtGnuplotEvent.cpp
+ @AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='qtterminal/QtGnuplotEvent.cpp' object='QtGnuplotEvent.obj' libtool=no @AMDEPBACKSLASH@
+ @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ @am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o QtGnuplotEvent.obj `if test -f 'qtterminal/QtGnuplotEvent.cpp'; then $(CYGPATH_W) 'qtterminal/QtGnuplotEvent.cpp'; else $(CYGPATH_W) '$(srcdir)/qtterminal/QtGnuplotEvent.cpp'; fi`
++
++.m.o:
++@am__fastdepOBJC_TRUE@	$(OBJCCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
++@am__fastdepOBJC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
++@AMDEP_TRUE@@am__fastdepOBJC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepOBJC_FALSE@	DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepOBJC_FALSE@	$(OBJCCOMPILE) -c -o $@ $<
++
++.m.obj:
++@am__fastdepOBJC_TRUE@	$(OBJCCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
++@am__fastdepOBJC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
++@AMDEP_TRUE@@am__fastdepOBJC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepOBJC_FALSE@	DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepOBJC_FALSE@	$(OBJCCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
++
++qt_term_mac.o: qtterminal/qt_term_mac.m
++@am__fastdepOBJC_TRUE@	$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT qt_term_mac.o -MD -MP -MF $(DEPDIR)/qt_term_mac.Tpo -c -o qt_term_mac.o `test -f 'qtterminal/qt_term_mac.m' || echo '$(srcdir)/'`qtterminal/qt_term_mac.m
++@am__fastdepOBJC_TRUE@	$(am__mv) $(DEPDIR)/qt_term_mac.Tpo $(DEPDIR)/qt_term_mac.Po
++@AMDEP_TRUE@@am__fastdepOBJC_FALSE@	source='qtterminal/qt_term_mac.m' object='qt_term_mac.o' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepOBJC_FALSE@	DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepOBJC_FALSE@	$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o qt_term_mac.o `test -f 'qtterminal/qt_term_mac.m' || echo '$(srcdir)/'`qtterminal/qt_term_mac.m
++
++qt_term_mac.obj: qtterminal/qt_term_mac.m
++@am__fastdepOBJC_TRUE@	$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT qt_term_mac.obj -MD -MP -MF $(DEPDIR)/qt_term_mac.Tpo -c -o qt_term_mac.obj `if test -f 'qtterminal/qt_term_mac.m'; then $(CYGPATH_W) 'qtterminal/qt_term_mac.m'; else $(CYGPATH_W) '$(srcdir)/qtterminal/qt_term_mac.m'; fi`
++@am__fastdepOBJC_TRUE@	$(am__mv) $(DEPDIR)/qt_term_mac.Tpo $(DEPDIR)/qt_term_mac.Po
++@AMDEP_TRUE@@am__fastdepOBJC_FALSE@	source='qtterminal/qt_term_mac.m' object='qt_term_mac.obj' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepOBJC_FALSE@	DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepOBJC_FALSE@	$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o qt_term_mac.obj `if test -f 'qtterminal/qt_term_mac.m'; then $(CYGPATH_W) 'qtterminal/qt_term_mac.m'; else $(CYGPATH_W) '$(srcdir)/qtterminal/qt_term_mac.m'; fi`
+ install-qtgnuplotDATA: $(qtgnuplot_DATA)
+ 	@$(NORMAL_INSTALL)
+ 	test -z "$(qtgnuplotdir)" || $(MKDIR_P) "$(DESTDIR)$(qtgnuplotdir)"
+--- src/qtterminal/Makefile.in.orig
++++ src/qtterminal/Makefile.in
+@@ -110,6 +110,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -155,6 +158,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- src/qtterminal/qt_term.cpp.orig
++++ src/qtterminal/qt_term.cpp
+@@ -45,10 +45,6 @@
+ #include <QtGui>
+ #include <QtNetwork>
+ 
+-#ifdef Q_WS_MAC
+-	#include <Cocoa/Cocoa.h>
+-#endif
+-
+ extern "C" {
+ 	#include "plot.h"      // for interactive
+ 	#include "term_api.h"  // for stdfn.h, JUSTIFY, encoding, *term definition, color.h term_interlock
+@@ -60,6 +56,7 @@ extern "C" {
+ 	#include "parse.h"     // for real_expression
+ 	#include "axis.h"
+ 	#include <signal.h>
++	double removeDockIcon();
+ }
+ 
+ #include "qt_term.h"
+@@ -309,9 +306,7 @@ void qt_init()
+ 
+ #ifdef Q_WS_MAC
+ 	// Don't display this application in the MAC OS X dock
+-	ProcessSerialNumber psn;
+-	if (GetCurrentProcess(&psn) == noErr)
+-		TransformProcessType(&psn, kProcessTransformToBackgroundApplication);
++	removeDockIcon();
+ #endif
+ 
+ 	// The creation of a QApplication mangled our locale settings
+--- /dev/null
++++ src/qtterminal/qt_term_mac.m
+@@ -0,0 +1,8 @@
++#include <Cocoa/Cocoa.h>
++
++void removeDockIcon()
++{
++	ProcessSerialNumber psn;
++	if (GetCurrentProcess(&psn) == noErr)
++		TransformProcessType(&psn, kProcessTransformToBackgroundApplication);
++}
+--- src/wxterminal/Makefile.in.orig
++++ src/wxterminal/Makefile.in
+@@ -110,6 +110,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -155,6 +158,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- term/Makefile.in.orig
++++ term/Makefile.in
+@@ -135,6 +135,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -180,6 +183,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
+--- tutorial/Makefile.in.orig
++++ tutorial/Makefile.in
+@@ -110,6 +110,9 @@ MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MKDIR_P = @MKDIR_P@
+ MOC = @MOC@
++OBJC = @OBJC@
++OBJCDEPMODE = @OBJCDEPMODE@
++OBJCFLAGS = @OBJCFLAGS@
+ OBJEXT = @OBJEXT@
+ PACKAGE = @PACKAGE@
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+@@ -155,6 +158,7 @@ abs_top_builddir = @abs_top_builddir@
+ abs_top_srcdir = @abs_top_srcdir@
+ ac_ct_CC = @ac_ct_CC@
+ ac_ct_CXX = @ac_ct_CXX@
++ac_ct_OBJC = @ac_ct_OBJC@
+ am__include = @am__include@
+ am__leading_dot = @am__leading_dot@
+ am__quote = @am__quote@
diff --git a/files/patch-src-variable_c.diff b/files/patch-src-variable_c.diff
index eb2abce..95eae92 100644
--- a/files/patch-src-variable_c.diff
+++ b/files/patch-src-variable_c.diff
@@ -1,6 +1,6 @@
---- src/variable.c.orig	2010-10-18 15:41:53.000000000 +0200
-+++ src/variable.c	2010-10-18 15:42:11.000000000 +0200
-@@ -244,13 +244,13 @@
+--- src/variable.c.orig
++++ src/variable.c
+@@ -250,13 +250,13 @@
  };
  #endif
  
diff --git a/files/patch-upstream-qt.diff b/files/patch-upstream-qt.diff
new file mode 100644
index 0000000..573932c
--- /dev/null
+++ b/files/patch-upstream-qt.diff
@@ -0,0 +1,86 @@
+--- src/qtterminal/QtGnuplotScene.cpp.orig
++++ src/qtterminal/QtGnuplotScene.cpp
+@@ -56,7 +56,7 @@ QtGnuplotScene::QtGnuplotScene(QtGnuplotEventHandler* eventHandler, QObject* par
+ 	m_eventHandler = eventHandler;
+ 	m_lastModifierMask = 0;
+ 	m_textAngle = 0.;
+-	m_textAlignment == Qt::AlignLeft;
++	m_textAlignment = Qt::AlignLeft;
+ 	m_currentZ = 1.;
+ 	m_currentPointSize = 1.;
+ 	m_enhanced = 0;
+--- src/qtterminal/QtGnuplotWidget.cpp.orig
++++ src/qtterminal/QtGnuplotWidget.cpp
+@@ -169,6 +169,15 @@ void QtGnuplotWidget::resizeEvent(QResizeEvent* event)
+ 	QWidget::resizeEvent(event);
+ }
+ 
++QPainter::RenderHints QtGnuplotWidget::renderHints() const
++{
++	QPainter::RenderHints hint = QPainter::TextAntialiasing;
++	if (m_antialias)
++		hint |= QPainter::Antialiasing;
++
++	return hint;
++}
++
+ /////////////////////////////////////////////////
+ // Slots
+ 
+@@ -178,7 +187,7 @@ QPixmap QtGnuplotWidget::createPixmap()
+ 	pixmap.fill();
+ 	QPainter painter(&pixmap);
+ 	painter.translate(0.5, 0.5);
+-	painter.setRenderHint(m_antialias ? QPainter::Antialiasing : QPainter::TextAntialiasing);
++	painter.setRenderHints(renderHints());
+ 	m_scene->render(&painter);
+ 	painter.end();
+ 	return pixmap;
+@@ -195,7 +204,7 @@ void QtGnuplotWidget::print()
+ 	if (QPrintDialog(&printer).exec() == QDialog::Accepted)
+ 	{
+ 		QPainter painter(&printer);
+-		painter.setRenderHint(m_antialias ? QPainter::Antialiasing : QPainter::TextAntialiasing);
++		painter.setRenderHints(renderHints());
+ 		m_scene->render(&painter);
+ 	}
+ }
+@@ -211,8 +220,10 @@ void QtGnuplotWidget::exportToPdf()
+ 	QPrinter printer;
+ 	printer.setOutputFormat(QPrinter::PdfFormat);
+ 	printer.setOutputFileName(fileName);
++	printer.setPaperSize(QSizeF(m_scene->width(), m_scene->height()), QPrinter::Point);
++	printer.setPageMargins(0, 0, 0, 0, QPrinter::Point);
+ 	QPainter painter(&printer);
+-	painter.setRenderHint(m_antialias ? QPainter::Antialiasing : QPainter::TextAntialiasing);
++	painter.setRenderHints(renderHints());
+ 	m_scene->render(&painter);
+ }
+ 
+@@ -266,7 +277,7 @@ void QtGnuplotWidget::loadSettings()
+ 
+ void QtGnuplotWidget::applySettings()
+ {
+-	m_view->setRenderHints(m_antialias ? QPainter::Antialiasing : QPainter::TextAntialiasing);
++	m_view->setRenderHints(renderHints());
+ 	m_view->setBackgroundBrush(m_backgroundColor);
+ }
+ 
+--- src/qtterminal/QtGnuplotWidget.h.orig
++++ src/qtterminal/QtGnuplotWidget.h
+@@ -47,6 +47,7 @@
+ #include "QtGnuplotEvent.h"
+ 
+ #include <QWidget>
++#include <QPainter>
+ 
+ class QtGnuplotScene;
+ class QGraphicsView;
+@@ -93,6 +94,7 @@ private:
+ 	void loadSettings();
+ 	void applySettings();
+ 	void saveSettings();
++	QPainter::RenderHints renderHints() const;
+ 
+ private:
+ 	int m_id;
diff --git a/files/patch-upstream-wxt-scroll.diff b/files/patch-upstream-wxt-scroll.diff
new file mode 100644
index 0000000..212b4f3
--- /dev/null
+++ b/files/patch-upstream-wxt-scroll.diff
@@ -0,0 +1,23 @@
+--- src/wxterminal/wxt_gui.cpp.orig
++++ src/wxterminal/wxt_gui.cpp
+@@ -1003,11 +1003,16 @@ void wxtPanel::OnRightUp( wxMouseEvent& event )
+ /* mouse wheel event */
+ void wxtPanel::OnMouseWheel( wxMouseEvent& event )
+ {
+-	UpdateModifiers(event);
++	int mouse_button;
+ 
+-	wxt_exec_event(GE_buttonpress, 0, 0, 
+-			event.GetWheelRotation() > 0 ? 4 : 5, 
+-			0, this->GetId());
++	UpdateModifiers(event);
++	mouse_button = (event.GetWheelRotation() > 0 ? 4 : 5);
++#if wxCHECK_VERSION(2, 9, 0)
++	/* GetWheelAxis: 0 is the Y axis, 1 is the X axis. */
++	if (event.GetWheelAxis() > 0)
++	    mouse_button += 2;
++#endif
++	wxt_exec_event(GE_buttonpress, 0, 0, mouse_button, 0, this->GetId());
+ }
+ 
+ /* the state of the modifiers is checked each time a key is pressed instead of
