Add configure operations to support MINGW on Windows.
authorPaul Smith <psmith@gnu.org>
Sat, 26 Feb 2005 01:41:48 +0000 (01:41 +0000)
committerPaul Smith <psmith@gnu.org>
Sat, 26 Feb 2005 01:41:48 +0000 (01:41 +0000)
ChangeLog
Makefile.am
config/.cvsignore
configure.in
main.c
tests/run_make_tests.pl
w32/.cvsignore [new file with mode: 0644]
w32/Makefile.am [new file with mode: 0644]
w32/subproc/sub_proc.c
w32/subproc/w32err.c

index 108cbc0717b1a602d228fb7594d05125cc7a791c..701501e7ab6bca90db86f462e1c759b65b2f3d1e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-02-24  Jonathan Grant  <jg@jguk.org>
+
+       * configure.in: Add MinGW configuration options, and extra w32 code
+        directory.
+       * Makefile.am: Add MinGW configuration options, and extra w32 code
+        directory.
+       * main.c: Determine correct program string (after last \ without .exe).
+       * subproc/sub_proc.c: `GetExitCodeProcess' from incompatible pointer
+        type fix x2
+       * w32/Makefile.am: Import to build win32 lib of sub_proc etc.
+       * subproc/w32err.c: MSVC thread directive not applied to MinGW builds.
+       * tests/run_make_tests.pl, tests/test_driver.pl: MSYS testing
+        environment support.
+
 2005-02-09  Paul D. Smith  <psmith@gnu.org>
 
        * maintMakefile: Update the CVS download URL to simplify them.
index b3d85c5d5f446b5cf8bf0c1158cad5b6ddbf3bbd..0877aa2881ce3618f89a654319c01bd297001c09 100644 (file)
@@ -4,6 +4,12 @@ AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news ansi2knr
 ACLOCAL_AMFLAGS        =  -I config
 
 SUBDIRS =      glob config po doc
+# Only process if target is MS-Windows
+if WINDOWSENV
+    SUBDIRS += w32
+    W32INC :=  -I $(top_srcdir)/w32/include
+    W32LIB :=  -Lw32 -lw32
+endif
 
 bin_PROGRAMS = make
 
@@ -25,12 +31,20 @@ noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \
                debug.h getopt.h gettext.h hash.h
 
 make_LDADD =   @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@
+# Only process if target is MS-Windows
+if WINDOWSENV
+    make_LDADD += $(W32LIB)
+endif
 
 man_MANS =     make.1
 
 DEFS =         -DLOCALEDIR=\"$(localedir)\" -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" @DEFS@
 
 AM_CPPFLAGS =  $(GLOBINC)
+# Only process if target is MS-Windows
+if WINDOWSENV
+    AM_CPPFLAGS +=     $(W32INC)
+endif
 
 
 # Extra stuff to include in the distribution.
index a183a3de0cfd06735bf91c5b8b3a2df501c88f05..33b30ed0cf51c8bb3ce48a632488897453702e80 100644 (file)
@@ -1,5 +1,6 @@
 *.m4
 config.*
 mkinstalldirs
+texinfo.tex
 
 Makefile Makefile.in
index a8c35ecb4b082354b41500eefba2fbb27b64bd25..7e4d54527e1a90735fa7844d42bccf1067c58af7 100644 (file)
@@ -235,6 +235,15 @@ AC_ARG_WITH(customs,
 # Tell automake about this, so it can include the right .c files.
 AM_CONDITIONAL(USE_CUSTOMS, test "$use_customs" = true)
 
+# See if the user asked to handle case insensitive file systems.
+
+AH_TEMPLATE(HAVE_CASE_INSENSITIVE_FS, [Use case insensitive file names])
+AC_ARG_ENABLE(case-insensitive-file-system,
+  AC_HELP_STRING([--enable-case-insensitive-file-system],
+                [enable case insensitive file system support]),
+  case_insensitive_fs="yes" AC_DEFINE(HAVE_CASE_INSENSITIVE_FS),
+  case_insensitive_fs="no")
+
 # See if we can handle the job server feature, and if the user wants it.
 
 AC_ARG_ENABLE(job-server,
@@ -331,6 +340,18 @@ AC_DEFINE_UNQUOTED(MAKE_HOST,"$host",[Build host information.])
 MAKE_HOST="$host"
 AC_SUBST(MAKE_HOST)
 
+w32_target_env=no
+AM_CONDITIONAL(WINDOWSENV, false)
+
+case "$host" in
+  *-*-mingw32)
+    AM_CONDITIONAL(WINDOWSENV, true)
+    w32_target_env=yes
+    AC_DEFINE([WINDOWS32], [1], [Use platform specific coding])
+    AC_DEFINE([HAVE_DOS_PATHS], [1], [Use platform specific coding])
+    ;;
+esac
+
 # Include the Maintainer's Makefile section, if it's here.
 
 MAINT_MAKEFILE=/dev/null
@@ -391,6 +412,11 @@ esac
 # Specify what files are to be created.
 AC_CONFIG_FILES(Makefile glob/Makefile po/Makefile.in config/Makefile doc/Makefile)
 
+# Only process if target is MS-Windows
+if test "$w32_target_env" == yes; then
+    AC_CONFIG_FILES(w32/Makefile)
+fi
+
 # OK, do it!
 
 AC_OUTPUT
diff --git a/main.c b/main.c
index 33c15b4944c8ee94553e15570683736ce2824d4b..42e1a00c625d9a0df7e15e6714afd95769d146fa 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1025,6 +1025,25 @@ main (int argc, char **argv, char **envp)
        }
       if (program == 0 && argv[0][1] == ':')
        program = argv[0] + 1;
+#endif
+#ifdef WINDOWS32
+      if (program == 0)
+        {
+          /* Extract program from full path */
+          int argv0_len;
+          char *p = strrchr (argv[0], '\\');
+          if (!p)
+            p = argv[0];
+          argv0_len = strlen(p);
+          if (argv0_len > 4
+              && streq (&p[argv0_len - 4], ".exe"))
+            {
+              /* Remove .exe extension */
+              p[argv0_len - 4] = '\0';
+              /* Increment past the initial '\' */
+              program = p + 1;
+            }
+        }
 #endif
       if (program == 0)
        program = argv[0];
index aeba4e8ff204d7e411b36b009bceecfd7a80ccec..5276d29b9d4b511d65d1447e252106ea23d25c99 100755 (executable)
@@ -12,6 +12,7 @@
 #                        (and others)
 
 $valgrind = 0;              # invoke make with valgrind
+$pure_log = undef;
 
 require "test_driver.pl";
 
@@ -215,7 +216,7 @@ sub set_more_defaults
    #
    # This is probably not specific enough.
    #
-   if ($osname =~ /Windows/i) {
+   if ($osname =~ /Windows/i || $osname =~ /MINGW32/i) {
      $port_type = 'W32';
    }
    # Bleah, the osname is so variable on DOS.  This kind of bites.
@@ -243,11 +244,17 @@ sub set_more_defaults
    #
    $wtime = $port_type eq 'UNIX' ? 1 : $port_type eq 'OS/2' ? 2 : 4;
 
+   print "Port type: $port_type\n" if $debug;
+   print "Make path: $make_path\n" if $debug;
+
    # Find the full pathname of Make.  For DOS systems this is more
-   # complicated, so we ask make itself.
+   # complicated, so we ask make itself.  The following shell code does not
+   # work on W32 (MinGW/MSYS)
 
-   $make_path = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
-   chop $make_path;
+   if ($port_type ne 'W32') {
+     $make_path = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
+     chop $make_path;
+   }
    print "Make\t= `$make_path'\n" if $debug;
 
    $string = `$make_path -v -f /dev/null 2> /dev/null`;
