Changeset 2591 for trunk/src/kmk/w32


Ignore:
Timestamp:
Jun 17, 2012, 10:45:31 PM (13 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 3.82. Previous GNU make base version was gnumake-2008-10-28-CVS.

Location:
trunk/src/kmk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

    • Property svn:ignore
      •  

        old new  
        1313stamp-*
        1414makebook*
         15
        1516.*gdbinit
         17.gdb_history
         18
        1619*.dep
        1720*.dvi
         
        3134*.pg
        3235*.pgs
         36
        3337README
        3438README.DOS
        3539README.W32
         40README.OS2
        3641aclocal.m4
        3742autom4te.cache
         
        5257config.h.W32
        5358config.h-vms
         59
        5460loadavg
        5561loadavg.c
        5662make
         63
        5764.deps
        5865.dep_segment
         66ID
         67TAGS
         68
        5969_*
        6070sun4
         
        7282sol2
        7383i486-linux
         84
        7485customs
         86
        7587install-sh
        7688mkinstalldirs
         89
         90.directive.asc
  • trunk/src/kmk/w32

    • Property svn:ignore
      •  

        old new  
        11Makefile
        22Makefile.in
         3.deps
  • trunk/src/kmk/w32/Makefile.am

    • Property svn:keywords deleted
    r1993 r2591  
    11# Makefile.am to create libw32.a for mingw32 host.
    22# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 # 2007 Free Software Foundation, Inc.
     3# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44# This file is part of GNU Make.
    55#
  • trunk/src/kmk/w32/compat/dirent.c

    r1993 r2591  
    11/* Directory entry code for Window platforms.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    1717
    1818
    19 #ifdef KMK
    20 # include "config.h" /* my_stat */
    21 #endif
     19#include <config.h>
    2220#include <sys/types.h>
    2321#include <sys/stat.h>
     
    142140
    143141        /* fill in struct dirent values */
    144         pDir->dir_sdReturn.d_ino = -1;
     142        pDir->dir_sdReturn.d_ino = (ino_t)-1;
    145143        strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
    146144
  • trunk/src/kmk/w32/include/dirent.h

    r1993 r2591  
    11/* Windows version of dirent.h
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/w32/include/pathstuff.h

    r1993 r2591  
    11/* Definitions for Windows path manipulation.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/w32/include/sub_proc.h

    r1993 r2591  
    11/* Definitions for Windows process invocation.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    2222 * Component Name:
    2323 *
    24  * $Date: 2007/10/24 20:06:32 $
     24 * $Date: 2010/07/13 01:20:43 $
    2525 *
    2626 * $Source: /sources/make/make/w32/include/sub_proc.h,v $
    2727 *
    28  * $Id: sub_proc.h,v 1.10 2007/10/24 20:06:32 eliz Exp $
     28 * $Id: sub_proc.h,v 1.12 2010/07/13 01:20:43 psmith Exp $
    2929 */
    3030
  • trunk/src/kmk/w32/include/w32err.h

    r1993 r2591  
    11/* Definitions for Windows error handling.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/w32/pathstuff.c

    r2454 r2591  
    11/* Path conversion for Windows pathnames.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007, 2009 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    1717
    1818#include <Windows.h> /* bird */
    19 #include <stdio.h>   /* bird */
     19#include "make.h"
    2020#include <string.h>
    2121#include <stdlib.h>
    22 #include "make.h"
    2322#include "pathstuff.h"
    2423
     
    8382                *etok = to_delim;
    8483                p = ++etok;
    85             } else
     84            } else
    8685                p += strlen(p);
    8786        } else {
  • trunk/src/kmk/w32/subproc/NMakefile

    r1993 r2591  
    33#
    44# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    5 # 2006, 2007 Free Software Foundation, Inc.
     5# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    66# This file is part of GNU Make.
    77#
  • trunk/src/kmk/w32/subproc/build.bat

    r1993 r2591  
    1919@echo off
    2020rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    21 rem 2005, 2006, 2007 Free Software Foundation, Inc.
     21rem 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    2222rem This file is part of GNU Make.
    2323rem
  • trunk/src/kmk/w32/subproc/misc.c

    r1993 r2591  
    11/* Process handling for Windows
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    1616this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1717
     18#include <config.h>
    1819#include <stddef.h>
    1920#include <stdlib.h>
     
    7879        }
    7980
    80         free(tmp);
     81        free(tmp);
    8182        return TRUE;
    8283}
  • trunk/src/kmk/w32/subproc/proc.h

    r1993 r2591  
    11/* Definitions for Windows
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/w32/subproc/sub_proc.c

    r1993 r2591  
    11/* Process handling for Windows.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    1616this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1717
     18#include <config.h>
    1819#include <stdlib.h>
    1920#include <stdio.h>
     21#ifdef _MSC_VER
     22# include <stddef.h>    /* for intptr_t */
     23#else
     24# include <stdint.h>
     25#endif
    2026#include <process.h>  /* for msvc _beginthreadex, _endthreadex */
    2127#include <signal.h>
     
    2531#include "proc.h"
    2632#include "w32err.h"
    27 #include "config.h"
    2833#include "debug.h"
    2934
    3035static char *make_command_line(char *shell_name, char *exec_path, char **argv);
     36extern char *xmalloc (unsigned int);
    3137
    3238typedef struct sub_process_t {
    33         int sv_stdin[2];
    34         int sv_stdout[2];
    35         int sv_stderr[2];
     39        intptr_t sv_stdin[2];
     40        intptr_t sv_stdout[2];
     41        intptr_t sv_stderr[2];
    3642        int using_pipes;
    3743        char *inp;
     
    4147        char * volatile errp;
    4248        volatile DWORD errcnt;
    43         int pid;
     49        pid_t pid;
    4450        int exit_code;
    4551        int signal;
     
    316322                return((HANDLE)pproc);
    317323        }
    318         pproc->sv_stdin[0]  = (int) stdin_pipes[0];
    319         pproc->sv_stdin[1]  = (int) stdin_pipes[1];
    320         pproc->sv_stdout[0] = (int) stdout_pipes[0];
    321         pproc->sv_stdout[1] = (int) stdout_pipes[1];
    322         pproc->sv_stderr[0] = (int) stderr_pipes[0];
    323         pproc->sv_stderr[1] = (int) stderr_pipes[1];
     324        pproc->sv_stdin[0]  = (intptr_t) stdin_pipes[0];
     325        pproc->sv_stdin[1]  = (intptr_t) stdin_pipes[1];
     326        pproc->sv_stdout[0] = (intptr_t) stdout_pipes[0];
     327        pproc->sv_stdout[1] = (intptr_t) stdout_pipes[1];
     328        pproc->sv_stderr[0] = (intptr_t) stderr_pipes[0];
     329        pproc->sv_stderr[1] = (intptr_t) stderr_pipes[1];
    324330
    325331        pproc->using_pipes = 1;
     
    343349         * pipe, bypassing pipes altogether.
    344350         */
    345         pproc->sv_stdin[1]  = (int) stdinh;
    346         pproc->sv_stdout[1] = (int) stdouth;
    347         pproc->sv_stderr[1] = (int) stderrh;
     351        pproc->sv_stdin[1]  = (intptr_t) stdinh;
     352        pproc->sv_stdout[1] = (intptr_t) stdouth;
     353        pproc->sv_stderr[1] = (intptr_t) stderrh;
    348354
    349355        pproc->last_err = pproc->lerrno = 0;
     
    354360
    355361static HANDLE
    356 find_file(char *exec_path, LPOFSTRUCT file_info)
     362find_file(const char *exec_path, const char *path_var,
     363          char *full_fname, DWORD full_len)
    357364{
    358365        HANDLE exec_handle;
    359366        char *fname;
    360367        char *ext;
    361 #ifdef KMK
    362         size_t exec_path_len;
    363 
    364         /*
    365          * if there is an .exe extension there already, don't waste time here.
    366          * If .exe scripts become common, they can be handled in a CreateProcess
    367          * failure path instead of here.
    368          */
    369         exec_path_len = strlen(exec_path);
    370         if (    exec_path_len > 4
    371                 &&      exec_path[exec_path_len - 4] == '.'
    372                 &&  !stricmp(exec_path + exec_path_len - 3, "exe")){
    373                 return((HANDLE)HFILE_ERROR);
    374         }
    375 
    376         fname = malloc(exec_path_len + 5);
    377 #else
    378         fname = malloc(strlen(exec_path) + 5);
    379 #endif
     368        DWORD req_len;
     369        int i;
     370        static const char *extensions[] =
     371          /* Should .com come before no-extension case?  */
     372          { ".exe", ".cmd", ".bat", "", ".com", NULL };
     373
     374        fname = xmalloc(strlen(exec_path) + 5);
    380375        strcpy(fname, exec_path);
    381376        ext = fname + strlen(fname);
    382377
    383         strcpy(ext, ".exe");
    384         if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
    385                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    386                 free(fname);
    387                 return(exec_handle);
    388         }
    389 
    390         strcpy(ext, ".cmd");
    391         if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
    392                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    393                 free(fname);
    394                 return(exec_handle);
    395         }
    396 
    397         strcpy(ext, ".bat");
    398         if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
    399                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    400                 free(fname);
    401                 return(exec_handle);
    402         }
    403 
    404         /* should .com come before this case? */
    405         if ((exec_handle = (HANDLE)OpenFile(exec_path, file_info,
    406                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    407                 free(fname);
    408                 return(exec_handle);
    409         }
    410 
    411         strcpy(ext, ".com");
    412         if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
    413                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    414                 free(fname);
    415                 return(exec_handle);
     378        for (i = 0; extensions[i]; i++) {
     379                strcpy(ext, extensions[i]);
     380                if (((req_len = SearchPath (path_var, fname, NULL, full_len,
     381                                            full_fname, NULL)) > 0
     382                     /* For compatibility with previous code, which
     383                        used OpenFile, and with Windows operation in
     384                        general, also look in various default
     385                        locations, such as Windows directory and
     386                        Windows System directory.  Warning: this also
     387                        searches PATH in the Make's environment, which
     388                        might not be what the Makefile wants, but it
     389                        seems to be OK as a fallback, after the
     390                        previous SearchPath failed to find on child's
     391                        PATH.  */
     392                     || (req_len = SearchPath (NULL, fname, NULL, full_len,
     393                                               full_fname, NULL)) > 0)
     394                    && req_len <= full_len
     395                    && (exec_handle =
     396                                CreateFile(full_fname,
     397                                           GENERIC_READ,
     398                                           FILE_SHARE_READ | FILE_SHARE_WRITE,
     399                                           NULL,
     400                                           OPEN_EXISTING,
     401                                           FILE_ATTRIBUTE_NORMAL,
     402                                           NULL)) != INVALID_HANDLE_VALUE) {
     403                        free(fname);
     404                        return(exec_handle);
     405                }
    416406        }
    417407
    418408        free(fname);
    419         return(exec_handle);
     409        return INVALID_HANDLE_VALUE;
    420410}
    421411
     
    440430        int file_not_found=0;
    441431        HANDLE exec_handle;
     432        char exec_fname[MAX_PATH];
     433        const char *path_var = NULL;
     434        char **ep;
    442435        char buf[256];
    443436        DWORD bytes_returned;
     
    447440        PROCESS_INFORMATION procInfo;
    448441        char *envblk=NULL;
    449         OFSTRUCT file_info;
    450 
     442#ifdef KMK
     443        size_t exec_path_len;
     444#endif
     445
     446
     447        /*
     448         *  Shell script detection...  if the exec_path starts with #! then
     449         *  we want to exec shell-script-name exec-path, not just exec-path
     450         *  NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl.  We do not
     451         *  hard-code the path to the shell or perl or whatever:  Instead, we
     452         *  assume it's in the path somewhere (generally, the NT tools
     453         *  bin directory)
     454         */
     455
     456#ifdef KMK
     457        /* kmk performace: Don't bother looking for shell scripts in .exe files. */
     458        exec_path_len = strlen(exec_path);
     459        if (exec_path_len > 4
     460            && exec_path[exec_path_len - 4] == '.'
     461            && !stricmp(exec_path + exec_path_len - 3, "exe")) {
     462                exec_handle =  INVALID_HANDLE_VALUE;
     463        }
     464        else {
     465#endif /* KMK */
     466                /* Use the Makefile's value of PATH to look for the program to
     467                   execute, because it could be different from Make's PATH
     468                   (e.g., if the target sets its own value.  */
     469                if (envp)
     470                        for (ep = envp; *ep; ep++) {
     471                                if (strncmp (*ep, "PATH=", 5) == 0
     472                                    || strncmp (*ep, "Path=", 5) == 0) {
     473                                        path_var = *ep + 5;
     474                                        break;
     475                                }
     476                        }
     477                exec_handle = find_file(exec_path, path_var,
     478                                        exec_fname, sizeof(exec_fname));
     479#ifdef KMK
     480        }
     481#endif
    451482
    452483        /*
    453          *  Shell script detection...  if the exec_path starts with #! then
    454          *  we want to exec shell-script-name exec-path, not just exec-path
    455          *  NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl.  We do not
    456          *  hard-code the path to the shell or perl or whatever:  Instead, we
    457          *  assume it's in the path somewhere (generally, the NT tools
    458          *  bin directory)
    459          *  We use OpenFile here because it is capable of searching the Path.
     484         * If we couldn't open the file, just assume that Windows will be
     485         * somehow able to find and execute it.
    460486         */
    461 
    462         exec_handle = find_file(exec_path, &file_info);
    463 
    464         /*
    465          * If we couldn't open the file, just assume that Windows32 will be able
    466          * to find and execute it.
    467          */
    468         if (exec_handle == (HANDLE)HFILE_ERROR) {
     487        if (exec_handle == INVALID_HANDLE_VALUE) {
    469488                file_not_found++;
    470489        }
     
    520539                command_line = make_command_line( shell_name, exec_path, argv);
    521540        else
    522                 command_line = make_command_line( shell_name, file_info.szPathName,
    523                                  argv);
     541                command_line = make_command_line( shell_name, exec_fname, argv);
    524542
    525543        if ( command_line == NULL ) {
     
    541559                exec_path = 0;  /* Search for the program in %Path% */
    542560        } else {
    543                 exec_path = file_info.szPathName;
     561                exec_path = exec_fname;
    544562        }
    545563
     
    608626        }
    609627
    610         pproc->pid = (int)procInfo.hProcess;
     628        pproc->pid = (pid_t)procInfo.hProcess;
    611629        /* Close the thread handle -- we'll just watch the process */
    612630        CloseHandle(procInfo.hThread);
  • trunk/src/kmk/w32/subproc/w32err.c

    r1993 r2591  
    11/* Error handling for Windows
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
Note: See TracChangeset for help on using the changeset viewer.