Add a mechanism for using autoconf to detect the quirks of Unix systems
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Mon, 25 Apr 2005 15:55:06 +0000 (15:55 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Mon, 25 Apr 2005 15:55:06 +0000 (15:55 +0000)
rather than relying on the user to edit the Makefile.  Makefile.gtk
still works as well as it ever did, but now we get a Makefile.in alongside
it.  mkunxarc.sh now relies on autoconf and friends to build the configure
script for the Unix source distribution.

git-svn-id: svn://svn.tartarus.org/sgt/putty@5673 cda61777-01e9-0310-a592-d414129be87e

README
Recipe
mkfiles.pl
mkunxarc.sh
unix/configure.ac [new file with mode: 0644]
unix/unix.h

diff --git a/README b/README
index e178791..8f2a791 100644 (file)
--- a/README
+++ b/README
@@ -42,11 +42,14 @@ For building on Windows:
 
 For building on Unix:
 
- - unix/Makefile.gtk is for Unix and GTK. If you don't have GTK, you
+ - unix/configure is for Unix and GTK. If you don't have GTK, you
    should still be able to build the command-line utilities (PSCP,
-   PSFTP, Plink, PuTTYgen) using this makefile. The makefile expects
-   you to change into the `unix' subdirectory, then run `make -f
-   Makefile.gtk'. Note that Unix PuTTY has mostly only been tested
+   PSFTP, Plink, PuTTYgen) using this script. To use it, change
+   into the `unix' subdirectory, run `./configure' and then `make'.
+ - unix/Makefile.gtk is for non-autoconfigured builds. This makefile
+   expects you to change into the `unix' subdirectory, then run `make
+   -f Makefile.gtk'. Note that Unix PuTTY has mostly only been tested
    on Linux so far; portability problems such as BSD-style ptys or
    different header file requirements are expected.
 
diff --git a/Recipe b/Recipe
index f0facd6..407b229 100644 (file)
--- a/Recipe
+++ b/Recipe
@@ -18,6 +18,7 @@
 !makefile borland windows/Makefile.bor
 !makefile lcc windows/Makefile.lcc
 !makefile gtk unix/Makefile.gtk
+!makefile ac unix/Makefile.in
 !makefile mpw mac/Makefile.mpw
 !makefile osx macosx/Makefile
 # Source directories.