@@ -283,10 +290,12 @@ sub set_more_defaults
 
    # Get Purify log info--if any.
 
-   $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/;
-   $pure_log = $1 || '';
-   $pure_log =~ s/%v/$make_name/;
-   $purify_errors = 0;
+   if (exists $ENV{PURIFYOPTIONS}
+       && $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/) {
+     $pure_log = $1 || '';
+     $pure_log =~ s/%v/$make_name/;
+     $purify_errors = 0;
+   }
 
    $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`;
    if ($string =~ /not supported/) {
diff --git a/w32/.cvsignore b/w32/.cvsignore
new file mode 100644 (file)
index 0000000..6179e0d
--- /dev/null
@@ -0,0 +1 @@
+Makefile Makefile.in
diff --git a/w32/Makefile.am b/w32/Makefile.am
new file mode 100644 (file)
index 0000000..fd6743d
--- /dev/null
@@ -0,0 +1,8 @@
+# Makefile.am to create libw32.a for mingw32 host.
+
+noinst_LIBRARIES = libw32.a
+
+libw32_a_SOURCES =  subproc/misc.c subproc/sub_proc.c subproc/w32err.c \
+                   pathstuff.c
+
+libw32_a_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/subproc -I$(top_srcdir)
index bf1e732bc0dd08fbd935b3ad0f5f2fc000db2448..63911fcde17329909b99c148a88d56bd1e396146 100644 (file)
@@ -664,13 +664,13 @@ process_pipe_io(
        DWORD wait_return;
        HANDLE ready_hand;
        bool_t child_dead = FALSE;
-
+       BOOL GetExitCodeResult;
 
        /*
         *  Create stdin thread, if needed
         */
-    pproc->inp = stdin_data;
-    pproc->incnt = stdin_data_len;
+       pproc->inp = stdin_data;
+       pproc->incnt = stdin_data_len;
        if (!pproc->inp) {
                stdin_eof = TRUE;
                CloseHandle((HANDLE)pproc->sv_stdin[0]);
@@ -762,7 +762,8 @@ process_pipe_io(
 
                } else if (ready_hand == childhand) {
 
-                       if (GetExitCodeProcess(childhand, &pproc->exit_code) == FALSE) {
+                       GetExitCodeResult = GetExitCodeProcess(childhand, (DWORD*)&pproc->exit_code);
+                       if (GetExitCodeResult == FALSE) {
                                pproc->last_err = GetLastError();
                                pproc->lerrno = E_SCALL;
                                goto done;
@@ -809,6 +810,7 @@ process_file_io(
        sub_process *pproc;
        HANDLE childhand;
        DWORD wait_return;
+       BOOL GetExitCodeResult;
 
        if (proc == NULL)
                pproc = process_wait_for_any_private();
@@ -852,7 +854,8 @@ process_file_io(
                goto done2;
        }
 
-       if (GetExitCodeProcess(childhand, &pproc->exit_code) == FALSE) {
+       GetExitCodeResult = GetExitCodeProcess(childhand, (DWORD*)&pproc->exit_code);
+       if (GetExitCodeResult == FALSE) {
                pproc->last_err = GetLastError();
                pproc->lerrno = E_SCALL;
        }
index 9bfa2c48a5c0b66dd3782a2e42199fe279c6e498..712fccdfcc80576308ca9d67eabd370811df6250 100644 (file)
  */\r
 char *\r
 map_windows32_error_to_string (DWORD ercode) {\r
-/* __declspec (thread) necessary if you will use multiple threads */\r
+/* __declspec (thread) necessary if you will use multiple threads on MSVC */\r
+#ifdef _MSC_VER\r
 __declspec (thread) static char szMessageBuffer[128];\r
-\r
+#else\r
+static char szMessageBuffer[128];\r
+#endif\r
        /* Fill message buffer with a default message in\r
         * case FormatMessage fails\r
         */\r