index 7881832..8905c3f 100755 (executable)
@@ -212,7 +212,7 @@ sub mfval($) {
     # Returns true if the argument is a known makefile type. Otherwise,
     # prints a warning and returns false;
     if (grep { $type eq $_ }
-       ("vc","vcproj","cygwin","borland","lcc","gtk","mpw","osx")) {
+       ("vc","vcproj","cygwin","borland","lcc","gtk","ac","mpw","osx")) {
            return 1;
        }
     warn "$.:unknown makefile type '$type'\n";
@@ -945,6 +945,64 @@ if (defined $makefiles{'gtk'}) {
     select STDOUT; close OUT;
 }
 
+if (defined $makefiles{'ac'}) {
+    $dirpfx = &dirpfx($makefiles{'ac'}, "/");
+
+    ##-- Unix/autoconf makefile
+    open OUT, ">$makefiles{'ac'}"; select OUT;
+    print
+    "# Makefile.in for $project_name under Unix with Autoconf.\n".
+    "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
+    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
+    # gcc command line option is -D not /D
+    ($_ = $help) =~ s/=\/D/=-D/gs;
+    print $_;
+    print
+    "\n".
+    "CC = \@CC\@\n".
+    "\n".
+    &splitline("CFLAGS = \@CFLAGS\@ \@CPPFLAGS\@ \@DEFS\@ \@GTK_CFLAGS\@ " .
+              (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
+    "XLDFLAGS = \@LDFLAGS\@ \@LIBS\@ \@GTK_LIBS\@\n".
+    "ULDFLAGS = \@LDFLAGS\@ \@LIBS\@\n".
+    "INSTALL=\@INSTALL\@\n",
+    "INSTALL_PROGRAM=\$(INSTALL)\n",
+    "INSTALL_DATA=\$(INSTALL)\n",
+    "prefix=\@prefix\@\n",
+    "exec_prefix=\@exec_prefix\@\n",
+    "bindir=\@bindir\@\n",
+    "mandir=\@mandir\@\n",
+    "man1dir=\$(mandir)/man1\n",
+    "\n".
+    $makefile_extra{'gtk'}->{'vars'} .
+    "\n".
+    ".SUFFIXES:\n".
+    "\n".
+    "\n".
+    "all: \@all_targets\@\n".
+    &splitline("all-cli:" . join "", map { " $_" } &progrealnames("U"))."\n".
+    &splitline("all-gtk:" . join "", map { " $_" } &progrealnames("X"))."\n";
+    print "\n";
+    foreach $p (&prognames("X:U")) {
+      ($prog, $type) = split ",", $p;
+      $objstr = &objects($p, "X.o", undef, undef);
+      print &splitline($prog . ": " . $objstr), "\n";
+      $libstr = &objects($p, undef, undef, "-lX");
+      print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
+                       $objstr . " $libstr", 69), "\n\n";
+    }
+    foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
+      print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
+          "\n";
+      print &splitline("\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c $d->{deps}->[0]\n");
+    }
+    print "\n";
+    print $makefile_extra{'gtk'}->{'end'};
+    print "\nclean:\n".
+    "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
+    select STDOUT; close OUT;
+}
+
 if (defined $makefiles{'mpw'}) {
     ##-- MPW Makefile
     open OUT, ">$makefiles{'mpw'}"; select OUT;
index 8630fff..8433c38 100755 (executable)
@@ -28,6 +28,9 @@ esac
 
 perl mkfiles.pl
 (cd doc && make -s ${docver:+"$docver"})
+# Track down automake's copy of install-sh
+cp `aclocal --print-ac-dir | sed 's/aclocal$/automake/'`/install-sh unix/.
+(cd unix && autoreconf  && rm -rf aclocal.m4 autom4te.cache)
 
 relver=`cat LATEST.VER`
 arcname="putty$arcsuffix"
diff --git a/unix/configure.ac b/unix/configure.ac
new file mode 100644 (file)
index 0000000..9156356
--- /dev/null
@@ -0,0 +1,44 @@
+# To compile this into a configure script, you need:
+# * Autoconf 2.50 or newer
+# * Gtk (for $prefix/share/aclocal/gtk.m4)
+# * Automake (for aclocal)
+# If you've got them, running "autoreconf" should work.
+
+AC_INIT
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_HEADERS([uxconfig.h:uxconfig.in])
+
+AC_PROG_INSTALL
+AC_PROG_CC
+if test "X$GCC" = Xyes; then
+    CFLAGS="$CFLAGS -Wall -Werror"
+fi
+
+AM_PATH_GTK([1.2.0], [all_targets="all-cli all-gtk"], [all_targets="all-cli"])
+AC_SUBST([all_targets])
+
+AC_SEARCH_LIBS([socket], [xnet])
+
+AC_CHECK_FUNCS([getaddrinfo ptsname pututline setresuid strsignal])
+
+AC_OUTPUT
+
+AH_BOTTOM([
+/* Convert autoconf definitions to ones that PuTTY wants. */
+
+#ifndef HAVE_GETADDRINFO
+# define NO_IPV6
+#endif
+#ifndef HAVE_SETRESUID
+# define HAVE_NO_SETRESUID
+#endif
+#ifndef HAVE_STRSIGNAL
+# define HAVE_NO_STRSIGNAL
+#endif
+#ifndef HAVE_PUTUTLINE
+# define OMIT_UTMP
+#endif
+#ifndef HAVE_PTSNAME
+# define BSD_PTYS
+#endif
+])
index 54cf39f..c0b56c7 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef PUTTY_UNIX_H
 #define PUTTY_UNIX_H
 
+#ifdef HAVE_CONFIG_H
+# include "uxconfig.h" /* Space to hide it from mkfiles.pl */
+#endif
+
 #include <stdio.h>                    /* for FILENAME_MAX */
 #include "charset.h"