Ignore:
Timestamp:
Mar 12, 2018, 8:32:29 PM (7 years ago)
Author:
bird
Message:

Imported make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6) from https://git.savannah.gnu.org/git/make.git.

Location:
vendor/gnumake/current
Files:
46 added
11 deleted
158 edited
5 moved

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current/AUTHORS

    r2596 r3138  
    3838      DJ Delorie <dj@delorie.com>
    3939      Rob Tulloh <rob_tulloh@tivoli.com>
    40       Eli Zaretskii <eliz@is.elta.co.il>
     40      Eli Zaretskii <eliz@gnu.org>
    4141      Jonathan Grant <jg@jguk.org>
    4242      Andreas Beuning <andreas.buening@nexgo.de>
    4343      Earnie Boyd <earnie@uses.sf.net>
     44      Troy Runkel <Troy.Runkel@mathworks.com>
    4445
    4546-----------------------------------
     
    4849  Janet Carson <janet_carson@tivoli.com>
    4950  Howard Chu <hyc@highlandsun.com>
     51  Ludovic CourtÚs <ludo@gnu.org>
    5052  Paul Eggert <eggert@twinsun.com>
     53  Ramon Garcia Fernandez <ramon.garcia.f@gmail.com>
    5154  Klaus Heinz <kamar@ease.rhein-main.de>
    5255  Michael Joosten
     
    5659  Markus Mauhart <qwe123@chello.at>
    5760  Greg McGary <greg@mcgary.org>
     61  Thien-Thi Nguyen <ttn@gnuvola.org>
    5862  Thomas Riedl <thomas.riedl@siemens.com>
    5963  Han-Wen Nienhuys <hanwen@cs.uu.nl>
     
    6165  Carl Staelin (Princeton University)
    6266  Ian Stewartson (Data Logic Limited)
    63   Ramon Garcia Fernandez <ramon.garcia.f@gmail.com>
     67  David A. Wheeler <dwheeler@dwheeler.com>
     68  David Boyce <dsb@boyski.com>
     69  Frank Heckenbach <f.heckenbach@fh-soft.de>
    6470
    6571With suggestions/comments/bug reports from a cast of ... well ...
     
    6773
    6874-------------------------------------------------------------------------------
    69 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
    70 2008, 2009, 2010 Free Software Foundation, Inc.
     75Copyright (C) 1997-2016 Free Software Foundation, Inc.
    7176This file is part of GNU Make.
    7277
  • vendor/gnumake/current/ChangeLog.1

    r2596 r3138  
    17041704
    17051705        * load.c: Use the symbol KERNEL_FILE_NAME instead of KERNEL_FILE.
    1706         * compatMakefile: Changed the comment for `LOAD_AVG' accordinly.
     1706        * compatMakefile: Changed the comment for `LOAD_AVG' accordingly.
    17071707
    17081708Thu Sep  7 16:46:26 1989  Roland McGrath  (mcgrath at paris.Berkeley.EDU)
     
    32193219        `shell_function_completed'.  Block children before forking and
    32203220        unblock after `shell_function_pid' is set properly and
    3221         `shell_functon_completed' is reset to 0.
     3221        `shell_function_completed' is reset to 0.
    32223222
    32233223        * commands.c (child_handler): When the child of the `shell' function
     
    44664466
    44674467        * rule.c (pattern_search): If an existent (non-intermediate)
    4468         dependendency was found via a terminal rule, set its
     4468        dependency was found via a terminal rule, set its
    44694469        `tried_implicit' flag, so it will never have implicit rule search done.
    44704470
     
    48274827
    48284828        * dir.c: Re-indented the `struct dir' definition to be right.
    4829         (dir_load): Cleaned up slighty.
     4829        (dir_load): Cleaned up slightly.
    48304830        (file_exists_p): Removed comment saying we could use `access', since
    48314831        that is a bad idea (except for setuid programs).  Cleaned up slightly.
     
    49834983
    49844984
    4985 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    4986 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 Free
    4987 Software Foundation, Inc.
     4985Copyright (C) 1988-2009 Free Software Foundation, Inc.
    49884986This file is part of GNU Make.
    49894987
  • vendor/gnumake/current/ChangeLog.2

    r1989 r3138  
    30813081        stores now the names of the variables only and reads their contents
    30823082        when they are accessed to reflect that these variables are really
    3083         global (ie. they CAN change WHILE make runs !) This handling is
     3083        global (i.e., they CAN change WHILE make runs !) This handling is
    30843084        made in lookup_variable()
    30853085
     
    66326632
    66336633
    6634 See ChangeLog.1, available in the CVS repository at:
    6635 
    6636         http://savannah.gnu.org/cvs/?group=make
     6634See ChangeLog.1, available in the Git repository at:
     6635
     6636        http://git.savannah.gnu.org/cgit/make.git/tree/
    66376637
    66386638for earlier changes.
    66396639
    66406640
    6641 Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
    6642 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
     6641Copyright (C) 1991-2007 Free Software Foundation, Inc.
    66436642This file is part of GNU Make.
    66446643
  • vendor/gnumake/current/ChangeLog.3

    r3137 r3138  
     12013-10-09  Paul Smith  <psmith@gnu.org>
     2
     3        Version 4.0 released.
     4
     5        * configure.ac: Updated for the release.
     6        * NEWS: Updated for the release.
     7
     8        * maintMakefile (tag-release): New target to add a Git tag.
     9        * read.c (eval): Typo fix.
     10        * ChangeLog.1: Typo fixes.
     11        * w32/subproc/sub_proc.c (process_cleanup): Typo fix.
     12
     132013-10-07  Eli Zaretskii  <eliz@gnu.org>
     14
     15        * w32/compat/posixfcn.c (tmpfile): Move declaration of h before
     16        the first executable statement.  Reported by Gisle Vanem
     17        <gvanem@yahoo.no>.
     18
     192013-10-05  Paul Smith  <psmith@gnu.org>
     20
     21        * makeint.h (MAP_USERFUNC): A new map type for function names.
     22        * main.c (initialize_stopchar_map): Set up the function name map.
     23
     24        * gnumake.h (gmk_func_ptr): Define a type for function pointers.
     25        (gmk_add_function): Convert the last argument to FLAGS.
     26        (GMK_FUNC_*): Define flags for the function.  Change the default
     27        behavior to "expand" since that's the most common one.
     28
     29        * function.c (function_table_entry): Use new function pointer type.
     30        (lookup_function): Accept any valid function name character based
     31        on the MAP_USERFUNC values.
     32        (define_new_function): Use the new calling signature.  Verify that
     33        registered functions have valid names.
     34
     35        * guile.c (guile_gmake_setup): Use new calling signatures.
     36        * loadapi.c (gmk_add_function): Ditto.
     37        * variable.h (define_new_function): Ditto.
     38
     39        * doc/make.texi (Loaded Object API): Make the registered function
     40        API documentation more clear.
     41
     422013-10-03  Eli Zaretskii  <eliz@gnu.org>
     43
     44        * function.c (abspath): Reset root_len to one for Cygwin only when
     45        HAVE_DOS_PATHS is defined.  Suggested by Christopher Faylor.
     46
     472013-10-02  Eli Zaretskii  <eliz@gnu.org>
     48
     49        * w32/compat/posixfcn.c (tmpfile): New function, a replacement for
     50        the Windows libc version.
     51
     52        Fix $abspath on Cygwin when HAVE_DOS_PATHS is in effect.
     53        * function.c (IS_ABSOLUTE) [__CYGWIN__]: Special definition for
     54        Cygwin.
     55        (abspath) [__CYGWIN__]: Reset root_len to 1 if the absolute file
     56        name has the Posix /foo/bar form.
     57        [HAVE_DOS_PATHS]: Use root_len instead of hard-coded 2.
     58
     592013-10-01  Paul Smith  <psmith@gnu.org>
     60
     61        * configure.ac: Update version to 3.99.93.
     62        * NEWS: Ditto.
     63
     642013-09-30  Paul Smith  <psmith@gnu.org>
     65
     66        * guile.c: Portability fixes for Guile 1.8.
     67
     682013-09-29  Paul Smith  <psmith@gnu.org>
     69
     70        * output.c (output_dump): Always write Enter/Leave messages to stdio.
     71        (log_working_directory): This now always writes to stdio, so we
     72        don't need the struct output parameter anymore.
     73        (output_start): Show the working directory when output_sync is not
     74        set or is recursive.
     75        * main.c (main): Ensure the special "already shown Enter message"
     76        token is removed from MAKE_RESTARTS before the user can see it.
     77        * function.c (func_shell_base): If the output_context stderr
     78        exists but is invalid, write to the real stderr.
     79        Fixes suggested by Frank Heckenbach <f.heckenbach@fh-soft.de>.
     80
     81        * output.c: Guard unistd.h inclusion, add io.h.
     82        * gnumake.h: Move GMK_EXPORT before the declarations.
     83        * make_msvc_net2003.vcproj: Add missing files.
     84        Changes for MSVC suggested by Gerte Hoogewerf <g.hoogewerf@gmail.com>
     85
     86        * function.c (func_shell_base) [EMX]: Fix EMX support for output-sync.
     87        * job.c (child_execute_job) [EMX]: Ditto.
     88        * job.h (child_execute_job) [EMX]: Ditto.
     89        * w32/compat/posixfcn.c: Invert the test for NO_OUTPUT_SYNC.
     90
     91        * guile.c (GSUBR_TYPE): Pre-2.0 Guile doesn't provide a typedef
     92        for gsubr pointers.  Create one.
     93        (guile_define_module): Use it.
     94        (internal_guile_eval): Force UTF-8 encoding for Guile strings.
     95
     96        * main.c (main): Clear GNUMAKEFLAGS after parsing, to avoid
     97        proliferation of options.
     98        * NEWS: Document it.
     99        * doc/make.texi (Options/Recursion): Ditto.
     100
     1012013-09-23  Eli Zaretskii  <eliz@gnu.org>
     102
     103        * w32/compat/posixfcn.c: Fix the forgotten OUTPUT_SYNC conditional.
     104
     105        * job.h: Ditto, but in a comment.
     106
     1072013-09-22  Paul Smith  <psmith@gnu.org>
     108
     109        * configure.ac: Update version to 3.99.92.
     110        * NEWS: Ditto.
     111
     112        * implicit.c (pattern_search): After second expansion be sure to
     113        handle order-only markers inside the expansion properly.
     114        Fixes Savannah bug #31155.
     115
     116        * guile.c (guile_define_module): Technically a void* cannot
     117        contain a pointer-to-function and some compilers warn about this.
     118        Cast the function pointers.
     119        * load.c (load_object): Ditto.
     120
     121        * read.c (eval): If load_file() returns -1, don't add this to the
     122        "to be rebuilt" list.
     123        * doc/make.texi (load Directive): Document it.
     124
     125        * guile.c (guile_gmake_setup): Don't initialize Guile so early.
     126        (func_guile): Lazily initialize Guile the first time the $(guile ..)
     127        function is invoked.  Guile can steal file descriptors which
     128        confuses our jobserver FD checking, so we don't want to initialize
     129        it before we have to.
     130
     131        VMS port updates by Hartmut Becker <becker.ismaning@freenet.de>
     132
     133        * makefile.com: Add output to the filelist.
     134        * output.c (va_copy): Add an implementation of this macro for VMS.
     135        * commands.c: Ensure filedef.h is #included before dep.h.
     136        * dir.c: Ditto.
     137        * file.c: Ditto.
     138        * guile.c: Ditto.
     139        * main.c: Ditto.
     140        * misc.c: Ditto.
     141        * read.c: Ditto.
     142        * rule.c: Ditto.
     143        * variable.c: Ditto.
     144        * readme.vms: Renamed to README.VMS and updates for this release.
     145        * Makefile.am: Ditto.
     146        * NEWS: Ditto.
     147        * README.template: Ditto.
     148        * Makefile.DOS.template: Ditto.
     149
     1502013-09-21  Paul Smith  <psmith@gnu.org>
     151
     152        * maintMakefile (check-alt-config): Create a target to test
     153        alternative configurations.  Each one will build make with a
     154        different configuration then run the test suite.
     155
     156        Invert the output-sync #define to NO_OUTPUT_SYNC
     157
     158        * configure.ac: Don't set OUTPUT_SYNC.
     159        * makeint.h: Ditto.
     160        * main.c: Use NO_OUTPUT_SYNC instead of OUTPUT_SYNC.
     161        * output.c: Ditto.
     162        * output.h: Ditto.
     163        * job.h: Ditto.
     164        * job.c: Ditto.
     165        * config.ami.template: Set NO_OUTPUT_SYNC.
     166        * config.h-vms.template: Ditto.
     167        * config.h.W32.template: Ditto.
     168        * configh.dos.template: Ditto.
     169
     170        Output generated while reading makefiles should be synced.
     171
     172        * main.c (make_sync): Define a context for syncing while reading
     173        makefiles and other top-level operations.
     174        (main): If we request syncing, enable it while we are parsing
     175        options, reading makefiles, etc. to capture that output.  Just
     176        before we start to run rules, dump the output if any.
     177        (die): Dump any output we've been syncing before we die
     178        * output.h (OUTPUT_SET): Disable output_context if not syncout.
     179
     180        Stderr generated from shell functions in recipes should be synced.
     181
     182        * job.h (FD_STDIN, FD_STDOUT, FD_STDERR): Create new macros to
     183        avoid magic numbers.
     184        (child_execute_job): Take a FD for stderr.
     185        * job.c (child_execute_job): Handle STDERR FD's in addition to
     186        stdin and stdout.
     187        (start_job_command): Call child_execute_job() with the new STDERR
     188        parameter.  Instead of performing the dup() here, send it to
     189        child_execute_job() where it's already being done.
     190        * function.c (func_shell_base): Pass the OUTPUT_CONTEXT stderr to
     191        child_execute_job() if it's set, otherwise FD_STDERR.
     192        * main.c (main): Pass FD_STDERR to child_execute_job().
     193
     1942013-09-19  Paul Smith  <psmith@gnu.org>
     195
     196        * main.c (main): Set MAKE_RESTARTS to negative before re-exec if
     197        we've already generated an "Entering" message.  If we are started
     198        and notice that MAKE_RESTARTS is negative, assume we already wrote
     199        "Entering" and don't write it again.
     200
     2012013-09-18  Paul Smith  <psmith@gnu.org>
     202
     203        * main.c (main): Set starting_directory before we write any
     204        errors.  Fixes Savannah bug #40043.
     205
     2062013-09-16  Eli Zaretskii  <eliz@gnu.org>
     207
     208        * output.c [WINDOWS32]: Include windows.h and sub_proc.h, to avoid
     209        compiler warnings for CLOSE_ON_EXEC.
     210
     2112013-09-16  Paul Smith  <psmith@gnu.org>
     212
     213        * configure.ac: Update version to 3.99.91.
     214        * NEWS: Ditto.
     215
     2162013-09-15  Paul Smith  <psmith@gnu.org>
     217
     218        * doc/make.texi (Error Messages): Add a bit more info to the
     219        section on static pattern errors, since they're common.
     220        Fixes Savannah bug #31326.
     221
     222        * read.c (eval_makefile): If the file open fails with an
     223        unrecoverable error, stop now rather than trying to make it.
     224        Fixes Savannah bug #27374.
     225
     226        * main.c (main): Perform the validation of the jobserver FDs
     227        early, before we read makefiles, to ensure that something hasn't
     228        opened and used those FDs for some other reason.
     229        Fixes Savannah bug #39934.
     230
     231        * main.c (main): Don't set MAKEFLAGS in the environment when we
     232        restart.  We have the original command line flags so keep the
     233        original MAKEFLAGS settings as well.
     234        Fixes Savannah bug #39203.
     235
     2362013-09-14  Paul Smith  <psmith@gnu.org>
     237
     238        * main.c (decode_debug_flags): Add support for the "n" flag to
     239        disable all debugging.
     240        * make.1: Document the "n" (none) flag.
     241        * doc/make.texi (Options Summary): Ditto.
     242        * NEWS: Ditto.
     243        Fixes Savannah bug #35248.
     244
     245        * misc.c (close_stdout): Move to output.c.
     246        * main.c (main): Move atexit call to output_init().
     247        * makeint.h: Remove close_stdout() declaration.
     248        * output.c (output_init): Add close_stdout at exit only if it's open.
     249        Fixes Savannah bug #33134.  Suggested by David Boyce <dsb@boyski.com>.
     250
     2512013-09-14  Paul Smith  <psmith@gnu.org>
     252
     253        * misc.c (set_append_mode, open_tmpfd, open_tmpfile): Move to output.c.
     254        * misc.h: Ditto.
     255        * output.h: Ditto.
     256        * main.c (main): Move stdio init into output.c:output_init().
     257        Change open_tmpfile() to output_tmpfile().
     258        * output.c: Rename open_*() to output_*().  set_append_mode() and
     259        open_tmpfd() are static.
     260        (_outputs, log_working_directory): Accept a struct output and
     261        print to that rather than the global context.
     262        (output_dump): In recurse mode print enter/leave once for the
     263        whole makefile.
     264        (output_init): Initialize this processes stdio as well as child's.
     265
     266        * vmsjobs.c: Reformat to be closer to convention.
     267
     2682013-09-12  Paul Smith  <psmith@gnu.org>
     269
     270        Rework output to handle synchronization and directory logging more
     271        reliably.
     272
     273        * output.c: New file.  Implement lazy synchronization and
     274        directory logging so that we manage them "just in time", and the
     275        destination of the output is set via a global state variable.
     276        * output.h: New file.
     277        * function.c (func_shell_base): Ensure the output is set up before
     278        running a shell command, in case it writes to stderr.
     279        (func_error): Use outputs() to generate output.
     280        * job.h (struct child): Add struct output to track the child's output.
     281        * job.c: Use struct output in the child structure to track output.
     282        (child_out, sync_init, assign_child_tempfiles, pump_from_tmp)
     283        (acquire_semaphore, release_semaphore, sync_output): Move most of
     284        the output_sync handling to output.c.
     285        (child_error): Set output, then use simple message() and error()
     286        not _s versions.
     287        * main.c (log_working_directory): Moved to output.c
     288        (trace_option, decode_trace_flags) Remove.  Remove support for
     289        different trace modes; we don't use it anymore.
     290        (die) Invoke output_close() before we exit.
     291        * misc.c (message_s, error_s): Removed; no longer needed.
     292        (message, error, fatal, perror_with_name, pfatal_with_name): Moved
     293        to output.c.
     294        * makeint.h: Remove message_s(), error_s(), and
     295        log_working_directory().  Remove the TRACE_* macros.
     296        * doc/make.texi: Enhance documentation for output sync, and remove
     297        MODE assignment for --trace.
     298        * make.1: Remove MODE assignment for --trace.
     299        * Makefile.am: Add new files.
     300        * NMakefile.template: Ditto.
     301        * SMakefile.template: Ditto.
     302        * build_w32.bat: Ditto.
     303        * dosbuild.bat: Ditto.
     304        * make.lnk: Ditto.
     305        * make_nsvc_net2003.vcproj: Ditto.
     306        * makefile.vms: Ditto.
     307        * po/POTFILES.in: Ditto.
     308
     3092013-08-22  Petr Machata  <pmachata@redhat.com>
     310
     311        * function.c (func_shell_base): Get rid of any avoidable limit on
     312        stack size for processes spawned via $(shell).
     313
     3142013-07-22  Paul Smith  <psmith@gnu.org>
     315
     316        * implicit.c (pattern_search): Use PARSE_SIMPLE_SEQ() even for
     317        non-second expansion prerequisites, to handle globbing in patterns.
     318        Fixes Savannah bug #39310.
     319
     320        * dep.h (PARSE_SIMPLE_SEQ): Macro for simple file sequence parsing.
     321        * default.c (set_default_suffixes): Use it.
     322        * file.c (split_prereqs): Ditto.
     323        * main.c (main): Ditto.
     324        * read.c (eval): Ditto.
     325        * rule.c (install_pattern_rule): Ditto.
     326        * file.c (split_prereqs): Use PARSEFS_NONE instead of 0.
     327
     3282013-07-21  Paul Smith  <psmith@gnu.org>
     329
     330        Cleanups detected by cppcheck.  Fixes Savannah bug #39158.
     331        * arscan.c (ar_scan): Reduce the scope of local variables.
     332        * dir.c (vms_hash): Ditto.
     333        (find_directory): Ditto.
     334        (file_impossible_p): Ditto.
     335        * expand.c (variable_expand_string): Ditto.
     336        * function.c (func_sort): Ditto.
     337        (func_and): Ditto.
     338        * job.c (reap_children): Ditto.
     339        (exec_command): Ditto.
     340        * main.c (main): Ditto.
     341        * misc.c (collapse_continuations): Ditto.
     342        * read.c (eval): Ditto.
     343        (parse_file_seq): Ditto.
     344        * vpath.c (gpath_search): Ditto.
     345        (selective_vpath_search): Ditto.
     346        * job.c (is_bourne_compatible_shell): Simplify for non-Windows systems.
     347        * remake.c (f_mtime): Remove duplicate test.
     348        * signame.c (strsignal): Fix bogus conditional.
     349
     350        * job.c (assign_child_tempfiles): Assign OUTFD to -1 for safety.
     351        (start_job_command): Don't test output_sync and sync_cmd: redundant.
     352        Changes suggested by Frank Heckenbach <f.heckenbach@fh-soft.de>.
     353
     3542013-07-14  Paul Smith  <psmith@gnu.org>
     355
     356        * filedef.h (update_status): Convert UPDATE_STATUS from a char to
     357        an enumeration.  Some systems declare "char" to be "unsigned"
     358        which broke the code (which expected to be able to use -1 as a
     359        flag).  Using magic values was unpleasant, so rather than just
     360        force "signed char" I reworked it to use an enum.
     361
     362        * dep.h (update_goal_chain): Return an update_status value not int.
     363        * remake.c (touch_file): Ditto.
     364        (update_goal_chain): Track the update_status enum.
     365
     366        * file.c (enter_file): Use new enumeration values with update_status.
     367        (remove_intermediates): Ditto.
     368        (print_file): Ditto.
     369        * commands.c (execute_file_commands): Ditto.
     370        * job.c (reap_children): Ditto.
     371        (start_job_command): Ditto.
     372        (start_waiting_job): Ditto.
     373        * main.c (main): Ditto.
     374        * remake.c (update_file): Ditto.
     375        (complain): Ditto.
     376        (update_file_1): Ditto.
     377        (notice_finished_file): Ditto.
     378        (remake_file): Ditto.
     379        * vmsjobs.c (vmsHandleChildTerm): Ditto.
     380
     3812013-07-09  Paul Smith  <psmith@gnu.org>
     382
     383        * implicit.c (pattern_search): Keep a local copy of the number of
     384        deps in deplist: the global max might change due to recursion.
     385        Fixes a bug reported by Martin d'Anjou <martin.danjou14@gmail.com>.
     386
     3872013-06-28  Paul Smith  <psmith@gnu.org>
     388
     389        * misc.c (set_append_mode): Set the O_APPEND flag on a file descriptor.
     390        (open_tmpfd): Set append mode on the temporary file descriptor.
     391        * main.c (main): Set append mode on stdout and stderr.
     392        * makeint.h (set_append_mode): Declare it.
     393
     3942013-06-22  Eli Zaretskii  <eliz@gnu.org>
     395
     396        * build_w32.bat (LinkGCC): Prevent a comment from being displayed
     397        at build time.
     398
     399        * job.c (construct_command_argv_internal) [WINDOWS32]: Use
     400        case-insensitive comparison with internal commands of non-Unix
     401        shells.
     402
     403        * main.c (find_and_set_default_shell): Don't use file_exists_p or
     404        dir_file_exists_p, as those call readdir, which can fail if PATH
     405        includes directories with non-ASCII characters, and that would
     406        cause Make to fail at startup with confusing diagnostics.  See
     407        https://sourceforge.net/mailarchive/message.php?msg_id=30846737
     408        for the details.
     409
     4102013-06-22  Paul Smith  <psmith@gnu.org>
     411
     412        Improve performance by using a character map to determine where we
     413        want to stop searching strings, rather than discrete comparisons.
     414
     415        * read.c (find_char_unquote): Pass a stop map instead of various
     416        flags and use that to check when to stop parsing the string.
     417        (eval): Use the new find_char_unquote() calling signature.
     418        (remove_comments): Ditto.
     419        (unescape_char): Ditto.
     420        (find_percent_cached): Ditto.
     421        (parse_file_seq): Use a stop-map flag.
     422        * main.c (stopchar_map): Character map definition.
     423        (initialize_stopchar_map): Initialize the map definition.
     424        (main): Invoke the map initialization function.
     425        * misc.c (end_of_token_w32): Remove unused function.
     426        * dir.c (dosify): Use STOP_SET to check for stop chars.
     427        * main.c (main): Ditto.
     428        * misc.c (end_of_token): Ditto.
     429        * function.c (subst_expand): Ditto.
     430        (func_notdir_suffix): Ditto.
     431        (func_basename_dir): Ditto.
     432        (abspath): Ditto.
     433        * job.c (is_bourne_compatible_shell): Ditto.
     434        * variable.c (parse_variable_definition): Ditto.
     435        * read.c (eval): Ditto.
     436        (conditional_line): Ditto.
     437        (find_percent_cached): Ditto.
     438        * dep.h (PARSE_FILE_SEQ): Update function declaration.
     439        * default.c (set_default_suffixes): Update PARSE_FILE_SEQ() call.
     440        * file.c (split_prereqs): Ditto.
     441        * function.c (string_glob): Ditto.
     442        * implicit.c (pattern_search): Ditto.
     443        * rule.c (install_pattern_rule): Ditto.
     444        * main.c (main): Ditto.
     445
     4462013-06-21  Paul Smith  <psmith@gnu.org>
     447
     448        * main.c (verify_flag): Global variable to determine whether to
     449        verify the database or not.
     450        (decode_debug_flags): If debug mode, enable verify_flag.
     451        (main): If MAKE_MAINTAINER_MODE, enable verify_flag, otherwise not.
     452        (die): Only verify the database if verify_flag is set.
     453        * file.c (enter_file): Don't check caching unless verify_flag.
     454        * makeint.h: Export verify_flag.
     455
     4562013-05-27  Paul Smith  <psmith@gnu.org>
     457
     458        * variable.c (define_automatic_variables): Create a new variable
     459        MAKE_HOST.
     460
     4612013-05-27  Hartmut Becker  <becker.ismaning@freenet.de>
     462
     463        * function.c (func_shell_base) [VMS]: Support VMS.
     464        * makefile.com [VMS]: Ditto.
     465        * makefile.vms [VMS]: Ditto.
     466        * makeint.h [VMS]: Ditto.
     467        * vmsjobs.c [VMS]: Ditto.
     468        * job.h: Define RECORD_SYNC_MUTEX() when OUTPUT_SYNC is not set.
     469        * load.c (unload_file): Fix signature if MAKE_LOAD is not set.
     470
     4712013-05-26  Paul Smith  <psmith@gnu.org>
     472
     473        * remake.c (f_mtime): Ensure that archive file names are in the
     474        string cache.  Fixes Savannah bug #38442.
     475
     476        * read.c (readline): To be safe, move the entire buffer if we
     477        detect a CR.  Fixes Savannah bug #38945.
     478
     479        * job.c (new_job): Compare OUT to the beginning of the OUT
     480        var/function, not IN.  Fixes Savannah bug #39035.
     481
     4822013-05-22  Paul Smith  <psmith@gnu.org>
     483
     484        * main.c (switches[]): Order switches so simple flags all come first.
     485        (define_makeflags): Rework to make option passing more
     486        reliable and the code less tricksy.  Ensure simple flags are kept
     487        in the initial batch of flags.  Do not allow any flags with
     488        options in that batch.  If there are only non-simple flags MAKEFLAGS
     489        begins with ' '.
     490        (print_data_base): Print the version.  Fixes part of Savannah #35336.
     491
     492        * read.c (eval_buffer): Initialize lineno.
     493
     4942013-05-18  Alexey Pavlov  <alexpux@gmail.com>  (tiny change)
     495
     496        * w32/Makefile.am (libw32_a_SOURCES): Add compat/posixfcn.c.
     497
     498        * configure.ac (OUTPUT_SYNC): Define for mingw32 target.
     499
     500        * job.c (construct_command_argv_internal) <sh_cmds_dos>
     501        [WINDOWS32]: Add "move".  Fixes Savannah bug #30714.
     502
     503        * guile.c: Move inclusion of makeint.h before gnumake.h.  This
     504        order must be observed when building Make, because gnumake.h must
     505        be included with GMK_BUILDING_MAKE defined, which makeint.h
     506        already does.  Otherwise, the linker will look for, and fail to
     507        find, gmk_* functions in some external dynamic library.
     508
     5092013-05-17  Benno Schulenberg  <bensberg@justemail.net>
     510
     511        * main.c (decode_output_sync_flags): Fix output message.
     512        * read.c (EXTRANEOUS): Ditto.
     513        (record_files): Ditto.
     514        * remake.c (update_file_1): Ditto.
     515
     5162013-05-17  Eli Zaretskii  <eliz@gnu.org>
     517
     518        * main.c (prepare_mutex_handle_string): Define conditioned on
     519        OUTPUT_SYNC.
     520
     521        * build_w32.bat: Copy config.h.W32 to config.h regardless of
     522        whether or not we are building from SCM.
     523
     5242013-05-17  Paul Smith  <psmith@gnu.org>
     525
     526        * configure.ac: Update version to 3.99.90.
     527        * NEWS: Ditto.
     528
     529        * Source (*.[ch]): Remove TABs, use GNU coding styles.
     530
     531        * ALL: Update copyright.
     532
     533        * hash.c (CALLOC): Use xcalloc() to handle out of memory errors.
     534
     535        * makeint.h: Prototype new unload_file() function.
     536        * load.c (unload_file): Create a function to unload a file.
     537        (struct load_list): Type to remember loaded objects.
     538        (loaded_syms): Global variable of remembered loaded objects so we
     539        can unload them later.  We don't have to remove from the list
     540        because the only time we unload is if we're about to re-exec.
     541        (load_object): Remove unneeded extra DLP argument.
     542        (load_file): Remove unneeded extra DLP argument.
     543        * filedef.h (struct file): Remove the DLP pointer and add the
     544        LOADED bit flag.  Saves 32/64 bytes per file, as this pointer is
     545        almost never needed.
     546        * read.c (eval): Set the new LOADED bit flag on the file.
     547        * file.c (rehash_file): Merge the loaded bitfield.
     548        * commands.c (execute_file_commands): Call unload_file() instead
     549        of dlclose() directly.
     550
     5512013-05-14  Paul Smith  <psmith@gnu.org>
     552
     553        * doc/make.texi (Loaded Object API): Document the requirement for
     554        the plugin_is_GPL_compatible symbol.
     555        * load.c (load_object): Check for plugin_is_GPL_compatible symbol.
     556
     5572013-05-13  Paul Smith  <psmith@gnu.org>
     558
     559        * filedef.h (struct file): Add a builtin flag.
     560        * file.c (enter_file): Unset the builtin flag.
     561        (rehash_file): Ditto.
     562        (print_file): Don't print builtin files if we've omitted them.
     563        * default.c (undefine_default_variables): New function: go through
     564        the default variables and undefine them.
     565        (set_default_suffixes): Mark these suffix rules as builtin.
     566        * makeint.h: Prototype.
     567        * main.c (main): Handle addition of -r and -R to MAKEFLAGS in the
     568        makefile.  Fixes Savannah bug #20501.
     569
     570        * main.c (define_makeflags): Assign o_env_override level to
     571        MAKEFLAGS to ensure it's set even in the presence of -e.
     572        Fixes Savannah bug #2216.
     573
     574        * makeint.h (TRACE_NONE, TRACE_RULE, TRACE_DIRECTORY): Define
     575        constants for the trace mode.
     576        * main.c: Add new --trace mode parsing.
     577        (decode_trace_flags): New function.
     578        (decode_switches): Call it.
     579        (define_makeflags): Fix a bug with long-name options.
     580        * misc.c (fatal): Remove special output-sync handling.
     581        * make.1: Document new --trace mode flags.
     582        * doc/make.texi (Options Summary): Ditto.
     583
     5842013-05-11  Eli Zaretskii  <eliz@gnu.org>
     585
     586        * job.c (child_out): Output the newline following the message
     587        before fllush-ing the stream.  Avoids displaying the following
     588        failure message, which goes to stderr, on the same line.
     589
     5902013-05-06  Eli Zaretskii  <eliz@gnu.org>
     591
     592        * gnumake.h (GMK_EXPORT) [_WIN32]: Move the dllexport declaration
     593        here from makeint.h.
     594
     595        * makeint.h (GMK_BUILDING_MAKE) [WINDOWS32]: Define before
     596        including gnumake.h.
     597
     598        * doc/make.texi (Loaded Object Example): Add a note about building
     599        shared objects on MS-Windows.
     600
     6012013-05-05  Paul Smith  <psmith@gnu.org>
     602
     603        * makeint.h (OUTPUT_SYNC_LINE, OUTPUT_SYNC_RECURSE): Rename
     604        output-sync options "job" to "line" and "make" to "recurse".
     605        * main.c (decode_output_sync_flags): Ditto.
     606        * job.c (reap_children): Ditto.
     607        (start_job_command): Ditto.
     608        * make.1: Ditto.
     609        * doc/make.texi (Parallel Output): Ditto.
     610
     611        * job.c (child_out): Write newlines explicitly, and don't do
     612        anything if the message is empty.
     613        (sync_output): Put working dir messages around stdout AND stderr.
     614        (start_job_command): Move the tmp file assignment earlier.  After
     615        we do it, write the command line to the temp file to get the order
     616        correct.
     617
     618        * misc.c (message): Remove special handling for output_sync.
     619        (error): Ditto.
     620
     6212013-05-04  Paul Smith  <psmith@gnu.org>
     622
     623        * loadapi.c (gmk_alloc): New function.
     624        * gnumake.h: Add gmk_alloc().  Clean GMK_EXPORT a bit to avoid MAIN.
     625        * makeint.h (GMK_EXPORT): New handling, vs. MAIN.
     626        * doc/make.texi (Loaded Object API): Add information on the memory
     627        handling functions.
     628        (Loaded Object Example): Create an example.
     629
     630        * job.c (pump_from_tmp): (Rename) Write to stdout/stderr using
     631        FILE* rather than fd.  It's not a good idea to mix and match.
     632
     6332013-05-04  Eli Zaretskii  <eliz@gnu.org>
     634
     635        * makeint.h (ftruncate) [_MSC_VER]: Redirect to _chsize.
     636        (_S_ISDIR): If not defined (MinGW64), define to S_ISDIR.
     637
     6382013-05-04  Paul Smith  <psmith@gnu.org>
     639
     640        * job.c (child_out): Handle EINTR and incomplete write scenarios.
     641        (sync_init): New function: separate the initialization code.
     642        (assign_child_tempfiles): Remove truncation from this function,
     643        (sync_output): and add it here after output is generated.
     644        (reap_children): Always call sync_output() in case output_sync was
     645        reset after the child started, due to error.
     646        (start_job_command): Create new sync_cmd variable.  Use new method
     647        for initializing the handle.
     648        If we're not syncing the output be sure any output we've saved is
     649        dumped immediately before starting the child.
     650
     6512013-05-04  Eli Zaretskii  <eliz@gnu.org>
     652
     653        * job.c (start_job_command): Make the condition for creating a
     654        temporary output file be identical to the Posix code branch.
     655        Suggested by Frank Heckenbach <f.heckenbach@fh-soft.de>.
     656
     6572013-05-03  Eli Zaretskii  <eliz@gnu.org>
     658
     659        * w32/subproc/sub_proc.c: Include makeint.h.  Remove a private
     660        incompatible prototype of xmalloc.
     661        (batch_file_with_spaces): New function, detects Windows batch
     662        files whose names include whitespace characters.
     663        (process_begin): If exec_name is a batch file with whitespace
     664        characters in its name, pass NULL as the first argument to
     665        CreateProcess.  This avoids weird failures due to buggy quoting by
     666        CreateProcess.  For the details, see the discussion starting at
     667        http://lists.gnu.org/archive/html/make-w32/2013-04/msg00008.html.
     668
     669        * load.c (load_object, load_file): Accept an additional argument
     670        DLP and return in it a pointer that can be used to unload the
     671        dynamic object.
     672
     673        * read.c (eval): Call load_file with an additional argument, and
     674        record the pointer returned there in the 'struct file' object of
     675        dynamic objects in that object's 'struct file'.
     676
     677        * commands.c (execute_file_commands): Unload dynamic objects
     678        before remaking them, to avoid failure to remake if the OS doesn't
     679        allow overwriting objects that are in use.
     680
     681        * filedef.h (struct file): New member dlopen_ptr.
     682
     683        * gnumake.h (GMK_EXPORT): Define to dllexport/dllimport
     684        decorations for Windows and to nothing on other platforms.
     685        (gmk_eval, gmk_expand, gmk_add_function): Add GMK_EXPORT qualifier
     686        to prototypes.
     687
     688        * makeint.h (MAIN): Define before including gnumake.h, to give
     689        correct dllexport decorations to exported functions.
     690        (load_file): Adjust prototype.
     691
     692        * loadapi.c: Don't include gnumake.h, since makeint.h already
     693        includes it, and takes care of defining MAIN before doing so.
     694
     695        * build_w32.bat (LinkGCC): Produce an import library for functions
     696        exported by Make for loadable dynamic objects.
     697
     698        * w32/compat/posixfcn.c (dlclose): New function.
     699
     700        * w32/include/dlfcn.h (dlclose): Add prototype.
     701
     7022013-05-01  Eli Zaretskii  <eliz@gnu.org>
     703
     704        * job.c (start_job_command) [WINDOWS32]: Make the same fix for
     705        MS-Windows as the previous commit did for Posix platforms.
     706        (construct_command_argv_internal): Don't treat a backslash as an
     707        escape character before whitespace, if the shell is not a Posix
     708        shell.   For the description of the problem, see
     709        http://lists.gnu.org/archive/html/make-w32/2013-04/msg00014.html.
     710
     7112013-05-01  Paul Smith  <psmith@gnu.org>
     712
     713        * job.c (start_job_command): Don't redirect output for recursive
     714        make jobs, unless we're in makefile synchronization mode.
     715
     7162013-04-30  Stefano Lattarini <stefano.lattarini@gmail.com>  (tiny change)
     717
     718        build: enable the 'silent-rules' automake options
     719
     720        * configure.ac (AM_INIT_AUTOMAKE): Here.  The future major Automake
     721        version 2.0 (ETA about one, one and half year from now) will enable
     722        it by default, so better prepare ourselves.
     723
     7242013-04-30  Stefano Lattarini <stefano.lattarini@gmail.com>  (tiny change)
     725
     726        build: require Autoconf >= 2.62 and Automake >= 1.11.1
     727
     728        Older versions of those tools should be considered fully obsolete.
     729        Also, GNU make already requires Gettext >= 0.18.1, which has been
     730        released six months after Automake 1.11.1 and two years after
     731        Autoconf 2.62; so the new requirement shouldn't be problematic
     732        for people already bootstrapping GNU make from the Git repository.
     733
     734        * configure.ac (AC_PREREQ): Require Autoconf 2.62 or later.
     735        (AM_INIT_AUTOMAKE): Require Automake 1.11.1 or later (1.11 had
     736        some serious bugs, and should not be used).
     737
     7382013-04-30  Stefano Lattarini <stefano.lattarini@gmail.com>  (tiny change)
     739
     740        build: get rid of 'HAVE_ANSI_COMPILER' C preprocessor conditional
     741
     742        GNU make already assume C89 or later throughout the codebase, and
     743        that preprocessor conditional was no longer used anyway.
     744
     745        * configure.ac: Remove AC_DEFINE of HAVE_ANSI_COMPILER.
     746        * config.ami.template: Remove #define of HAVE_ANSI_COMPILER.
     747        * config.h-vms.template: Likewise.
     748        * config.h.W32.template: Likewise.
     749        * configh.dos.template: Likewise.
     750
     7512013-04-30  Stefano Lattarini <stefano.lattarini@gmail.com>  (tiny change)
     752
     753        cosmetics: fix few innocuous typos
     754
     755        Most of these were found using Lucas De Marchi's 'codespell' tool.
     756
     757        * ChangeLog: Fix minor typos.
     758        * ChangeLog.2: Likewise.
     759        * README.Amiga: Likewise.
     760        * TODO.private: Likewise.
     761        * function.c: Likewise.
     762        * glob/glob.h: Likewise.
     763        * job.c: Likewise.
     764        * main.c: Likewise.
     765        * readme.vms: Likewise.
     766        * remake.c: Likewise.
     767        * tests/ChangeLog: Likewise.
     768        * tests/NEWS: Likewise.
     769        * tests/README: Likewise.
     770        * tests/scripts/variables/private: Likewise.
     771        * vmsdir.h: Likewise.
     772        * signame.c: Likewise.  While at it, improve line wrapping in the
     773        touched comment.
     774
     7752013-04-29  Eli Zaretskii  <eliz@gnu.org>
     776
     777        * w32/include/dlfcn.h: New file.
     778
     779        * w32/compat/posixfcn.c: Include dlfcn.h.
     780        (dlopen, dlerror, dlsym) [MAKE_LOAD]: New functions, in support of
     781        dynamic loading.
     782
     783        * config.h.W32.template (MAKE_LOAD): Define.
     784
     785        * load.c (load_object) [HAVE_DOS_PATHS]: Support backslashes and
     786        drive letters in file names of dynamic objects.
     787
     788        * job.c (construct_command_argv_internal) [WINDOWS32]: Return
     789        right after generating new_argv for one_shell case.  This fixes
     790        the Windows build for both Unixy shell and stock Windows shells.
     791
     7922013-04-28  Eli Zaretskii  <eliz@gnu.org>
     793
     794        * dir.c (local_stat) [WINDOWS32]: Use the wrapper on MS-Windows.
     795        If the argument ends in "dir/.", make sure the parent dir exists
     796        and is indeed a directory.  Fixes Savannah bug #37065.
     797
     7982013-04-28  Paul Smith  <psmith@gnu.org>
     799
     800        * makeint.h (message_s, error_s): Functions that print to strings
     801        rather than directly to files.
     802        * misc.c (message_s, error_s): Create them.
     803        * job.c (child_error): Print error messages to the output sync
     804        logs, if one exists, rather then directly to the terminal.
     805        (reap_children): Move the per-line sync after child_error().
     806
     807        * configure.ac: Remove support for pre-ANSI variadic function calls.
     808        * makeint.h: Ditto.
     809        * misc.c: Ditto.
     810        * config.ami.template: Ditto.
     811        * config.h-vms.template: Ditto.
     812        * config.h.W32.template: Ditto.
     813        * configh.dos.template: Ditto.
     814
     815        Implement a "per-job" output synchronization option.
     816
     817        * main.c (decode_output_sync_flags): Recognize the new option.
     818        * makeint.h (OUTPUT_SYNC_JOB): Add new values for "job"
     819        * job.c (assign_child_tempfiles): In per-job mode, truncate the
     820        temp file for re-use by the next job.
     821        (sync_output): Don't close the temp files as we may still use them.
     822        (free_child): Close the temp files here as we definitely don't
     823        need them.
     824        (new_job): In per-job output mode, sync_output() after each job.
     825        * job.h (struct child): Avoid ifdefs.
     826        * make.1: Add new options to the man page.
     827        * doc/make.texi (Parallel Output): Break documentation on input
     828        and output into separate sections for readability.  Document the
     829        new "job" and "none" modes.
     830
     8312013-04-27  Paul Smith  <psmith@gnu.org>
     832
     833        * job.c (construct_command_argv_internal): Fix oneshell support
     834        for non-POSIX-sh shells.
     835
     836        * load.c (load_object): Extract all POSIX-isms into a separate
     837        function for portability.
     838        (load_file): Check the .LOADED variable first and don't invoke
     839        load_object() if it's already been loaded.
     840
     8412013-04-27  Eli Zaretskii  <eliz@gnu.org>
     842
     843        * read.c (record_files): Pay attention to .ONESHELL in MS-Windows.
     844
     845        * job.c (construct_command_argv_internal): Support .ONESHELL on
     846        MS-Windows, when the shell is not a Unixy shell.
     847
     8482013-04-27  Eli Zaretskii  <eliz@gnu.org>
     849
     850        * job.c: Fix compilation error on GNU/Linux due to "label at end
     851        of compound statement".
     852
     8532013-04-27  Frank Heckenbach <f.heckenbach@fh-soft.de>  (tiny change)
     854
     855        * job.c (sync_output): Don't discard the output if
     856        acquire_semaphore fails; instead, dump the output unsynchronized.
     857
     8582013-04-27  Eli Zaretskii  <eliz@gnu.org>
     859
     860        Support --output-sync on MS-Windows.
     861        * w32/compat/posixfcn.c: New file, with emulations of Posix
     862        functions and Posix functionality for MS-Windows.
     863
     864        * w32/subproc/sub_proc.c: Include io.h.
     865        (process_noinherit): New function, forces a file descriptor to not
     866        be inherited by child processes.
     867        (process_easy): Accept two additional arguments, and use them to
     868        set up the standard output and standard error handles of the child
     869        process.
     870
     871        * w32/include/sub_proc.h (process_easy): Adjust prototype.
     872        (process_noinherit): Add prototype.
     873
     874        * read.c [WINDOWS32]: Include windows.h and sub_proc.h.
     875
     876        * makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
     877        defined.  This is needed because the MS-Windows build doesn't have
     878        a canonical place for LOCALEDIR.
     879        (WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
     880        windows.h header too much stuff that could conflict with the code.
     881
     882        * main.c <sync_mutex>: New static variable.
     883        <switches>: Add support for "--sync-mutex" switch.
     884        (decode_output_sync_flags): Decode the --sync-mutex= switch.
     885        (prepare_mutex_handle_string) [WINDOWS32]: New function.
     886        (main): Add "output-sync" to .FEATURES.
     887
     888        * job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
     889        process_noinherit.
     890        (F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
     891        New macros.
     892        (RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
     893        (sync_handle_t): New typedef.
     894
     895        * job.c <sync_handle>: Change type to sync_handle_t.
     896        (FD_NOT_EMPTY): Seek to the file's end.  Suggested by Frank
     897        Heckenbach <f.heckenbach@fh-soft.de>.
     898        (pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
     899        the duration of this function, and then change back before
     900        returning.
     901        (start_job_command) [WINDOWS32]: Support output_sync mode on
     902        MS-Windows.  Use a system-wide mutex instead of locking
     903        stdout/stderr.  Call process_easy with two additional arguments:
     904        child->outfd and child->errfd.
     905        (exec_command) [WINDOWS32]: Pass two additional arguments, both
     906        -1, to process_easy, to adjust for the changed function signature.
     907
     908        * function.c (windows32_openpipe) [WINDOWS32]: This function now
     909        returns an int, which is -1 if it fails and zero otherwise.  It
     910        also calls 'error' instead of 'fatal', to avoid exiting
     911        prematurely.
     912        (func_shell_base) [WINDOWS32]: Call perror_with_name if
     913        windows32_openpipe fails, now that it always returns.  This avoids
     914        a compiler warning that error_prefix is not used in the MS-Windows
     915        build.
     916
     917        * config.h.W32.template (OUTPUT_SYNC): Define.
     918
     919        * build_w32.bat: Add w32/compat/posixfcn.c to compilation and
     920        linking commands.
     921
     9222013-04-20  Stefano Lattarini <stefano.lattarini@gmail.com>  (tiny change)
     923
     924        * README.git: Our autoconf input file is 'configure.ac', not
     925        'configure.in'.  Adjust accordingly.
     926        * build_w32.bat: Likewise.
     927        * config.h-vms.template: Likewise.
     928        * Makefile.DOS.template: Likewise.
     929
     9302013-04-16  Paul Smith  <psmith@gnu.org>
     931
     932        * misc.c (open_tmpfd): Add a new function that returns a temporary
     933        file by file descriptor.
     934        (open_tmpfile): Move here from main.c.
     935        * job.c (assign_child_tempfiles): Use the new open_tmpfd().
     936
     9372013-04-15  Paul Smith  <psmith@gnu.org>
     938
     939        * makeint.h (OUTPUT_SYNC_TARGET, OUTPUT_SYNC_MAKE): Rename.
     940        * job.c (start_job_command): Use new constants.
     941        * main.c: New -O argument format.
     942
     943        * doc/make.texi (Options Summary): Document the argument to -O.
     944        * make.1: Ditto.
     945
     946        * main.c (define_makeflags): Don't add space between a single-char
     947        option and its argument.
     948
     9492013-04-06  Paul Smith  <psmith@gnu.org>
     950
     951        * doc/make.texi (Implicit Variables): Clarify LDFLAGS vs. LDLIBS.
     952        Fixes Savannah bug #37970.
     953
     954        * remake.c (check_dep): Reconsider files waiting on prerequisites,
     955        as they may have finished.  Fixes Savannah bug #37703.
     956
     9572013-02-28  Paul Smith  <psmith@gnu.org>
     958
     959        * function.c (func_realpath): On Solaris (at least) realpath() can
     960        fail due to EINTR, so loop it.  Fixes Savannah bug #38420.
     961
     9622013-02-25  Paul Smith  <psmith@gnu.org>
     963
     964        Add a proposed supported API for GNU make loaded objects.
     965
     966        * doc/make.texi (Loaded Object API): Document it.
     967        * Makefile.am (make_SOURCES): Add new loadapi.c.
     968        * dep.h: Remove eval_buffer(); moved to loadapi.c:gmk_eval().
     969        * read.c (eval_buffer): Change eval_buffer() signature.
     970        * main.c (main): Change eval_buffer() signature.
     971        * variable.h (define_new_function): Change func_ptr signature.
     972        * load.c (SYMBOL_EXTENSION): Change the extension.
     973        * loadapi.c: Implement the new API.
     974        * gnumake.h (gmk_eval): New function prototype.
     975        (gmk_expand) Ditto.
     976        (gmk_add_function) Ditto.
     977        * gmk-default.scm (gmk-eval): Remove: now implemented in guile.c.
     978        * guile.c (guile_expand_wrapper): Use gmk_expand()
     979        (guile_eval_wrapper): Implement eval here to avoid double-expansion.
     980        (guile_define_module): Define gmk-eval.
     981        (func_guile): Use new func_ptr calling model.
     982        (guile_gmake_setup): Use gmk_add_function() to declare $(guile ...)
     983        * function.c (function_table_entry): Provide alternative func_ptr.
     984        (func_eval): New signature for eval_buffer();
     985        (function_table_init): New initialization for function_table_entry.
     986        (expand_builtin_function): Support alternative invocation signature.
     987        (define_new_function): Ditto.
     988
     9892013-01-20  Paul Smith  <psmith@gnu.org>
     990
     991        * gnumake.h: New file to contain externally-visible content.
     992        * makeint.h: Include gnumake.h.  Move gmk_floc type to gnumake.h.
     993        * Makefile.am (include_HEADERS): Install the gnumake.h header.
     994
     995        * makeint.h: Change struct floc to gmk_floc typedef.
     996        * Many: Use the new typedef.
     997
     998        * make.h: Rename to makeint.h.
     999        * Many: Use the new name makeint.h.
     1000
     10012013-01-19  Paul Smith  <psmith@gnu.org>
     1002
     1003        * doc/make.texi (load Directive): Update to discuss location of
     1004        loaded object file.
     1005        (Remaking Loaded Objects): Document remaking of loaded objects.
     1006
     1007        * main.c (main): Rename READ_MAKEFILES to READ_FILES.
     1008        * read.c: Change READ_MAKEFILES to READ_FILES since it now
     1009        contains loaded object files as well.
     1010        (read_all_makefiles): Ditto.
     1011        (eval_makefile): Ditto.
     1012        (eval): Add any loaded file to the READ_FILES list, so that it
     1013        will be considered for re-build.
     1014
     1015        * load.c (load_file): Return the simple filename (no symbol) in
     1016        the LDNAME argument (now a const char **).
     1017        This filename should no longer have "./" prepended: modify the
     1018        function to always check the current directory if the name has no
     1019        "/", before using the normal methods.
     1020        * make.h: Change the load_file() prototype.
     1021
     1022        * README.git: Add a bit more documentation on Git workflow & rules.
     1023
     10242013-01-13  Paul Smith  <psmith@gnu.org>
     1025
     1026        * main.c (main): Restore all make flags after re-exec is complete.
     1027        Fixes Savannah bug #38051.
     1028
     10292013-01-12  Paul Smith  <psmith@gnu.org>
     1030
     1031        Convert CVS archive to Git.
     1032
     1033        * configure.in: Rename to configure.ac.
     1034        * README.cvs: Rename to README.git and rework for Git.
     1035        * maintMakefile: Use git clean for cleanup.
     1036        * ChangeLog: Use new Git repository URL.
     1037        * ChangeLog.2: Ditto.
     1038        * Makefile.am: Change documentation for Git
     1039        * Makefile.DOS.template: Ditto.
     1040        * README.template: Ditto.
     1041        * build_w32.bat: Ditto.
     1042        * prepare_w32.bat: Ditto.
     1043        * .cvsignore: Rename to .gitignore, and change to Git format.
     1044
     10452012-12-08  Eli Zaretskii  <eliz@gnu.org>
     1046
     1047        * job.c (create_batch_file): Fix last change: always increment the
     1048        counter of batch files before trying to use it.
     1049
     10502012-12-07  Eli Zaretskii  <eliz@gnu.org>
     1051
     1052        * job.c (construct_command_argv_internal): Remove " from
     1053        sh_chars_dos[].  Ignore an escaped backslash inside a string
     1054        quoted with "..".  This lifts the 4KB or 8KB command-line length
     1055        limitation imposed by the Windows shells when a command uses quoted
     1056        strings, because we now don't call the shell in that case.
     1057
     1058        * job.c (create_batch_file): Declare the counter of batch files
     1059        static, to avoid having 2 jobs using the same file name and
     1060        stepping on each other's toes.  When all 64K names are used up,
     1061        make one more loop looking for slots that became vacant.  This
     1062        avoids leaving behind temporary batch files in the temporary
     1063        directory, which happens frequently on a fast machine when using
     1064        parallel builds.
     1065        (reap_children): Add debug message for when removal of a temporary
     1066        batch file fails.
     1067
     10682012-10-29  Paul Smith  <psmith@gnu.org>
     1069
     1070        New feature: "load" directive for dynamically-loaded objects.
     1071
     1072        * NEWS: Document new "load" directive.
     1073        * doc/make.texi (Extending make): New chapter on extensions to make.
     1074        * configure.in: Check for dlopen/dlsym/dlerror and -ldl.
     1075        * Makefile.am (make_SOURCES): Add new file load.c.
     1076        * make.h: Prototype for load_file().
     1077        * main.c (main): Add "load" to .FEATURES if it's available.
     1078        * read.c (eval): Parse "load" and "-load" directives.
     1079
     10802012-09-29  Paul Smith  <psmith@gnu.org>
     1081
     1082        * configure.in: Require a new version of gettext (1.18.1).
     1083        Fixes Savannah bug #37307.
     1084
     10852012-09-09  Paul Smith  <psmith@gnu.org>
     1086
     1087        * configure.in (bsd_signal): Define _GNU_SOURCE, a la make.h.
     1088        Fixes Savannah bug #32247.
     1089
     1090        * remake.c (update_file_1): Force intermediate files to be
     1091        considered, not pruned, if their non-intermediate parent needs to
     1092        be remade.  Fixes Savannah bug #30653.
     1093
     1094        * job.c (construct_command_argv_internal): Keep the command line
     1095        on the heap for very long lines.  Fixes Savannah bug #36451.
     1096
     1097        * function.c (func_realpath): BSD realpath(3) doesn't fail if the
     1098        file does not exist: use stat.  Fixes Savannah bug #35919.
     1099
     1100        * file.c (expand_deps): Duplicate the current variable buffer, not
     1101        the old pointer.  Fixes Savannah bug #36925.
     1102
     1103        * read.c (eval): If we detect an initial UTF-8 BOM, skip it.
     1104        Fixes Savannah bug #36529.
     1105        (record_target_var): Remove unused variable "fname".
     1106        (eval): Use the correct pointer when adding to the variable buffer.
     1107        Fixes Savannah bug #36106.
     1108
     11092012-09-09  Eli Zaretskii  <eliz@gnu.org>
     1110
     1111        * read.c (unescape_char): Fix a thinko in the last change.
     1112
     11132012-09-09  Paul Smith  <psmith@gnu.org>
     1114
     1115        * default.c (default_variables): Use a correct default LIBPPATERNS
     1116        for MacOS.  Fixes Savannah bug #37197.
     1117
     1118        * read.c (record_files): Reset the default macro values if .POSIX
     1119        is set.  Fixes Savannah bug #37069.
     1120        (parse_file_seq): Break out of an infinite loop if we're not
     1121        making progress when parsing archive references.
     1122
     11232012-09-01  Eli Zaretskii  <eliz@gnu.org>
     1124
     1125        * README.W32.template: Update for job-server and Guile support.
     1126
     1127        * read.c (unescape_char): Advance 'p' after copying the unescaped
     1128        characters.  Otherwise the backslashes are incorrectly erased from
     1129        the original string.
     1130
     11312012-03-05  Paul Smith  <psmith@gnu.org>
     1132
     1133        Update copyright notices to use year ranges, as allowed by
     1134        clarifications in the GNU Maintainer's Manual.
     1135
     11362012-03-04  Paul Smith  <psmith@gnu.org>
     1137
     1138        * read.c (unescape_char): New function to remove escapes from a char.
     1139        (record_files): Call it on the dependency string to unescape ":".
     1140        Fixes Savannah bug #12126 and bug #16545.
     1141
     1142        * make.h (CSTRLEN): Determine the length of a constant string.
     1143        * main.c: Use the new macro.
     1144        * read.c: Ditto.
     1145        * variable.h: Ditto.
     1146        * function.c: Simplify checks for function alternatives.
     1147
     1148        * expand.c (variable_append): If the current set is local and the
     1149        next one is not a parent, then treat the next set as
     1150        local as well.  Fixes Savannah bug #35468.
     1151
     11522012-03-03  Paul Smith  <psmith@gnu.org>
     1153
     1154        * acinclude.m4 (AC_STRUCT_ST_MTIM_NSEC): Add support for AIX 5.2+
     1155        nanosecond timestamps.  Fixes Savannah bug #32485.
     1156
     1157        Convert uses of `foo' for quoting to 'foo' to reflect changes in
     1158        the GNU Coding Standards.  Fixes Savannah bug #34530.
     1159
     1160        * job.c (construct_command_argv_internal): In oneshell we need to
     1161        break the SHELLFLAGS up for argv.  Fixes Savannah bug #35397.
     1162
     1163        * function.c (func_filter_filterout): Recompute the length of each
     1164        filter word in case it was compressed due to escape chars.  Don't
     1165        reset the string as it's freed.  Fixes Savannah bug #35410.
     1166
     1167        * misc.c (collapse_continuations): Only use POSIX-style
     1168        backslash/newline handling if the .POSIX target is set.
     1169        Addresses Savannah bug #16670 without backward-incompatibility.
     1170        * NEWS: Document behavior change.
     1171        * doc/make.texi (Splitting Lines): New section describing how to
     1172        use backslash/newline to split long lines.
     1173
     11742012-02-26  Paul Smith  <psmith@gnu.org>
     1175
     1176        * implicit.c (pattern_search): Check the stem length to avoid
     1177        stack overflows in stem_str.  Fixes Savannah bug #35525.
     1178
     11792012-02-03  Eli Zaretskii  <eliz@gnu.org>
     1180
     1181        * w32/subproc/sub_proc.c (proc_stdin_thread, proc_stdout_thread)
     1182        (proc_stderr_thread, process_pipe_io): Ifdef away unused
     1183        functions.
     1184
     1185        * w32/subproc/w32err.c (map_windows32_error_to_string) [_MSC_VER]:
     1186        Don't use TLS storage for szMessageBuffer.  Ifdef away special
     1187        code for handling Winsock error codes.  Make the function return a
     1188        `const char *'.  Suggested by Ozkan Sezer.  Fixes Savannah bug #34832.
     1189
     11902012-01-29  Paul Smith  <psmith@gnu.org>
     1191
     1192        * gmk-default.scm (to-string-maybe): Variables map to empty strings.
     1193        In Guile 2.0, (define ...) results in a variable object so make
     1194        sure that maps to an empty string in make.
     1195
     1196        * variable.c (parse_variable_definition): New POSIX assignment ::=
     1197        Take a struct variable to return more information after parsing.
     1198        (assign_variable_definition): New parse_variable_definition() call.
     1199        * variable.h: New declaration of parse_variable_definition().
     1200        * read.c (do_define): New parse_variable_definition() call.
     1201        (parse_var_assignment): Ditto.
     1202        (get_next_mword): Parse ::= as a variable assignment.
     1203        * doc/make.texi (Flavors): Describe the new ::= syntax.
     1204        * NEWS: Mention the ::= operator.
     1205
     1206        * variable.h (struct variable): Rearrange elts to reduce struct size.
     1207
     1208        * function.c (func_file): Create a new function, $(file ...)
     1209        * doc/make.texi (File Function): Document the $(file ..) function.
     1210        * NEWS: Announce it.
     1211
     1212        * gmk-default.scm (to-string-maybe): Use a more portable way to
     1213        test for unprintable characters.
     1214        * configure.in [GUILE]: Guile 1.6 doesn't have pkg-config
     1215        * build_w32.bat: Ditto.
     1216
     12172012-01-28  Eli Zaretskii  <eliz@gnu.org>
     1218
     1219        * config.h.W32.template: Update from config.h.in.
     1220
     1221        Support a Windows build with Guile.
     1222
     1223        * README.W32.template: Update with instructions for building with
     1224        Guile.
     1225
     1226        * build_w32.bat: Support building with Guile.
     1227
     1228        * make.h [HAVE_STDINT_H]: Include stdint.h.
     1229
     1230        * main.c (main, clean_jobserver): Move declarations of variables
     1231        not used in the WINDOWS32 build to the #else branch, to avoid
     1232        compiler warnings.
     1233
     1234        Fix failures on MS-Windows when Make's standard handles are invalid.
     1235        This can happen when Make is invoked from a GUI application.
     1236
     1237        * w32/subproc/sub_proc.c (process_init_fd): Don't dereference
     1238        pproc if it is a NULL pointer.
     1239        (process_begin, process_cleanup): Don't try to close pipe handles
     1240        whose value is INVALID_HANDLE_VALUE.
     1241        (process_easy): Initialize hIn, hOut, and hErr to
     1242        INVALID_HANDLE_VALUE.  If DuplicateHandle fails with
     1243        ERROR_INVALID_HANDLE, duplicate a handle for the null device
     1244        instead of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE or
     1245        STD_ERROR_HANDLE.  Don't try to close pipe handles whose value is
     1246        INVALID_HANDLE_VALUE.
     1247
     1248        * function.c (windows32_openpipe): Initialize hIn and hErr to
     1249        INVALID_HANDLE_VALUE.  If DuplicateHandle fails with
     1250        ERROR_INVALID_HANDLE, duplicate a handle for the null device
     1251        instead of STD_INPUT_HANDLE or STD_ERROR_HANDLE.  Fix indentation.
     1252        Don't try to close handles whose value is INVALID_HANDLE_VALUE.
     1253
     12542012-01-25  Eli Zaretskii  <eliz@gnu.org>
     1255
     1256        * function.c (define_new_function): Fix format strings in calls to
     1257        `fatal'.
     1258
     12592012-01-17  Paul Smith  <psmith@gnu.org>
     1260
     1261        * guile.c (func_guile): Handle NULL returns from Guile.
     1262
     12632012-01-16  Paul Smith  <psmith@gnu.org>
     1264
     1265        * make.h (PATH_SEPARATOR_CHAR): Allow resetting for crosscompiling
     1266        for Windows.  Patch by Chris Sutcliffe <ir0nh34d@gmail.com>
     1267        Fixes Savannah bug #34818.
     1268
     12692012-01-15  Paul Smith  <psmith@gnu.org>
     1270
     1271        * variable.h: Prototype an interface for defining new make functions.
     1272        * function.c (define_new_function): Define it.
     1273        (func_guile): Remove the "guile" function.
     1274        (function_table_init): Ditto.
     1275        * guile.c (func_guile): Add the "guile" function here.
     1276        (setup_guile): Call define_new_function() to define it.
     1277        (guile_eval_string): Obsolete.
     1278
     1279        * all: Update copyright notices.
     1280
     12812012-01-12  Paul Smith  <psmith@gnu.org>
     1282
     1283        Support GNU Guile as an embedded extension language for GNU make.
     1284
     1285        * NEWS: Note the new Guile capability.
     1286        * Makefile.am (EXTRA_DIST, make_SOURCES): Add new guile source files.
     1287        (AM_CFLAGS): Add Guile compiler flags.
     1288        (guile): Add a rule for converting default SCM into a C header.
     1289        * configure.in: Add support for --with-guile.
     1290        Also, convert the entire file to properly escaped autoconf m4, and
     1291        utilize newer features such as AS_IF() and AS_CASE().
     1292        * doc/make.texi (Guile Function): Document the GNU guile integration.
     1293        * make.h (guile_eval_string, guile_boot): Prototypes for Guile.
     1294        * main.c (main): Run guile_boot() to handle main().
     1295        (real_main): All the previous content of main() is here.
     1296        (real_main): Add "guile" to the .FEATURES variable.
     1297        * function.c (func_guile): Call Guile.
     1298        * guile.c: New file implementing GNU make integration with GNU Guile.
     1299        * gmk-default.scm: The integration of GNU make with Guile uses
     1300        Guile itself for much of the parsing and conversion of return
     1301        types, etc.  This implementation is embedded into GNU make.
     1302        * config.h-vms.template: Disable Guile support.
     1303        * config.h.W32.template: Ditto.
     1304        * configh.dos.template: Ditto.
     1305        * config.ami.template: Ditto.
     1306        * makefile.vms: Add new Guile files.
     1307        * Makefile.DOS.template: Ditto.
     1308        * Makefile.ami: Ditto.
     1309        * NMakefile.template: Ditto.
     1310        * SMakefile.template: Ditto.
     1311        * build_w32.bat: Ditto.
     1312        * dosbuild.bat: Ditto.
     1313        * make_msvc_net2001.vcproj: Ditto.
     1314
     13152011-11-15  Paul Smith  <psmith@gnu.org>
     1316
     1317        * main.c (main): Use %ld when printing DWORD values.
     1318        * job.c (new_job): Ditto.
     1319        * w32/include/sub_proc.h: Use const.
     1320        * w32/subproc/sub_proc.c (open_jobserver_semaphore): Use const.
     1321        Fixes Savannah bug #34830.  Changes suggested by Ozkan Sezer.
     1322
     1323        * configure.in (MAKE_JOBSERVER): Enable jobserver on W32 systems.
     1324        * config.h.W32.template (MAKE_JOBSERVER): Ditto.
     1325
     13262011-11-14  Paul Smith  <psmith@gnu.org>
     1327
     1328        * read.c (eval): parse_file_seq() might shorten the string due to
     1329        backslash removal.  Start parsing again at the colon.
     1330        Fixes Savannah bug #33399.
     1331
     13322011-11-13  Paul Smith  <psmith@gnu.org>
     1333
     1334        * file.c (file_timestamp_cons): Match up data types to avoid warnings.
     1335        * filedef.h: Ditto.
     1336        * misc.c (concat): Ditto.
     1337        * read.c (eval): Assign value to avoid warnings.
     1338        * function.c (func_shell_base): Use fork() instead of vfork() to
     1339        avoid warnings.
     1340        * make.h (INTEGER_TYPE_SIGNED): Use <=0 to avoid warnings.
     1341        Fixes Savannah bug #34608.
     1342
     1343        * job.c (construct_command_argv): Remove _p.
     1344        (construct_command_argv_internal): Remove _ptr.
     1345        Fixes Savannah bug #32567.
     1346
     1347        * main.c (clean_jobserver): Don't write the free token to the pipe.
     1348        Change suggested by Tim Newsome <tnewsome@aristanetworks.com>
     1349
     1350        * acinclude.m4 (AC_STRUCT_ST_MTIM_NSEC): Add support for Darwin.
     1351        * filedef.h (FILE_TIMESTAMP_STAT_MODTIME): Ditto.
     1352        Patch provided by Troy Runkel <Troy.Runkel@mathworks.com>
     1353
     13542011-10-11  Troy Runkel  <Troy.Runkel@mathworks.com>
     1355
     1356        * config.h.W32: Enable job server support for Windows.
     1357        * main.c [WINDOWS32]: Include sub_proc.h
     1358        (main): Create a named semaphore to implement the job server.
     1359        (clean_jobserver): Free the job server semaphore when make is finished.
     1360        * job.c [WINDOWS32]: Define WAIT_NOHANG
     1361        (reap_children): Support non-blocking wait for child processes.
     1362        (free_child): Release job server semaphore when child process finished.
     1363        (job_noop): Don't define function on Windows.
     1364        (set_child_handler_action_flags): Don't define function on Windows.
     1365        (new_job): Wait for job server semaphore or child process termination.
     1366        (exec_command): Pass new parameters to process_wait_for_any.
     1367        * w32/include/sub_proc.h [WINDOWS32]: New/updated EXTERN_DECL entries.
     1368        * w32/subproc/sub_proc.c [WINDOWS32]: Added job server implementation.
     1369        (open_jobserver_semaphore): Open existing job server semaphore by name.
     1370        (create_jobserver_semaphore): Create new job server named semaphore.
     1371        (free_jobserver_semaphore): Close existing job server semaphore.
     1372        (acquire_jobserver_semaphore): Decrement job server semaphore count.
     1373        (release_jobserver_semaphore): Increment job server semaphore count.
     1374        (has_jobserver_semaphore): Returns whether job server semaphore exists.
     1375        (get_jobserver_semaphore_name): Returns name of job server semaphore.
     1376        (wait_for_semaphore_or_child_process): Wait for either the job server
     1377        semaphore to become signalled or a child process to terminate.
     1378        (process_wait_for_any_private): Support for non-blocking wait for child.
     1379        (process_wait_for_any): Added support for non-blocking wait for child.
     1380        (process_file_io): Pass new parameters to process_wait_for_any_private.
     1381
     13822011-09-18  Paul Smith  <psmith@gnu.org>
     1383
     1384        * main.c (main): If we're re-exec'ing and we're the master make,
     1385        then restore the job_slots value so it goes back into MAKEFLAGS
     1386        properly.  See Savannah bug #33873.
     1387
     1388        * remake.c (library_search): STD_DIRS is computed when other
     1389        static vars like buflen etc. are computed, so it must be static
     1390        as well.  See Savannah bug #32511.
     1391
     13922011-09-16  Paul Smith  <psmith@gnu.org>
     1393
     1394        * maintMakefile (do-po-update): Apparently we have to avoid
     1395        certificate checks on the http://translationproject.org site now.
     1396
     13972011-09-12  Paul Smith  <psmith@gnu.org>
     1398
     1399        * read.c (eval): Ensure exported variables are defined in the
     1400        global scope.  Fixes Savannah bug #32498.
     1401
     14022011-09-11  Paul Smith  <psmith@gnu.org>
     1403
     1404        * Makefile.am (dist-hook): Remove w32/Makefile and .deps/ from the
     1405        dist file.  Fixes Savannah bug #31489.
     1406
     1407        * doc/make.texi (Complex Makefile): Add a hint about using
     1408        #!/usr/bin/make (for Savannah support request #106459)
     1409
     14102011-09-02  Paul Smith  <psmith@gnu.org>
     1411
     1412        * remake.c (touch_file): If we have both -n and -t, -n takes
     1413        precedence.  Patch from Michael Witten <mfwitten@gmail.com>
     1414
     14152011-08-29  Paul Smith  <psmith@gnu.org>
     1416
     1417        * expand.c (variable_expand_string): Always allocate a new buffer
     1418        for a string we're expanding.  The string we're working on can get
     1419        freed while we work on it (for example if it's the value of a
     1420        variable which modifies itself using an eval operation).
     1421        See Savannah patch #7534 for the original report by Lubomir Rintel.
     1422
     14232011-06-12  Paul Smith  <psmith@gnu.org>
     1424
     1425        * read.c (parse_file_seq): Move the check for empty members out of
     1426        the loop so we can go to the next member properly.
     1427        Another fix for Savannah bug #30612.
     1428
     1429        * config.h-vms.template: Newer versions of VMS have strncasecmp()
     1430        Patch provided by: Hartmut Becker <becker.ismaning@freenet.de>
     1431
     14322011-05-07  Paul Smith  <psmith@gnu.org>
     1433
     1434        * expand.c (variable_append): Add a LOCAL argument to track
     1435        whether this is the first invocation or not.  If it's not and
     1436        private_var is set, then skip this variable and try the next one.
     1437        Fixes Savannah bug #32872.
     1438
     1439        * read.c (parse_file_seq): Ensure existence checks use glob().
     1440
     14412011-05-07  Eli Zaretskii  <eliz@gnu.org>
     1442
     1443        * job.c (construct_command_argv_internal): Don't assume shellflags
     1444        is always non-NULL.  Escape-protect characters special to the
     1445        shell when copying the value of SHELL into new_line.  Fixes
     1446        Savannah bug #23922.
     1447
     14482011-05-02  Paul Smith  <psmith@gnu.org>
     1449
     1450        * doc/make.texi (Special Variables): Add documentation for the new
     1451        words in .FEATURES.  Fixes Savannah bug #32058.
     1452        (Flavor Function): Rewrite the section on the flavor function.
     1453        Fixes Savannah bug #31582.
     1454
     1455        * function.c (func_sort): Use the same algorithm to count the
     1456        number of words we will get after the split, as we use to split.
     1457        Based on a patch from Matthias Hopf.  Fixes Savannah bug #33125.
     1458
     1459        * make.h: Make global variable stack_limit extern.
     1460        Fixes Savannah bug #32753.
     1461
     14622011-05-01  Paul Smith  <psmith@gnu.org>
     1463
     1464        * read.c (parse_file_seq): Don't try to invoke glob() unless there
     1465        are potential wildcard characters in the filename.  Performance
     1466        enhancement suggested by Michael Meeks <michael.meeks@novell.com>
     1467
     14682011-04-29 Boris Kolpackov  <boris@codesynthesis.com>
     1469
     1470        * read.c (eval_makefile): Delay caching of the file name until after
     1471        all the expansions and searches.
     1472
     14732011-04-17  David A. Wheeler  <dwheeler@dwheeler.com>
     1474
     1475        * doc/make.texi (Reading Makefiles): Document "!=".
     1476        (Setting): Ditto.
     1477        (Features): Ditto.
     1478        * variable.h (enum variable_flavor): New type "f_shell".
     1479        * variable.c (shell_result): Send a string to the shell and store
     1480        the output.
     1481        (do_variable_definition): Handle f_shell variables: expand the
     1482        value, then send it to the shell and store the result.
     1483        (parse_variable_definition): Parse "!=" shell assignments.
     1484        * read.c (get_next_mword): Treat "!=" as a varassign word.
     1485        * function.c (fold_newlines): If trim_newlines is set remove all
     1486        trailing newlines; otherwise remove only the last newline.
     1487        (func_shell_base): Move the guts of the shell function here.
     1488        (func_shell): Call func_shell_base().
     1489
     14902011-02-21  Paul Smith  <psmith@gnu.org>
     1491
     1492        * strcache.c (various): Increase performance based on comments
     1493        from Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.  Stop looking for
     1494        a buffer when we find the first one that fits, not the best fit.
     1495        If there is not enough free space in a buffer move it to a
     1496        separate list so we don't have to walk it again.
     1497        * make.h (NDEBUG): Turn off asserts unless maintainer mode is set.
     1498        (strcache_add_len, strcache_setbufsize): Use unsigned length/size.
     1499        * maintMakefile (AM_CPPFLAGS): Enable MAKE_MAINTAINER_MODE.
     1500
     1501        * remake.c (complain): Move translation lookups closer to use.
     1502
     15032011-02-13  Paul Smith  <psmith@gnu.org>
     1504
     1505        * doc/make.texi: Clean up references to "static" variables and
     1506        semicolon errors.  Patch from Michael Witten <mfwitten@gmail.com>.
     1507
     15082010-12-27  Paul Smith  <psmith@gnu.org>
     1509
     1510        * make.1: Update the header/footer info in the man page.
     1511
     15122010-11-28  Paul Smith  <psmith@gnu.org>
     1513
     1514        * read.c (record_target_var): Don't reset v if it's the same as
     1515        the global version.  Fixes Savannah bug #31743.
     1516
     15172010-11-06  Paul Smith  <psmith@gnu.org>
     1518
     1519        * variable.c (print_auto_variable): Print auto variables; ignore others.
     1520        (print_noauto_variable): Print non-auto variables; ignore others.
     1521        (print_variable_set): Allow the caller to select which type to print.
     1522        (print_target_variables): Show all the non-auto variables for a target.
     1523
     1524        * default.c (install_default_suffix_rules): Initialize recipe_prefix.
     1525        * rule.c (install_pattern_rule): Ditto.
     1526        * read.c (record_files): Pass in the current recipe prefix.  Remember
     1527        it in the struct command for these targets.
     1528        (eval): Remember the value of RECIPEPREFIX when we start parsing.
     1529        Do not remove recipe prefixes from the recipe here: we'll do it later.
     1530        * job.c (start_job_command): Remove recipe prefix characters early,
     1531        before we print the output or chop it up.
     1532        * file.c (print_file): If recipe_prefix is not standard, reset it
     1533        in -p output.  Assign target variables in -p output as well.
     1534
     1535        * commands.c (chop_commands): Max command lines is USHRT_MAX.
     1536        Set any_recurse as a bitfield.
     1537        * make.h (USHRT_MAX): Define if not set.
     1538
     15392010-10-27  Paul Smith  <psmith@gnu.org>
     1540
     1541        * commands.h (struct commands): Rearrange to make better use of
     1542        memory.  Add new recipe_prefix value.
     1543
     15442010-10-26  Paul Smith  <psmith@gnu.org>
     1545
     1546        * doc/make.texi (Setting): Document the treatment of
     1547        backslash-newline in variable values.
     1548        * misc.c (collapse_continuations): Do not collapse multiple
     1549        backslash-newlines into a single space.  Fixes Savannah bug #16670.
     1550
     15512010-08-29  Paul Smith  <psmith@gnu.org>
     1552
     1553        * doc/make.texi (Implicit Variables): Document LDLIBS and LOADLIBES.
     1554        Fixes Savannah bug #30807.
     1555        (Instead of Execution): Mention that included makefiles are still
     1556        rebuilt even with -n.  Fixes Savannah bug #30762.
     1557
     1558        * configure.in: Bump to 3.82.90.
     1559
     1560        * make.h: Add trace_flag variable.
     1561        * main.c (switches): Add --trace option.
     1562        (trace_flag): Declare variable.
     1563        * job.c (start_job_command): Show recipe if trace_flag is set.
     1564        (new_job): Show trace messages if trace_flag is set.
     1565        * doc/make.texi (Options Summary): Document the new --trace option.
     1566        * make.1: Add --trace documentation.
     1567        * NEWS: Mention --trace.
     1568
     1569        * job.c (child_error): Show recipe filename/linenumber on error.
     1570        Also show "(ignored)" when appropriate even for signals/coredumps.
     1571        * NEWS: Mention file/linenumber change.
     1572
     1573        * main.c (main): Print version info when DB_BASIC is set.
     1574
     1575        * job.c (construct_command_argv_internal): If shellflags is not
     1576        set, choose an appropriate default value.  Fixes Savannah bug #30748.
     1577
     15782010-08-27  Eli Zaretskii  <eliz@gnu.org>
     1579
     1580        * variable.c (define_automatic_variables) [__MSDOS__ || WINDOWS32]:
     1581        Remove trailing backslashes in $(@D), $(<D), etc., for consistency
     1582        with forward slashes.  Fixes Savannah bug #30795.
     1583
     15842010-08-13  Paul Smith  <psmith@gnu.org>
     1585
     1586        * NEWS: Accidentally forgot to back out the sorted wildcard
     1587        enhancement in 3.82, so update NEWS.
     1588        Also add NEWS about the error check for explicit and pattern
     1589        targets in the same rule, added to 3.82.
     1590
     1591        * main.c (main): Add "oneshell" to $(.FEATURES) (forgot to add
     1592        this in 3.82!)
     1593
     1594        * read.c (parse_file_seq): Fix various errors parsing archives
     1595        with multiple objects in the parenthesis, as well as wildcards.
     1596        Fixes Savannah bug #30612.
     1597
     15982010-08-10  Paul Smith  <psmith@gnu.org>
     1599
     1600        * main.c (main): Expand MAKEFLAGS before adding it to the
     1601        environment when re-exec'ing.  Fixes Savannah bug #30723.
     1602
     16032010-08-07  Eli Zaretskii  <eliz@gnu.org>
     1604
     1605        * w32/subproc/build.bat: Make all 3 cl.exe compile command lines
     1606        use the same /I switches.  Fixes Savannah bug #30662.
     1607
     1608        * function.c (func_shell) [WINDOWS32]: Reset just_print_flag
     1609        around the call to construct_command_argv, so that a temporary
     1610        batch file _is_ created when needed for $(shell).
     1611        Fixes Savannah bug #16362.
     1612
     16132010-08-07 Juan Manuel Guerrero  <juan.guerrero@gmx.de>
     1614
     1615        * configh.dos.template (HAVE_STRNCASECMP): Define.
     1616
    116172010-07-28  Paul Smith  <psmith@gnu.org>
    21618
     
    39965612
    39975613
    3998 See ChangeLog.2, available in the CVS repository at:
    3999 
    4000         http://savannah.gnu.org/cvs/?group=make
     5614See ChangeLog.2, available in the Git repository at:
     5615
     5616        http://git.savannah.gnu.org/cgit/make.git/tree/
    40015617
    40025618for earlier changes.
    40035619
    40045620
    4005 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
    4006 Software Foundation, Inc.
     5621Copyright (C) 2000-2013 Free Software Foundation, Inc.
    40075622This file is part of GNU Make.
    40085623
  • vendor/gnumake/current/Makefile.DOS.template

    r2596 r3138  
    22# Makefile.in generated automatically by automake 1.2 from Makefile.am
    33#
    4 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
    5 # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     4# Copyright (C) 1994-2016 Free Software Foundation, Inc.
    65# This file is part of GNU Make.
    76#
     
    9089BUILT_SOURCES = README build.sh-in
    9190
    92 EXTRA_DIST =    $(BUILT_SOURCES) $(man_MANS) README.customs remote-cstms.c  make-stds.texi texinfo.tex SCOPTIONS SMakefile  Makefile.ami README.Amiga config.ami amiga.c amiga.h  NMakefile README.DOS configh.dos configure.bat makefile.com  README.W32 build_w32.bat config.h-W32 subproc.bat make.lnk  config.h-vms makefile.vms readme.vms vmsdir.h vmsfunctions.c  vmsify.c
     91EXTRA_DIST =    $(BUILT_SOURCES) $(man_MANS) README.customs remote-cstms.c  make-stds.texi texinfo.tex SCOPTIONS SMakefile  Makefile.ami README.Amiga config.ami amiga.c amiga.h  NMakefile README.DOS configh.dos configure.bat makefile.com  README.W32 build_w32.bat config.h-W32 subproc.bat make.lnk  config.h-vms makefile.vms README.VMS vmsdir.h vmsfunctions.c  vmsify.c gmk-default.scm gmk-default.h
    9392
    9493SUBDIRS =       glob doc
     
    124123
    125124NROFF = nroff
    126 DIST_COMMON =  README ABOUT-NLS AUTHORS COPYING ChangeLog INSTALL Makefile.am  Makefile.in NEWS acconfig.h aclocal.m4 alloca.c build.sh-in config.h-in  configure configure.in getloadavg.c
     125DIST_COMMON =  README ABOUT-NLS AUTHORS COPYING ChangeLog INSTALL Makefile.am  Makefile.in NEWS acconfig.h aclocal.m4 alloca.c build.sh-in config.h-in  configure configure.ac getloadavg.c
    127126
    128127DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
     
    508507dist-hook:
    509508        (cd $(srcdir); \
    510          w32=`find w32 -follow \( -name CVS -prune \) -o -type f -print`; \
     509         w32=`find w32 -follow \( -name .git -prune \) -o -type f -print`; \
    511510         tar chf - $$w32) \
    512511        | (cd $(distdir); tar xfBp -)
  • vendor/gnumake/current/Makefile.am

    r2596 r3138  
    11# This is a -*-Makefile-*-, or close enough
    22#
    3 # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    4 # 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     3# Copyright (C) 1997-2016 Free Software Foundation, Inc.
    54# This file is part of GNU Make.
    65#
     
    1817# this program.  If not, see <http://www.gnu.org/licenses/>.
    1918
    20 AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news
    21 ACLOCAL_AMFLAGS = -I config
     19AUTOMAKE_OPTIONS = dist-bzip2 silent-rules std-options
     20ACLOCAL_AMFLAGS = -I config
    2221
    2322MAKE_HOST =     @MAKE_HOST@
     
    2827  W32INC =      -I $(top_srcdir)/w32/include
    2928  W32LIB =      -Lw32 -lw32
     29  ossrc =
     30else
     31  ossrc =       posixos.c
    3032endif
    3133
     
    3335
    3436bin_PROGRAMS =  make
     37include_HEADERS = gnumake.h
    3538
    3639if USE_CUSTOMS
     
    4043endif
    4144
    42 
    4345make_SOURCES =  ar.c arscan.c commands.c default.c dir.c expand.c file.c \
    44                 function.c getopt.c getopt1.c implicit.c job.c main.c \
    45                 misc.c read.c remake.c $(remote) rule.c signame.c \
    46                 strcache.c variable.c version.c vpath.c hash.c
     46                function.c getopt.c getopt1.c guile.c implicit.c job.c load.c \
     47                loadapi.c main.c misc.c $(ossrc) output.c read.c remake.c \
     48                rule.c signame.c strcache.c variable.c version.c vpath.c \
     49                hash.c $(remote)
    4750
    4851EXTRA_make_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c
    4952
    50 noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \
    51                 debug.h getopt.h gettext.h hash.h
    52 
    53 make_LDADD =    @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@
     53noinst_HEADERS = commands.h dep.h filedef.h job.h makeint.h rule.h variable.h \
     54                debug.h getopt.h gettext.h hash.h output.h os.h
     55
     56make_LDADD =    @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@ \
     57                $(GUILE_LIBS)
    5458# Only process if target is MS-Windows
    5559if WINDOWSENV
     
    6266
    6367AM_CPPFLAGS =   $(GLOBINC)
     68AM_CFLAGS =     $(GUILE_CFLAGS)
    6469# Only process if target is MS-Windows
    6570if WINDOWSENV
     
    7075# Extra stuff to include in the distribution.
    7176
    72 EXTRA_DIST =    README build.sh.in $(man_MANS) \
     77EXTRA_DIST =    ChangeLog README build.sh.in $(man_MANS) \
    7378                README.customs README.OS2 \
    7479                SCOPTIONS SMakefile \
     
    7782                README.W32 NMakefile config.h.W32 build_w32.bat subproc.bat \
    7883                make_msvc_net2003.sln make_msvc_net2003.vcproj \
    79                 readme.vms makefile.vms makefile.com config.h-vms \
    80                 vmsdir.h vmsfunctions.c vmsify.c
     84                README.VMS makefile.vms makefile.com config.h-vms \
     85                vmsdir.h vmsfunctions.c vmsify.c vms_exit.c vms_progname.c \
     86                vms_export_symbol.c vms_export_symbol_test.com \
     87                gmk-default.scm gmk-default.h
    8188
    8289# This is built during configure, but behind configure's back
     
    8491DISTCLEANFILES = build.sh
    8592
    86 # Forward targets
    87 
    88 html:
    89         cd doc && $(MAKE) $(AM_MAKEFLAGS) $@
    90 
    91 .PHONY: html
    92 
    9393# --------------- Internationalization Section
    9494
     
    101101
    102102# Whether or not make needs to be installed setgid.
    103 # The value should be either `true' or `false'.
    104 # On many systems, the getloadavg function (used to implement the `-l'
     103# The value should be either 'true' or 'false'.
     104# On many systems, the getloadavg function (used to implement the '-l'
    105105# switch) will not work unless make is installed setgid kmem.
    106106#
     
    118118           else \
    119119             echo "$$app needs to be owned by group $(inst_group) and setgid;"; \
    120              echo "otherwise the \`-l' option will probably not work."; \
     120             echo "otherwise the '-l' option will probably not work."; \
    121121             echo "You may need special privileges to complete the installation"; \
    122122             echo "of $$app."; \
     
    124124         else true; fi
    125125
     126# --------------- Generate the Guile default module content
     127
     128guile.$(OBJEXT): gmk-default.h
     129gmk-default.h: $(srcdir)/gmk-default.scm
     130        (echo 'static const char *const GUILE_module_defn = " '\\ \
     131          && sed -e 's/;.*//' -e '/^[ \t]*$$/d' -e 's/"/\\"/g' -e 's/$$/ \\/' \
     132                 $(srcdir)/gmk-default.scm \
     133          && echo '";') > $@
     134
    126135# --------------- Local DIST Section
    127136
     
    130139dist-hook:
    131140        (cd $(srcdir); \
    132          sub=`find w32 tests -follow \( -name CVS -prune -o -name .cvsignore -o -name work -prune \) -o \( -name \*.orig -o -name \*.rej -o -name \*~ -prune \) -o -type f -print`; \
     141         sub=`find w32 tests -follow \( -name .git -o -name .deps -o -name work -o -name .gitignore -o -name \*.orig -o -name \*.rej -o -name \*~ -o -name Makefile \) -prune -o -type f -print`; \
    133142         tar chf - $$sub) \
    134143        | (cd $(distdir); tar xfBp -)
     
    168177MAKETESTFLAGS =
    169178
    170 check-regression:
    171         @if test -f "$(srcdir)/tests/run_make_tests"; then \
     179check-regression: tests/config-flags.pm
     180        @if test -f '$(srcdir)/tests/run_make_tests'; then \
     181          ulimit -n 128; \
    172182          if $(PERL) -v >/dev/null 2>&1; then \
    173             case `cd $(srcdir); pwd` in `pwd`) : ;; \
     183            case `cd '$(srcdir)'; pwd` in `pwd`) : ;; \
    174184              *) test -d tests || mkdir tests; \
    175185                 rm -f srctests; \
    176                  if ln -s "$(srcdir)/tests" srctests; then \
     186                 if ln -s '$(srcdir)/tests' srctests; then \
    177187                   for f in run_make_tests run_make_tests.pl test_driver.pl scripts; do \
    178188                     rm -f tests/$$f; ln -s ../srctests/$$f tests; \
    179189                   done; fi ;; \
    180190            esac; \
    181             echo "cd tests && $(PERL) ./run_make_tests.pl -make ../make$(EXEEXT) $(MAKETESTFLAGS)"; \
    182             cd tests && $(PERL) ./run_make_tests.pl -make ../make$(EXEEXT) $(MAKETESTFLAGS); \
     191            echo "cd tests && $(PERL) ./run_make_tests.pl -srcdir $(abs_srcdir) -make ../make$(EXEEXT) $(MAKETESTFLAGS)"; \
     192            cd tests && $(PERL) ./run_make_tests.pl -srcdir '$(abs_srcdir)' -make '../make$(EXEEXT)' $(MAKETESTFLAGS); \
    183193          else \
    184194            echo "Can't find a working Perl ($(PERL)); the test suite requires Perl."; \
    185195          fi; \
    186          else \
     196        else \
    187197          echo "Can't find the GNU Make test suite ($(srcdir)/tests)."; \
    188          fi
     198        fi
    189199
    190200
     
    192202
    193203# Tell automake that I haven't forgotten about this file and it will be
    194 # created before we build a distribution (see maintMakefile in the CVS
     204# created before we build a distribution (see maintMakefile in the Git
    195205# distribution).
    196206
  • vendor/gnumake/current/Makefile.ami

    r2596 r3138  
    11# -*-Makefile-*- for GNU make on Amiga
    22#
    3 # NOTE: If you have no `make' program at all to process this makefile, run
    4 # `build.sh' instead.
    5 #
    6 # Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    7 # 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     3# NOTE: If you have no 'make' program at all to process this makefile, run
     4# 'build.sh' instead.
     5#
     6# Copyright (C) 1995-2016 Free Software Foundation, Inc.
    87# This file is part of GNU Make.
    98#
     
    3332
    3433# Define these for your system as follows:
    35 #       -DNO_ARCHIVES           To disable `ar' archive support.
     34#       -DNO_ARCHIVES           To disable 'ar' archive support.
    3635#       -DNO_FLOAT              To avoid using floating-point numbers.
    3736#       -DENUM_BITFIELDS        If the compiler isn't GCC but groks enum foo:2.
     
    4039#                               so beware.
    4140# NeXT 1.0a uses an old version of GCC, which required -D__inline=inline.
    42 # See also `config.h'.
     41# See also 'config.h'.
    4342defines =
    4443
    4544# Which flavor of remote job execution support to use.
    46 # The code is found in `remote-$(REMOTE).c'.
     45# The code is found in 'remote-$(REMOTE).c'.
    4746REMOTE = stub
    4847
     
    7877exec_prefix =
    7978
    80 # Directory to install `make' in.
     79# Directory to install 'make' in.
    8180bindir = sc:c
    82 # Directory to find libraries in for `-lXXX'.
     81# Directory to find libraries in for '-lXXX'.
    8382libdir = lib:
    8483# Directory to search by default for included makefiles.
     
    9089# Number to put on the man page filename.
    9190manext = 1
    92 # Prefix to put on installed `make' binary file name.
     91# Prefix to put on installed 'make' binary file name.
    9392binprefix =
    94 # Prefix to put on installed `make' man page file name.
     93# Prefix to put on installed 'make' man page file name.
    9594manprefix = $(binprefix)
    9695
    9796# Whether or not make needs to be installed setgid.
    98 # The value should be either `true' or `false'.
    99 # On many systems, the getloadavg function (used to implement the `-l'
     97# The value should be either 'true' or 'false'.
     98# On many systems, the getloadavg function (used to implement the '-l'
    10099# switch) will not work unless make is installed setgid kmem.
    101100install_setgid = false
     
    103102group = sys
    104103
    105 # Program to install `make'.
     104# Program to install 'make'.
    106105INSTALL_PROGRAM = copy
    107106# Program to install the man page.
     
    119118CTAGS = ctags -w
    120119
    121 objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o      \
    122        rule.o implicit.o default.o variable.o expand.o function.o       \
    123        vpath.o version.o ar.o arscan.o signame.o strcache.o hash.o      \
    124        remote-$(REMOTE).o $(GETOPT) $(ALLOCA) $(extras)
     120#guile = guile.o
     121
     122objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o   \
     123       rule.o implicit.o default.o variable.o expand.o function.o    \
     124       vpath.o version.o ar.o arscan.o signame.o strcache.o hash.o   \
     125       remote-$(REMOTE).o $(GETOPT) $(ALLOCA) $(extras) $(guile)
     126
    125127srcs = $(srcdir)commands.c $(srcdir)job.c $(srcdir)dir.c             \
    126128       $(srcdir)file.c $(srcdir)getloadavg.c $(srcdir)misc.c         \
     
    129131       $(srcdir)variable.c $(srcdir)expand.c $(srcdir)function.c     \
    130132       $(srcdir)vpath.c $(srcdir)version.c $(srcdir)hash.c           \
    131        $(srcdir)remote-$(REMOTE).c                                     \
    132        $(srcdir)ar.c $(srcdir)arscan.c $(srcdir)strcache.c              \
    133        $(srcdir)signame.c $(srcdir)signame.h $(GETOPT_SRC)            \
    134        $(srcdir)commands.h $(srcdir)dep.h $(srcdir)filedep.h            \
    135        $(srcdir)job.h $(srcdir)make.h $(srcdir)rule.h                \
     133       $(srcdir)guile.c $(srcdir)remote-$(REMOTE).c                  \
     134       $(srcdir)ar.c $(srcdir)arscan.c $(srcdir)strcache.c           \
     135       $(srcdir)signame.c $(srcdir)signame.h $(GETOPT_SRC)           \
     136       $(srcdir)commands.h $(srcdir)dep.h $(srcdir)filedep.h         \
     137       $(srcdir)job.h $(srcdir)makeint.h $(srcdir)rule.h             \
    136138       $(srcdir)variable.h $(ALLOCA_SRC) $(srcdir)config.h.in
    137139
     
    143145info: make.info
    144146dvi: make.dvi
    145 # Some makes apparently use .PHONY as the default goal if it is before `all'.
     147# Some makes apparently use .PHONY as the default goal if it is before 'all'.
    146148.PHONY: all check info dvi
    147149
     
    179181        cd glob; $(MAKE) libglob.a
    180182FORCE:
    181 
    182 tagsrcs = $(srcs) $(srcdir)remote-*.c
    183183
    184184.PHONY: install installdirs
     
    197197           else \
    198198             echo "$@ needs to be owned by group $(group) and setgid;"; \
    199              echo "otherwise the \`-l' option will probably not work."; \
     199             echo "otherwise the '-l' option will probably not work."; \
    200200             echo "You may need special privileges to install $@."; \
    201201           fi; \
     
    214214        done
    215215# Run install-info only if it exists.
    216 # Use `if' instead of just prepending `-' to the
     216# Use 'if' instead of just prepending '-' to the
    217217# line so we notice real errors from install-info.
    218 # We use `$(SHELL) -c' because some shells do not
     218# We use '$(SHELL) -c' because some shells do not
    219219# fail gracefully when there is an unknown command.
    220220        if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
     
    267267
    268268# The automatically generated dependencies below may omit config.h
    269 # because it is included with ``#include <config.h>'' rather than
    270 # ``#include "config.h"''.  So we add the explicit dependency to make sure.
     269# because it is included with '#include <config.h>' rather than
     270# '#include "config.h"'.  So we add the explicit dependency to make sure.
    271271$(objs): config.h
    272272
     
    274274
    275275# Automatically generated dependencies.
    276 commands.o: commands.c make.h dep.h filedef.h variable.h job.h \
     276commands.o: commands.c makeint.h dep.h filedef.h variable.h job.h \
    277277 commands.h
    278 job.o: job.c make.h job.h filedef.h commands.h variable.h
    279 dir.o: dir.c make.h
    280 file.o: file.c make.h dep.h filedef.h job.h commands.h variable.h
    281 misc.o: misc.c make.h dep.h
    282 main.o: main.c make.h dep.h filedef.h variable.h job.h commands.h \
     278job.o: job.c makeint.h job.h filedef.h commands.h variable.h
     279dir.o: dir.c makeint.h
     280file.o: file.c makeint.h dep.h filedef.h job.h commands.h variable.h
     281misc.o: misc.c makeint.h dep.h
     282main.o: main.c makeint.h dep.h filedef.h variable.h job.h commands.h \
    283283 getopt.h
    284 read.o: read.c make.h dep.h filedef.h job.h commands.h variable.h \
     284guile.o: guile.c makeint.h dep.h debug.h variable.h gmk-default.h
     285read.o: read.c makeint.h dep.h filedef.h job.h commands.h variable.h \
    285286 glob/glob.h
    286 remake.o: remake.c make.h filedef.h job.h commands.h dep.h
    287 rule.o: rule.c make.h dep.h filedef.h job.h commands.h variable.h \
     287remake.o: remake.c makeint.h filedef.h job.h commands.h dep.h
     288rule.o: rule.c makeint.h dep.h filedef.h job.h commands.h variable.h \
    288289 rule.h
    289 implicit.o: implicit.c make.h rule.h dep.h filedef.h
    290 default.o: default.c make.h rule.h dep.h filedef.h job.h commands.h \
     290implicit.o: implicit.c makeint.h rule.h dep.h filedef.h
     291default.o: default.c makeint.h rule.h dep.h filedef.h job.h commands.h \
    291292 variable.h
    292 variable.o: variable.c make.h dep.h filedef.h job.h commands.h \
     293variable.o: variable.c makeint.h dep.h filedef.h job.h commands.h \
    293294 variable.h
    294 expand.o: expand.c make.h filedef.h job.h commands.h variable.h
    295 function.o: function.c make.h filedef.h variable.h dep.h job.h \
     295expand.o: expand.c makeint.h filedef.h job.h commands.h variable.h
     296function.o: function.c makeint.h filedef.h variable.h dep.h job.h \
    296297 commands.h amiga.h
    297 vpath.o: vpath.c make.h filedef.h variable.h
    298 strcache.o: strcache.c make.h hash.h
     298vpath.o: vpath.c makeint.h filedef.h variable.h
     299strcache.o: strcache.c makeint.h hash.h
    299300version.o: version.c
    300 ar.o: ar.c make.h filedef.h dep.h
    301 arscan.o: arscan.c make.h
     301ar.o: ar.c makeint.h filedef.h dep.h
     302arscan.o: arscan.c makeint.h
    302303signame.o: signame.c signame.h
    303 remote-stub.o: remote-stub.c make.h filedef.h job.h commands.h
     304remote-stub.o: remote-stub.c makeint.h filedef.h job.h commands.h
    304305getopt.o: getopt.c
    305306getopt1.o : getopt1.c getopt.h
    306307getloadavg.o: getloadavg.c
    307 amiga.o: amiga.c make.h variable.h amiga.h
     308amiga.o: amiga.c makeint.h variable.h amiga.h
  • vendor/gnumake/current/NEWS

    r2596 r3138  
    11GNU make NEWS                                               -*-indented-text-*-
    22  History of user-visible changes.
    3   28 July 2010
     3  10 June 2016
    44
    55See the end of this file for copyrights and conditions.
     
    1111
    1212
    13 Version 3.82
     13Version 4.2.1 (10 Jun 2016)
     14
     15A complete list of bugs fixed in this version is available here:
     16h
     17ttp://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=107&set=custom
     18
     19This release is a bug-fix release.
     20
     21
     22
     23Version 4.2 (22 May 2016)
     24
     25A complete list of bugs fixed in this version is available here:
     26
     27http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=106&set=custom
     28
     29* New variable: $(.SHELLSTATUS) is set to the exit status of the last != or
     30  $(shell ...) function invoked in this instance of make.  This will be "0" if
     31  successful or not "0" if not successful.  The variable value is unset if no
     32  != or $(shell ...) function has been invoked.
     33
     34* The $(file ...) function can now read from a file with $(file <FILE).
     35  The function is expanded to the contents of the file.  The contents are
     36  expanded verbatim except that the final newline, if any, is stripped.
     37
     38* The makefile line numbers shown by GNU make now point directly to the
     39  specific line in the recipe where the failure or warning occurred.
     40  Sample changes suggested by Brian Vandenberg <phantall@gmail.com>
     41
     42* The interface to GNU make's "jobserver" is stable as documented in the
     43  manual, for tools which may want to access it.
     44
     45  WARNING: Backward-incompatibility! The internal-only command line option
     46  --jobserver-fds has been renamed for publishing, to --jobserver-auth.
     47
     48* The amount of parallelism can be determined by querying MAKEFLAGS, even when
     49  the job server is enabled (previously MAKEFLAGS would always contain only
     50  "-j", with no number, when job server was enabled).
     51
     52* VMS-specific changes:
     53
     54  * Perl test harness now works.
     55
     56  * Full support for converting Unix exit status codes to VMS exit status
     57    codes.  BACKWARD INCOMPATIBILITY Notice: On a child failure the VMS exit
     58    code is now the encoded Unix exit status that Make usually generates, not
     59    the VMS exit status of the child.
     60
     61
     62
     63Version 4.1 (05 Oct 2014)
     64
     65A complete list of bugs fixed in this version is available here:
     66
     67http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=105&set=custom
     68
     69* New variables: $(MAKE_TERMOUT) and $(MAKE_TERMERR) are set to non-empty
     70  values if stdout or stderr, respectively, are believed to be writing to a
     71  terminal.  These variables are exported by default.
     72
     73* Allow a no-text-argument form of the $(file ...) function.  Without a text
     74  argument nothing is written to the file: it is simply opened in the
     75  requested mode, then closed again.
     76
     77* Change the fatal error for mixed explicit and implicit rules, that was
     78  introduced in GNU make 3.82, to a non-fatal error.  However, this syntax is
     79  still deprecated and may return to being illegal in a future version of GNU
     80  make.  Makefiles that rely on this syntax should be fixed.
     81  See https://savannah.gnu.org/bugs/?33034
     82
     83* VMS-specific changes:
     84
     85  * Support for library files added, including support for using the GNV ar
     86    utility.
     87
     88  * Partial support for properly encoding Unix exit status codes into VMS exit
     89    status codes.
     90
     91    WARNING: Backward-incompatibility! These are different exit status codes
     92    than Make exited with in the past.
     93
     94  * Macros to hold the current make command are set up to translate the
     95    argv[0] string to a VMS format path name and prefix it with "MCR " so that
     96    the macro has a space in it.
     97
     98    WARNING: Backward-incompatibility!  This may break complex makefiles that
     99    do processing on those macros.  This is unlikely because so much in that
     100    area was not and is still not currently working on VMS, it is unlikely to
     101    find such a complex makefile, so this is more likely to impact
     102    construction of a future makefile.
     103
     104  * A command file is always used to run the commands for a recipe.
     105
     106    WARNING: Backward-incompatibility!  Running the make self tests has
     107    exposed that there are significant differences in behavior when running
     108    with the command file mode.  It is unknown if this will be noticed by most
     109    existing VMS makefiles.
     110
     111
     112Version 4.0 (09 Oct 2013)
     113
     114A complete list of bugs fixed in this version is available here:
     115
     116http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=101&set=custom
     117
     118* WARNING: Backward-incompatibility!
     119  If .POSIX is specified, then make adheres to the POSIX backslash/newline
     120  handling requirements, which introduces the following changes to the
     121  standard backslash/newline handling in non-recipe lines:
     122  * Any trailing space before the backslash is preserved
     123  * Each backslash/newline (plus subsequent whitespace) is converted to a
     124    single space
     125
     126* New feature: GNU Guile integration
     127  This version of GNU make can be compiled with GNU Guile integration.
     128  GNU Guile serves as an embedded extension language for make.
     129  See the "Guile Function" section in the GNU Make manual for details.
     130  Currently GNU Guile 1.8 and 2.0+ are supported.  In Guile 1.8 there is no
     131  support for internationalized character sets.  In Guile 2.0+, scripts can be
     132  encoded in UTF-8.
     133
     134* New command line option: --output-sync (-O) enables grouping of output by
     135  target or by recursive make.  This is useful during parallel builds to avoid
     136  mixing output from different jobs together giving hard-to-understand
     137  results.  Original implementation by David Boyce <dsb@boyski.com>.
     138  Reworked and enhanced by Frank Heckenbach <f.heckenbach@fh-soft.de>.
     139  Windows support by Eli Zaretskii <eliz@gnu.org>.
     140
     141* New command line option: --trace enables tracing of targets.  When enabled
     142  the recipe to be invoked is printed even if it would otherwise be suppressed
     143  by .SILENT or a "@" prefix character.  Also before each recipe is run the
     144  makefile name and linenumber where it was defined are shown as well as the
     145  prerequisites that caused the target to be considered out of date.
     146
     147* New command line option argument: --debug now accepts a "n" (none) flag
     148  which disables all debugging settings that are currently enabled.
     149
     150* New feature: The "job server" capability is now supported on Windows.
     151  Implementation contributed by Troy Runkel <Troy.Runkel@mathworks.com>
     152
     153* New feature: The .ONESHELL capability is now supported on Windows.  Support
     154  added by Eli Zaretskii <eliz@gnu.org>.
     155
     156* New feature: "!=" shell assignment operator as an alternative to the
     157  $(shell ...) function.  Implemented for compatibility with BSD makefiles.
     158  Note there are subtle differences between "!=" and $(shell ...).  See the
     159  description in the GNU make manual.
     160  WARNING: Backward-incompatibility!
     161  Variables ending in "!" previously defined as "variable!= value" will now be
     162  interpreted as shell assignment.  Change your assignment to add whitespace
     163  between the "!" and "=": "variable! = value"
     164
     165* New feature: "::=" simple assignment operator as defined by POSIX in 2012.
     166  This operator has identical functionality to ":=" in GNU make, but will be
     167  portable to any implementation of make conforming to a sufficiently new
     168  version of POSIX (see http://austingroupbugs.net/view.php?id=330).  It is
     169  not necessary to define the .POSIX target to access this operator.
     170
     171* New feature: Loadable objects
     172  This version of GNU make contains a "technology preview": the ability to
     173  load dynamic objects into the make runtime.  These objects can be created by
     174  the user and can add extended functionality, usable by makefiles.
     175
     176* New function: $(file ...) writes to a file.
     177
     178* New variable: $(GNUMAKEFLAGS) will be parsed for make flags, just like
     179  MAKEFLAGS is.  It can be set in the environment or the makefile, containing
     180  GNU make-specific flags to allow your makefile to be portable to other
     181  versions of make.  Once this variable is parsed, GNU make will set it to the
     182  empty string so that flags will not be duplicated on recursion.
     183
     184* New variable: `MAKE_HOST' gives the name of the host architecture
     185  make was compiled for.  This is the same value you see after 'Built for'
     186  when running 'make --version'.
     187
     188* Behavior of MAKEFLAGS and MFLAGS is more rigorously defined.  All simple
     189  flags are grouped together in the first word of MAKEFLAGS.  No options that
     190  accept arguments appear in the first word.  If no simple flags are present
     191  MAKEFLAGS begins with a space.  Flags with both short and long versions
     192  always use the short versions in MAKEFLAGS.  Flags are listed in
     193  alphabetical order using ASCII ordering.  MFLAGS never begins with "- ".
     194
     195* Setting the -r and -R options in MAKEFLAGS inside a makefile now works as
     196  expected, removing all built-in rules and variables, respectively.
     197
     198* If a recipe fails, the makefile name and linenumber of the recipe are shown.
     199
     200* A .RECIPEPREFIX setting is remembered per-recipe and variables expanded
     201  in that recipe also use that recipe prefix setting.
     202
     203* In -p output, .RECIPEPREFIX settings are shown and all target-specific
     204  variables are output as if in a makefile, instead of as comments.
     205
     206* On MS-Windows, recipes that use ".." quoting will no longer force
     207  invocation of commands via temporary batch files and stock Windows
     208  shells, they will be short-circuited and invoked directly.  (In
     209  other words, " is no longer a special character for stock Windows
     210  shells.)  This avoids hitting shell limits for command length when
     211  quotes are used, but nothing else in the command requires the shell.
     212  This change could potentially mean some minor incompatibilities in
     213  behavior when the recipe uses quoted string on shell command lines.
     214
     215
     216
     217Version 3.82 (28 Jul 2010)
    14218
    15219A complete list of bugs fixed in this version is available here:
     
    19223* Compiling GNU make now requires a conforming ISO C 1989 compiler and
    20224  standard runtime library.
    21 
    22 * WARNING: Future backward-incompatibility!
    23   Wildcards are not documented as returning sorted values, but up to and
    24   including this release the results have been sorted and some makefiles are
    25   apparently depending on that.  In the next release of GNU make, for
    26   performance reasons, we may remove that sorting.  If your makefiles
    27   require sorted results from wildcard expansions, use the $(sort ...)
    28   function to request it explicitly.
    29225
    30226* WARNING: Backward-incompatibility!
     
    44240
    45241* WARNING: Backward-incompatibility!
     242  Wildcards were not documented as returning sorted values, but the results
     243  have been sorted up until this release..  If your makefiles require sorted
     244  results from wildcard expansions, use the $(sort ...)  function to request
     245  it explicitly.
     246
     247* WARNING: Backward-incompatibility!
    46248  As a result of parser enhancements, three backward-compatibility issues
    47249  exist: first, a prerequisite containing an "=" cannot be escaped with a
     
    116318  multi-line variable assignment.
    117319
    118 
    119 
    120 Version 3.81
     320* VMS-specific changes:
     321
     322  * Michael Gehre (at VISTEC-SEMI dot COM) supplied a fix for a problem with
     323    timestamps of object modules in OLBs. The timestamps were not correctly
     324    adjusted to GMT based time, if the local VMS time was using a daylight
     325    saving algorithm and if daylight saving was switched off.
     326
     327  * John Eisenbraun (at HP dot COM) supplied fixes and and an enhancement to
     328    append output redirection in action lines.
     329
     330  * Rework of ctrl+c and ctrl+y handling.
     331
     332  * Fix a problem with cached strings, which showed on case-insensitive file
     333    systems.
     334
     335  * Build fixes for const-ified code in VMS specific sources.
     336
     337  * A note on appending the redirected output. With this change, a simple
     338    mechanism is implemented to make ">>" work in action lines. In VMS
     339    there is no simple feature like ">>" to have DCL command or program
     340    output redirected and appended to a file. GNU make for VMS already
     341    implements the redirection of output. If such a redirection is detected,
     342    an ">" on the action line, GNU make creates a DCL command procedure to
     343    execute the action and to redirect its output. Based on that, now ">>"
     344    is also recognized and a similar but different command procedure is
     345    created to implement the append. The main idea here is to create a
     346    temporary file which collects the output and which is appended to the
     347    wanted output file. Then the temporary file is deleted. This is all done
     348    in the command procedure to keep changes in make small and simple. This
     349    obviously has some limitations but it seems good enough compared with
     350    the current ">" implementation. (And in my opinion, redirection is not
     351    really what GNU make has to do.) With this approach, it may happen that
     352    the temporary file is not yet appended and is left in SYS$SCRATCH.
     353    The temporary file names look like "CMDxxxxx.". Any time the created
     354    command procedure can not complete, this happens. Pressing Ctrl+Y to
     355    abort make is one case. In case of Ctrl+Y the associated command
     356    procedure is left in SYS$SCRATCH as well. Its name is CMDxxxxx.COM.
     357
     358  * Change in the Ctrl+Y handling. The CtrlY handler now uses $delprc to
     359    delete all children. This way also actions with DCL commands will be
     360    stopped. As before the CtrlY handler then sends SIGQUIT to itself,
     361    which is handled in common code.
     362
     363  * Change in deleteing temporary command files. Temporary command files
     364    are now deleted in the vms child termination handler. That deletes
     365    them even if a Ctrl+C was pressed.
     366
     367  * The behavior of pressing Ctrl+C is not changed. It still has only an
     368    effect, after the current action is terminated. If that doesn't happen
     369    or takes too long, Ctrl+Y should be used instead.
     370
     371
     372
     373Version 3.81 (01 Apr 2006)
    121374
    122375* GNU make is ported to OS/2.
     
    131384  might have caused the target to rebuild.  Starting with the _next_
    132385  release of GNU make, '$?' will contain all prerequisites that caused
    133   the target to be considered out of date.  See this Savannah bug:
    134   http://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=16051
     386  the target to be considered out of date.
     387  See http://savannah.gnu.org/bugs/?16051
    135388
    136389* WARNING: Backward-incompatibility!
     
    241494
    242495* On VMS there is now support for case-sensitive filesystems such as ODS5.
    243   See the readme.vms file for information.
     496  See the README.VMS file for information.
    244497
    245498* Parallel builds (-jN) no longer require a working Bourne shell on
     
    260513
    261514
    262 Version 3.80
     515Version 3.80 (03 Oct 2002)
    263516
    264517* A new feature exists: order-only prerequisites.  These prerequisites
     
    337590* Updated to autoconf 2.54 and automake 1.7.  Users should not be impacted.
    338591
     592* VMS-specific changes:
     593
     594  * In default.c define variable ARCH as IA64 for VMS on Itanium systems.
     595
     596  * In makefile.vms avoid name collision for glob and globfree.
     597
     598  * This is the VMS port of GNU Make done by Hartmut.Becker@compaq.com.
     599
     600    It is based on the specific version 3.77k and on 3.78.1. 3.77k was done
     601    by Klaus Kämpf <kkaempf@rmi.de>, the code was based on the VMS port of
     602    GNU Make 3.60 by Mike Moretti.
     603
     604    It was ported on OpenVMS/Alpha V7.1, DECC V5.7-006. It was re-build and
     605    tested on OpenVMS/Alpha V7.2, OpenVMS/VAX 7.1 and 5.5-2. Different
     606    versions of DECC were used. VAXC was tried: it fails; but it doesn't
     607    seem worth to get it working. There are still some PTRMISMATCH warnings
     608    during the compile. Although perl is working on VMS the test scripts
     609    don't work. The function $shell is still missing.
     610
     611    There is a known bug in some of the VMS CRTLs. It is in the shipped
     612    versions of VMS V7.2 and V7.2-1 and in the currently (October 1999)
     613    available ECOs for VMS V7.1 and newer versions. It is fixed in versions
     614    shipped with newer VMS versions and all ECO kits after October 1999. It
     615    only shows up during the daylight saving time period (DST): stat()
     616    returns a modification time 1 hour ahead. This results in GNU make
     617    warning messages. For a just created source you will see:
     618
     619     $ gmake x.exe
     620     gmake.exe;1: *** Warning: File 'x.c' has modification time in the future
     621     (940582863 > 940579269)
     622     cc    /obj=x.obj x.c
     623     link  x.obj    /exe=x.exe
     624     gmake.exe;1: *** Warning:  Clock skew detected.  Your build may be
     625     incomplete.
     626
     627
    339628A complete list of bugs fixed in this version is available here:
    340629
     
    343632
    344633
    345 Version 3.79.1
     634Version 3.79.1 (23 Jun 2000)
    346635
    347636* .SECONDARY with no prerequisites now prevents any target from being
     
    353642
    354643
    355 Version 3.79
     644Version 3.79 (04 Apr 2000)
    356645
    357646* GNU make optionally supports internationalization and locales via the
     
    394683
    395684* Hartmut Becker provided many updates for the VMS port of GNU make.
    396   See the readme.vms file for more details.
    397 
    398 
    399 Version 3.78
     685  See the README.VMS file for more details.
     686
     687* VMS-specific changes:
     688
     689  * Fix a problem with automatically remaking makefiles. GNU make uses an
     690    execve to restart itself after a successful remake of the makefile. On
     691    UNIX systems execve replaces the running program with a new one and
     692    resets all signal handling to the default. On VMS execve creates a child
     693    process, signal and exit handlers of the parent are still active, and,
     694    unfortunately, corrupt the exit code from the child. Fix in job.c:
     695    ignore SIGCHLD.
     696
     697  * Added some switches to reflect latest features of DECC. Modifications in
     698    makefile.vms.
     699
     700  * Set some definitions to reflect latest features of DECC. Modifications in
     701    config.h-vms (which is copied to config.h).
     702
     703  * Added extern strcmpi declaration to avoid 'implicitly declared' messages.
     704    Modification in make.h.
     705
     706  * Default rule for C++, conditionals for gcc (GCC_IS_NATIVE) or DEC/Digital/
     707    Compaq c/c++ compilers. Modifications in default.c.
     708
     709  * Usage of opendir() and friends, suppress file version. Modifications in
     710    dir.c.
     711
     712  * Added VMS specific code to handle ctrl+c and ctrl+y to abort make.
     713    Modifications in job.c.
     714
     715  * Added support to have case sensitive targets and dependencies but to
     716    still use case blind file names. This is especially useful for Java
     717    makefiles on VMS:
     718
     719        .SUFFIXES :
     720        .SUFFIXES : .class .java
     721        .java.class :
     722                javac "$<
     723        HelloWorld.class :      HelloWorld.java
     724
     725  * A new macro WANT_CASE_SENSITIVE_TARGETS in config.h-vms was introduced.
     726    It needs to be enabled to get this feature; default is disabled.  The
     727    macro HAVE_CASE_INSENSITIVE_FS must not be touched: it is still enabled.
     728    Modifications in file.c and config.h-vms.
     729
     730  * Bootstrap make to start building make is still makefile.com, but make
     731    needs to be re-made with a make to make a correct version: ignore all
     732    possible warnings, delete all objects, rename make.exe to a different
     733    name and run it.
     734
     735  * Made some minor modifications to the bootstrap build makefile.com.
     736
     737
     738Version 3.78 (22 Sep 1999)
    400739
    401740* Two new functions, $(error ...) and $(warning ...) are available.  The
     
    454793
    455794
    456 Version 3.77
     795Version 3.77 (28 Jul 1998)
    457796
    458797* Implement BSD make's "?=" variable assignment operator.  The variable
     
    500839  and to the DOS port from Eli Zaretski (see README.DOS).
    501840
    502 
    503 Version 3.76.1
     841* VMS-specific changes:
     842
     843  * This is the VMS port of GNU Make.
     844    It is based on the VMS port of GNU Make 3.60 by Mike Moretti.
     845    This port was done by Klaus Kämpf <kkaempf@rmi.de>
     846
     847  * There is first-level support available from proGIS Software, Germany.
     848    Visit their web-site at http://www.progis.de to get information
     849    about other vms software and forthcoming updates to gnu make.
     850
     851  * /bin/sh style I/O redirection is supported. You can now write lines like
     852        mcr sys$disk:[]program.exe < input.txt > output.txt &> error.txt
     853
     854  * Makefile variables are looked up in the current environment. You can set
     855    symbols or logicals in DCL and evaluate them in the Makefile via
     856    $(<name-of-symbol-or-logical>).  Variables defined in the Makefile
     857    override VMS symbols/logicals !
     858
     859  * Functions for file names are working now. See the GNU Make manual for
     860    $(dir ...)  and $(wildcard ...).  Unix-style and VMS-style names are
     861    supported as arguments.
     862
     863  * The default rules are set up for GNU C. Building an executable from a
     864    single source file is as easy as 'make file.exe'.
     865
     866  * The variable $(ARCH) is predefined as ALPHA or VAX resp. Makefiles for
     867    different VMS systems can now be written by checking $(ARCH) as in
     868      ifeq ($(ARCH),ALPHA)
     869        $(ECHO) "On the Alpha"
     870      else
     871        $(ECHO) "On the VAX"
     872      endif
     873
     874  * Command lines of excessive length are correctly broken and written to a
     875    batch file in sys$scratch for later execution. There's no limit to the
     876    lengths of commands (and no need for .opt files :-) any more.
     877
     878  * Empty commands are handled correctly and don't end in a new DCL process.
     879
     880
     881Version 3.76.1 (19 Sep 1997)
    504882
    505883* Small (but serious) bug fix.  Quick rollout to get into the GNU source CD.
    506884
    507885
    508 Version 3.76
     886Version 3.76 (16 Sep 1997)
    509887
    510888* GNU make now uses automake to control Makefile.in generation.  This
     
    549927  Delorie <dj@delorie.com>.
    550928
    551 * John W. Eaton has updated the VMS port to support libraries and VPATH.
    552 
    553 
    554 Version 3.75
     929* VMS-specific changes:
     930
     931  * John W. Eaton has updated the VMS port to support libraries and VPATH.
     932
     933  * The cd command is supported if it's called as $(CD). This invokes
     934    the 'builtin_cd' command which changes the directory.
     935    Calling 'set def' doesn't do the trick, since a sub-shell is
     936    spawned for this command, the directory is changed *in this sub-shell*
     937    and the sub-shell ends.
     938
     939  * Libraries are not supported. They were in GNU Make 3.60 but somehow I
     940    didn't care porting the code. If there is enough interest, I'll do it at
     941    some later time.
     942
     943  * The variable $^ separates files with commas instead of spaces (It's the
     944    natural thing to do for VMS).
     945
     946  * See defaults.c for VMS default suffixes and my definitions for default
     947    rules and variables.
     948
     949  * The shell function is not implemented yet.
     950
     951  * Load average routines haven't been implemented for VMS yet.
     952
     953  * The default include directory for including other makefiles is
     954    SYS$SYSROOT:[SYSLIB] (I don't remember why I didn't just use
     955    SYS$LIBRARY: instead; maybe it wouldn't work that way).
     956
     957  * The default makefiles make looks for are: makefile.vms, gnumakefile,
     958    makefile., and gnumakefile. .
     959
     960  * The stat() function and handling of time stamps in VMS is broken, so I
     961    replaced it with a hack in vmsfunctions.c. I will provide a full rewrite
     962    somewhere in the future. Be warned, the time resolution inside make is
     963    less than what vms provides. This might be a problem on the faster Alphas.
     964
     965  * You can use a : in a filename only if you precede it with a backslash ('\').
     966    E.g.- hobbes\:[bogas.files]
     967
     968  * Make ignores success, informational, or warning errors (-S-, -I-, or -W-).
     969    But it will stop on -E- and -F- errors. (unless you do something
     970    to override this in your makefile, or whatever).
     971
     972  * Remote stuff isn't implemented yet.
     973
     974  * Multiple line DCL commands, such as "if" statements, must be put inside
     975    command files.  You can run a command file by using \@.
     976
     977Version 3.75 (27 Aug 1996)
    555978
    556979* The directory messages printed by `-w' and implicitly in sub-makes,
     
    573996  <rob_tulloh@tivoli.com>.
    574997
    575 
    576 Version 3.73
     998* VMS-specific changes:
     999
     1000  * Lots of default settings are adapted for VMS. See default.c.
     1001
     1002  * Long command lines are now converted to command files.
     1003
     1004  * Comma (',') as a separator is now allowed. See makefile.vms for an example.
     1005
     1006
     1007Version 3.73 (05 Apr 1995)
    5771008
    5781009* Converted to use Autoconf version 2, so `configure' has some new options.
     
    5831014
    5841015
    585 Version 3.72
     1016Version 3.72 (04 Nov 1994)
    5861017
    5871018* DJ Delorie has ported Make to MS-DOS using the GO32 extender.
     
    6181049
    6191050
    620 Version 3.71
     1051Version 3.71 (21 May 1994)
    6211052
    6221053* The automatic variables `$(@D)', `$(%D)', `$(*D)', `$(<D)', `$(?D)', and
     
    6411072
    6421073
    643 Version 3.70
     1074Version 3.70 (03 Jan 1994)
    6441075
    6451076* It is no longer a fatal error to have a NUL character in a makefile.
     
    6531084
    6541085
    655 Version 3.69
     1086Version 3.69 (07 Nov 1993)
    6561087
    6571088* Implicit rule search for archive member references is now done in the
     
    6721103  cause a paradoxical situation in cases like:
    6731104
    674         export variable = $(shell echo value)
     1105        export variable = $(shell echo value)
    6751106
    6761107  When Make attempted to put this variable in the environment for a
     
    6841115
    6851116
    686 Version 3.68
     1117Version 3.68 (28 Jul 1993)
    6871118
    6881119* You can list several archive member names inside parenthesis:
     
    6961127
    6971128* A suffix rule `.X.a' now produces two pattern rules:
    698         (%.o): %.X      # Previous versions produced only this.
    699         %.a: %.X        # Now produces this as well, just like other suffixes.
     1129        (%.o): %.X      # Previous versions produced only this.
     1130        %.a: %.X        # Now produces this as well, just like other suffixes.
    7001131
    7011132* The new flag `--warn-undefined-variables' says to issue a warning message
     
    7111142
    7121143
    713 Version 3.66
     1144Version 3.66 (21 May 1993)
    7141145
    7151146* `make --version' (or `make -v') now exits immediately after printing
     
    7171148
    7181149
    719 Version 3.65
     1150Version 3.65 (09 May 1993)
    7201151
    7211152* Make now supports long-named members in `ar' archive files.
    7221153
    7231154
    724 Version 3.64
     1155Version 3.64 (21 Apr 1993)
    7251156
    7261157* Make now supports the `+=' syntax for a variable definition which appends
     
    7371168
    7381169
    739 Version 3.63
     1170Version 3.63 (22 Jan 1993)
    7401171
    7411172* Make now uses a standard GNU `configure' script.  See the new file
     
    7711202  Make runs.  Instead, only variables specified on the command line or in
    7721203  the environment are exported by default.  To export others, use:
    773         export VARIABLE
     1204        export VARIABLE
    7741205  or you can define variables with:
    775         export VARIABLE = VALUE
     1206        export VARIABLE = VALUE
    7761207  or:
    777         export VARIABLE := VALUE
     1208        export VARIABLE := VALUE
    7781209  You can use just:
    779         export
     1210        export
    7801211  or:
    781         .EXPORT_ALL_VARIABLES:
     1212        .EXPORT_ALL_VARIABLES:
    7821213  to get the old behavior.  See the node `Variables/Recursion' in the manual
    7831214  for a full description.
     
    7991230* A single `include' directive can now specify more than one makefile to
    8001231  include, like this:
    801         include file1 file2
     1232        include file1 file2
    8021233  You can also use shell file name patterns in an `include' directive:
    803         include *.mk
     1234        include *.mk
    8041235
    8051236* The default directories to search for included makefiles, and for
     
    9461377
    9471378* Messages indicating failed recipe lines now contain the target name:
    948         make: *** [target] Error 1
     1379        make: *** [target] Error 1
    9491380
    9501381* The `-p' output format has been changed somewhat to look more like
     
    11501581
    11511582-------------------------------------------------------------------------------
    1152 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    1153 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    1154 2010 Free Software Foundation, Inc.  This file is part of GNU Make.
     1583Copyright (C) 1988-2016 Free Software Foundation, Inc.
     1584This file is part of GNU Make.
    11551585
    11561586GNU Make is free software; you can redistribute it and/or modify it under the
  • vendor/gnumake/current/NMakefile.template

    r2596 r3138  
    44# run 'build_w32.bat' instead.
    55#
    6 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    7 # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     6# Copyright (C) 1996-2016 Free Software Foundation, Inc.
    87# This file is part of GNU Make.
    98#
     
    3433
    3534LDFLAGS_debug = w32\subproc\WinDebug\subproc.lib /NOLOGO /SUBSYSTEM:console\
    36         /INCREMENTAL:no /PDB:WinDebug/make.pdb /OUT:WinDebug/make.exe /DEBUG
     35        /STACK:0x400000 /INCREMENTAL:no /PDB:WinDebug/make.pdb /OUT:WinDebug/make.exe /DEBUG
    3736LDFLAGS_release = w32\subproc\WinRel\subproc.lib /NOLOGO /SUBSYSTEM:console\
    38         /INCREMENTAL:no /OUT:WinRel/make.exe
     37        /STACK:0x400000 /INCREMENTAL:no /OUT:WinRel/make.exe
    3938
    4039all: config.h subproc Release Debug
     
    7473LIBS = kernel32.lib user32.lib advapi32.lib
    7574
     75guile = $(OUTDIR)/guile.obj
     76
    7677OBJS = \
    7778        $(OUTDIR)/ar.obj \
     
    8990        $(OUTDIR)/implicit.obj \
    9091        $(OUTDIR)/job.obj \
     92        $(OUTDIR)/load.obj \
    9193        $(OUTDIR)/main.obj \
    9294        $(OUTDIR)/misc.obj \
     95        $(OUTDIR)/output.obj \
    9396        $(OUTDIR)/read.obj \
    9497        $(OUTDIR)/remake.obj \
     
    103106        $(OUTDIR)/fnmatch.obj \
    104107        $(OUTDIR)/dirent.obj \
    105         $(OUTDIR)/pathstuff.obj
     108        $(OUTDIR)/pathstuff.obj \
     109        $(OUTDIR)/posixfcn.obj \
     110        $(OUTDIR)/w32os.obj \
     111        $(guile)
    106112
    107113$(OUTDIR)/make.exe: $(OUTDIR) $(OBJS)
     
    119125$(OUTDIR)/dirent.obj : w32/compat/dirent.c
    120126        $(CC) $(CFLAGS) /c $?
     127$(OUTDIR)/posixfcn.obj : w32/compat/posixfcn.c
     128        $(CC) $(CFLAGS) /c $?
    121129$(OUTDIR)/pathstuff.obj : w32/pathstuff.c
    122130        $(CC) $(CFLAGS) /c $?
     131$(OUTDIR)/w32os.obj : w32/w32os.c
     132        $(CC) $(CFLAGS) /c $?
  • vendor/gnumake/current/README.Amiga

    r2596 r3138  
    1212- Allows to use Device-Names in targets:
    1313
    14         c:make : make.o
     14        c:make : make.o
    1515
    1616    is ok. To distinguish between device-names and target : or ::, MAKE
     
    2020- Replaces @@ by a newline in any command line:
    2121
    22         if exists make @@\
    23             delete make.bak quiet @@\
    24             rename make make.bak @@\
    25         endif @@\
    26         $(CC) Link Make.o To make
     22        if exists make @@\
     23            delete make.bak quiet @@\
     24            rename make make.bak @@\
     25        endif @@\
     26        $(CC) Link Make.o To make
    2727
    28     works. Note that the @@ must stand alone (ie. "make@@\" is illegal).
    29     Also be carefull that there is a space after the "\" (ie, at the
     28    works. Note that the @@ must stand alone (i.e., "make@@\" is illegal).
     29    Also be careful that there is a space after the "\" (i.e., at the
    3030    beginning of the next line).
    3131- Can be made resident to save space and time
     
    3737    dummy.h : src/*.c
    3838
    39 tries to make dummy.h from "src/*.c" (ie. no wildcard-expansion takes
     39tries to make dummy.h from "src/*.c" (i.e., no wildcard-expansion takes
    4040place). You have to use "$(wildcard src/*.c)" instead.
    4141
     
    4343----------------------
    4444
    45 To recompile, you need SAS/C 6.51. make itself is not neccessary, there
     45To recompile, you need SAS/C 6.51. make itself is not necessary, there
    4646is an smakefile.
    4747
    48481. Copy config.ami to config.h
    49 2. If you use make to compie, copy Makefile.ami to Makefile and
     492. If you use make to compile, copy Makefile.ami to Makefile and
    5050    glob/Makefile.ami to glob/Makefile. Copy make into the current
    5151    directory.
     
    5555INSTALLATION
    5656
    57 Copy make somewhere in your search path (eg. sc:c or sc:bin).
     57Copy make somewhere in your search path (e.g., sc:c or sc:bin).
    5858If you plan to use recursive makes, install make resident:
    5959
     
    6363
    6464-------------------------------------------------------------------------------
    65 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    66 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     65Copyright (C) 1995-2016 Free Software Foundation, Inc.
    6766This file is part of GNU Make.
    6867
  • vendor/gnumake/current/README.DOS.template

    r2596 r3138  
    99
    1010   2. Supports both stock DOS COMMAND.COM and Unix-style shells
    11       (details in ``Notes'' below).
     11      (details in 'Notes' below).
    1212
    1313   3. Supports DOS drive letters in dependencies and pattern rules.
    1414
    1515   4. Better support for DOS-style backslashes in pathnames (but see
    16       ``Notes'' below).
     16      'Notes' below).
    1717
    1818   5. The $(shell) built-in can run arbitrary complex commands,
     
    5656      environment), or the DJGPP port of GNU Tar.
    5757
    58    2. Invoke the `configure.bat' batch file.
     58   2. Invoke the 'configure.bat' batch file.
    5959
    6060      If you are building Make in-place, i.e. in the same directory
     
    6363      directory as an argument to the batch file, like this:
    6464
    65         c:\djgpp\gnu\make-%VERSION%\configure.bat c:/djgpp/gnu/make-%VERSION%
     65        c:\djgpp\gnu\make-%VERSION%\configure.bat c:/djgpp/gnu/make-%VERSION%
    6666
    6767      Note the forward slashes in the source path argument: you MUST
     
    6969
    7070   3. If configure.bat doesn't find a working Make, it will suggest to
    71       use the `dosbuild.bat' batch file to build Make.  Either do as it
     71      use the 'dosbuild.bat' batch file to build Make.  Either do as it
    7272      suggests or install another Make program (a pre-compiled binary
    7373      should be available from the usual DJGPP sites) and rerun
     
    8585      need to tell Make where the sources are, like this:
    8686
    87                 make srcdir=c:/djgpp/gnu/make-%VERSION%
     87                make srcdir=c:/djgpp/gnu/make-%VERSION%
    8888
    8989      (configure.bat will tell you this when it finishes).  You MUST
     
    9292
    9393   6. After Make finishes, if you have a Unix-style shell installed,
    94       you can use the `install' target to install the package.  You
     94      you can use the 'install' target to install the package.  You
    9595      will also need GNU Fileutils and GNU Sed for this (they should
    9696      be available from the DJGPP sites).
     
    100100      DESTDIR variable when invoking "make install", like this:
    101101
    102                 make install DESTDIR=c:/other/dir
     102                make install DESTDIR=c:/other/dir
    103103
    104104      This causes the make executable to be placed in c:/other/dir/bin,
     
    108108      and the docs manually.  Copy make.exe to a directory on your
    109109      PATH, make.i* info files to your Info directory, and update the
    110       file `dir' in your Info directory by adding the following item
     110      file 'dir' in your Info directory by adding the following item
    111111      to the main menu:
    112112
    113         * Make: (make.info).           The GNU make utility.
    114 
    115       If you have the `install-info' program (from the GNU Texinfo
     113        * Make: (make.info).           The GNU make utility.
     114
     115      If you have the 'install-info' program (from the GNU Texinfo
    116116      package), it will do that for you if you invoke it like this:
    117117
    118         install-info --info-dir=c:/djgpp/info c:/djgpp/info/make.info
     118        install-info --info-dir=c:/djgpp/info c:/djgpp/info/make.info
    119119
    120120      (If your Info directory is other than C:\DJGPP\INFO, change this
    121121      command accordingly.)
    122122
    123    7. The `clean' targets also require Unix-style shell, and GNU Sed
    124       and `rm' programs (the latter from Fileutils).
     123   7. The 'clean' targets also require Unix-style shell, and GNU Sed
     124      and 'rm' programs (the latter from Fileutils).
    125125
    126126   8. To run the test suite, type "make check".  This requires a Unix
     
    145145      This port supports both DOS shells (the stock COMMAND.COM and its
    146146      4DOS/NDOS replacements), and Unix-style shells (tested with the
    147       venerable Stewartson's `ms_sh' 2.3 and the DJGPP port of `bash' by
     147      venerable Stewartson's 'ms_sh' 2.3 and the DJGPP port of 'bash' by
    148148      Daisuke Aoyama <jack@st.rim.or.jp>).
    149149
     
    167167      batch file or a command internal to the shell is invoked.  (Even
    168168      when a command is an internal shell command, Make will first
    169       search the $PATH for it, so that if a Makefile calls `mkdir',
    170       you can install, say, a port of GNU `mkdir' and have it called
     169      search the $PATH for it, so that if a Makefile calls 'mkdir',
     170      you can install, say, a port of GNU 'mkdir' and have it called
    171171      in that case.)
    172172
    173       The key to all this is the extended functionality of `spawn' and
    174       `system' functions from the DJGPP library; this port just calls
    175       `system' where it would invoke the shell on Unix.  The most
     173      The key to all this is the extended functionality of 'spawn' and
     174      'system' functions from the DJGPP library; this port just calls
     175      'system' where it would invoke the shell on Unix.  The most
    176176      important aspect of these functions is that they use a special
    177177      mechanism to pass long (up to 16KB) command lines to DJGPP
    178       programs.  In addition, `system' emulates some internal
    179       commands, like `cd' (so that you can now use forward slashes
     178      programs.  In addition, 'system' emulates some internal
     179      commands, like 'cd' (so that you can now use forward slashes
    180180      with it, and can also change the drive if the directory is on
    181181      another drive).  Another aspect worth mentioning is that you can
     
    187187
    188188      The $(shell) built-in is implemented in this port by calling
    189       `popen'.  Since `popen' calls `system', the above considerations
     189      'popen'.  Since 'popen' calls 'system', the above considerations
    190190      are valid for $(shell) as well.  In particular, you can put
    191191      arbitrary complex commands, including pipes and redirection,
     
    198198      Many Unix Makefiles include a line which sets the SHELL, for
    199199      those versions of Make which don't have this as the default.
    200       Since many DOS systems don't have `sh' installed (in fact, most
    201       of them don't even have a `/bin' directory), this port takes
     200      Since many DOS systems don't have 'sh' installed (in fact, most
     201      of them don't even have a '/bin' directory), this port takes
    202202      such directives with a grain of salt.  It will only honor such a
    203       directive if the basename of the shell name (like `sh' in the
     203      directive if the basename of the shell name (like 'sh' in the
    204204      above example) can indeed be found in the directory that is
    205       mentioned in the SHELL= line (`/bin' in the above example), or
     205      mentioned in the SHELL= line ('/bin' in the above example), or
    206206      in the current working directory, or anywhere on the $PATH (in
    207207      that order).  If the basename doesn't include a filename
     
    238238      Makefiles to MSDOS and leave the line which sets the shell
    239239      intact, so that people who do have Unixy shell could use it for
    240       targets which aren't converted to DOS (like `install' and
    241       `uninstall', for example).
     240      targets which aren't converted to DOS (like 'install' and
     241      'uninstall', for example).
    242242
    243243
     
    259259      letter-case issue.  Make is internally case-sensitive, but all
    260260      file operations are case-insensitive on Windows 9x, so
    261       e.g. files `FAQ', `faq' and `Faq' all refer to the same file, as
     261      e.g. files 'FAQ', 'faq' and 'Faq' all refer to the same file, as
    262262      far as Windows is concerned.  The underlying DJGPP C library
    263263      functions honor the letter-case of the filenames they get from
     
    266266      many Makefiles otherwise.  (The details of which filenames are
    267267      converted to lower case are explained in the DJGPP libc docs,
    268       under the `_preserve_fncase' and `_lfn_gen_short_fname'
     268      under the '_preserve_fncase' and '_lfn_gen_short_fname'
    269269      functions, but as a thumb rule, any filename that is stored in
    270270      upper case in the directory, is a valid DOS 8+3 filename and
     
    283283      There are a lot of places throughout the program sources which
    284284      make implicit assumptions about the pathname syntax.  In
    285       particular, the directories are assumed to be separated by `/',
    286       and any pathname which doesn't begin with a `/' is assumed to be
     285      particular, the directories are assumed to be separated by '/',
     286      and any pathname which doesn't begin with a '/' is assumed to be
    287287      relative to the current directory.  This port attempts to
    288288      support DOS-style pathnames which might include the drive letter
     
    297297      are advised to stay away from backslashes whenever possible.  In
    298298      particular, filename globbing won't work on pathnames with
    299       backslashes, because the GNU `glob' library doesn't support them
     299      backslashes, because the GNU 'glob' library doesn't support them
    300300      (backslash is special in filename wildcards, and I didn't want
    301301      to break that).
     
    316316   group).  For other bugs, please follow the procedure explained in
    317317   the "Bugs" chapter of the Info docs.  If you don't have an Info
    318    reader, look up that chapter in the `make.i1' file with any text
     318   reader, look up that chapter in the 'make.i1' file with any text
    319319   browser/editor.
    320320
    321321
    322322   Enjoy,
    323                         Eli Zaretskii <eliz@is.elta.co.il>
     323                        Eli Zaretskii <eliz@is.elta.co.il>
    324324
    325325
    326326
    327327-------------------------------------------------------------------------------
    328 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    329 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     328Copyright (C) 1996-2016 Free Software Foundation, Inc.
    330329This file is part of GNU Make.
    331330
  • vendor/gnumake/current/README.OS2.template

    r2596 r3138  
    141141_getcwd2() are NOT used).  The testsuite interpretes the whole output of
    142142make, especially statements like make[1]: Entering directory
    143 `C:/somewhere/make-3.79.1/tests' where the testsuite does not expect the
     143'C:/somewhere/make-3.79.1/tests' where the testsuite does not expect the
    144144drive letter. This would be interpreted as an error even if there is
    145145none.
     
    162162
    163163-------------------------------------------------------------------------------
    164 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    165 Foundation, Inc.
     164Copyright (C) 2003-2016 Free Software Foundation, Inc.
    166165This file is part of GNU Make.
    167166
  • vendor/gnumake/current/README.W32.template

    r2596 r3138  
    1 This version of GNU make has been tested on Microsoft Windows 2000/XP/2003.
     1This version of GNU make has been tested on:
     2  Microsoft Windows 2000/XP/2003/Vista/7/8/10
    23It has also been used on Windows 95/98/NT, and on OS/2.
    34
    4 It builds with the MinGW port of GCC (tested with GCC 3.4.2).
    5 
    6 It also builds with MSVC 2.x, 4.x, 5.x, 6.x, and 2003 as well as
    7 with .NET 7.x and .NET 2003.
    8 
    9 The Windows 32-bit port of GNU make is maintained jointly by various
    10 people.  It was originally made by Rob Tulloh.
     5It builds with the MinGW port of GCC (tested with GCC 3.4.2, 4.8.1,
     6and 4.9.3).
     7
     8It also builds with MSVC 2.x, 4.x, 5.x, 6.x, 2003, and 14 (2015) as
     9well as with .NET 7.x and .NET 2003.
     10
     11As of version 4.0, a build with Guile is supported (tested with Guile
     122.0.3).  To build with Guile, you will need, in addition to Guile
     13itself, its dependency libraries and the pkg-config program.  The
     14latter is used to figure out which compilation and link switches and
     15libraries need to be mentioned on the compiler command lines to
     16correctly link with Guile.  A Windows port of pkg-config can be found
     17on ezwinports site:
     18
     19  http://sourceforge.net/projects/ezwinports/
     20
     21The libraries on which Guile depends can vary depending on your
     22version and build of Guile.  At the very least, the Boehm's GC library
     23will be needed, and typically also GNU MP, libffi, libunistring, and
     24libtool's libltdl.  Whoever built the port of Guile you have should
     25also provide you with these dependencies or a URL where to download
     26them.  A precompiled 32-bit Windows build of Guile is available from
     27the ezwinports site mentioned above.
     28
     29The Windows port of GNU make is maintained jointly by various people.
     30It was originally made by Rob Tulloh.
     31It is currently maintained by Eli Zaretskii.
    1132
    1233
     
    1435---------------------------------------------------------
    1536
    16  1. At the Windows command prompt run:
    17 
    18       if not exist NMakefile copy NMakefile.template NMakefile
    19       if not exist config.h copy config.h.W32 config.h
    20 
    21     Then edit config.h to your liking (especially the few shell-related
     37 1. Edit config.h.W32 to your liking (especially the few shell-related
    2238    defines near the end, or HAVE_CASE_INSENSITIVE_FS which corresponds
    23     to './configure --enable-case-insensitive-file-system').
     39    to './configure --enable-case-insensitive-file-system').  (We don't
     40    recommend to define HAVE_CASE_INSENSITIVE_FS, but you may wish to
     41    consider that if you have a lot of files whose names are in upper
     42    case, while Makefile rules are written for lower-case versions.)
    2443
    2544
     
    3857    correct PATH and other environment variables for it, then execute ...
    3958
    40         build_w32.bat gcc
    41 
    42     This produces gnumake.exe in the current directory.
     59        build_w32.bat gcc
     60
     61    This produces gnumake.exe in the GccRel directory.
     62    If you want a version of GNU make built with debugging enabled,
     63    add the --debug option.
     64
     65    The batch file will probe for Guile installation, and will build
     66    gnumake.exe with Guile if it finds it.  If you have Guile
     67    installed, but want to build Make without Guile support, type
     68
     69        build_w32.bat --without-guile gcc
    4370
    4471
     
    5279    menue entry from the cl-installation), then execute EITHER ...
    5380
    54         build_w32.bat
    55 
    56     (this produces WinDebug/gnumake.exe and WinRel/gnumake.exe)
     81        build_w32.bat
     82
     83    This produces gnumake.exe in the WinRel directory.
     84    If you want a version of GNU make built with debugging enabled,
     85    add the --debug option.
    5786
    5887    ... OR ...
    5988
    60         nmake /f NMakefile
     89        nmake /f NMakefile
    6190
    6291    (this produces WinDebug/make.exe and WinRel/make.exe).
    6392
     93    The batch file will probe for Guile installation, and will build
     94    gnumake.exe with Guile if it finds it.  If you have Guile
     95    installed, but want to build Make without Guile support, type
     96
     97        build_w32.bat --without-guile
    6498
    6599-------------------
     
    69103GNU make on Windows 32-bit platforms:
    70104
    71         This version of make is ported natively to Windows32 platforms
    72         (Windows NT 3.51, Windows NT 4.0, Windows 2000, Windows XP,
    73         Windows 95, and Windows 98). It does not rely on any 3rd party
    74         software or add-on packages for building. The only thing
    75         needed is a Windows compiler.  Two compilers supported
    76         officially are the MinGW port of GNU GCC, and the various
    77         versions of the Microsoft C compiler.
    78 
    79         Do not confuse this port of GNU make with other Windows32 projects
    80         which provide a GNU make binary. These are separate projects
    81         and are not connected to this port effort.
     105        This version of make is ported natively to Windows32 platforms
     106        (Windows NT 3.51, Windows NT 4.0, Windows 2000, Windows XP,
     107        Windows 95, and Windows 98). It does not rely on any 3rd party
     108        software or add-on packages for building. The only thing
     109        needed is a Windows compiler.  Two compilers supported
     110        officially are the MinGW port of GNU GCC, and the various
     111        versions of the Microsoft C compiler.
     112
     113        Do not confuse this port of GNU make with other Windows32 projects
     114        which provide a GNU make binary. These are separate projects
     115        and are not connected to this port effort.
    82116
    83117GNU make and sh.exe:
    84118
    85         This port prefers if you have a working sh.exe somewhere on
    86         your system. If you don't have sh.exe, the port falls back to
    87         MSDOS mode for launching programs (via a batch file).  The
    88         MSDOS mode style execution has not been tested that carefully
    89         though (The author uses GNU bash as sh.exe).
    90 
    91         There are very few true ports of Bourne shell for NT right now.
    92         There is a version of GNU bash available from Cygnus "Cygwin"
    93         porting effort (http://www.cygwin.com/).
    94         Other possibilities are the MKS version of sh.exe, or building
     119        This port prefers if you have a working sh.exe somewhere on
     120        your system. If you don't have sh.exe, the port falls back to
     121        MSDOS mode for launching programs (via a batch file).  The
     122        MSDOS mode style execution has not been tested that carefully
     123        though (The author uses GNU bash as sh.exe).
     124
     125        There are very few true ports of Bourne shell for NT right now.
     126        There is a version of GNU bash available from Cygnus "Cygwin"
     127        porting effort (http://www.cygwin.com/).
     128        Other possibilities are the MKS version of sh.exe, or building
    95129        your own with a package like NutCracker (DataFocus) or Portage
    96130        (Consensys).  Also MinGW includes sh (http://mingw.org/).
     
    98132GNU make and brain-dead shells (BATCH_MODE_ONLY_SHELL):
    99133
    100         Some versions of Bourne shell do not behave well when invoked
    101         as 'sh -c' from CreateProcess().  The main problem is they seem
    102         to have a hard time handling quoted strings correctly. This can
    103         be circumvented by writing commands to be executed to a batch
    104         file and then executing the command by calling 'sh file'.
    105 
    106         To work around this difficulty, this version of make supports
    107         a batch mode.  When BATCH_MODE_ONLY_SHELL is defined at compile
    108         time, make forces all command lines to be executed via script
    109         files instead of by command line.  In this mode you must have a
    110         working sh.exe in order to use parallel builds (-j).
    111 
    112         A native Windows32 system with no Bourne shell will also run
    113         in batch mode.  All command lines will be put into batch files
    114         and executed via $(COMSPEC) (%COMSPEC%).  However, parallel
    115         builds ARE supported with Windows shells (cmd.exe and
    116         command.com).  See the next section about some peculiarities
    117         of parallel builds on Windows.
     134        Some versions of Bourne shell do not behave well when invoked
     135        as 'sh -c' from CreateProcess().  The main problem is they seem
     136        to have a hard time handling quoted strings correctly. This can
     137        be circumvented by writing commands to be executed to a batch
     138        file and then executing the command by calling 'sh file'.
     139
     140        To work around this difficulty, this version of make supports
     141        a batch mode.  When BATCH_MODE_ONLY_SHELL is defined at compile
     142        time, make forces all command lines to be executed via script
     143        files instead of by command line.  In this mode you must have a
     144        working sh.exe in order to use parallel builds (-j).
     145
     146        A native Windows32 system with no Bourne shell will also run
     147        in batch mode.  All command lines will be put into batch files
     148        and executed via $(COMSPEC) (%COMSPEC%).  However, parallel
     149        builds ARE supported with Windows shells (cmd.exe and
     150        command.com).  See the next section about some peculiarities
     151        of parallel builds on Windows.
    118152
    119153Support for parallel builds
    120154
    121         Parallel builds (-jN) are supported in this port, with 2
    122         limitations:
    123 
    124           - The number of concurrent processes has a hard limit of 64,
    125             due to the way this port implements waiting for its
    126             subprocesses;
    127 
    128           - The job server method (available when Make runs on Posix
    129             platforms) is not supported, which means you must pass an
    130             explicit -jN switch to sub-Make's in a recursive Makefile.
    131             If a sub-Make does not receive an explicit -jN switch, it
    132             will default to -j1, i.e. no parallelism in sub-Make's.
     155        Parallel builds (-jN) are supported in this port, with 1
     156        limitation: The number of concurrent processes has a hard
     157        limit of 64, due to the way this port implements waiting for
     158        its subprocesses.
    133159
    134160GNU make and Cygnus GNU Windows32 tools:
    135161
    136         Good news! Make now has native support for Cygwin sh. To enable,
    137         define the HAVE_CYGWIN_SHELL in config.h and rebuild make
    138         from scratch. This version of make tested with B20.1 of Cygwin.
    139         Do not define BATCH_MODE_ONLY_SHELL if you use HAVE_CYGWIN_SHELL.
     162        Good news! Make now has native support for Cygwin sh. To enable,
     163        define the HAVE_CYGWIN_SHELL in config.h and rebuild make
     164        from scratch. This version of make tested with B20.1 of Cygwin.
     165        Do not define BATCH_MODE_ONLY_SHELL if you use HAVE_CYGWIN_SHELL.
    140166
    141167GNU make and the MKS shell:
    142168
    143         There is now semi-official support for the MKS shell. To turn this
    144         support on, define HAVE_MKS_SHELL in the config.h.W32 before you
    145         build make.  Do not define BATCH_MODE_ONLY_SHELL if you turn
    146         on HAVE_MKS_SHELL.
     169        There is now semi-official support for the MKS shell. To turn this
     170        support on, define HAVE_MKS_SHELL in the config.h.W32 before you
     171        build make.  Do not define BATCH_MODE_ONLY_SHELL if you turn
     172        on HAVE_MKS_SHELL.
    147173
    148174GNU make handling of drive letters in pathnames (PATH, vpath, VPATH):
    149175
    150         There is a caveat that should be noted with respect to handling
    151         single character pathnames on Windows systems.  When colon is
    152         used in PATH variables, make tries to be smart about knowing when
    153         you are using colon as a separator versus colon as a drive
    154         letter. Unfortunately, something as simple as the string 'x:/'
    155         could be interpreted 2 ways: (x and /) or (x:/).
    156 
    157         Make chooses to interpret a letter plus colon (e.g. x:/) as a
    158         drive letter pathname.  If it is necessary to use single
    159         character directories in paths (VPATH, vpath, Path, PATH), the
    160         user must do one of two things:
    161 
    162         a. Use semicolon as the separator to disambiguate colon. For
    163             example use 'x;/' if you want to say 'x' and '/' are
    164             separate components.
    165 
    166         b. Qualify the directory name so that there is more than
    167             one character in the path(s) used. For example, none
    168             of these settings are ambiguous:
    169 
    170               ./x:./y
    171               /some/path/x:/some/path/y
    172               x:/some/path/x:x:/some/path/y
    173 
    174         Please note that you are free to mix colon and semi-colon in the
    175         specification of paths. Make is able to figure out the intended
    176         result and convert the paths internally to the format needed
    177         when interacting with the operating system, providing the path
    178         is not within quotes, e.g. "x:/test/test.c".
    179 
    180         You are encouraged to use colon as the separator character.
    181         This should ease the pain of deciding how to handle various path
    182         problems which exist between platforms. If colon is used on
    183         both Unix and Windows systems, then no ifdef'ing will be
    184         necessary in the makefile source.
     176        There is a caveat that should be noted with respect to handling
     177        single character pathnames on Windows systems.  When colon is
     178        used in PATH variables, make tries to be smart about knowing when
     179        you are using colon as a separator versus colon as a drive
     180        letter. Unfortunately, something as simple as the string 'x:/'
     181        could be interpreted 2 ways: (x and /) or (x:/).
     182
     183        Make chooses to interpret a letter plus colon (e.g. x:/) as a
     184        drive letter pathname.  If it is necessary to use single
     185        character directories in paths (VPATH, vpath, Path, PATH), the
     186        user must do one of two things:
     187
     188        a. Use semicolon as the separator to disambiguate colon. For
     189            example use 'x;/' if you want to say 'x' and '/' are
     190            separate components.
     191
     192        b. Qualify the directory name so that there is more than
     193            one character in the path(s) used. For example, none
     194            of these settings are ambiguous:
     195
     196              ./x:./y
     197              /some/path/x:/some/path/y
     198              x:/some/path/x:x:/some/path/y
     199
     200        Please note that you are free to mix colon and semi-colon in the
     201        specification of paths. Make is able to figure out the intended
     202        result and convert the paths internally to the format needed
     203        when interacting with the operating system, providing the path
     204        is not within quotes, e.g. "x:/test/test.c".
     205
     206        You are encouraged to use colon as the separator character.
     207        This should ease the pain of deciding how to handle various path
     208        problems which exist between platforms. If colon is used on
     209        both Unix and Windows systems, then no ifdef'ing will be
     210        necessary in the makefile source.
    185211
    186212GNU make test suite:
    187213
    188         I verified all functionality with a slightly modified version
    189         of make-test-%VERSION% (modifications to get test suite to run
    190         on Windows NT). All tests pass in an environment that includes
    191         sh.exe.  Tests were performed on both Windows NT and Windows 95.
     214        I verified all functionality with a slightly modified version
     215        of make-test-%VERSION% (modifications to get test suite to run
     216        on Windows NT). All tests pass in an environment that includes
     217        sh.exe.  Tests were performed on both Windows NT and Windows 95.
    192218
    193219Pathnames and white space:
    194220
    195         Unlike Unix, Windows 95/NT systems encourage pathnames which
    196         contain white space (e.g. C:\Program Files\). These sorts of
    197         pathnames are valid on Unix too, but are never encouraged.
    198         There is at least one place in make (VPATH/vpath handling) where
    199         paths containing white space will simply not work. There may be
    200         others too. I chose to not try and port make in such a way so
    201         that these sorts of paths could be handled. I offer these
    202         suggestions as workarounds:
    203 
    204                 1. Use 8.3 notation. i.e. "x:/long~1/", which is actually
    205                    "x:\longpathtest".  Type "dir /x" to view these filenames
    206                    within the cmd.exe shell.
    207                 2. Rename the directory so it does not contain white space.
    208 
    209         If you are unhappy with this choice, this is free software
    210         and you are free to take a crack at making this work. The code
    211         in w32/pathstuff.c and vpath.c would be the places to start.
     221        Unlike Unix, Windows 95/NT systems encourage pathnames which
     222        contain white space (e.g. C:\Program Files\). These sorts of
     223        pathnames are valid on Unix too, but are never encouraged.
     224        There is at least one place in make (VPATH/vpath handling) where
     225        paths containing white space will simply not work. There may be
     226        others too. I chose to not try and port make in such a way so
     227        that these sorts of paths could be handled. I offer these
     228        suggestions as workarounds:
     229
     230                1. Use 8.3 notation. i.e. "x:/long~1/", which is actually
     231                   "x:\longpathtest".  Type "dir /x" to view these filenames
     232                   within the cmd.exe shell.
     233                2. Rename the directory so it does not contain white space.
     234
     235        If you are unhappy with this choice, this is free software
     236        and you are free to take a crack at making this work. The code
     237        in w32/pathstuff.c and vpath.c would be the places to start.
    212238
    213239Pathnames and Case insensitivity:
    214240
    215         Unlike Unix, Windows 95/NT systems are case insensitive but case
    216         preserving.  For example if you tell the file system to create a
    217         file named "Target", it will preserve the case.  Subsequent access to
    218         the file with other case permutations will succeed (i.e. opening a
    219         file named "target" or "TARGET" will open the file "Target").
    220 
    221         By default, GNU make retains its case sensitivity when comparing
    222         target names and existing files or directories.  It can be
    223         configured, however, into a case preserving and case insensitive
    224         mode by adding a define for HAVE_CASE_INSENSITIVE_FS to
    225         config.h.W32.
    226 
    227         For example, the following makefile will create a file named
    228         Target in the directory subdir which will subsequently be used
    229         to satisfy the dependency of SUBDIR/DepTarget on SubDir/TARGET.
    230         Without HAVE_CASE_INSENSITIVE_FS configured, the dependency link
    231         will not be made:
    232 
    233         subdir/Target:
    234                 touch $@
    235 
    236         SUBDIR/DepTarget: SubDir/TARGET
    237                 cp $^ $@
    238 
    239         Reliance on this behavior also eliminates the ability of GNU make
    240         to use case in comparison of matching rules.  For example, it is
    241         not possible to set up a C++ rule using %.C that is different
    242         than a C rule using %.c.  GNU make will consider these to be the
    243         same rule and will issue a warning.
     241        Unlike Unix, Windows 95/NT systems are case insensitive but case
     242        preserving.  For example if you tell the file system to create a
     243        file named "Target", it will preserve the case.  Subsequent access to
     244        the file with other case permutations will succeed (i.e. opening a
     245        file named "target" or "TARGET" will open the file "Target").
     246
     247        By default, GNU make retains its case sensitivity when comparing
     248        target names and existing files or directories.  It can be
     249        configured, however, into a case preserving and case insensitive
     250        mode by adding a define for HAVE_CASE_INSENSITIVE_FS to
     251        config.h.W32.
     252
     253        For example, the following makefile will create a file named
     254        Target in the directory subdir which will subsequently be used
     255        to satisfy the dependency of SUBDIR/DepTarget on SubDir/TARGET.
     256        Without HAVE_CASE_INSENSITIVE_FS configured, the dependency link
     257        will not be made:
     258
     259        subdir/Target:
     260                touch $@
     261
     262        SUBDIR/DepTarget: SubDir/TARGET
     263                cp $^ $@
     264
     265        Reliance on this behavior also eliminates the ability of GNU make
     266        to use case in comparison of matching rules.  For example, it is
     267        not possible to set up a C++ rule using %.C that is different
     268        than a C rule using %.c.  GNU make will consider these to be the
     269        same rule and will issue a warning.
    244270
    245271SAMBA/NTFS/VFAT:
    246272
    247         I have not had any success building the debug version of this
    248         package using SAMBA as my file server. The reason seems to be
    249         related to the way VC++ 4.0 changes the case name of the pdb
    250         filename it is passed on the command line. It seems to change
    251         the name always to to lower case. I contend that the VC++
    252         compiler should not change the casename of files that are passed
    253         as arguments on the command line. I don't think this was a
    254         problem in MSVC 2.x, but I know it is a problem in MSVC 4.x.
    255 
    256         The package builds fine on VFAT and NTFS filesystems.
    257 
    258         Most all of the development I have done to date has been using
    259         NTFS and long file names. I have not done any considerable work
    260         under VFAT. VFAT users may wish to be aware that this port of
    261         make does respect case sensitivity.
     273        I have not had any success building the debug version of this
     274        package using SAMBA as my file server. The reason seems to be
     275        related to the way VC++ 4.0 changes the case name of the pdb
     276        filename it is passed on the command line. It seems to change
     277        the name always to to lower case. I contend that the VC++
     278        compiler should not change the casename of files that are passed
     279        as arguments on the command line. I don't think this was a
     280        problem in MSVC 2.x, but I know it is a problem in MSVC 4.x.
     281
     282        The package builds fine on VFAT and NTFS filesystems.
     283
     284        Most all of the development I have done to date has been using
     285        NTFS and long file names. I have not done any considerable work
     286        under VFAT. VFAT users may wish to be aware that this port of
     287        make does respect case sensitivity.
    262288
    263289FAT:
    264290
    265         Version 3.76 added support for FAT filesystems. Make works
    266         around some difficulties with stat'ing of files and caching of
    267         filenames and directories internally.
     291        Version 3.76 added support for FAT filesystems. Make works
     292        around some difficulties with stat'ing of files and caching of
     293        filenames and directories internally.
    268294
    269295Bug reports:
    270296
    271         Please submit bugs via the normal bug reporting mechanism which
    272         is described in the GNU make manual and the base README.
     297        Please submit bugs via the normal bug reporting mechanism which
     298        is described in the GNU make manual and the base README.
    273299
    274300
    275301-------------------------------------------------------------------------------
    276 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    277 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     302Copyright (C) 1996-2016 Free Software Foundation, Inc.
    278303This file is part of GNU Make.
    279304
  • vendor/gnumake/current/README.customs

    r2596 r3138  
    3636documentation.  You should also install the man pages (contrary to
    3737comments in the documentation, they weren't installed automatically for
    38 me; I had to cd to the ``pmake-2.1.33/doc'' directory and run ``pmake
    39 install'' there directly).
     38me; I had to cd to the 'pmake-2.1.33/doc' directory and run 'pmake
     39install' there directly).
    4040
    4141
     
    4444
    4545Once you've installed Customs, you can build GNU make to use it.  When
    46 configuring GNU make, merely use the ``--with-customs=DIR'' option.
    47 Provide the directory containing the ``lib'' and ``include/customs''
     46configuring GNU make, merely use the '--with-customs=DIR' option.
     47Provide the directory containing the 'lib' and 'include/customs'
    4848subdirectories as DIR.  For example, if you installed the customs
    4949library in /usr/local/lib and the headers in /usr/local/include/customs,
    50 then you'd pass ``--with-customs=/usr/local'' as an option to configure.
     50then you'd pass '--with-customs=/usr/local' as an option to configure.
    5151
    5252Run make (or use build.sh) normally to build GNU make as described in
     
    9898
    9999-------------------------------------------------------------------------------
    100 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
    101 2009, 2010 Free Software Foundation, Inc.
     100Copyright (C) 1998-2016 Free Software Foundation, Inc.
    102101This file is part of GNU Make.
    103102
  • vendor/gnumake/current/README.template

    r2596 r3138  
    99For general building and installation instructions, see the file INSTALL.
    1010
    11 If you need to build GNU Make and have no other `make' program to use,
    12 you can use the shell script `build.sh' instead.  To do this, first run
    13 `configure' as described in INSTALL.  Then, instead of typing `make' to
    14 build the program, type `sh build.sh'.  This should compile the program
     11If you need to build GNU Make and have no other 'make' program to use,
     12you can use the shell script 'build.sh' instead.  To do this, first run
     13'configure' as described in INSTALL.  Then, instead of typing 'make' to
     14build the program, type 'sh build.sh'.  This should compile the program
    1515in the current directory.  Then you will have a Make program that you can
    16 use for `./make install', or whatever else.
     16use for './make install', or whatever else.
    1717
    1818Some systems' Make programs are broken and cannot process the Makefile for
    1919GNU Make.  If you get errors from your system's Make when building GNU
    20 Make, try using `build.sh' instead.
     20Make, try using 'build.sh' instead.
    2121
    2222
    2323GNU Make is free software.  See the file COPYING for copying conditions.
    24 
     24GNU Make is copyright by the Free Software Foundation.  Copyright notices
     25condense sequential years into a range; e.g. "1987-1994" means all years
     26from 1987 to 1994 inclusive.
    2527
    2628Downloading
     
    6567
    6668You can send GNU make bug reports to <bug-make@gnu.org>.  Please see the
    67 section of the GNU make manual entitled `Problems and Bugs' for
     69section of the GNU make manual entitled 'Problems and Bugs' for
    6870information on submitting useful and complete bug reports.
    6971
     
    8082  news:gnu.utils.bug
    8183
    82   http://savannah.gnu.org/support/?group=make
    8384
    84 You may also find interesting patches to GNU Make available here:
    85 
    86   http://savannah.gnu.org/patch/?group=make
    87 
    88 Note these patches are provided by our users as a service and we make no
    89 statements regarding their correctness.  Please contact the authors
    90 directly if you have a problem or suggestion for a patch available on
    91 this page.
    92 
    93 
    94 CVS Access
     85Git Access
    9586----------
    9687
    97 The GNU make source repository is available via anonymous CVS from the
    98 GNU Subversions CVS server; look here for details:
     88The GNU make source repository is available via Git from the
     89GNU Savannah Git server; look here for details:
    9990
    100   http://savannah.gnu.org/cvs/?group=make
     91  http://savannah.gnu.org/git/?group=make
    10192
    102 Please note: you won't be able to build GNU make from CVS without
     93Please note: you won't be able to build GNU make from Git without
    10394installing appropriate maintainer's tools, such as GNU m4, automake,
    104 autoconf, Perl, GNU make, and GCC.  See the README.cvs file for hints on
     95autoconf, Perl, GNU make, and GCC.  See the README.git file for hints on
    10596how to build GNU make once these tools are available.  We make no
    106 guarantees about the contents or quality of the latest code in the CVS
     97guarantees about the contents or quality of the latest code in the Git
    10798repository: it is not unheard of for code that is known to be broken to
    10899be checked in.  Use at your own risk.
     
    113104
    114105It has been reported that the XLC 1.2 compiler on AIX 3.2 is buggy such
    115 that if you compile make with `cc -O' on AIX 3.2, it will not work
    116 correctly.  It is said that using `cc' without `-O' does work.
     106that if you compile make with 'cc -O' on AIX 3.2, it will not work
     107correctly.  It is said that using 'cc' without '-O' does work.
    117108
    118109The standard /bin/sh on SunOS 4.1.3_U1 and 4.1.4 is broken and cannot be
     
    124115One area that is often a problem in configuration and porting is the code
    125116to check the system's current load average.  To make it easier to test and
    126 debug this code, you can do `make check-loadavg' to see if it works
    127 properly on your system.  (You must run `configure' beforehand, but you
     117debug this code, you can do 'make check-loadavg' to see if it works
     118properly on your system.  (You must run 'configure' beforehand, but you
    128119need not build Make itself to run this test.)
    129120
     
    132123Please report any bugs that you find in this area.  If you run into
    133124difficulties, then as a workaround you should be able to disable LFS by
    134 adding the `--disable-largefile' option to the `configure' script.
     125adding the '--disable-largefile' option to the 'configure' script.
    135126
    136127On systems that support micro- and nano-second timestamp values and
     
    152143    Customs distributed build environment from the Pmake distribution.
    153144
    154   - See readme.vms for details about GNU Make on OpenVMS.
     145  - See README.VMS for details about GNU Make on OpenVMS.
    155146
    156147  - See README.Amiga for details about GNU Make on AmigaDOS.
     
    173164
    174165-------------------------------------------------------------------------------
    175 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    176 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    177 2010 Free Software Foundation, Inc.
     166Copyright (C) 1988-2016 Free Software Foundation, Inc.
    178167This file is part of GNU Make.
    179168
  • vendor/gnumake/current/SMakefile.template

    r2596 r3138  
    44# run 'build.sh' instead.
    55#
    6 # Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    7 # 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     6# Copyright (C) 1995-2016 Free Software Foundation, Inc.
    87# This file is part of GNU Make.
    98#
     
    2726# Ultrix 2.2 make doesn't expand the value of VPATH.
    2827VPATH = /make-%VERSION%/
    29 # This must repeat the value, because configure will remove `VPATH = .'.
     28# This must repeat the value, because configure will remove 'VPATH = .'.
    3029srcdir = /make-%VERSION%/
    3130
     
    3938
    4039# Define these for your system as follows:
    41 #       -DNO_ARCHIVES           To disable `ar' archive support.
     40#       -DNO_ARCHIVES           To disable 'ar' archive support.
    4241#       -DNO_FLOAT              To avoid using floating-point numbers.
    4342#       -DENUM_BITFIELDS        If the compiler isn't GCC but groks enum foo:2.
     
    4645#                               so beware.
    4746# NeXT 1.0a uses an old version of GCC, which required -D__inline=inline.
    48 # See also `config.h'.
     47# See also 'config.h'.
    4948defines =
    5049
    5150# Which flavor of remote job execution support to use.
    52 # The code is found in `remote-$(REMOTE).c'.
     51# The code is found in 'remote-$(REMOTE).c'.
    5352REMOTE = stub
    5453
     
    8483exec_prefix =
    8584
    86 # Directory to install `make' in.
     85# Directory to install 'make' in.
    8786bindir = sc:c
    88 # Directory to find libraries in for `-lXXX'.
     87# Directory to find libraries in for '-lXXX'.
    8988libdir = lib:
    9089# Directory to search by default for included makefiles.
     
    9695# Number to put on the man page filename.
    9796manext = 1
    98 # Prefix to put on installed `make' binary file name.
     97# Prefix to put on installed 'make' binary file name.
    9998binprefix =
    100 # Prefix to put on installed `make' man page file name.
     99# Prefix to put on installed 'make' man page file name.
    101100manprefix = $(binprefix)
    102101
    103102# Whether or not make needs to be installed setgid.
    104 # The value should be either `true' or `false'.
    105 # On many systems, the getloadavg function (used to implement the `-l'
     103# The value should be either 'true' or 'false'.
     104# On many systems, the getloadavg function (used to implement the '-l'
    106105# switch) will not work unless make is installed setgid kmem.
    107106install_setgid = false
     
    109108group = sys
    110109
    111 # Program to install `make'.
     110# Program to install 'make'.
    112111INSTALL_PROGRAM = copy
    113112# Program to install the man page.
     
    125124CTAGS = ctags -w
    126125
    127 objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o      \
    128        rule.o implicit.o default.o variable.o expand.o function.o       \
    129        vpath.o version.o ar.o arscan.o signame.o strcache.o hash.o      \
    130        remote-$(REMOTE).o $(GLOB) $(GETOPT) $(ALLOCA) $(extras)
     126#guile = guile.o
     127
     128objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o   \
     129       rule.o implicit.o default.o variable.o expand.o function.o    \
     130       vpath.o version.o ar.o arscan.o signame.o strcache.o hash.o   \
     131       output.o remote-$(REMOTE).o $(GLOB) $(GETOPT) $(ALLOCA)       \
     132       $(extras) $(guile)
     133
    131134srcs = $(srcdir)commands.c $(srcdir)job.c $(srcdir)dir.c             \
    132135       $(srcdir)file.c $(srcdir)getloadavg.c $(srcdir)misc.c         \
     
    135138       $(srcdir)variable.c $(srcdir)expand.c $(srcdir)function.c     \
    136139       $(srcdir)vpath.c $(srcdir)version.c $(srcdir)hash.c           \
    137        $(srcdir)remote-$(REMOTE).c                                     \
    138        $(srcdir)ar.c $(srcdir)arscan.c $(srcdir)strcache.c              \
    139        $(srcdir)signame.c $(srcdir)signame.h $(GETOPT_SRC)            \
     140       $(srcdir)guile.c $(srcdir)remote-$(REMOTE).c                  \
     141       $(srcdir)ar.c $(srcdir)arscan.c $(srcdir)strcache.c           \
     142       $(srcdir)signame.c $(srcdir)signame.h $(GETOPT_SRC)           \
    140143       $(srcdir)commands.h $(srcdir)dep.h $(srcdir)file.h            \
    141        $(srcdir)job.h $(srcdir)make.h $(srcdir)rule.h                \
     144       $(srcdir)job.h $(srcdir)makeint.h $(srcdir)rule.h             \
     145       $(srcdir)output.c $(srcdir)output.h                           \
    142146       $(srcdir)variable.h $(ALLOCA_SRC) $(srcdir)config.h.in
    143147
     
    149153info: make.info
    150154dvi: make.dvi
    151 # Some makes apparently use .PHONY as the default goal if it is before `all'.
     155# Some makes apparently use .PHONY as the default goal if it is before 'all'.
    152156.PHONY: all check info dvi
    153157
  • vendor/gnumake/current/TODO.private

    r2596 r3138  
    77They are listed in no particular order!
    88
    9 Also, I don't gaurantee that all of them will be ultimately deemed "good
     9Also, I don't guarantee that all of them will be ultimately deemed "good
    1010ideas" and implemented.  These are just the ones that, at first blush,
    1111seem to have some merit (and that I can remember).
     
    100100    means this isn't 100% trivial, but it probably won't be hard.
    101101
    102  8) Integration of Guile as an embedded scripting language.  This means:
    103     allowing Guile functions to be declared in makefiles somehow, then
    104     providing a syntax for invoking them.  At least one formulation of
    105     that would have the function resolve to a string which would be
    106     substituted in the makefile, kind of like $(shell ...) does now, but
    107     using the embedded interpreter so there's no process forked of
    108     course.  Obviously this is an optional add-on feature.
    109 
    110     It could be more advanced than that, even, who knows?  Maybe make
    111     could provide Guile functions that allow Guile scripts more direct
    112     access to internal make structures, somehow.  This kind of thing
    113     needs a lot of thought.
    114 
    115     Also there's always the flip side: in some very fundamental ways
    116     make isn't the best choice right now for a complex build tool.  It's
    117     great for simple-to-medium tasks, but there are already other tools
    118     available for the really tough situations.  Ask yourself,
    119     realistically, how much work is worthwhile to add to make, given the
    120     fundamentals you can't really overcome without significantly
    121     affecting backward compatibility--and then why not use another tool
    122     in the first place?
    123 
    124     Something to think about.
    125 
    126102
    127103
    128104-------------------------------------------------------------------------------
    129 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    130 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     105Copyright (C) 1997-2016 Free Software Foundation, Inc.
    131106This file is part of GNU Make.
    132107
  • vendor/gnumake/current/acinclude.m4

    r2596 r3138  
    22dnl
    33dnl Automake will incorporate this into its generated aclocal.m4.
    4 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
    5 dnl 2008, 2009, 2010 Free Software Foundation, Inc.
     4dnl Copyright (C) 1998-2016 Free Software Foundation, Inc.
    65dnl This file is part of GNU Make.
    76dnl
     
    101100dnl ---------------------------------------------------------------------------
    102101dnl From Paul Eggert <eggert@twinsun.com>
     102dnl Update for Darwin by Troy Runkel <Troy.Runkel@mathworks.com>
     103dnl Update for AIX by Olexiy Buyanskyy (Savannah bug 32485)
    103104
    104105AC_DEFUN([AC_STRUCT_ST_MTIM_NSEC],
    105  [AC_CACHE_CHECK([for nanoseconds field of struct stat.st_mtim],
     106 [AC_CACHE_CHECK([for nanoseconds field of struct stat],
    106107   ac_cv_struct_st_mtim_nsec,
    107108   [ac_save_CPPFLAGS="$CPPFLAGS"
    108109    ac_cv_struct_st_mtim_nsec=no
    109     # tv_nsec -- the usual case
    110     # _tv_nsec -- Solaris 2.6, if
     110    # st_mtim.tv_nsec -- the usual case
     111    # st_mtim._tv_nsec -- Solaris 2.6, if
    111112    #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
    112113    #    && !defined __EXTENSIONS__)
    113     # st__tim.tv_nsec -- UnixWare 2.1.2
    114     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
     114    # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
     115    # st_mtime_n -- AIX 5.2 and above
     116    # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
     117    for ac_val in st_mtim.tv_nsec st_mtim._tv_nsec st_mtim.st__tim.tv_nsec st_mtime_n st_mtimespec.tv_nsec; do
    115118      CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
    116119      AC_TRY_COMPILE([#include <sys/types.h>
    117120#include <sys/stat.h>
    118         ], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
     121        ], [struct stat s; s.ST_MTIM_NSEC;],
    119122        [ac_cv_struct_st_mtim_nsec=$ac_val; break])
    120123    done
  • vendor/gnumake/current/alloca.c

    r54 r3138  
    117117find_stack_direction (void)
    118118{
    119   static char *addr = NULL;     /* Address of first `dummy', once known.  */
     119  static char *addr = NULL;     /* Address of first 'dummy', once known.  */
    120120  auto char dummy;              /* To get stack address.  */
    121121
  • vendor/gnumake/current/amiga.c

    r2596 r3138  
    11/* Running commands on Amiga
    2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1995-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    1615this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1716
    18 #include "make.h"
     17#include "makeint.h"
    1918#include "variable.h"
    2019#include "amiga.h"
     
    2625
    2726static const char Amiga_version[] = "$VER: Make 3.74.3 (12.05.96) \n"
    28                     "Amiga Port by A. Digulla (digulla@home.lake.de)";
     27                    "Amiga Port by A. Digulla (digulla@home.lake.de)";
    2928
    3029int
     
    3837    for (aptr=argv; *aptr; aptr++)
    3938    {
    40         len += strlen (*aptr) + 4;
     39        len += strlen (*aptr) + 4;
    4140    }
    4241
     
    4443
    4544    if (!buffer)
    46       fatal (NILF, "MyExecute: Cannot allocate space for calling a command");
     45      O (fatal, NILF, "MyExecute: Cannot allocate space for calling a command\n");
    4746
    4847    ptr = buffer;
     
    5049    for (aptr=argv; *aptr; aptr++)
    5150    {
    52         if (((*aptr)[0] == ';' && !(*aptr)[1]))
    53         {
    54             *ptr ++ = '"';
    55             strcpy (ptr, *aptr);
    56             ptr += strlen (ptr);
    57             *ptr ++ = '"';
    58         }
    59         else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
    60         {
    61             *ptr ++ = '\n';
    62             continue;
    63         }
    64         else
    65         {
    66             strcpy (ptr, *aptr);
    67             ptr += strlen (ptr);
    68         }
    69         *ptr ++ = ' ';
    70         *ptr = 0;
     51        if (((*aptr)[0] == ';' && !(*aptr)[1]))
     52        {
     53            *ptr ++ = '"';
     54            strcpy (ptr, *aptr);
     55            ptr += strlen (ptr);
     56            *ptr ++ = '"';
     57        }
     58        else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
     59        {
     60            *ptr ++ = '\n';
     61            continue;
     62        }
     63        else
     64        {
     65            strcpy (ptr, *aptr);
     66            ptr += strlen (ptr);
     67        }
     68        *ptr ++ = ' ';
     69        *ptr = 0;
    7170    }
    7271
     
    7473
    7574    status = SystemTags (buffer,
    76         SYS_UserShell, TRUE,
    77         TAG_END);
     75        SYS_UserShell, TRUE,
     76        TAG_END);
    7877
    7978    FreeMem (buffer, len);
    8079
    81     if (SetSignal(0L,0L) & SIGBREAKF_CTRL_C)
    82         status = 20;
     80    if (SetSignal (0L,0L) & SIGBREAKF_CTRL_C)
     81        status = 20;
    8382
    8483    /* Warnings don't count */
    8584    if (status == 5)
    86         status = 0;
     85        status = 0;
    8786
    8887    return status;
     
    9291wildcard_expansion (char *wc, char *o)
    9392{
    94 #   define PATH_SIZE    1024
     93#   define PATH_SIZE    1024
    9594    struct AnchorPath * apath;
    9695
    9796    if ( (apath = AllocMem (sizeof (struct AnchorPath) + PATH_SIZE,
    98             MEMF_CLEAR))
    99         )
     97            MEMF_CLEAR))
     98        )
    10099    {
    101         apath->ap_Strlen = PATH_SIZE;
     100        apath->ap_Strlen = PATH_SIZE;
    102101
    103         if (MatchFirst (wc, apath) == 0)
    104         {
    105             do
    106             {
    107                 o = variable_buffer_output (o, apath->ap_Buf,
    108                         strlen (apath->ap_Buf));
    109                 o = variable_buffer_output (o, " ",1);
    110             } while (MatchNext (apath) == 0);
    111         }
     102        if (MatchFirst (wc, apath) == 0)
     103        {
     104            do
     105            {
     106                o = variable_buffer_output (o, apath->ap_Buf,
     107                        strlen (apath->ap_Buf));
     108                o = variable_buffer_output (o, " ",1);
     109            } while (MatchNext (apath) == 0);
     110        }
    112111
    113         MatchEnd (apath);
    114         FreeMem (apath, sizeof (struct AnchorPath) + PATH_SIZE);
     112        MatchEnd (apath);
     113        FreeMem (apath, sizeof (struct AnchorPath) + PATH_SIZE);
    115114    }
    116115
  • vendor/gnumake/current/amiga.h

    r2596 r3138  
    11/* Definitions for amiga specific things
    2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1995-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
  • vendor/gnumake/current/ar.c

    r2596 r3138  
    1 /* Interface to `ar' archives for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     1/* Interface to 'ar' archives for GNU Make.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53
    64This file is part of GNU Make.
     
    1816this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1917
    20 #include "make.h"
    21 
    22 #ifndef NO_ARCHIVES
     18#include "makeint.h"
     19
     20#ifndef NO_ARCHIVES
    2321
    2422#include "filedef.h"
     
    2725
    2826/* Return nonzero if NAME is an archive-member reference, zero if not.  An
    29    archive-member reference is a name like `lib(member)' where member is a
     27   archive-member reference is a name like 'lib(member)' where member is a
    3028   non-empty string.
    31    If a name like `lib((entry))' is used, a fatal error is signaled at
     29   If a name like 'lib((entry))' is used, a fatal error is signaled at
    3230   the attempt to use this unsupported feature.  */
    3331
     
    4644
    4745  if (p[1] == '(' && end[-1] == ')')
    48     fatal (NILF, _("attempt to use unsupported feature: `%s'"), name);
     46    OS (fatal, NILF, _("attempt to use unsupported feature: '%s'"), name);
    4947
    5048  return 1;
     
    6462  p = strchr (*arname_p, '(');
    6563  *(p++) = '\0';
    66   p[strlen(p) - 1] = '\0';
     64  p[strlen (p) - 1] = '\0';
    6765  *memname_p = p;
    6866}
     
    7068
    7169
    72 /* This function is called by `ar_scan' to find which member to look at.  */
     70/* This function is called by 'ar_scan' to find which member to look at.  */
    7371
    7472/* ARGSUSED */
    7573static long int
    7674ar_member_date_1 (int desc UNUSED, const char *mem, int truncated,
    77                   long int hdrpos UNUSED, long int datapos UNUSED,
     75                  long int hdrpos UNUSED, long int datapos UNUSED,
    7876                  long int size UNUSED, long int date,
    79                   int uid UNUSED, int gid UNUSED, int mode UNUSED,
    80                   const void *name)
     77                  int uid UNUSED, int gid UNUSED, unsigned int mode UNUSED,
     78                  const void *name)
    8179{
    8280  return ar_name_equal (name, mem, truncated) ? date : 0;
     
    125123ar_touch (const char *name)
    126124{
    127   error (NILF, _("touch archive member is not available on VMS"));
     125  O (error, NILF, _("touch archive member is not available on VMS"));
    128126  return -1;
    129127}
     
    149147    {
    150148    case -1:
    151       error (NILF, _("touch: Archive `%s' does not exist"), arname);
     149      OS (error, NILF, _("touch: Archive '%s' does not exist"), arname);
    152150      break;
    153151    case -2:
    154       error (NILF, _("touch: `%s' is not a valid archive"), arname);
     152      OS (error, NILF, _("touch: '%s' is not a valid archive"), arname);
    155153      break;
    156154    case -3:
     
    158156      break;
    159157    case 1:
    160       error (NILF,
    161              _("touch: Member `%s' does not exist in `%s'"), memname, arname);
     158      OSS (error, NILF,
     159           _("touch: Member '%s' does not exist in '%s'"), memname, arname);
    162160      break;
    163161    case 0:
     
    165163      break;
    166164    default:
    167       error (NILF,
    168              _("touch: Bad return code from ar_member_touch on `%s'"), name);
     165      OS (error, NILF,
     166          _("touch: Bad return code from ar_member_touch on '%s'"), name);
    169167    }
    170168
     
    176174
    177175
    178 /* State of an `ar_glob' run, passed to `ar_glob_match'.  */
     176/* State of an 'ar_glob' run, passed to 'ar_glob_match'.  */
     177
     178/* On VMS, (object) modules in libraries do not have suffixes. That is, to
     179   find a match for a pattern, the pattern must not have any suffix. So the
     180   suffix of the pattern is saved and the pattern is stripped (ar_glob).
     181   If there is a match and the match, which is a module name, is added to
     182   the chain, the saved suffix is added back to construct a source filename
     183   (ar_glob_match). */
    179184
    180185struct ar_glob_state
     
    182187    const char *arname;
    183188    const char *pattern;
     189#ifdef VMS
     190    char *suffix;
     191#endif
    184192    unsigned int size;
    185193    struct nameseq *chain;
     
    187195  };
    188196
    189 /* This function is called by `ar_scan' to match one archive
     197/* This function is called by 'ar_scan' to match one archive
    190198   element against the pattern in STATE.  */
    191199
    192200static long int
    193201ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
    194                long int hdrpos UNUSED, long int datapos UNUSED,
     202               long int hdrpos UNUSED, long int datapos UNUSED,
    195203               long int size UNUSED, long int date UNUSED, int uid UNUSED,
    196                int gid UNUSED, int mode UNUSED, const void *arg)
     204               int gid UNUSED, unsigned int mode UNUSED, const void *arg)
    197205{
    198206  struct ar_glob_state *state = (struct ar_glob_state *)arg;
     
    202210      /* We have a match.  Add it to the chain.  */
    203211      struct nameseq *new = xcalloc (state->size);
    204       new->name = strcache_add (concat (4, state->arname, "(", mem, ")"));
     212#ifdef VMS
     213      if (state->suffix)
     214        new->name = strcache_add(
     215            concat(5, state->arname, "(", mem, state->suffix, ")"));
     216      else
     217#endif
     218        new->name = strcache_add(concat(4, state->arname, "(", mem, ")"));
    205219      new->next = state->chain;
    206220      state->chain = new;
     
    214228   Metacharacters can be quoted with backslashes if QUOTE is nonzero.  */
    215229static int
    216 glob_pattern_p (const char *pattern, int quote)
     230ar_glob_pattern_p (const char *pattern, int quote)
    217231{
    218232  const char *p;
     
    224238      case '?':
    225239      case '*':
    226         return 1;
     240        return 1;
    227241
    228242      case '\\':
    229         if (quote)
    230           ++p;
    231         break;
     243        if (quote)
     244          ++p;
     245        break;
    232246
    233247      case '[':
    234         opened = 1;
    235         break;
     248        opened = 1;
     249        break;
    236250
    237251      case ']':
    238         if (opened)
    239           return 1;
    240         break;
     252        if (opened)
     253          return 1;
     254        break;
    241255      }
    242256
     
    254268  const char **names;
    255269  unsigned int i;
    256 
    257   if (! glob_pattern_p (member_pattern, 1))
     270#ifdef VMS
     271  char *vms_member_pattern;
     272#endif
     273  if (! ar_glob_pattern_p (member_pattern, 1))
    258274    return 0;
    259275
     
    262278  state.arname = arname;
    263279  state.pattern = member_pattern;
     280#ifdef VMS
     281    {
     282      /* In a copy of the pattern, find the suffix, save it and  remove it from
     283         the pattern */
     284      char *lastdot;
     285      vms_member_pattern = xstrdup(member_pattern);
     286      lastdot = strrchr(vms_member_pattern, '.');
     287      state.suffix = lastdot;
     288      if (lastdot)
     289        {
     290          state.suffix = xstrdup(lastdot);
     291          *lastdot = 0;
     292        }
     293      state.pattern = vms_member_pattern;
     294    }
     295#endif
    264296  state.size = size;
    265297  state.chain = 0;
    266298  state.n = 0;
    267299  ar_scan (arname, ar_glob_match, &state);
     300
     301#ifdef VMS
     302  /* Deallocate any duplicated string */
     303  free(vms_member_pattern);
     304  if (state.suffix)
     305    {
     306      free(state.suffix);
     307    }
     308#endif
    268309
    269310  if (state.chain == 0)
     
    288329}
    289330
    290 #endif  /* Not NO_ARCHIVES.  */
     331#endif  /* Not NO_ARCHIVES.  */
  • vendor/gnumake/current/arscan.c

    r2596 r3138  
    11/* Library function for scanning an archive file.
    2 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1987-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
     18
     19#ifdef TEST
     20/* Hack, the real error() routine eventually pulls in die from main.c */
     21#define error(a, b, c, d)
     22#endif
    2023
    2124#ifdef HAVE_FCNTL_H
     
    2528#endif
    2629
    27 #ifndef NO_ARCHIVES
     30#ifndef NO_ARCHIVES
    2831
    2932#ifdef VMS
     
    3336#include <descrip.h>
    3437#include <ctype.h>
    35 #if __DECC
     38#include <ssdef.h>
     39#include <stsdef.h>
     40#include <rmsdef.h>
     41
     42/* This symbol should be present in lbrdef.h. */
     43#ifndef LBR$_HDRTRUNC
     44#pragma extern_model save
     45#pragma extern_model globalvalue
     46extern unsigned int LBR$_HDRTRUNC;
     47#pragma extern_model restore
     48#endif
     49
    3650#include <unixlib.h>
    3751#include <lbr$routines.h>
    38 #endif
    39 
     52
     53const char *
     54vmsify (const char *name, int type);
     55
     56/* Time conversion from VMS to Unix
     57   Conversion from local time (stored in library) to GMT (needed for gmake)
     58   Note: The tm_gmtoff element is a VMS extension to the ANSI standard. */
     59static time_t
     60vms_time_to_unix(void *vms_time)
     61{
     62  struct tm *tmp;
     63  time_t unix_time;
     64
     65  unix_time = decc$fix_time(vms_time);
     66  tmp = localtime(&unix_time);
     67  unix_time -= tmp->tm_gmtoff;
     68
     69  return unix_time;
     70}
     71
     72
     73/* VMS library routines need static variables for callback */
    4074static void *VMS_lib_idx;
    4175
    42 static char *VMS_saved_memname;
    43 
    44 static time_t VMS_member_date;
     76static const void *VMS_saved_arg;
    4577
    4678static long int (*VMS_function) ();
    4779
     80static long int VMS_function_ret;
     81
     82
     83/* This is a callback procedure for lib$get_index */
    4884static int
    49 VMS_get_member_info (struct dsc$descriptor_s *module, unsigned long *rfa)
     85VMS_get_member_info(struct dsc$descriptor_s *module, unsigned long *rfa)
    5086{
    5187  int status, i;
    52   long int fnval;
    53 
    54   time_t val;
     88  const int truncated = 0; /* Member name may be truncated */
     89  time_t member_date; /* Member date */
     90  char *filename;
     91  unsigned int buffer_length; /* Actual buffer length */
     92
     93  /* Unused constants - Make does not actually use most of these */
     94  const int file_desc = -1; /* archive file descriptor for reading the data */
     95  const int header_position = 0; /* Header position */
     96  const int data_position = 0; /* Data position in file */
     97  const int data_size = 0; /* Data size */
     98  const int uid = 0; /* member gid */
     99  const int gid = 0; /* member gid */
     100  const int mode = 0; /* member protection mode */
     101  /* End of unused constants */
    55102
    56103  static struct dsc$descriptor_s bufdesc =
    57104    { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL };
    58105
     106  /* Only need the module definition */
    59107  struct mhddef *mhd;
    60   char filename[128];
    61 
    62   bufdesc.dsc$a_pointer = filename;
    63   bufdesc.dsc$w_length = sizeof (filename);
    64 
    65   status = lbr$set_module (&VMS_lib_idx, rfa, &bufdesc,
    66                            &bufdesc.dsc$w_length, 0);
    67   if (! (status & 1))
     108
     109  /* If a previous callback is non-zero, just return that status */
     110  if (VMS_function_ret)
    68111    {
    69       error (NILF, _("lbr$set_module() failed to extract module info, status = %d"),
    70              status);
    71 
    72       lbr$close (&VMS_lib_idx);
    73 
    74       return 0;
     112      return SS$_NORMAL;
    75113    }
    76114
    77   mhd = (struct mhddef *) filename;
    78 
    79 #ifdef __DECC
    80   /* John Fowler <jfowler@nyx.net> writes this is needed in his environment,
    81    * but that decc$fix_time() isn't documented to work this way.  Let me
    82    * know if this causes problems in other VMS environments.
    83    */
    84   {
    85     /* Modified by M. Gehre at 11-JAN-2008 because old formula is wrong:
    86      * val = decc$fix_time (&mhd->mhd$l_datim) + timezone - daylight*3600;
    87      * a) daylight specifies, if the timezone has daylight saving enabled, not
    88      *    if it is active
    89      * b) what we need is the information, if daylight saving was active, if
    90      *    the library module was replaced. This information we get using the
    91      *    localtime function
    92      */
    93 
    94     struct tm *tmp;
    95 
    96     /* Conversion from VMS time to C time */
    97     val = decc$fix_time (&mhd->mhd$l_datim);
    98 
    99     /*
    100      * Conversion from local time (stored in library) to GMT (needed for gmake)
    101      * Note: The tm_gmtoff element is a VMS extension to the ANSI standard.
    102      */
    103     tmp = localtime (&val);
    104     val -= tmp->tm_gmtoff;
    105   }
    106 #endif
    107 
     115  /* lbr_set_module returns more than just the module header. So allocate
     116     a buffer which is big enough: the maximum LBR$C_MAXHDRSIZ. That's at
     117     least bigger than the size of struct mhddef.
     118     If the request is too small, a buffer truncated warning is issued so
     119     it can be reissued with a larger buffer.
     120     We do not care if the buffer is truncated, so that is still a success. */
     121  mhd = xmalloc(LBR$C_MAXHDRSIZ);
     122  bufdesc.dsc$a_pointer = (char *) mhd;
     123  bufdesc.dsc$w_length = LBR$C_MAXHDRSIZ;
     124
     125  status = lbr$set_module(&VMS_lib_idx, rfa, &bufdesc, &buffer_length, 0);
     126
     127  if ((status != LBR$_HDRTRUNC) && !$VMS_STATUS_SUCCESS(status))
     128    {
     129      ON(error, NILF,
     130          _("lbr$set_module() failed to extract module info, status = %d"),
     131          status);
     132
     133      lbr$close(&VMS_lib_idx);
     134
     135      return status;
     136    }
     137
     138#ifdef TEST
     139  /* When testing this code, it is useful to know the length returned */
     140  printf("Input length = %d, actual = %d\n",
     141      bufdesc.dsc$w_length, buffer_length);
     142#endif
     143
     144  /* Conversion from VMS time to C time.
     145     VMS defectlet - mhddef is sub-optimal, for the time, it has a 32 bit
     146     longword, mhd$l_datim, and a 32 bit fill instead of two longwords, or
     147     equivalent. */
     148  member_date = vms_time_to_unix(&mhd->mhd$l_datim);
     149  free(mhd);
     150
     151  /* Here we have a problem.  The module name on VMS does not have
     152     a file type, but the filename pattern in the "VMS_saved_arg"
     153     may have one.
     154     But only the method being called knows how to interpret the
     155     filename pattern.
     156     There are currently two different formats being used.
     157     This means that we need a VMS specific code in those methods
     158     to handle it. */
     159  filename = xmalloc(module->dsc$w_length + 1);
     160
     161  /* TODO: We may need an option to preserve the case of the module
     162     For now force the module name to lower case */
    108163  for (i = 0; i < module->dsc$w_length; i++)
    109     filename[i] = _tolower ((unsigned char)module->dsc$a_pointer[i]);
     164    filename[i] = _tolower((unsigned char )module->dsc$a_pointer[i]);
    110165
    111166  filename[i] = '\0';
    112167
    113   VMS_member_date = (time_t) -1;
    114 
    115   fnval =
    116     (*VMS_function) (-1, filename, 0, 0, 0, 0, val, 0, 0, 0,
    117                      VMS_saved_memname);
    118 
    119   if (fnval)
    120     {
    121       VMS_member_date = fnval;
    122       return 0;
    123     }
    124   else
    125     return 1;
     168  VMS_function_ret = (*VMS_function)(file_desc, filename, truncated,
     169      header_position, data_position, data_size, member_date, uid, gid, mode,
     170      VMS_saved_arg);
     171
     172  free(filename);
     173  return SS$_NORMAL;
    126174}
     175
    127176
    128177/* Takes three arguments ARCHIVE, FUNCTION and ARG.
     
    156205
    157206long int
    158 ar_scan (const char *archive, ar_member_func_t function, const void *arg)
     207ar_scan (const char *archive, ar_member_func_t function, const void *varg)
    159208{
    160   char *p;
     209  char *vms_archive;
    161210
    162211  static struct dsc$descriptor_s libdesc =
    163212    { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL };
    164213
    165   unsigned long func = LBR$C_READ;
    166   unsigned long type = LBR$C_TYP_UNK;
    167   unsigned long index = 1;
    168 
     214  const unsigned long func = LBR$C_READ;
     215  const unsigned long type = LBR$C_TYP_UNK;
     216  const unsigned long index = 1;
     217  unsigned long lib_idx;
    169218  int status;
    170219
    171   status = lbr$ini_control (&VMS_lib_idx, &func, &type, 0);
    172 
    173   if (! (status & 1))
     220  VMS_saved_arg = varg;
     221
     222  /* Null archive string can show up in test and cause an access violation */
     223  if (archive == NULL)
    174224    {
    175       error (NILF, _("lbr$ini_control() failed with status = %d"), status);
     225      /* Null filenames do not exist */
     226      return -1;
     227    }
     228
     229  /* archive path name must be in VMS format */
     230  vms_archive = (char *) vmsify(archive, 0);
     231
     232  status = lbr$ini_control(&VMS_lib_idx, &func, &type, 0);
     233
     234  if (!$VMS_STATUS_SUCCESS(status))
     235    {
     236      ON(error, NILF, _("lbr$ini_control() failed with status = %d"), status);
    176237      return -2;
    177238    }
    178239
    179   /* there is no such descriptor with "const char *dsc$a_pointer" */
    180   libdesc.dsc$a_pointer = (char *)archive;
    181   libdesc.dsc$w_length = strlen (archive);
    182 
    183   status = lbr$open (&VMS_lib_idx, &libdesc, 0, 0, 0, 0, 0);
    184 
    185   if (! (status & 1))
     240  libdesc.dsc$a_pointer = vms_archive;
     241  libdesc.dsc$w_length = strlen(vms_archive);
     242
     243  status = lbr$open(&VMS_lib_idx, &libdesc, 0, NULL, 0, NULL, 0);
     244
     245  if (!$VMS_STATUS_SUCCESS(status))
    186246    {
    187       error (NILF, _("unable to open library `%s' to lookup member `%s'"),
    188              archive, (char *)arg);
    189       return -1;
     247
     248      /* TODO: A library format failure could mean that this is a file
     249         generated by the GNU AR utility and in that case, we need to
     250         take the UNIX codepath.  This will also take a change to the
     251         GNV AR wrapper program. */
     252
     253      switch (status)
     254        {
     255      case RMS$_FNF:
     256        /* Archive does not exist */
     257        return -1;
     258      default:
     259#ifndef TEST
     260        OSN(error, NILF,
     261            _("unable to open library '%s' to lookup member status %d"),
     262            archive, status);
     263#endif
     264        /* For library format errors, specification says to return -2 */
     265        return -2;
     266        }
    190267    }
    191268
    192   VMS_saved_memname = (char *)arg;
    193 
    194   /* For comparison, delete .obj from arg name.  */
    195 
    196   p = strrchr (VMS_saved_memname, '.');
    197   if (p)
    198     *p = '\0';
    199 
    200269  VMS_function = function;
    201270
    202   VMS_member_date = (time_t) -1;
    203   lbr$get_index (&VMS_lib_idx, &index, VMS_get_member_info, 0);
    204 
    205   /* Undo the damage.  */
    206   if (p)
    207     *p = '.';
    208 
    209   lbr$close (&VMS_lib_idx);
    210 
    211   return VMS_member_date > 0 ? VMS_member_date : 0;
     271  /* Clear the return status, as we are supposed to stop calling the
     272     callback function if it becomes non-zero, and this is a static
     273     variable. */
     274  VMS_function_ret = 0;
     275
     276  status = lbr$get_index(&VMS_lib_idx, &index, VMS_get_member_info, NULL, 0);
     277
     278  lbr$close(&VMS_lib_idx);
     279
     280  /* Unless a failure occurred in the lbr$ routines, return the
     281     the status from the 'function' routine. */
     282  if ($VMS_STATUS_SUCCESS(status))
     283    {
     284      return VMS_function_ret;
     285    }
     286
     287  /* This must be something wrong with the library and an error
     288     message should already have been printed. */
     289  return -2;
    212290}
    213291
     
    215293
    216294/* SCO Unix's compiler defines both of these.  */
    217 #ifdef  M_UNIX
    218 #undef  M_XENIX
     295#ifdef  M_UNIX
     296#undef  M_XENIX
    219297#endif
    220298
     
    225303
    226304#if (!defined (PORTAR) || PORTAR == 0) && (!defined (PORT5AR) || PORT5AR == 0)
    227 #undef  PORTAR
     305#undef  PORTAR
    228306#ifdef M_XENIX
    229307/* According to Jim Sievert <jas1@rsvl.unisys.com>, for SCO XENIX defining
     
    254332
    255333#ifndef WINDOWS32
    256 # ifndef __BEOS__
     334# if !defined (__ANDROID__) && !defined (__BEOS__)
    257335#  include <ar.h>
    258336# else
    259    /* BeOS 5 doesn't have <ar.h> but has archives in the same format
     337   /* These platforms don't have <ar.h> but have archives in the same format
    260338    * as many other Unices.  This was taken from GNU binutils for BeOS.
    261339    */
    262 #  define ARMAG "!<arch>\n"     /* String that begins an archive file.  */
    263 #  define SARMAG 8              /* Size of that string.  */
    264 #  define ARFMAG "`\n"          /* String in ar_fmag at end of each header.  */
     340#  define ARMAG "!<arch>\n"     /* String that begins an archive file.  */
     341#  define SARMAG 8              /* Size of that string.  */
     342#  define ARFMAG "`\n"          /* String in ar_fmag at end of each header.  */
    265343struct ar_hdr
    266344  {
    267     char ar_name[16];           /* Member file name, sometimes / terminated. */
    268     char ar_date[12];           /* File date, decimal seconds since Epoch.  */
    269     char ar_uid[6], ar_gid[6];  /* User and group IDs, in ASCII decimal.  */
    270     char ar_mode[8];            /* File mode, in ASCII octal.  */
    271     char ar_size[10];           /* File size, in ASCII decimal.  */
    272     char ar_fmag[2];            /* Always contains ARFMAG.  */
     345    char ar_name[16];           /* Member file name, sometimes / terminated. */
     346    char ar_date[12];           /* File date, decimal seconds since Epoch.  */
     347    char ar_uid[6], ar_gid[6];  /* User and group IDs, in ASCII decimal.  */
     348    char ar_mode[8];            /* File mode, in ASCII octal.  */
     349    char ar_size[10];           /* File size, in ASCII decimal.  */
     350    char ar_fmag[2];            /* Always contains ARFMAG.  */
    273351  };
    274352# endif
     
    295373
    296374/* Cray's <ar.h> apparently defines this.  */
    297 #ifndef AR_HDR_SIZE
    298 # define   AR_HDR_SIZE  (sizeof (struct ar_hdr))
     375#ifndef AR_HDR_SIZE
     376# define   AR_HDR_SIZE  (sizeof (struct ar_hdr))
    299377#endif
    300378
     
    332410#ifdef AIAMAG
    333411  FL_HDR fl_header;
    334 #ifdef AIAMAGBIG
     412# ifdef AIAMAGBIG
    335413  int big_archive = 0;
    336414  FL_HDR_BIG fl_header_big;
    337 #endif
    338 #else
    339   int long_name = 0;
     415# endif
    340416#endif
    341417  char *namemap = 0;
     
    346422  {
    347423    char buf[SARMAG];
    348     register int nread = read (desc, buf, SARMAG);
     424    int nread;
     425    EINTRLOOP (nread, read (desc, buf, SARMAG));
    349426    if (nread != SARMAG || memcmp (buf, ARMAG, SARMAG))
    350427      {
    351         (void) close (desc);
    352         return -2;
     428        (void) close (desc);
     429        return -2;
    353430      }
    354431  }
     
    356433#ifdef AIAMAG
    357434  {
    358     register int nread = read (desc, &fl_header, FL_HSZ);
    359 
     435    int nread;
     436    EINTRLOOP (nread, read (desc, &fl_header, FL_HSZ));
    360437    if (nread != FL_HSZ)
    361438      {
    362         (void) close (desc);
    363         return -2;
     439        (void) close (desc);
     440        return -2;
    364441      }
    365442#ifdef AIAMAGBIG
     
    368445    if (!memcmp (fl_header.fl_magic, AIAMAGBIG, SAIAMAG))
    369446      {
    370         big_archive = 1;
    371 
    372         /* seek back to beginning of archive */
    373         if (lseek (desc, 0, 0) < 0)
    374           {
    375             (void) close (desc);
    376             return -2;
    377           }
    378 
    379         /* re-read the header into the "big" structure */
    380         nread = read (desc, &fl_header_big, FL_HSZ_BIG);
    381         if (nread != FL_HSZ_BIG)
    382           {
    383             (void) close (desc);
    384             return -2;
    385           }
     447        off_t o;
     448
     449        big_archive = 1;
     450
     451        /* seek back to beginning of archive */
     452        EINTRLOOP (o, lseek (desc, 0, 0));
     453        if (o < 0)
     454          {
     455            (void) close (desc);
     456            return -2;
     457          }
     458
     459        /* re-read the header into the "big" structure */
     460        EINTRLOOP (nread, read (desc, &fl_header_big, FL_HSZ_BIG));
     461        if (nread != FL_HSZ_BIG)
     462          {
     463            (void) close (desc);
     464            return -2;
     465          }
    386466      }
    387467    else
     
    389469       /* Check to make sure this is a "normal" archive. */
    390470      if (memcmp (fl_header.fl_magic, AIAMAG, SAIAMAG))
    391         {
     471        {
    392472          (void) close (desc);
    393473          return -2;
    394         }
     474        }
    395475  }
    396476#else
     
    401481    unsigned short int buf;
    402482#endif
    403     register int nread = read(desc, &buf, sizeof (buf));
     483    int nread;
     484    EINTRLOOP (nread, read (desc, &buf, sizeof (buf)));
    404485    if (nread != sizeof (buf) || buf != ARMAG)
    405486      {
    406         (void) close (desc);
    407         return -2;
     487        (void) close (desc);
     488        return -2;
    408489      }
    409490  }
     
    423504    if ( big_archive )
    424505      {
    425         sscanf (fl_header_big.fl_fstmoff, "%20ld", &member_offset);
    426         sscanf (fl_header_big.fl_lstmoff, "%20ld", &last_member_offset);
     506        sscanf (fl_header_big.fl_fstmoff, "%20ld", &member_offset);
     507        sscanf (fl_header_big.fl_lstmoff, "%20ld", &last_member_offset);
    427508      }
    428509    else
    429510#endif
    430511      {
    431         sscanf (fl_header.fl_fstmoff, "%12ld", &member_offset);
    432         sscanf (fl_header.fl_lstmoff, "%12ld", &last_member_offset);
     512        sscanf (fl_header.fl_fstmoff, "%12ld", &member_offset);
     513        sscanf (fl_header.fl_lstmoff, "%12ld", &last_member_offset);
    433514      }
    434515
    435516    if (member_offset == 0)
    436517      {
    437         /* Empty archive.  */
    438         close (desc);
    439         return 0;
     518        /* Empty archive.  */
     519        close (desc);
     520        return 0;
    440521      }
    441522#else
    442 #ifndef M_XENIX
     523#ifndef M_XENIX
    443524    register long int member_offset = sizeof (int);
    444 #else   /* Xenix.  */
     525#else   /* Xenix.  */
    445526    register long int member_offset = sizeof (unsigned short int);
    446 #endif  /* Not Xenix.  */
     527#endif  /* Not Xenix.  */
    447528#endif
    448529#endif
     
    450531    while (1)
    451532      {
    452         register int nread;
    453         struct ar_hdr member_header;
     533        register int nread;
     534        struct ar_hdr member_header;
    454535#ifdef AIAMAGBIG
    455         struct ar_hdr_big member_header_big;
     536        struct ar_hdr_big member_header_big;
    456537#endif
    457538#ifdef AIAMAG
    458         char name[256];
    459         int name_len;
    460         long int dateval;
    461         int uidval, gidval;
    462         long int data_offset;
    463 #else
    464         char namebuf[sizeof member_header.ar_name + 1];
    465         char *name;
    466         int is_namemap;         /* Nonzero if this entry maps long names.  */
    467 #endif
    468         long int eltsize;
    469         int eltmode;
    470         long int fnval;
    471 
    472         if (lseek (desc, member_offset, 0) < 0)
    473           {
    474             (void) close (desc);
    475             return -2;
    476           }
     539        char name[256];
     540        int name_len;
     541        long int dateval;
     542        int uidval, gidval;
     543        long int data_offset;
     544#else
     545        char namebuf[sizeof member_header.ar_name + 1];
     546        char *name;
     547        int is_namemap;         /* Nonzero if this entry maps long names.  */
     548        int long_name = 0;
     549#endif
     550        long int eltsize;
     551        unsigned int eltmode;
     552        long int fnval;
     553        off_t o;
     554
     555        EINTRLOOP (o, lseek (desc, member_offset, 0));
     556        if (o < 0)
     557          {
     558            (void) close (desc);
     559            return -2;
     560          }
    477561
    478562#ifdef AIAMAG
     
    480564
    481565#ifdef AIAMAGBIG
    482         if (big_archive)
    483           {
    484             nread = read (desc, &member_header_big,
    485                           AR_MEMHDR_SZ(member_header_big) );
    486 
    487             if (nread != AR_MEMHDR_SZ(member_header_big))
    488               {
    489                 (void) close (desc);
    490                 return -2;
    491               }
    492 
    493             sscanf (member_header_big.ar_namlen, "%4d", &name_len);
    494             nread = read (desc, name, name_len);
    495 
    496             if (nread != name_len)
    497               {
    498                 (void) close (desc);
    499                 return -2;
    500               }
    501 
    502             name[name_len] = 0;
    503 
    504             sscanf (member_header_big.ar_date, "%12ld", &dateval);
    505             sscanf (member_header_big.ar_uid, "%12d", &uidval);
    506             sscanf (member_header_big.ar_gid, "%12d", &gidval);
    507             sscanf (member_header_big.ar_mode, "%12o", &eltmode);
    508             sscanf (member_header_big.ar_size, "%20ld", &eltsize);
    509 
    510             data_offset = (member_offset + AR_MEMHDR_SZ(member_header_big)
    511                            + name_len + 2);
    512           }
    513         else
    514 #endif
    515           {
    516             nread = read (desc, &member_header,
    517                           AR_MEMHDR_SZ(member_header) );
    518 
    519             if (nread != AR_MEMHDR_SZ(member_header))
    520               {
    521                 (void) close (desc);
    522                 return -2;
    523               }
    524 
    525             sscanf (member_header.ar_namlen, "%4d", &name_len);
    526             nread = read (desc, name, name_len);
    527 
    528             if (nread != name_len)
    529               {
    530                 (void) close (desc);
    531                 return -2;
    532               }
    533 
    534             name[name_len] = 0;
    535 
    536             sscanf (member_header.ar_date, "%12ld", &dateval);
    537             sscanf (member_header.ar_uid, "%12d", &uidval);
    538             sscanf (member_header.ar_gid, "%12d", &gidval);
    539             sscanf (member_header.ar_mode, "%12o", &eltmode);
    540             sscanf (member_header.ar_size, "%12ld", &eltsize);
    541 
    542             data_offset = (member_offset + AR_MEMHDR_SZ(member_header)
    543                            + name_len + 2);
    544           }
    545         data_offset += data_offset % 2;
    546 
    547         fnval =
    548           (*function) (desc, name, 0,
    549                        member_offset, data_offset, eltsize,
    550                        dateval, uidval, gidval,
    551                        eltmode, arg);
    552 
    553 #else   /* Not AIAMAG.  */
    554         nread = read (desc, &member_header, AR_HDR_SIZE);
    555         if (nread == 0)
    556           /* No data left means end of file; that is OK.  */
    557           break;
    558 
    559         if (nread != AR_HDR_SIZE
     566        if (big_archive)
     567          {
     568            EINTRLOOP (nread, read (desc, &member_header_big,
     569                                    AR_MEMHDR_SZ(member_header_big)));
     570
     571            if (nread != AR_MEMHDR_SZ(member_header_big))
     572              {
     573                (void) close (desc);
     574                return -2;
     575              }
     576
     577            sscanf (member_header_big.ar_namlen, "%4d", &name_len);
     578            EINTRLOOP (nread, read (desc, name, name_len));
     579
     580            if (nread != name_len)
     581              {
     582                (void) close (desc);
     583                return -2;
     584              }
     585
     586            name[name_len] = 0;
     587
     588            sscanf (member_header_big.ar_date, "%12ld", &dateval);
     589            sscanf (member_header_big.ar_uid, "%12d", &uidval);
     590            sscanf (member_header_big.ar_gid, "%12d", &gidval);
     591            sscanf (member_header_big.ar_mode, "%12o", &eltmode);
     592            sscanf (member_header_big.ar_size, "%20ld", &eltsize);
     593
     594            data_offset = (member_offset + AR_MEMHDR_SZ(member_header_big)
     595                           + name_len + 2);
     596          }
     597        else
     598#endif
     599          {
     600            EINTRLOOP (nread, read (desc, &member_header,
     601                                    AR_MEMHDR_SZ(member_header)));
     602
     603            if (nread != AR_MEMHDR_SZ(member_header))
     604              {
     605                (void) close (desc);
     606                return -2;
     607              }
     608
     609            sscanf (member_header.ar_namlen, "%4d", &name_len);
     610            EINTRLOOP (nread, read (desc, name, name_len));
     611
     612            if (nread != name_len)
     613              {
     614                (void) close (desc);
     615                return -2;
     616              }
     617
     618            name[name_len] = 0;
     619
     620            sscanf (member_header.ar_date, "%12ld", &dateval);
     621            sscanf (member_header.ar_uid, "%12d", &uidval);
     622            sscanf (member_header.ar_gid, "%12d", &gidval);
     623            sscanf (member_header.ar_mode, "%12o", &eltmode);
     624            sscanf (member_header.ar_size, "%12ld", &eltsize);
     625
     626            data_offset = (member_offset + AR_MEMHDR_SZ(member_header)
     627                           + name_len + 2);
     628          }
     629        data_offset += data_offset % 2;
     630
     631        fnval =
     632          (*function) (desc, name, 0,
     633                       member_offset, data_offset, eltsize,
     634                       dateval, uidval, gidval,
     635                       eltmode, arg);
     636
     637#else   /* Not AIAMAG.  */
     638        EINTRLOOP (nread, read (desc, &member_header, AR_HDR_SIZE));
     639        if (nread == 0)
     640          /* No data left means end of file; that is OK.  */
     641          break;
     642
     643        if (nread != AR_HDR_SIZE
    560644#if defined(ARFMAG) || defined(ARFZMAG)
    561             || (
     645            || (
    562646# ifdef ARFMAG
    563647                memcmp (member_header.ar_fmag, ARFMAG, 2)
     
    573657               )
    574658#endif
    575             )
    576           {
    577             (void) close (desc);
    578             return -2;
    579           }
    580 
    581         name = namebuf;
    582         memcpy (name, member_header.ar_name, sizeof member_header.ar_name);
    583         {
    584           register char *p = name + sizeof member_header.ar_name;
    585           do
    586             *p = '\0';
    587           while (p > name && *--p == ' ');
     659            )
     660          {
     661            (void) close (desc);
     662            return -2;
     663          }
     664
     665        name = namebuf;
     666        memcpy (name, member_header.ar_name, sizeof member_header.ar_name);
     667        {
     668          register char *p = name + sizeof member_header.ar_name;
     669          do
     670            *p = '\0';
     671          while (p > name && *--p == ' ');
    588672
    589673#ifndef AIAMAG
    590           /* If the member name is "//" or "ARFILENAMES/" this may be
    591              a list of file name mappings.  The maximum file name
    592              length supported by the standard archive format is 14
    593              characters.  This member will actually always be the
    594              first or second entry in the archive, but we don't check
    595              that.  */
    596           is_namemap = (!strcmp (name, "//")
    597                         || !strcmp (name, "ARFILENAMES/"));
    598 #endif  /* Not AIAMAG. */
    599           /* On some systems, there is a slash after each member name.  */
    600           if (*p == '/')
    601             *p = '\0';
     674          /* If the member name is "//" or "ARFILENAMES/" this may be
     675             a list of file name mappings.  The maximum file name
     676             length supported by the standard archive format is 14
     677             characters.  This member will actually always be the
     678             first or second entry in the archive, but we don't check
     679             that.  */
     680          is_namemap = (!strcmp (name, "//")
     681                        || !strcmp (name, "ARFILENAMES/"));
     682#endif  /* Not AIAMAG. */
     683          /* On some systems, there is a slash after each member name.  */
     684          if (*p == '/')
     685            *p = '\0';
    602686
    603687#ifndef AIAMAG
    604           /* If the member name starts with a space or a slash, this
    605              is an index into the file name mappings (used by GNU ar).
    606              Otherwise if the member name looks like #1/NUMBER the
    607              real member name appears in the element data (used by
    608              4.4BSD).  */
    609           if (! is_namemap
    610               && (name[0] == ' ' || name[0] == '/')
    611               && namemap != 0)
    612             {
    613               name = namemap + atoi (name + 1);
    614               long_name = 1;
    615             }
    616           else if (name[0] == '#'
    617                    && name[1] == '1'
    618                    && name[2] == '/')
    619             {
    620               int namesize = atoi (name + 3);
    621 
    622               name = alloca (namesize + 1);
    623               nread = read (desc, name, namesize);
    624               if (nread != namesize)
    625                 {
    626                   close (desc);
    627                   return -2;
    628                 }
    629               name[namesize] = '\0';
    630 
    631               long_name = 1;
    632             }
     688          /* If the member name starts with a space or a slash, this
     689             is an index into the file name mappings (used by GNU ar).
     690             Otherwise if the member name looks like #1/NUMBER the
     691             real member name appears in the element data (used by
     692             4.4BSD).  */
     693          if (! is_namemap
     694              && (name[0] == ' ' || name[0] == '/')
     695              && namemap != 0)
     696            {
     697              name = namemap + atoi (name + 1);
     698              long_name = 1;
     699            }
     700          else if (name[0] == '#'
     701                   && name[1] == '1'
     702                   && name[2] == '/')
     703            {
     704              int namesize = atoi (name + 3);
     705
     706              name = alloca (namesize + 1);
     707              EINTRLOOP (nread, read (desc, name, namesize));
     708              if (nread != namesize)
     709                {
     710                  close (desc);
     711                  return -2;
     712                }
     713              name[namesize] = '\0';
     714
     715              long_name = 1;
     716            }
    633717#endif /* Not AIAMAG. */
    634         }
    635 
    636 #ifndef M_XENIX
    637         sscanf (TOCHAR (member_header.ar_mode), "%o", &eltmode);
    638         eltsize = atol (TOCHAR (member_header.ar_size));
    639 #else   /* Xenix.  */
    640         eltmode = (unsigned short int) member_header.ar_mode;
    641         eltsize = member_header.ar_size;
    642 #endif  /* Not Xenix.  */
    643 
    644         fnval =
    645           (*function) (desc, name, ! long_name, member_offset,
    646                        member_offset + AR_HDR_SIZE, eltsize,
    647 #ifndef M_XENIX
    648                        atol (TOCHAR (member_header.ar_date)),
    649                        atoi (TOCHAR (member_header.ar_uid)),
    650                        atoi (TOCHAR (member_header.ar_gid)),
    651 #else   /* Xenix.  */
    652                        member_header.ar_date,
    653                        member_header.ar_uid,
    654                        member_header.ar_gid,
    655 #endif  /* Not Xenix.  */
    656                        eltmode, arg);
     718        }
     719
     720#ifndef M_XENIX
     721        sscanf (TOCHAR (member_header.ar_mode), "%o", &eltmode);
     722        eltsize = atol (TOCHAR (member_header.ar_size));
     723#else   /* Xenix.  */
     724        eltmode = (unsigned short int) member_header.ar_mode;
     725        eltsize = member_header.ar_size;
     726#endif  /* Not Xenix.  */
     727
     728        fnval =
     729          (*function) (desc, name, ! long_name, member_offset,
     730                       member_offset + AR_HDR_SIZE, eltsize,
     731#ifndef M_XENIX
     732                       atol (TOCHAR (member_header.ar_date)),
     733                       atoi (TOCHAR (member_header.ar_uid)),
     734                       atoi (TOCHAR (member_header.ar_gid)),
     735#else   /* Xenix.  */
     736                       member_header.ar_date,
     737                       member_header.ar_uid,
     738                       member_header.ar_gid,
     739#endif  /* Not Xenix.  */
     740                       eltmode, arg);
    657741
    658742#endif  /* AIAMAG.  */
    659743
    660         if (fnval)
    661           {
    662             (void) close (desc);
    663             return fnval;
    664           }
     744        if (fnval)
     745          {
     746            (void) close (desc);
     747            return fnval;
     748          }
    665749
    666750#ifdef AIAMAG
    667         if (member_offset == last_member_offset)
    668           /* End of the chain.  */
    669           break;
     751        if (member_offset == last_member_offset)
     752          /* End of the chain.  */
     753          break;
    670754
    671755#ifdef AIAMAGBIG
    672         if (big_archive)
     756        if (big_archive)
    673757         sscanf (member_header_big.ar_nxtmem, "%20ld", &member_offset);
    674         else
    675 #endif
    676           sscanf (member_header.ar_nxtmem, "%12ld", &member_offset);
    677 
    678         if (lseek (desc, member_offset, 0) != member_offset)
    679           {
    680             (void) close (desc);
    681             return -2;
    682           }
    683 #else
    684 
    685         /* If this member maps archive names, we must read it in.  The
    686            name map will always precede any members whose names must
    687            be mapped.  */
    688         if (is_namemap)
    689           {
    690             char *clear;
    691             char *limit;
    692 
    693             namemap = alloca (eltsize);
    694             nread = read (desc, namemap, eltsize);
    695             if (nread != eltsize)
    696               {
    697                 (void) close (desc);
    698                 return -2;
    699               }
    700 
    701             /* The names are separated by newlines.  Some formats have
    702                a trailing slash.  Null terminate the strings for
    703                convenience.  */
    704             limit = namemap + eltsize;
    705             for (clear = namemap; clear < limit; clear++)
    706               {
    707                 if (*clear == '\n')
    708                   {
    709                     *clear = '\0';
    710                     if (clear[-1] == '/')
    711                       clear[-1] = '\0';
    712                   }
    713               }
    714 
    715             is_namemap = 0;
    716           }
    717 
    718         member_offset += AR_HDR_SIZE + eltsize;
    719         if (member_offset % 2 != 0)
    720           member_offset++;
     758        else
     759#endif
     760          sscanf (member_header.ar_nxtmem, "%12ld", &member_offset);
     761
     762        if (lseek (desc, member_offset, 0) != member_offset)
     763          {
     764            (void) close (desc);
     765            return -2;
     766          }
     767#else
     768
     769        /* If this member maps archive names, we must read it in.  The
     770           name map will always precede any members whose names must
     771           be mapped.  */
     772        if (is_namemap)
     773          {
     774            char *clear;
     775            char *limit;
     776
     777            namemap = alloca (eltsize);
     778            EINTRLOOP (nread, read (desc, namemap, eltsize));
     779            if (nread != eltsize)
     780              {
     781                (void) close (desc);
     782                return -2;
     783              }
     784
     785            /* The names are separated by newlines.  Some formats have
     786               a trailing slash.  Null terminate the strings for
     787               convenience.  */
     788            limit = namemap + eltsize;
     789            for (clear = namemap; clear < limit; clear++)
     790              {
     791                if (*clear == '\n')
     792                  {
     793                    *clear = '\0';
     794                    if (clear[-1] == '/')
     795                      clear[-1] = '\0';
     796                  }
     797              }
     798
     799            is_namemap = 0;
     800          }
     801
     802        member_offset += AR_HDR_SIZE + eltsize;
     803        if (member_offset % 2 != 0)
     804          member_offset++;
    721805#endif
    722806      }
     
    751835      struct ar_hdr hdr;
    752836#if !defined (__hpux) && !defined (cray)
    753       return strneq (name, mem, sizeof(hdr.ar_name) - 1);
    754 #else
    755       return strneq (name, mem, sizeof(hdr.ar_name) - 2);
     837      return strneq (name, mem, sizeof (hdr.ar_name) - 1);
     838#else
     839      return strneq (name, mem, sizeof (hdr.ar_name) - 2);
    756840#endif /* !__hpux && !cray */
    757841#endif /* !AIAMAG */
    758842    }
     843
     844  return !strcmp (name, mem);
     845#else
     846  /* VMS members do not have suffixes, but the filenames usually
     847     have.
     848     Do we need to strip VMS disk/directory format paths?
     849
     850     Most VMS compilers etc. by default are case insensitive
     851     but produce uppercase external names, incl. module names.
     852     However the VMS librarian (ar) and the linker by default
     853     are case sensitive: they take what they get, usually
     854     uppercase names. So for the non-default settings of the
     855     compilers etc. there is a need to have a case sensitive
     856     mode. */
     857  {
     858    int len;
     859    len = strlen(mem);
     860    int match;
     861    char *dot;
     862    if ((dot=strrchr(name,'.')))
     863      match = (len == dot - name) && !strncasecmp(name, mem, len);
     864    else
     865      match = !strcasecmp (name, mem);
     866    return match;
     867  }
    759868#endif /* !VMS */
    760 
    761   return !strcmp (name, mem);
    762869}
    763870
     
    767874static long int
    768875ar_member_pos (int desc UNUSED, const char *mem, int truncated,
    769                long int hdrpos, long int datapos UNUSED, long int size UNUSED,
     876               long int hdrpos, long int datapos UNUSED, long int size UNUSED,
    770877               long int date UNUSED, int uid UNUSED, int gid UNUSED,
    771                int mode UNUSED, const void *name)
     878               unsigned int mode UNUSED, const void *name)
    772879{
    773880  if (!ar_name_equal (name, mem, truncated))
     
    789896  int fd;
    790897  struct ar_hdr ar_hdr;
    791   int i;
     898  off_t o;
     899  int r;
    792900  unsigned int ui;
    793901  struct stat statbuf;
     
    798906    return 1;
    799907
    800   fd = open (arname, O_RDWR, 0666);
     908  EINTRLOOP (fd, open (arname, O_RDWR, 0666));
    801909  if (fd < 0)
    802910    return -3;
    803911  /* Read in this member's header */
    804   if (lseek (fd, pos, 0) < 0)
     912  EINTRLOOP (o, lseek (fd, pos, 0));
     913  if (o < 0)
    805914    goto lose;
    806   if (AR_HDR_SIZE != read (fd, &ar_hdr, AR_HDR_SIZE))
     915  EINTRLOOP (r, read (fd, &ar_hdr, AR_HDR_SIZE));
     916  if (r != AR_HDR_SIZE)
    807917    goto lose;
    808918  /* Write back the header, thus touching the archive file.  */
    809   if (lseek (fd, pos, 0) < 0)
     919  EINTRLOOP (o, lseek (fd, pos, 0));
     920  if (o < 0)
    810921    goto lose;
    811   if (AR_HDR_SIZE != write (fd, &ar_hdr, AR_HDR_SIZE))
     922  EINTRLOOP (r, write (fd, &ar_hdr, AR_HDR_SIZE));
     923  if (r != AR_HDR_SIZE)
    812924    goto lose;
    813925  /* The file's mtime is the time we we want.  */
    814   EINTRLOOP (i, fstat (fd, &statbuf));
    815   if (i < 0)
     926  EINTRLOOP (r, fstat (fd, &statbuf));
     927  if (r < 0)
    816928    goto lose;
    817929#if defined(ARFMAG) || defined(ARFZMAG) || defined(AIAMAG) || defined(WINDOWS32)
     
    819931  for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++)
    820932    ar_hdr.ar_date[ui] = ' ';
    821   sprintf (TOCHAR (ar_hdr.ar_date), "%ld", (long int) statbuf.st_mtime);
     933  sprintf (TOCHAR (ar_hdr.ar_date), "%lu", (long unsigned) statbuf.st_mtime);
    822934#ifdef AIAMAG
    823   ar_hdr.ar_date[strlen(ar_hdr.ar_date)] = ' ';
     935  ar_hdr.ar_date[strlen (ar_hdr.ar_date)] = ' ';
    824936#endif
    825937#else
     
    827939#endif
    828940  /* Write back this member's header */
    829   if (lseek (fd, pos, 0) < 0)
     941  EINTRLOOP (o, lseek (fd, pos, 0));
     942  if (o < 0)
    830943    goto lose;
    831   if (AR_HDR_SIZE != write (fd, &ar_hdr, AR_HDR_SIZE))
     944  EINTRLOOP (r, write (fd, &ar_hdr, AR_HDR_SIZE));
     945  if (r != AR_HDR_SIZE)
    832946    goto lose;
    833947  close (fd);
     
    835949
    836950 lose:
    837   i = errno;
     951  r = errno;
    838952  close (fd);
    839   errno = i;
     953  errno = r;
    840954  return -3;
    841955}
     
    847961long int
    848962describe_member (int desc, const char *name, int truncated,
    849                  long int hdrpos, long int datapos, long int size,
    850                  long int date, int uid, int gid, int mode, const void *arg)
     963                 long int hdrpos, long int datapos, long int size,
     964                 long int date, int uid, int gid, unsigned int mode,
     965                 const void *arg)
    851966{
    852967  extern char *ctime ();
    853968
    854   printf (_("Member `%s'%s: %ld bytes at %ld (%ld).\n"),
    855           name, truncated ? _(" (name might be truncated)") : "",
    856           size, hdrpos, datapos);
     969  printf (_("Member '%s'%s: %ld bytes at %ld (%ld).\n"),
     970          name, truncated ? _(" (name might be truncated)") : "",
     971          size, hdrpos, datapos);
    857972  printf (_("  Date %s"), ctime (&date));
    858973  printf (_("  uid = %d, gid = %d, mode = 0%o.\n"), uid, gid, mode);
     
    868983}
    869984
    870 #endif  /* TEST.  */
    871 #endif  /* NO_ARCHIVES.  */
     985#endif  /* TEST.  */
     986#endif  /* NO_ARCHIVES.  */
  • vendor/gnumake/current/build.template

    r2596 r3138  
    11#!/bin/sh
    2 # Shell script to build GNU Make in the absence of any `make' program.
     2# Shell script to build GNU Make in the absence of any 'make' program.
    33# @configure_input@
    44
    5 # Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
    6 # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     5# Copyright (C) 1993-2016 Free Software Foundation, Inc.
    76# This file is part of GNU Make.
    87#
     
    2423srcdir='@srcdir@'
    2524CC='@CC@'
    26 CFLAGS='@CFLAGS@'
     25CFLAGS='@CFLAGS@ @GUILE_CFLAGS@'
    2726CPPFLAGS='@CPPFLAGS@'
    28 LDFLAGS='@LDFLAGS@'
     27LDFLAGS='@AM_LDFLAGS@ @LDFLAGS@'
    2928ALLOCA='@ALLOCA@'
    30 LOADLIBES='@LIBS@ @LIBINTL@'
     29LOADLIBES='@LIBS@ @GUILE_LIBS@ @LIBINTL@'
    3130eval extras=\'@LIBOBJS@\'
    3231REMOTE='@REMOTE@'
     
    4039# Common prefix for machine-dependent installed files.
    4140exec_prefix=`eval echo @exec_prefix@`
    42 # Directory to find libraries in for `-lXXX'.
     41# Directory to find libraries in for '-lXXX'.
    4342libdir=${exec_prefix}/lib
    4443# Directory to search by default for included makefiles.
     
    4847aliaspath=${localedir}${PATH_SEPARATOR}.
    4948
    50 defines="-DALIASPATH=\"${aliaspath}\" -DLOCALEDIR=\"${localedir}\" -DLIBDIR=\"${libdir}\" -DINCLUDEDIR=\"${includedir}\""' @DEFS@'
     49defines="-DLOCALEDIR=\"${localedir}\" -DLIBDIR=\"${libdir}\" -DINCLUDEDIR=\"${includedir}\""' @DEFS@'
    5150
    5251# Exit as soon as any command fails.
  • vendor/gnumake/current/build_w32.bat

    r2596 r3138  
    11@echo off
    2 rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 rem 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2rem Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43rem This file is part of GNU Make.
    54rem
     
    1716rem with this program.  If not, see <http://www.gnu.org/licenses/>.
    1817
    19 if exist config.h.W32 GoTo NotCVS
    20 sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.in > config.h.W32.sed
    21 echo s,%%PACKAGE%%,make,g >> config.h.W32.sed
    22 sed -f config.h.W32.sed config.h.W32.template > config.h.W32
    23 :NotCVS
    24 if not exist config.h copy config.h.W32 config.h
    25 cd w32\subproc
    26 echo "Creating the subproc library"
    27 %ComSpec% /c build.bat %1
    28 cd ..\..
    29 
    30 if exist link.dbg del link.dbg
    31 if exist link.rel del link.rel
    32 echo "Creating GNU Make for Windows 9X/NT/2K/XP"
    33 if "%1" == "gcc" GoTo GCCBuild
    34 set make=gnumake
    35 echo on
    36 if not exist .\WinDebug\nul mkdir .\WinDebug
    37 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D TIVOLI /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c variable.c
    38 echo WinDebug\variable.obj >>link.dbg
    39 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c rule.c
    40 echo WinDebug\rule.obj >>link.dbg
    41 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c remote-stub.c
    42 echo WinDebug\remote-stub.obj >>link.dbg
    43 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c commands.c
    44 echo WinDebug\commands.obj >>link.dbg
    45 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c file.c
    46 echo WinDebug\file.obj >>link.dbg
    47 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c getloadavg.c
    48 echo WinDebug\getloadavg.obj >>link.dbg
    49 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c default.c
    50 echo WinDebug\default.obj >>link.dbg
    51 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c signame.c
    52 echo WinDebug\signame.obj >>link.dbg
    53 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c expand.c
    54 echo WinDebug\expand.obj >>link.dbg
    55 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c dir.c
    56 echo WinDebug\dir.obj >>link.dbg
    57 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c main.c
    58 echo WinDebug\main.obj >>link.dbg
    59 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c getopt1.c
    60 echo WinDebug\getopt1.obj >>link.dbg
    61 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c job.c
    62 echo WinDebug\job.obj >>link.dbg
    63 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c read.c
    64 echo WinDebug\read.obj >>link.dbg
    65 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c version.c
    66 echo WinDebug\version.obj >>link.dbg
    67 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c getopt.c
    68 echo WinDebug\getopt.obj >>link.dbg
    69 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c arscan.c
    70 echo WinDebug\arscan.obj >>link.dbg
    71 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c hash.c
    72 echo WinDebug\hash.obj >>link.dbg
    73 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c strcache.c
    74 echo WinDebug\strcache.obj >>link.dbg
    75 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c remake.c
    76 echo WinDebug\remake.obj >>link.dbg
    77 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c misc.c
    78 echo WinDebug\misc.obj >>link.dbg
    79 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c ar.c
    80 echo WinDebug\ar.obj >>link.dbg
    81 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c function.c
    82 echo WinDebug\function.obj >>link.dbg
    83 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c vpath.c
    84 echo WinDebug\vpath.obj >>link.dbg
    85 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c implicit.c
    86 echo WinDebug\implicit.obj >>link.dbg
    87 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c  .\w32\compat\dirent.c
    88 echo WinDebug\dirent.obj >>link.dbg
    89 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c  .\glob\glob.c
    90 echo WinDebug\glob.obj >>link.dbg
    91 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c  .\glob\fnmatch.c
    92 echo WinDebug\fnmatch.obj >>link.dbg
    93 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c  .\w32\pathstuff.c
    94 echo WinDebug\pathstuff.obj >>link.dbg
    95 echo off
    96 echo "Linking WinDebug/%make%.exe"
    97 rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\windebug\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /OUT:.\WinDebug/%make%.exe .\WinDebug/variable.obj  .\WinDebug/rule.obj  .\WinDebug/remote-stub.obj  .\WinDebug/commands.obj  .\WinDebug/file.obj  .\WinDebug/getloadavg.obj  .\WinDebug/default.obj  .\WinDebug/signame.obj  .\WinDebug/expand.obj  .\WinDebug/dir.obj  .\WinDebug/main.obj  .\WinDebug/getopt1.obj  .\WinDebug/job.obj  .\WinDebug/read.obj  .\WinDebug/version.obj  .\WinDebug/getopt.obj  .\WinDebug/arscan.obj  .\WinDebug/remake.obj  .\WinDebug/hash.obj  .\WinDebug/strcache.obj  .\WinDebug/misc.obj  .\WinDebug/ar.obj  .\WinDebug/function.obj  .\WinDebug/vpath.obj  .\WinDebug/implicit.obj  .\WinDebug/dirent.obj  .\WinDebug/glob.obj  .\WinDebug/fnmatch.obj  .\WinDebug/pathstuff.obj
    98 echo kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\windebug\subproc.lib >>link.dbg
    99 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /OUT:.\WinDebug/%make%.exe @link.dbg
    100 if not exist .\WinDebug/%make%.exe echo "WinDebug build failed"
    101 if exist .\WinDebug/%make%.exe echo "WinDebug build succeeded!"
    102 if not exist .\WinRel\nul mkdir .\WinRel
    103 echo on
    104 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /D TIVOLI /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c variable.c
    105 echo WinRel\variable.obj >>link.rel
    106 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c rule.c
    107 echo WinRel\rule.obj >>link.rel
    108 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c remote-stub.c
    109 echo WinRel\remote-stub.obj >>link.rel
    110 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c commands.c
    111 echo WinRel\commands.obj >>link.rel
    112 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c file.c
    113 echo WinRel\file.obj >>link.rel
    114 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c getloadavg.c
    115 echo WinRel\getloadavg.obj >>link.rel
    116 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c default.c
    117 echo WinRel\default.obj >>link.rel
    118 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c signame.c
    119 echo WinRel\signame.obj >>link.rel
    120 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c expand.c
    121 echo WinRel\expand.obj >>link.rel
    122 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c dir.c
    123 echo WinRel\dir.obj >>link.rel
    124 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c main.c
    125 echo WinRel\main.obj >>link.rel
    126 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c getopt1.c
    127 echo WinRel\getopt1.obj >>link.rel
    128 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c job.c
    129 echo WinRel\job.obj >>link.rel
    130 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c read.c
    131 echo WinRel\read.obj >>link.rel
    132 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c version.c
    133 echo WinRel\version.obj >>link.rel
    134 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c getopt.c
    135 echo WinRel\getopt.obj >>link.rel
    136 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c arscan.c
    137 echo WinRel\arscan.obj >>link.rel
    138 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c remake.c
    139 echo WinRel\remake.obj >>link.rel
    140 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c hash.c
    141 echo WinRel\hash.obj >>link.rel
    142 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c strcache.c
    143 echo WinRel\strcache.obj >>link.rel
    144 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c misc.c
    145 echo WinRel\misc.obj >>link.rel
    146 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c ar.c
    147 echo WinRel\ar.obj >>link.rel
    148 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c function.c
    149 echo WinRel\function.obj >>link.rel
    150 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c vpath.c
    151 echo WinRel\vpath.obj >>link.rel
    152 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c implicit.c
    153 echo WinRel\implicit.obj >>link.rel
    154 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c  .\w32\compat\dirent.c
    155 echo WinRel\dirent.obj >>link.rel
    156 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c  .\glob\glob.c
    157 echo WinRel\glob.obj >>link.rel
    158 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c  .\glob\fnmatch.c
    159 echo WinRel\fnmatch.obj >>link.rel
    160 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c  .\w32\pathstuff.c
    161 echo WinRel\pathstuff.obj >>link.rel
    162 echo off
    163 echo "Linking WinRel/%make%.exe"
    164 rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\winrel\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /OUT:.\WinRel/%make%.exe .\WinRel/variable.obj  .\WinRel/rule.obj  .\WinRel/remote-stub.obj  .\WinRel/commands.obj  .\WinRel/file.obj  .\WinRel/getloadavg.obj  .\WinRel/default.obj  .\WinRel/signame.obj  .\WinRel/expand.obj  .\WinRel/dir.obj  .\WinRel/main.obj  .\WinRel/getopt1.obj  .\WinRel/job.obj  .\WinRel/read.obj  .\WinRel/version.obj  .\WinRel/getopt.obj  .\WinRel/arscan.obj  .\WinRel/remake.obj  .\WinRel/misc.obj  .\WinRel/hash.obj  .\WinRel/strcache.obj  .\WinRel/ar.obj  .\WinRel/function.obj  .\WinRel/vpath.obj  .\WinRel/implicit.obj  .\WinRel/dirent.obj  .\WinRel/glob.obj  .\WinRel/fnmatch.obj  .\WinRel/pathstuff.obj
    165 echo kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\winrel\subproc.lib >>link.rel
    166 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /OUT:.\WinRel/%make%.exe @link.rel
    167 if not exist .\WinRel/%make%.exe echo "WinRel build failed"
    168 if exist .\WinRel/%make%.exe echo "WinRel build succeeded!"
    169 set make=
    170 GoTo BuildEnd
    171 :GCCBuild
    172 echo on
    173 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c variable.c
    174 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c rule.c
    175 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c remote-stub.c
    176 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c commands.c
    177 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c file.c
    178 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getloadavg.c
    179 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c default.c
    180 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c signame.c
    181 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c expand.c
    182 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c dir.c
    183 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c main.c
    184 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getopt1.c
    185 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c job.c
    186 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c read.c
    187 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c version.c
    188 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getopt.c
    189 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c arscan.c
    190 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c remake.c
    191 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c hash.c
    192 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c strcache.c
    193 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c misc.c
    194 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ar.c
    195 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c function.c
    196 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c vpath.c
    197 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c implicit.c
    198 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./glob/glob.c -o glob.o
    199 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./glob/fnmatch.c -o fnmatch.o
    200 gcc -mthreads -Wall -gdwarf-2 -g3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./w32/pathstuff.c -o pathstuff.o
    201 gcc -mthreads -gdwarf-2 -g3 -o gnumake.exe variable.o rule.o remote-stub.o commands.o file.o getloadavg.o default.o signame.o expand.o dir.o main.o getopt1.o job.o read.o version.o getopt.o arscan.o remake.o misc.o hash.o strcache.o ar.o function.o vpath.o implicit.o glob.o fnmatch.o pathstuff.o w32_misc.o sub_proc.o w32err.o -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
    202 :BuildEnd
    203 echo on
     18call :Reset
     19
     20if "%1" == "-h" goto Usage
     21if "%1" == "--help" goto Usage
     22
     23set MAKE=gnumake
     24set GUILE=Y
     25set COMPILER=msvc
     26
     27:ParseSW
     28if "%1" == "--debug" goto SetDebug
     29if "%1" == "--without-guile" goto NoGuile
     30if "%1" == "gcc" goto SetCC
     31if "%1" == "" goto DoneSW
     32
     33:SetDebug
     34set DEBUG=Y
     35shift
     36goto ParseSW
     37
     38:NoGuile
     39set GUILE=N
     40echo Building without Guile
     41shift
     42goto ParseSW
     43
     44:SetCC
     45set COMPILER=gcc
     46echo Building with GCC
     47shift
     48goto ParseSW
     49
     50rem Build with Guile is supported only on NT and later versions
     51:DoneSW
     52echo.
     53echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8
     54if "%DEBUG%" == "Y" echo Building without compiler optimizations
     55
     56if "%COMPILER%" == "gcc" goto GccBuild
     57
     58set OUTDIR=.\WinRel
     59set "OPTS=/O2 /D NDEBUG"
     60set LINKOPTS=
     61if "%DEBUG%" == "Y" set OUTDIR=.\WinDebug
     62if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG"
     63if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG
     64call :Build
     65goto Done
     66
     67:GccBuild
     68set OUTDIR=.\GccRel
     69set OPTS=-O2
     70if "%DEBUG%" == "Y" set OPTS=-O0
     71if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug
     72call :Build
     73goto Done
     74
     75:Done
     76call :Reset
     77goto :EOF
     78
     79:Build
     80:: Clean the directory if it exists
     81if exist %OUTDIR%\nul rmdir /S /Q %OUTDIR%
     82
     83:: Recreate it
     84mkdir %OUTDIR%
     85mkdir %OUTDIR%\glob
     86mkdir %OUTDIR%\w32
     87mkdir %OUTDIR%\w32\compat
     88mkdir %OUTDIR%\w32\subproc
     89
     90if "%GUILE%" == "Y" call :ChkGuile
     91
     92echo.
     93echo Compiling %OUTDIR% version
     94
     95if exist config.h.W32.template call :ConfigSCM
     96copy config.h.W32 %OUTDIR%\config.h
     97
     98call :Compile ar
     99call :Compile arscan
     100call :Compile commands
     101call :Compile default
     102call :Compile dir
     103call :Compile expand
     104call :Compile file
     105call :Compile function
     106call :Compile getloadavg
     107call :Compile getopt
     108call :Compile getopt1
     109call :Compile glob\fnmatch
     110call :Compile glob\glob
     111call :Compile guile GUILE
     112call :Compile hash
     113call :Compile implicit
     114call :Compile job
     115call :Compile load
     116call :Compile loadapi
     117call :Compile main GUILE
     118call :Compile misc
     119call :Compile output
     120call :Compile read
     121call :Compile remake
     122call :Compile remote-stub
     123call :Compile rule
     124call :Compile signame
     125call :Compile strcache
     126call :Compile variable
     127call :Compile version
     128call :Compile vpath
     129call :Compile w32\compat\posixfcn
     130call :Compile w32\pathstuff
     131call :Compile w32\subproc\misc
     132call :Compile w32\subproc\sub_proc
     133call :Compile w32\subproc\w32err
     134call :Compile w32\w32os
     135
     136if not "%COMPILER%" == "gcc" call :Compile w32\compat\dirent
     137
     138call :Link
     139
     140echo.
     141if not exist %OUTDIR%\%MAKE%.exe echo %OUTDIR% build FAILED!
     142if exist %OUTDIR%\%MAKE%.exe echo %OUTDIR% build succeeded.
     143goto :EOF
     144
     145:Compile
     146set EXTRAS=
     147if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%"
     148if "%COMPILER%" == "gcc" goto GccCompile
     149
     150:: MSVC Compile
     151echo on
     152cl.exe /nologo /MT /W4 /EHsc %OPTS% /I %OUTDIR% /I . /I glob /I w32/include /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR%OUTDIR% /Fp%OUTDIR%\%MAKE%.pch /Fo%OUTDIR%\%1.obj /Fd%OUTDIR%\%MAKE%.pdb %EXTRAS% /c %1.c
     153@echo off
     154echo %OUTDIR%\%1.obj >>%OUTDIR%\link.sc
     155goto :EOF
     156
     157:GccCompile
     158:: GCC Compile
     159echo on
     160gcc -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR% -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%\%1.o -c %1.c
     161@echo off
     162goto :EOF
     163
     164:Link
     165echo Linking %OUTDIR%/%MAKE%.exe
     166if "%COMPILER%" == "gcc" goto GccLink
     167
     168:: MSVC Link
     169echo %GUILELIBS% kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib >>%OUTDIR%\link.sc
     170echo on
     171link.exe /NOLOGO /SUBSYSTEM:console /PDB:%OUTDIR%\%MAKE%.pdb %LINKOPTS% /OUT:%OUTDIR%\%MAKE%.exe @%OUTDIR%\link.sc
     172@echo off
     173goto :EOF
     174
     175:GccLink
     176:: GCC Link
     177echo on
     178gcc -mthreads -gdwarf-2 -g3 -o %OUTDIR%\%MAKE%.exe %OUTDIR%\variable.o %OUTDIR%\rule.o %OUTDIR%\remote-stub.o %OUTDIR%\commands.o %OUTDIR%\file.o %OUTDIR%\getloadavg.o %OUTDIR%\default.o %OUTDIR%\signame.o %OUTDIR%\expand.o %OUTDIR%\dir.o %OUTDIR%\main.o %OUTDIR%\getopt1.o %OUTDIR%\guile.o %OUTDIR%\job.o %OUTDIR%\output.o %OUTDIR%\read.o %OUTDIR%\version.o %OUTDIR%\getopt.o %OUTDIR%\arscan.o %OUTDIR%\remake.o %OUTDIR%\misc.o %OUTDIR%\hash.o %OUTDIR%\strcache.o %OUTDIR%\ar.o %OUTDIR%\function.o %OUTDIR%\vpath.o %OUTDIR%\implicit.o %OUTDIR%\loadapi.o %OUTDIR%\load.o %OUTDIR%\glob\glob.o %OUTDIR%\glob\fnmatch.o %OUTDIR%\w32\pathstuff.o %OUTDIR%\w32\compat\posixfcn.o %OUTDIR%\w32\w32os.o %OUTDIR%\w32\subproc\misc.o %OUTDIR%\w32\subproc\sub_proc.o %OUTDIR%\w32\subproc\w32err.o %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -Wl,--out-implib=%OUTDIR%\libgnumake-1.dll.a
     179@echo off
     180goto :EOF
     181
     182:ConfigSCM
     183echo Generating config from SCM templates
     184sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.ac > %OUTDIR%\config.h.W32.sed
     185echo s,%%PACKAGE%%,make,g >> %OUTDIR%\config.h.W32.sed
     186sed -f %OUTDIR%\config.h.W32.sed config.h.W32.template > config.h.W32
     187echo static const char *const GUILE_module_defn = ^" \> gmk-default.h
     188sed -e "s/;.*//" -e "/^[ \t]*$/d" -e "s/\"/\\\\\"/g" -e "s/$/ \\\/" gmk-default.scm >> gmk-default.h
     189echo ^";>> gmk-default.h
     190goto :EOF
     191
     192:ChkGuile
     193if not "%OS%" == "Windows_NT" goto NoGuile
     194pkg-config --help > %OUTDIR%\guile.tmp 2> NUL
     195if ERRORLEVEL 1 goto NoPkgCfg
     196
     197echo Checking for Guile 2.0
     198if not "%COMPILER%" == "gcc" set PKGMSC=--msvc-syntax
     199pkg-config --cflags --short-errors "guile-2.0" > %OUTDIR%\guile.tmp
     200if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp
     201
     202pkg-config --libs --static --short-errors %PKGMSC% "guile-2.0" > %OUTDIR%\guile.tmp
     203if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp
     204
     205if not "%GUILECFLAGS%" == "" goto GuileDone
     206
     207echo Checking for Guile 1.8
     208pkg-config --cflags --short-errors "guile-1.8" > %OUTDIR%\guile.tmp
     209if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp
     210
     211pkg-config --libs --static --short-errors %PKGMSC% "guile-1.8" > %OUTDIR%\guile.tmp
     212if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp
     213
     214if not "%GUILECFLAGS%" == "" goto GuileDone
     215
     216echo No Guile found, building without Guile
     217goto GuileDone
     218
     219:NoPkgCfg
     220echo pkg-config not found, building without Guile
     221
     222:GuileDone
     223if "%GUILECFLAGS%" == "" goto :EOF
     224
     225echo Guile found, building with Guile
     226set "GUILECFLAGS=%GUILECFLAGS% -DHAVE_GUILE"
     227goto :EOF
     228
     229:Usage
     230echo Usage: %0 [options] [gcc]
     231echo Options:
     232echo.  --debug           For GCC only, make a debug build
     233echo.                    (MSVC build always makes both debug and release)
     234echo.  --without-guile   Do not compile Guile support even if found
     235echo.  --help            Display these instructions and exit
     236goto :EOF
     237
     238:Reset
     239set COMPILER=
     240set DEBUG=
     241set GUILE=
     242set GUILECFLAGS=
     243set GUILELIBS=
     244set LINKOPTS=
     245set MAKE=
     246set NOGUILE=
     247set OPTS=
     248set OUTDIR=
     249set PKGMSC=
     250goto :EOF
  • vendor/gnumake/current/commands.c

    r2596 r3138  
    11/* Command processing for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
     18#include "filedef.h"
    2019#include "dep.h"
    21 #include "filedef.h"
    2220#include "variable.h"
    2321#include "job.h"
     
    2927
    3028#if VMS
    31 # define FILE_LIST_SEPARATOR ','
     29# define FILE_LIST_SEPARATOR (vms_comma_separator ? ',' : ' ')
    3230#else
    3331# define FILE_LIST_SEPARATOR ' '
    3432#endif
    3533
    36 int remote_kill (int id, int sig);
    37 
    38 #ifndef HAVE_UNISTD_H
     34#ifndef HAVE_UNISTD_H
    3935int getpid ();
    4036#endif
     
    7268  const char *at, *percent, *star, *less;
    7369
    74 #ifndef NO_ARCHIVES
    75   /* If the target is an archive member `lib(member)',
    76      then $@ is `lib' and $% is `member'.  */
     70#ifndef NO_ARCHIVES
     71  /* If the target is an archive member 'lib(member)',
     72     then $@ is 'lib' and $% is 'member'.  */
    7773
    7874  if (ar_name (file->name))
     
    9490    }
    9591  else
    96 #endif  /* NO_ARCHIVES.  */
     92#endif  /* NO_ARCHIVES.  */
    9793    {
    9894      at = file->name;
     
    104100    {
    105101      /* In Unix make, $* is set to the target name with
    106         any suffix in the .SUFFIXES list stripped off for
    107          explicit rules.  We store this in the `stem' member.  */
     102        any suffix in the .SUFFIXES list stripped off for
     103         explicit rules.  We store this in the 'stem' member.  */
    108104      const char *name;
    109105      unsigned int len;
    110106
    111 #ifndef NO_ARCHIVES
     107#ifndef NO_ARCHIVES
    112108      if (ar_name (file->name))
    113         {
    114           name = strchr (file->name, '(') + 1;
    115           len = strlen (name) - 1;
    116         }
     109        {
     110          name = strchr (file->name, '(') + 1;
     111          len = strlen (name) - 1;
     112        }
    117113      else
    118114#endif
    119         {
    120           name = file->name;
    121           len = strlen (name);
    122         }
     115        {
     116          name = file->name;
     117          len = strlen (name);
     118        }
    123119
    124120      for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next)
    125         {
    126           unsigned int slen = strlen (dep_name (d));
    127           if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
    128             {
    129               file->stem = strcache_add_len (name, len - slen);
    130               break;
    131             }
    132         }
     121        {
     122          unsigned int slen = strlen (dep_name (d));
     123          if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
     124            {
     125              file->stem = strcache_add_len (name, len - slen);
     126              break;
     127            }
     128        }
    133129      if (d == 0)
    134         file->stem = "";
     130        file->stem = "";
    135131    }
    136132  star = file->stem;
     
    151147    less = at;
    152148
    153 #define DEFINE_VARIABLE(name, len, value) \
     149#define DEFINE_VARIABLE(name, len, value) \
    154150  (void) define_variable_for_file (name,len,value,o_automatic,0,file)
    155151
     
    204200    cp = plus_value;
    205201
    206     qmark_len = plus_len + 1;   /* Will be this or less.  */
     202    qmark_len = plus_len + 1;   /* Will be this or less.  */
    207203    for (d = file->deps; d != 0; d = d->next)
    208204      if (! d->ignore_mtime && ! d->need_2nd_expansion)
     
    210206          const char *c = dep_name (d);
    211207
    212 #ifndef NO_ARCHIVES
     208#ifndef NO_ARCHIVES
    213209          if (ar_name (c))
    214210            {
     
    224220          *cp++ = FILE_LIST_SEPARATOR;
    225221          if (! (d->changed || always_make_flag))
    226             qmark_len -= len + 1;       /* Don't space in $? for this one.  */
     222            qmark_len -= len + 1;       /* Don't space in $? for this one.  */
    227223        }
    228224
     
    279275
    280276        c = dep_name (d);
    281 #ifndef NO_ARCHIVES
     277#ifndef NO_ARCHIVES
    282278        if (ar_name (c))
    283           {
    284             c = strchr (c, '(') + 1;
    285             len = strlen (c) - 1;
    286           }
    287         else
    288 #endif
    289           len = strlen (c);
     279          {
     280            c = strchr (c, '(') + 1;
     281            len = strlen (c) - 1;
     282          }
     283        else
     284#endif
     285          len = strlen (c);
    290286
    291287        if (d->ignore_mtime)
    292288          {
    293289            memcpy (bp, c, len);
    294             bp += len;
    295             *bp++ = FILE_LIST_SEPARATOR;
    296           }
    297         else
     290            bp += len;
     291            *bp++ = FILE_LIST_SEPARATOR;
     292          }
     293        else
    298294          {
    299295            memcpy (cp, c, len);
     
    323319  }
    324320
    325 #undef  DEFINE_VARIABLE
     321#undef  DEFINE_VARIABLE
    326322}
    327323
    328324
    329325/* Chop CMDS up into individual command lines if necessary.
    330    Also set the `lines_flags' and `any_recurse' members.  */
     326   Also set the 'lines_flags' and 'any_recurse' members.  */
    331327
    332328void
     
    405401     CMDS->any_recurse flag.  */
    406402
     403  if (nlines > USHRT_MAX)
     404    ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines);
     405
    407406  cmds->ncommand_lines = nlines;
    408407  cmds->command_lines = lines;
     
    413412  for (idx = 0; idx < nlines; ++idx)
    414413    {
    415       int flags = 0;
     414      unsigned char flags = 0;
    416415      const char *p = lines[idx];
    417416
    418       while (isblank (*p) || *p == '-' || *p == '@' || *p == '+')
     417      while (ISBLANK (*p) || *p == '-' || *p == '@' || *p == '+')
    419418        switch (*(p++))
    420419          {
     
    436435
    437436      cmds->lines_flags[idx] = flags;
    438       cmds->any_recurse |= flags & COMMANDS_RECURSE;
     437      cmds->any_recurse |= flags & COMMANDS_RECURSE ? 1 : 0;
    439438    }
    440439}
     
    454453
    455454  for (p = file->cmds->commands; *p != '\0'; ++p)
    456     if (!isspace ((unsigned char)*p) && *p != '-' && *p != '@')
     455    if (!ISSPACE (*p) && *p != '-' && *p != '@' && *p != '+')
    457456      break;
    458457  if (*p == '\0')
     
    460459      /* If there are no commands, assume everything worked.  */
    461460      set_command_state (file, cs_running);
    462       file->update_status = 0;
     461      file->update_status = us_success;
    463462      notice_finished_file (file);
    464463      return;
     
    470469
    471470  set_file_variables (file);
     471
     472  /* If this is a loaded dynamic object, unload it before remaking.
     473     Some systems don't support overwriting a loaded object.  */
     474  if (file->loaded)
     475    unload_file (file->name);
    472476
    473477  /* Start the commands running.  */
     
    516520
    517521      if (susp_count != 0)
    518         fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count);
     522        fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count);
    519523      else if (susp_count == (DWORD)-1)
    520         {
    521           DWORD ierr = GetLastError ();
    522 
    523           fprintf (stderr, "SuspendThread: error %ld: %s\n",
    524                    ierr, map_windows32_error_to_string (ierr));
    525         }
     524        {
     525          DWORD ierr = GetLastError ();
     526
     527          fprintf (stderr, "SuspendThread: error %ld: %s\n",
     528                   ierr, map_windows32_error_to_string (ierr));
     529        }
    526530    }
    527531#endif
     
    539543      struct child *c;
    540544      for (c = children; c != 0; c = c->next)
    541         if (!c->remote)
    542           (void) kill (c->pid, SIGTERM);
     545        if (!c->remote)
     546          (void) kill (c->pid, SIGTERM);
    543547    }
    544548
     
    558562
    559563      /* Remote children won't automatically get signals sent
    560         to the process group, so we must send them.  */
     564        to the process group, so we must send them.  */
    561565      for (c = children; c != 0; c = c->next)
    562         if (c->remote)
    563           (void) remote_kill (c->pid, sig);
     566        if (c->remote)
     567          (void) remote_kill (c->pid, sig);
    564568
    565569      for (c = children; c != 0; c = c->next)
    566         delete_child_targets (c);
     570        delete_child_targets (c);
    567571
    568572      /* Clean up the children.  We don't just use the call below because
    569         we don't want to print the "Waiting for children" message.  */
     573        we don't want to print the "Waiting for children" message.  */
    570574      while (job_slots_used > 0)
    571         reap_children (1, 0);
     575        reap_children (1, 0);
    572576    }
    573577  else
     
    584588    /* We don't want to send ourselves SIGQUIT, because it will
    585589       cause a core dump.  Just exit instead.  */
    586     exit (EXIT_FAILURE);
     590    exit (MAKE_TROUBLE);
    587591#endif
    588592
     
    620624    {
    621625      time_t file_date = (file->last_mtime == NONEXISTENT_MTIME
    622                           ? (time_t) -1
    623                           : (time_t) FILE_TIMESTAMP_S (file->last_mtime));
     626                          ? (time_t) -1
     627                          : (time_t) FILE_TIMESTAMP_S (file->last_mtime));
    624628      if (ar_member_date (file->name) != file_date)
    625         {
    626           if (on_behalf_of)
    627             error (NILF, _("*** [%s] Archive member `%s' may be bogus; not deleted"),
    628                    on_behalf_of, file->name);
    629           else
    630             error (NILF, _("*** Archive member `%s' may be bogus; not deleted"),
    631                    file->name);
    632         }
     629        {
     630          if (on_behalf_of)
     631            OSS (error, NILF,
     632                 _("*** [%s] Archive member '%s' may be bogus; not deleted"),
     633                 on_behalf_of, file->name);
     634          else
     635            OS (error, NILF,
     636                _("*** Archive member '%s' may be bogus; not deleted"),
     637                file->name);
     638        }
    633639      return;
    634640    }
     
    641647    {
    642648      if (on_behalf_of)
    643         error (NILF, _("*** [%s] Deleting file `%s'"), on_behalf_of, file->name);
     649        OSS (error, NILF,
     650             _("*** [%s] Deleting file '%s'"), on_behalf_of, file->name);
    644651      else
    645         error (NILF, _("*** Deleting file `%s'"), file->name);
     652        OS (error, NILF, _("*** Deleting file '%s'"), file->name);
    646653      if (unlink (file->name) < 0
    647           && errno != ENOENT)   /* It disappeared; so what.  */
    648         perror_with_name ("unlink: ", file->name);
     654          && errno != ENOENT)   /* It disappeared; so what.  */
     655        perror_with_name ("unlink: ", file->name);
    649656    }
    650657}
     
    665672  delete_target (child->file, NULL);
    666673
    667   /* Also remove any non-precious targets listed in the `also_make' member.  */
     674  /* Also remove any non-precious targets listed in the 'also_make' member.  */
    668675  for (d = child->file->also_make; d != 0; d = d->next)
    669676    delete_target (d->file, child->file->name);
     
    685692    puts (_(" (built-in):"));
    686693  else
    687     printf (_(" (from `%s', line %lu):\n"),
     694    printf (_(" (from '%s', line %lu):\n"),
    688695            cmds->fileinfo.filenm, cmds->fileinfo.lineno);
    689696
     
    692699    {
    693700      const char *end;
    694 
    695       end = strchr (s, '\n');
    696       if (end == 0)
    697         end = s + strlen (s);
     701      int bs;
     702
     703      /* Print one full logical recipe line: find a non-escaped newline.  */
     704      for (end = s, bs = 0; *end != '\0'; ++end)
     705        {
     706          if (*end == '\n' && !bs)
     707            break;
     708
     709          bs = *end == '\\' ? !bs : 0;
     710        }
    698711
    699712      printf ("%c%.*s\n", cmd_prefix, (int) (end - s), s);
  • vendor/gnumake/current/commands.h

    r2596 r3138  
    11/* Definition of data structures describing shell commands for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    2220struct commands
    2321  {
    24     struct floc fileinfo;       /* Where commands were defined.  */
    25     char *commands;             /* Commands text.  */
    26     unsigned int ncommand_lines;/* Number of command lines.  */
    27     char **command_lines;       /* Commands chopped up into lines.  */
    28     char *lines_flags;          /* One set of flag bits for each line.  */
    29     int any_recurse;            /* Nonzero if any `lines_recurse' elt has */
    30                                 /* the COMMANDS_RECURSE bit set.  */
     22    floc fileinfo;              /* Where commands were defined.  */
     23    char *commands;             /* Commands text.  */
     24    char **command_lines;       /* Commands chopped up into lines.  */
     25    unsigned char *lines_flags; /* One set of flag bits for each line.  */
     26    unsigned short ncommand_lines;/* Number of command lines.  */
     27    char recipe_prefix;         /* Recipe prefix for this command set.  */
     28    unsigned int any_recurse:1; /* Nonzero if any 'lines_flags' elt has */
     29                                /* the COMMANDS_RECURSE bit set.  */
    3130  };
    3231
    33 /* Bits in `lines_flags'.  */
    34 #define COMMANDS_RECURSE        1 /* Recurses: + or $(MAKE).  */
    35 #define COMMANDS_SILENT         2 /* Silent: @.  */
    36 #define COMMANDS_NOERROR        4 /* No errors: -.  */
     32/* Bits in 'lines_flags'.  */
     33#define COMMANDS_RECURSE        1 /* Recurses: + or $(MAKE).  */
     34#define COMMANDS_SILENT         2 /* Silent: @.  */
     35#define COMMANDS_NOERROR        4 /* No errors: -.  */
    3736
     37RETSIGTYPE fatal_error_signal (int sig);
    3838void execute_file_commands (struct file *file);
    3939void print_commands (const struct commands *cmds);
  • vendor/gnumake/current/config.ami.template

    r2596 r3138  
    11/* config.h -- hand-massaged for Amiga                                  -*-C-*-
    2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1995-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    1817/* Define if on AIX 3.
    1918   System headers sometimes define this.
    20    We just want to avoid a redefinition error message.  */
     19   We just want to avoid a redefinition error message.  */
    2120#ifndef _ALL_SOURCE
    2221/* #undef _ALL_SOURCE */
     
    3938/* #undef DGUX */
    4039
    41 /* Define if the `getloadavg' function needs to be run setuid or setgid.  */
     40/* Define if the 'getloadavg' function needs to be run setuid or setgid.  */
    4241/* #undef GETLOADAVG_PRIVILEGED */
    4342
    44 /* Define to `unsigned long' or `unsigned long long'
     43/* Define to 'unsigned long' or 'unsigned long long'
    4544   if <inttypes.h> doesn't define.  */
    4645#define uintmax_t unsigned long
    4746
    48 /* Define to `int' if <sys/types.h> doesn't define.  */
     47/* Define to 'int' if <sys/types.h> doesn't define.  */
    4948#define gid_t int
    5049
     
    5554/* #undef HAVE_ALLOCA_H */
    5655
    57 /* Define if you don't have vprintf but do have _doprnt.  */
    58 /* #undef HAVE_DOPRNT */
    59 
    6056/* Define if your system has a working fnmatch function.  */
    6157/* #undef HAVE_FNMATCH */
    6258
    63 /* Define if your system has its own `getloadavg' function.  */
     59/* Define if your system has its own 'getloadavg' function.  */
    6460/* #undef HAVE_GETLOADAVG */
    6561
     
    6763/* #undef HAVE_GETMNTENT */
    6864
    69 /* Define if the `long double' type works.  */
     65/* Embed GNU Guile support */
     66/* #undef HAVE_GUILE */
     67
     68/* Define if the 'long double' type works.  */
    7069/* #undef HAVE_LONG_DOUBLE */
    7170
    72 /* Define if you support file names longer than 14 characters.  */
     71/* Define if you support file names longer than 14 characters.  */
    7372#define HAVE_LONG_FILE_NAMES 1
    7473
    75 /* Define if you have a working `mmap' system call.  */
     74/* Define if you have a working 'mmap' system call.  */
    7675/* #undef HAVE_MMAP */
    7776
     
    8685/* #undef HAVE_ST_BLOCKS */
    8786
    88 /* Define if you have the strcoll function and it is properly defined.  */
     87/* Define if you have the strcoll function and it is properly defined.  */
    8988#define HAVE_STRCOLL 1
    9089
     
    9594#define HAVE_STRFTIME 1
    9695
    97 /* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
     96/* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
    9897/* #undef HAVE_SYS_WAIT_H */
    9998
     
    111110/* #undef HAVE_UTIME_NULL */
    112111
    113 /* Define if you have <vfork.h>.  */
    114 /* #undef HAVE_VFORK_H */
    115 
    116 /* Define if you have the vprintf function.  */
    117 #define HAVE_VPRINTF 1
    118 
    119112/* Define if you have the wait3 system call.  */
    120113/* #undef HAVE_WAIT3 */
    121114
    122 /* Define if on MINIX.  */
     115/* Define if on MINIX.  */
    123116/* #undef _MINIX */
    124117
     
    132125/* #undef NO_MINUS_C_MINUS_O */
    133126
    134 /* Define to `int' if <sys/types.h> doesn't define.  */
     127/* Define to 'int' if <sys/types.h> doesn't define.  */
    135128#define pid_t int
    136129
     
    153146   direction of stack growth for your system; otherwise it will be
    154147   automatically deduced at run-time.
    155         STACK_DIRECTION > 0 => grows toward higher addresses
    156         STACK_DIRECTION < 0 => grows toward lower addresses
    157         STACK_DIRECTION = 0 => direction of growth unknown
     148        STACK_DIRECTION > 0 => grows toward higher addresses
     149        STACK_DIRECTION < 0 => grows toward lower addresses
     150        STACK_DIRECTION = 0 => direction of growth unknown
    158151 */
    159152#define STACK_DIRECTION -1
    160153
    161 /* Define if the `S_IS*' macros in <sys/stat.h> do not work properly.  */
     154/* Define if the 'S_IS*' macros in <sys/stat.h> do not work properly.  */
    162155/* #undef STAT_MACROS_BROKEN */
    163156
    164 /* Define if your compiler conforms to the ANSI C standard. */
    165 #define HAVE_ANSI_COMPILER 1
    166 
    167 /* Define if you have the ANSI C header files.  */
     157/* Define if you have the ANSI C header files.  */
    168158#define STDC_HEADERS
    169159
     
    171161/* #undef SVR4 */
    172162
    173 /* Define if `sys_siglist' is declared by <signal.h>.  */
     163/* Define if 'sys_siglist' is declared by <signal.h>.  */
    174164/* #undef SYS_SIGLIST_DECLARED */
    175165
    176 /* Define to `int' if <sys/types.h> doesn't define.  */
     166/* Define to 'int' if <sys/types.h> doesn't define.  */
    177167#define uid_t int
    178168
     
    184174/* #undef UMAX4_3 */
    185175
    186 /* Define vfork as fork if vfork does not work.  */
    187 /* #undef vfork */
    188 
    189176/* Name of this package (needed by automake) */
    190177#define PACKAGE "%PACKAGE%"
     
    193180#define VERSION "%VERSION%"
    194181
    195 /* Define to the name of the SCCS `get' command.  */
     182/* Define to the name of the SCCS 'get' command.  */
    196183#define SCCS_GET "get"
    197184
    198 /* Define this if the SCCS `get' command understands the `-G<file>' option.  */
     185/* Define this if the SCCS 'get' command understands the '-G<file>' option.  */
    199186/* #undef SCCS_GET_MINUS_G */
    200187
     
    206193/* #undef ST_MTIM_NSEC */
    207194
    208 /* Define this if the C library defines the variable `sys_siglist'.  */
     195/* Define this if the C library defines the variable 'sys_siglist'.  */
    209196/* #undef HAVE_SYS_SIGLIST */
    210197
    211 /* Define this if the C library defines the variable `_sys_siglist'.  */
     198/* Define this if the C library defines the variable '_sys_siglist'.  */
    212199/* #undef HAVE__SYS_SIGLIST */
    213200
    214 /* Define this if you have the `union wait' type in <sys/wait.h>.  */
     201/* Define this if you have the 'union wait' type in <sys/wait.h>.  */
    215202/* #undef HAVE_UNION_WAIT */
    216203
     
    248235/* #undef HAVE_SETEUID */
    249236
    250 /* Define if you have the setlinebuf function.  */
     237/* Define if you have the setlinebuf function.  */
    251238/* #undef HAVE_SETLINEBUF */
    252239
     
    257244/* #undef HAVE_SETREUID */
    258245
    259 /* Define if you have the sigsetmask function.  */
     246/* Define if you have the sigsetmask function.  */
    260247/* #undef HAVE_SIGSETMASK */
    261248
     
    302289/* #undef HAVE_NDIR_H */
    303290
    304 /* Define to 1 if you have the <stdarg.h> header file. */
    305 #define HAVE_STDARG_H 1
    306 
    307291/* Define if you have the <stdlib.h> header file.  */
    308292/* #undef HAVE_STDLIB_H */
     
    335319/* #undef HAVE_LIBKSTAT */
    336320
     321/* Define to 1 if you have the `isatty' function. */
     322/* #undef HAVE_ISATTY */
     323
     324/* Define to 1 if you have the `ttyname' function. */
     325/* #undef HAVE_TTYNAME */
     326
    337327/* Define if you have the sun library (-lsun).  */
    338328/* #undef HAVE_LIBSUN */
    339329
     330/* Output sync sypport */
     331#define NO_OUTPUT_SYNC
     332
    340333/* Define for Case Insensitve behavior */
    341334#define HAVE_CASE_INSENSITIVE_FS
  • vendor/gnumake/current/config.h-vms.template

    r2596 r3138  
    11/* config.h-vms. Generated by hand by Klaus Kämpf <kkaempf@rmi.de>      -*-C-*-
    22
    3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    4 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     3Copyright (C) 1996-2016 Free Software Foundation, Inc.
    54This file is part of GNU Make.
    65
     
    1817
    1918/* config.h.  Generated automatically by configure.  */
    20 /* config.h.in.  Generated automatically from configure.in by autoheader.  */
     19/* config.h.in.  Generated automatically from configure.ac by autoheader.  */
     20
     21/* Pull in types.h here to get __CRTL_VER defined for old versions of the
     22   compiler which don't define it. */
     23#ifdef __DECC
     24# include <types.h>
     25#endif
    2126
    2227/* Define to 1 if on AIX 3.
     
    3641/* #undef HAVE_GETTEXT */
    3742
     43/* Embed GNU Guile support */
     44/* #undef HAVE_GUILE */
     45
    3846/* Define to 1 if your locale.h file contains LC_MESSAGES.  */
    3947/* #undef HAVE_LC_MESSAGES */
     
    5866/* #undef DGUX */
    5967
    60 /* Define to 1 if the `getloadavg' function needs to be run setuid or setgid.  */
     68/* Define to 1 if the 'getloadavg' function needs to be run setuid or setgid.  */
    6169/* #undef GETLOADAVG_PRIVILEGED */
    6270
    63 /* Define to `unsigned long' or `unsigned long long'
     71/* Define to 'unsigned long' or 'unsigned long long'
    6472   if <inttypes.h> doesn't define.  */
    6573#define uintmax_t unsigned long
    6674
    67 /* Define to `int' if <sys/types.h> doesn't define.  */
     75/* Define to 'int' if <sys/types.h> doesn't define.  */
    6876/* #undef gid_t */
    6977
     
    7482/* #undef HAVE_ALLOCA_H */
    7583
    76 /* Define to 1 if you don't have vprintf but do have _doprnt.  */
    77 /* #undef HAVE_DOPRNT */
    78 
    7984/* Define to 1 if you have the fdopen function.  */
    8085#define HAVE_FDOPEN 1
     
    8388/* #undef HAVE_FNMATCH */
    8489
    85 /* Define to 1 if your system has its own `getloadavg' function.  */
     90/* Define to 1 if your system has its own 'getloadavg' function.  */
    8691/* #undef HAVE_GETLOADAVG */
    8792
     
    8994/* #undef HAVE_GETMNTENT */
    9095
    91 /* Define to 1 if the `long double' type works.  */
     96/* Define to 1 if the 'long double' type works.  */
    9297/* #undef HAVE_LONG_DOUBLE */
    9398
     
    95100#define HAVE_LONG_FILE_NAMES 1
    96101
    97 /* Define to 1 if you have a working `mmap' system call.  */
     102/* Define to 1 if you have a working 'mmap' system call.  */
    98103/* #undef HAVE_MMAP */
    99104
     
    111116/* #undef HAVE_STRCOLL */
    112117
     118/* Define to 1 if you have the strncasecmp' function. */
     119#if __CRTL_VER >= 70000000
     120#define HAVE_STRNCASECMP 1
     121#endif
     122
    113123/* Define to 1 if your struct stat has st_rdev.  */
    114124/* #undef HAVE_ST_RDEV */
     
    135145/* #undef HAVE_UTIME_NULL */
    136146
    137 /* Define to 1 if you have <vfork.h>.  */
    138 /* #undef HAVE_VFORK_H */
    139 
    140 /* Define to 1 if you have the vprintf function.  */
    141 #define HAVE_VPRINTF 1
    142 
    143147/* Define to 1 if you have the wait3 system call.  */
    144148/* #undef HAVE_WAIT3 */
     
    156160/* #undef NO_MINUS_C_MINUS_O */
    157161
    158 /* Define to `int' if <sys/types.h> doesn't define.  */
     162/* Define to 'int' if <sys/types.h> doesn't define.  */
    159163/* I assume types.h is available for all 5.0 cc/cxx compilers */
    160164#if __DECC_VER < 50090000
     
    180184   direction of stack growth for your system; otherwise it will be
    181185   automatically deduced at run-time.
    182         STACK_DIRECTION > 0 => grows toward higher addresses
    183         STACK_DIRECTION < 0 => grows toward lower addresses
    184         STACK_DIRECTION = 0 => direction of growth unknown
     186        STACK_DIRECTION > 0 => grows toward higher addresses
     187        STACK_DIRECTION < 0 => grows toward lower addresses
     188        STACK_DIRECTION = 0 => direction of growth unknown
    185189 */
    186190/* #undef STACK_DIRECTION */
    187191
    188 /* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly.  */
     192/* Define to 1 if the 'S_IS*' macros in <sys/stat.h> do not work properly.  */
    189193/* #undef STAT_MACROS_BROKEN */
    190194
     
    195199/* #undef SVR4 */
    196200
    197 /* Define to 1 if `sys_siglist' is declared by <signal.h>.  */
     201/* Define to 1 if 'sys_siglist' is declared by <signal.h>.  */
    198202/* #undef SYS_SIGLIST_DECLARED */
    199203
    200 /* Define to `int' if <sys/types.h> doesn't define.  */
     204/* Define to 'int' if <sys/types.h> doesn't define.  */
    201205#if __DECC_VER < 50090000
    202206#define uid_t int
     
    210214/* #undef UMAX4_3 */
    211215
    212 /* Define vfork as fork if vfork does not work.  */
    213 /* #undef vfork */
    214 
    215216/* Name of this package (needed by automake) */
    216217#define PACKAGE "%PACKAGE%"
     
    219220#define VERSION "%VERSION%"
    220221
    221 /* Define to the name of the SCCS `get' command.  */
     222/* Define to the name of the SCCS 'get' command.  */
    222223/* #undef SCCS_GET */
    223224
    224 /* Define this if the SCCS `get' command understands the `-G<file>' option.  */
     225/* Define this if the SCCS 'get' command understands the '-G<file>' option.  */
    225226/* #undef SCCS_GET_MINUS_G */
    226227
     
    232233/* #undef ST_MTIM_NSEC */
    233234
    234 /* Define to 1 if the C library defines the variable `sys_siglist'.  */
     235/* Define to 1 if the C library defines the variable 'sys_siglist'.  */
    235236/* #undefine HAVE_SYS_SIGLIST */
    236237
    237 /* Define to 1 if the C library defines the variable `_sys_siglist'.  */
     238/* Define to 1 if the C library defines the variable '_sys_siglist'.  */
    238239/* #undef HAVE__SYS_SIGLIST */
    239240
    240 /* Define to 1 if you have the `union wait' type in <sys/wait.h>.  */
     241/* Define to 1 if you have the 'union wait' type in <sys/wait.h>.  */
    241242/* #undef HAVE_UNION_WAIT */
    242243
     
    255256/* Define to 1 if you have the gethostname function.  */
    256257/* #undef HAVE_GETHOSTNAME */
    257 
    258 /* Define to 1 if you have the getloadavg function.  */
    259 /* #undef HAVE_GETLOADAVG */
    260258
    261259/* Define to 1 if you have the memmove function.  */
     
    333331/* #undef HAVE_NDIR_H */
    334332
    335 /* Define to 1 if your compiler conforms to the ANSI C standard. */
    336 #define HAVE_ANSI_COMPILER 1
    337 
    338 /* Define to 1 if you have the <stdarg.h> header file. */
    339 #define HAVE_STDARG_H 1
    340 
    341333/* Define to 1 if you have the <stdlib.h> header file.  */
    342334#define HAVE_STDLIB_H 1
     
    370362/* Define to 1 if you have the sun library (-lsun).  */
    371363/* #undef HAVE_LIBSUN */
     364
     365/* Define to 1 if you have the `isatty' function. */
     366/* #undef HAVE_ISATTY */
     367
     368/* Define to 1 if you have the `ttyname' function. */
     369/* #undef HAVE_TTYNAME */
    372370
    373371/* Use high resolution file timestamps if nonzero. */
     
    387385/* #undef _DIRENT_HAVE_D_NAMLEN */
    388386
    389 /* On older systems without 7.0 backport of CRTL the first one is defined */
    390 #ifdef __CRTL_VER
    391 # if __CRTL_VER < 70000000
    392 #  define HAVE_VMSDIR_H 1
    393 # endif
    394 #else
    395 # if __VMS_VER < 70000000
    396 #  define HAVE_VMSDIR_H 1
    397 # endif
     387/* On older systems without 7.0 backport of CRTL use non-VMS code for opendir() etc. */
     388#if __CRTL_VER < 70000000
     389# define HAVE_VMSDIR_H 1
    398390#endif
    399391
     
    421413/* Define if using alloca.c.  */
    422414/* #undef C_ALLOCA */
    423 /* maybe this should be placed into make.h */
    424 #if     defined(__VAX) && defined(__DECC)
    425 #define alloca(n)       __ALLOCA(n)
    426 #endif
     415/* maybe this should be placed into makeint.h */
     416#if     defined(__VAX) && defined(__DECC)
     417#define alloca(n)       __ALLOCA(n)
     418#endif
     419
     420/* Output sync sypport */
     421#define NO_OUTPUT_SYNC
     422
     423/* Define to 1 to write even short single-line actions into a VMS/DCL command
     424   file; this also enables exporting make environment variables into the
     425   (sub-)process, which executes the action.
     426   The usual make rules apply whether a shell variable - here a DCL symbol or
     427   VMS logical [see CRTL getenv()] - is added to the make environment and
     428   is exported. */
     429#define USE_DCL_COM_FILE 1
    427430
    428431/* Build host information. */
  • vendor/gnumake/current/config.h.W32.template

    r2596 r3138  
    11/* config.h.W32 -- hand-massaged config.h file for Windows builds       -*-C-*-
    22
    3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    4 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     3Copyright (C) 1996-2016 Free Software Foundation, Inc.
    54This file is part of GNU Make.
    65
     
    2928#endif
    3029
    31 /* Define to 1 if the `closedir' function returns void instead of `int'. */
     30/* Define to 1 if the 'closedir' function returns void instead of 'int'. */
    3231/* #undef CLOSEDIR_VOID */
    3332
    34 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
    35    systems. This function is required for `alloca.c' support on those systems.
     33/* Define to one of '_getb67', 'GETB67', 'getb67' for Cray-2 and Cray-YMP
     34   systems. This function is required for 'alloca.c' support on those systems.
    3635   */
    3736/* #undef CRAY_STACKSEG_END */
    3837
    39 /* Define to 1 if using `alloca.c'. */
     38/* Define to 1 if using 'alloca.c'. */
    4039/* #undef C_ALLOCA */
    4140
    42 /* Define to 1 if using `getloadavg.c'. */
    43 /*#define C_GETLOADAVG 1*/
     41/* Define to 1 if using 'getloadavg.c'. */
     42#define C_GETLOADAVG 1
    4443
    4544/* Define to 1 for DGUX with <sys/dg_sys_info.h>. */
     
    5352#define FILE_TIMESTAMP_HI_RES 0
    5453
    55 /* Define to 1 if the `getloadavg' function needs to be run setuid or setgid.
     54/* Define to 1 if the 'getloadavg' function needs to be run setuid or setgid.
    5655   */
    5756/* #undef GETLOADAVG_PRIVILEGED */
    5857
    59 /* Define to 1 if you have `alloca', as a function or macro. */
     58/* Define to 1 if you have 'alloca', as a function or macro. */
    6059#define HAVE_ALLOCA 1
    6160
     
    6463/* #undef HAVE_ALLOCA_H */
    6564
    66 /* Define if your compiler conforms to the ANSI C standard. */
    67 #define HAVE_ANSI_COMPILER 1
    68 
    69 /* Define to 1 if you have the `bsd_signal' function. */
    70 /* #undef HAVE_BSD_SIGNAL */
     65/* Define to 1 if you have the 'atexit' function. */
     66#define HAVE_ATEXIT 1
    7167
    7268/* Use case insensitive file names */
    7369/* #undef HAVE_CASE_INSENSITIVE_FS */
    7470
    75 /* Define if you have the clock_gettime function. */
     71/* Define to 1 if you have the clock_gettime function. */
    7672/* #undef HAVE_CLOCK_GETTIME */
    7773
     74/* Embed GNU Guile support.  Windows build sets this on the
     75   compilation command line.  */
     76/* #undef HAVE_GUILE */
     77
    7878/* Define if the GNU dcgettext() function is already present or preinstalled.
    7979   */
    8080/* #undef HAVE_DCGETTEXT */
    8181
    82 /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
     82/* Define to 1 if you have the declaration of 'bsd_signal', and to 0 if you
     83   don't. */
     84#define HAVE_DECL_BSD_SIGNAL 0
     85
     86/* Define to 1 if you have the declaration of 'sys_siglist', and to 0 if you
     87   don't. */
     88#define HAVE_DECL_SYS_SIGLIST 0
     89
     90/* Define to 1 if you have the declaration of '_sys_siglist', and to 0 if you
     91   don't. */
     92#define HAVE_DECL__SYS_SIGLIST 0
     93
     94/* Define to 1 if you have the declaration of '__sys_siglist', and to 0 if you
     95   don't. */
     96#define HAVE_DECL___SYS_SIGLIST 0
     97
     98/* Define to 1 if you have the <dirent.h> header file, and it defines 'DIR'.
    8399   */
    84100#define HAVE_DIRENT_H 1
     
    91107#endif
    92108
    93 /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
    94 /* #undef HAVE_DOPRNT */
    95 
    96109/* Use platform specific coding */
    97110#define HAVE_DOS_PATHS 1
    98111
    99 /* Define to 1 if you have the `dup2' function. */
     112/* Define to 1 if you have the 'dup2' function. */
    100113#define HAVE_DUP2 1
    101114
     
    103116#define HAVE_FCNTL_H 1
    104117
    105 /* Define to 1 if you have the `fdopen' function. */
    106 /*#define HAVE_FDOPEN 1*/
    107 
    108 /* Define to 1 if you have the `fork' function. */
    109 /* #undef HAVE_FORK */
    110 
    111 /* Define to 1 if you have the `getcwd' function.  */
     118/* Define to 1 if you have the 'fdopen' function. */
     119#ifdef __MINGW32__
     120#define HAVE_FDOPEN 1
     121#endif
     122
     123/* Define to 1 if you have the 'fileno' function. */
     124#define HAVE_FILENO 1
     125
     126/* Define to 1 if you have the 'getcwd' function.  */
    112127#define HAVE_GETCWD 1
    113128
    114 /* Define to 1 if you have the `getgroups' function. */
     129/* Define to 1 if you have the 'getgroups' function. */
    115130/* #undef HAVE_GETGROUPS */
    116131
    117 /* Define to 1 if you have the `gethostbyname' function. */
     132/* Define to 1 if you have the 'gethostbyname' function. */
    118133/* #undef HAVE_GETHOSTBYNAME */
    119134
    120 /* Define to 1 if you have the `gethostname' function. */
     135/* Define to 1 if you have the 'gethostname' function. */
    121136/* #undef HAVE_GETHOSTNAME */
    122137
    123 /* Define to 1 if you have the `getloadavg' function. */
     138/* Define to 1 if you have the 'getloadavg' function. */
    124139/* #undef HAVE_GETLOADAVG */
    125140
    126 /* Define to 1 if you have the `getrlimit' function. */
     141/* Define to 1 if you have the 'getrlimit' function. */
    127142/* #undef HAVE_GETRLIMIT */
    128143
     
    130145/* #undef HAVE_GETTEXT */
    131146
    132 /* Define if you have a standard gettimeofday function */
    133 /* #undef HAVE_GETTIMEOFDAY */
     147/* Define to 1 if you have a standard gettimeofday function */
     148#ifdef __MINGW32__
     149#define HAVE_GETTIMEOFDAY 1
     150#endif
    134151
    135152/* Define if you have the iconv() function. */
     
    137154
    138155/* Define to 1 if you have the <inttypes.h> header file. */
    139 /*#define HAVE_INTTYPES_H 1*/
    140 
    141 /* Define to 1 if you have the `dgc' library (-ldgc). */
     156#ifdef __MINGW32__
     157#define HAVE_INTTYPES_H 1
     158#endif
     159
     160/* Define to 1 if you have the 'dgc' library (-ldgc). */
    142161/* #undef HAVE_LIBDGC */
    143162
    144 /* Define to 1 if you have the `kstat' library (-lkstat). */
     163/* Define to 1 if you have the 'kstat' library (-lkstat). */
    145164/* #undef HAVE_LIBKSTAT */
    146165
     
    151170/*#define HAVE_LOCALE_H 1*/
    152171
     172/* Define to 1 if you have the 'lstat' function. */
     173/* #undef HAVE_LSTAT */
     174
    153175/* Define to 1 if you have the <mach/mach.h> header file. */
    154176/* #undef HAVE_MACH_MACH_H */
    155177
    156 /* Define to 1 if you have the `memmove' function. */
    157 #define HAVE_MEMMOVE 1
    158 
    159178/* Define to 1 if you have the <memory.h> header file. */
    160179#define HAVE_MEMORY_H 1
    161180
    162 /* Define to 1 if you have the `mkstemp' function. */
     181/* Define to 1 if you have the 'mkstemp' function. */
    163182/* #undef HAVE_MKSTEMP */
    164183
    165 /* Define to 1 if you have the `mktemp' function. */
     184/* Define to 1 if you have the 'mktemp' function. */
    166185#define HAVE_MKTEMP 1
    167186
    168 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
     187/* Define to 1 if you have the <ndir.h> header file, and it defines 'DIR'. */
    169188/* #undef HAVE_NDIR_H */
    170189
     
    172191/* #undef HAVE_NLIST_H */
    173192
    174 /* Define to 1 if you have the `pipe' function. */
     193/* Define to 1 if you have the 'pipe' function. */
    175194/* #undef HAVE_PIPE */
    176195
    177 /* Define to 1 if you have the `pstat_getdynamic' function. */
     196/* Define to 1 if you have the 'pstat_getdynamic' function. */
    178197/* #undef HAVE_PSTAT_GETDYNAMIC */
    179198
    180 /* Define to 1 if you have the `realpath' function. */
     199/* Define to 1 if you have the 'readlink' function. */
     200/* #undef HAVE_READLINK */
     201
     202/* Define to 1 if you have the 'realpath' function. */
    181203/* #undef HAVE_REALPATH */
    182204
    183 /* Define if <signal.h> defines the SA_RESTART constant. */
     205/* Define to 1 if <signal.h> defines the SA_RESTART constant. */
    184206/* #undef HAVE_SA_RESTART */
    185207
    186 /* Define to 1 if you have the `setegid' function. */
     208/* Define to 1 if you have the 'setegid' function. */
    187209/* #undef HAVE_SETEGID */
    188210
    189 /* Define to 1 if you have the `seteuid' function. */
     211/* Define to 1 if you have the 'seteuid' function. */
    190212/* #undef HAVE_SETEUID */
    191213
    192 /* Define to 1 if you have the `setlinebuf' function. */
     214/* Define to 1 if you have the 'setlinebuf' function. */
    193215/* #undef HAVE_SETLINEBUF */
    194216
    195 /* Define to 1 if you have the `setlocale' function. */
     217/* Define to 1 if you have the 'setlocale' function. */
    196218/*#define HAVE_SETLOCALE 1*/
    197219
    198 /* Define to 1 if you have the `setregid' function. */
     220/* Define to 1 if you have the 'setregid' function. */
    199221/* #undef HAVE_SETREGID */
    200222
    201 /* Define to 1 if you have the `setreuid' function. */
     223/* Define to 1 if you have the 'setreuid' function. */
    202224/* #undef HAVE_SETREUID */
    203225
    204 /* Define to 1 if you have the `setrlimit' function. */
     226/* Define to 1 if you have the 'setrlimit' function. */
    205227/* #undef HAVE_SETRLIMIT */
    206228
    207 /* Define to 1 if you have the `setvbuf' function. */
    208 /*#define HAVE_SETVBUF 1 */
    209 
    210 /* Define to 1 if you have the `sigaction' function. */
     229/* Define to 1 if you have the 'setvbuf' function. */
     230#define HAVE_SETVBUF 1
     231
     232/* Define to 1 if you have the 'sigaction' function. */
    211233/* #undef HAVE_SIGACTION */
    212234
    213 /* Define to 1 if you have the `sigsetmask' function. */
     235/* Define to 1 if you have the 'sigsetmask' function. */
    214236/* #undef HAVE_SIGSETMASK */
    215237
    216 /* Define to 1 if you have the `socket' function. */
     238/* Define to 1 if you have the 'socket' function. */
    217239/* #undef HAVE_SOCKET */
    218240
    219 /* Define to 1 if you have the <stdarg.h> header file. */
    220 #define HAVE_STDARG_H 1
    221 
    222241/* Define to 1 if you have the <stdint.h> header file. */
    223 /*#define HAVE_STDINT_H 1*/
     242#ifdef __MINGW32__
     243#define HAVE_STDINT_H 1
     244#endif
    224245
    225246/* Define to 1 if you have the <stdlib.h> header file. */
    226247#define HAVE_STDLIB_H 1
    227248
    228 /* Define to 1 if you have the `strcasecmp' function. */
    229 /* #undef HAVE_STRCASECMP */
    230 
    231 /* Define to 1 if you have the `strcmpi' function. */
    232 /* #undef HAVE_STRCMPI */
    233 
    234 /* Define to 1 if you have the `stricmp' function. */
     249/* Define to 1 if you have the 'strcasecmp' function. */
     250#ifdef __MINGW32__
     251#define HAVE_STRCASECMP 1
     252#endif
     253
     254/* Define to 1 if you have the 'strcmpi' function. */
     255#define HAVE_STRCMPI 1
     256
     257/* Define to 1 if you have the 'strcoll' function and it is properly defined.
     258   */
     259#define HAVE_STRCOLL 1
     260
     261/* Define to 1 if you have the 'strdup' function. */
     262#define HAVE_STRDUP 1
     263
     264/* Define to 1 if you have the 'strerror' function. */
     265#define HAVE_STRERROR 1
     266
     267/* Define to 1 if you have the 'stricmp' function. */
    235268#define HAVE_STRICMP 1
    236 
    237 /* Define to 1 if you have the `strncasecmp' function. */
    238 /* #undef HAVE_STRNCASECMP */
    239 
    240 /* Define to 1 if you have the `strncmpi' function. */
    241 /* #undef HAVE_STRNCMPI */
    242 
    243 /* Define to 1 if you have the `strnicmp' function. */
    244 #define HAVE_STRNICMP 1
    245 
    246 /* Define to 1 if you have the `strchr' function. */
    247 #define HAVE_STRCHR 1
    248 
    249 /* Define to 1 if you have the `strcoll' function and it is properly defined.
    250    */
    251 #define HAVE_STRCOLL 1
    252 
    253 /* Define to 1 if you have the `strdup' function. */
    254 /* #define HAVE_STRDUP 1*/
    255 
    256 /* Define to 1 if you have the `strerror' function. */
    257 #define HAVE_STRERROR 1
    258269
    259270/* Define to 1 if you have the <strings.h> header file. */
     
    263274#define HAVE_STRING_H 1
    264275
    265 /* Define to 1 if you have the `strsignal' function. */
     276/* Define to 1 if you have the 'strncasecmp' function. */
     277#ifdef __MINGW32__
     278#define HAVE_STRNCASECMP 1
     279#endif
     280
     281/* Define to 1 if you have the 'strncmpi' function. */
     282/* #undef HAVE_STRNCMPI */
     283
     284/* Define to 1 if you have the 'strndup' function. */
     285/* #undef HAVE_STRNDUP */
     286
     287/* Define to 1 if you have the 'strnicmp' function. */
     288#ifdef __MINGW32__
     289#define HAVE_STRNICMP 1
     290#endif
     291
     292/* Define to 1 if you have the 'strsignal' function. */
    266293/* #undef HAVE_STRSIGNAL */
    267294
    268 /* Define to 1 if `n_un.n_name' is member of `struct nlist'. */
     295/* Define to 1 if you have the `isatty' function. */
     296#define HAVE_ISATTY 1
     297
     298/* Define to 1 if you have the `ttyname' function. */
     299#define HAVE_TTYNAME 1
     300char *ttyname (int);
     301
     302/* Define to 1 if 'n_un.n_name' is a member of 'struct nlist'. */
    269303/* #undef HAVE_STRUCT_NLIST_N_UN_N_NAME */
    270304
    271 /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
     305/* Define to 1 if you have the <sys/dir.h> header file, and it defines 'DIR'.
    272306   */
    273307/* #undef HAVE_SYS_DIR_H */
    274308
    275 /* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
     309/* Define to 1 if you have the <sys/ndir.h> header file, and it defines 'DIR'.
    276310   */
    277311/* #undef HAVE_SYS_NDIR_H */
    278312
    279313/* Define to 1 if you have the <sys/param.h> header file. */
    280 /* #define HAVE_SYS_PARAM_H 1 */
     314#ifdef __MINGW32__
     315#define HAVE_SYS_PARAM_H 1
     316#endif
    281317
    282318/* Define to 1 if you have the <sys/resource.h> header file. */
     
    284320
    285321/* Define to 1 if you have the <sys/stat.h> header file. */
    286 /* #define HAVE_SYS_STAT_H 1 */
     322#define HAVE_SYS_STAT_H 1
    287323
    288324/* Define to 1 if you have the <sys/timeb.h> header file. */
    289 /*#define HAVE_SYS_TIMEB_H 1*/
     325#define HAVE_SYS_TIMEB_H 1
    290326
    291327/* Define to 1 if you have the <sys/time.h> header file. */
    292 /*#define HAVE_SYS_TIME_H 1*/
     328#ifdef __MINGW32__
     329#define HAVE_SYS_TIME_H 1
     330#endif
    293331
    294332/* Define to 1 if you have the <sys/types.h> header file. */
    295 /*#define HAVE_SYS_TYPES_H 1*/
     333#define HAVE_SYS_TYPES_H 1
    296334
    297335/* Define to 1 if you have the <sys/wait.h> header file. */
    298336/* #undef HAVE_SYS_WAIT_H */
    299337
    300 /* Define this if you have the \`union wait' type in <sys/wait.h>. */
     338/* Define to 1 if you have the \'union wait' type in <sys/wait.h>. */
    301339/* #undef HAVE_UNION_WAIT */
    302340
    303341/* Define to 1 if you have the <unistd.h> header file. */
    304 /* #define HAVE_UNISTD_H 1*/
    305 
    306 /* Define to 1 if you have the <varargs.h> header file. */
    307 /* #undef HAVE_VARARGS_H */
    308 
    309 /* Define to 1 if you have the `vfork' function. */
    310 /* #undef HAVE_VFORK */
    311 
    312 /* Define to 1 if you have the <vfork.h> header file. */
    313 /* #undef HAVE_VFORK_H */
    314 
    315 /* Define to 1 if you have the `vprintf' function. */
    316 #define HAVE_VPRINTF 1
    317 
    318 
    319 /* Define to 1 if you have the `wait3' function. */
     342#ifdef __MINGW32__
     343#define HAVE_UNISTD_H 1
     344#endif
     345
     346/* Define to 1 if you have the 'wait3' function. */
    320347/* #undef HAVE_WAIT3 */
    321348
    322 /* Define to 1 if you have the `waitpid' function. */
     349/* Define to 1 if you have the 'waitpid' function. */
    323350/* #undef HAVE_WAITPID */
    324 
    325 /* Define to 1 if `fork' works. */
    326 /* #undef HAVE_WORKING_FORK */
    327 
    328 /* Define to 1 if `vfork' works. */
    329 /* #undef HAVE_WORKING_VFORK */
    330351
    331352/* Build host information. */
    332353#define MAKE_HOST "Windows32"
    333354
    334 /* Define this to enable job server support in GNU make. */
    335 /* #undef MAKE_JOBSERVER */
    336 
    337 /* Define to 1 if your `struct nlist' has an `n_un' member. Obsolete, depend
    338    on `HAVE_STRUCT_NLIST_N_UN_N_NAME */
     355/* Define to 1 to enable job server support in GNU make. */
     356#define MAKE_JOBSERVER 1
     357
     358/* Define to 1 to enable 'load' support in GNU make. */
     359#define MAKE_LOAD 1
     360
     361/* Define to 1 to enable symbolic link timestamp checking. */
     362/* #undef MAKE_SYMLINKS */
     363
     364/* Define to 1 if your 'struct nlist' has an 'n_un' member. Obsolete, depend
     365   on 'HAVE_STRUCT_NLIST_N_UN_N_NAME */
    339366/* #undef NLIST_NAME_UNION */
    340367
    341 /* Define if struct nlist.n_name is a pointer rather than an array. */
     368/* Define to 1 if struct nlist.n_name is a pointer rather than an array. */
    342369/* #undef NLIST_STRUCT */
    343370
     
    348375#define PACKAGE "%PACKAGE%"
    349376
    350 /* Define to 1 if the C compiler supports function prototypes. */
    351 #define PROTOTYPES 1
    352 
    353 /* Define as the return type of signal handlers (`int' or `void'). */
     377/* Define to the address where bug reports for this package should be sent. */
     378#define PACKAGE_BUGREPORT "bug-make@gnu.org"
     379
     380/* Define to the full name of this package. */
     381#define PACKAGE_NAME "GNU make"
     382
     383/* Define to the home page for this package. */
     384#define PACKAGE_URL "http://www.gnu.org/software/make/"
     385
     386/* Define to the version of this package. */
     387#define PACKAGE_VERSION "%VERSION%"
     388
     389/* Define to the character that separates directories in PATH. */
     390#define PATH_SEPARATOR_CHAR ';'
     391
     392/* Define as the return type of signal handlers ('int' or 'void'). */
    354393#define RETSIGTYPE void
    355394
     
    360399/* #undef SCCS_GET_MINUS_G */
    361400
    362 /* Define to 1 if the `setvbuf' function takes the buffering type as its
     401/* Define to 1 if the 'setvbuf' function takes the buffering type as its
    363402   second argument and the buffer pointer as the third, as on System V before
    364403   release 3. */
     
    367406/* If using the C implementation of alloca, define if you know the
    368407   direction of stack growth for your system; otherwise it will be
    369    automatically deduced at run-time.
    370         STACK_DIRECTION > 0 => grows toward higher addresses
    371         STACK_DIRECTION < 0 => grows toward lower addresses
    372         STACK_DIRECTION = 0 => direction of growth unknown */
     408   automatically deduced at run time.
     409        STACK_DIRECTION > 0 => grows toward higher addresses
     410        STACK_DIRECTION < 0 => grows toward lower addresses
     411        STACK_DIRECTION = 0 => direction of growth unknown */
    373412/* #undef STACK_DIRECTION */
    374413
    375 /* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
     414/* Define to 1 if the 'S_IS*' macros in <sys/stat.h> do not work properly. */
    376415/* #undef STAT_MACROS_BROKEN */
    377416
     
    386425
    387426/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
    388 /* #define TIME_WITH_SYS_TIME 1 */
     427#ifdef __MINGW32__
     428#define TIME_WITH_SYS_TIME 1
     429#endif
    389430
    390431/* Define to 1 for Encore UMAX. */
     
    421462/* #undef _POSIX_1_SOURCE */
    422463
    423 /* Define to 1 if you need to in order for `stat' and other things to work. */
    424 #define _POSIX_SOURCE 1
    425 
    426 /* Define like PROTOTYPES; this can be used by system headers. */
    427 /*#define __PROTOTYPES 1*/
    428 
    429 /* Define to empty if `const' does not conform to ANSI C. */
     464/* Define to 1 if you need to in order for 'stat' and other things to work. */
     465/* #undef _POSIX_SOURCE */
     466
     467/* Define to empty if 'const' does not conform to ANSI C. */
    430468/* #undef const */
    431469
    432470#include <sys/types.h>
    433471
    434 /* Define to `int' if <sys/types.h> doesn't define. */
     472/* Define to 'int' if <sys/types.h> doesn't define. */
    435473#define gid_t int
    436474
    437 /* Define to `int' if <sys/types.h> does not define. */
     475/* Define to 'int' if <sys/types.h> does not define. */
    438476/* GCC 4.x reportedly defines pid_t.  */
    439477#ifndef _PID_T_
     
    445483#endif
    446484
    447 /* Define to `int' if <sys/types.h> doesn't define. */
     485/* Define to 'int' if <sys/types.h> doesn't define. */
    448486#define uid_t int
    449487
    450488/* Define uintmax_t if not defined in <stdint.h> or <inttypes.h>. */
     489#if !HAVE_STDINT_H && !HAVE_INTTYPES_H
    451490#define uintmax_t unsigned long
    452 
    453 /* Define as `fork' if `vfork' does not work. */
    454 /*#define vfork fork*/
    455 
    456 /* Define to `unsigned long' or `unsigned long long'
    457    if <inttypes.h> doesn't define.  */
    458 #define uintmax_t unsigned long
    459 
    460 /* Define if you support file names longer than 14 characters.  */
    461 #define HAVE_LONG_FILE_NAMES 1
    462 
    463 /* Define if your struct stat has st_rdev.  */
    464 #undef HAVE_ST_RDEV
    465 #define HAVE_ST_RDEV 1
    466 
    467 /* Define if you have the strftime function.  */
    468 #undef HAVE_STRFTIME
    469 #define HAVE_STRFTIME 1
     491#endif
    470492
    471493/* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
    472494/* #undef HAVE_SYS_WAIT_H */
    473 
    474 /* Define if your struct tm has tm_zone.  */
    475 /* #undef HAVE_TM_ZONE */
    476 
    477 /* Define if you don't have tm_zone but do have the external array
    478    tzname.  */
    479 #undef HAVE_TZNAME
    480 #define HAVE_TZNAME 1
    481 
    482 /* Define if utime(file, NULL) sets file's timestamp to the present.  */
    483 #undef HAVE_UTIME_NULL
    484 #define HAVE_UTIME_NULL 1
    485495
    486496/* Define to the installation directory for locales.  */
  • vendor/gnumake/current/config/.gitignore

    • Property svn:eol-style set to LF
    r3137 r3138  
    1 *.m4
    2 config.*
    3 mkinstalldirs
    4 texinfo.tex
    5 mdate-sh
     1ar-lib
    62compile
     3config.guess
     4config.rpath
     5config.sub
    76depcomp
    87install-sh
     8mdate-sh
    99missing
    10 
    11 Makefile Makefile.in
     10texinfo.tex
     11*.m4
     12!dospaths.m4
  • vendor/gnumake/current/config/ChangeLog.1

    r3137 r3138  
     12012-01-15  Paul Smith  <psmith@gnu.org>
     2
     3        * dospaths.m4: Use AC_LANG_PROGRAM to encapsulate the test code.
     4        Fixes Savannah bug #35256.  Patch from Sebastian Pipping.
     5
    162006-03-09  Paul Smith  <psmith@gnu.org>
    27
     
    3035
    3136
    32 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
    33 Foundation, Inc.
     37Copyright (C) 2002-2016 Free Software Foundation, Inc.
    3438This file is part of GNU Make.
    3539
  • vendor/gnumake/current/config/Makefile.am

    r2596 r3138  
    11# -*-Makefile-*-, or close enough
    2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
    3 # Software Foundation, Inc.
     2# Copyright (C) 2002-2016 Free Software Foundation, Inc.
    43# This file is part of GNU Make.
    54#
     
    1716# this program.  If not, see <http://www.gnu.org/licenses/>.
    1817
    19 EXTRA_DIST =    codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 nls.m4 \
    20                 intdiv0.m4 inttypes-pri.m4 inttypes.m4 inttypes_h.m4 \
    21                 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 \
    22                 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4 longlong.m4 \
    23                 dospaths.m4 po.m4 signed.m4 longdouble.m4 wchar_t.m4 \
    24                 wint_t.m4 intmax.m4 printf-posix.m4 xsize.m4 size_max.m4
     18# Autoconf / automake know how to handle this directory.
  • vendor/gnumake/current/config/dospaths.m4

    r2596 r3138  
    22# By Paul Smith <psmith@gnu.org>.  Based on dos.m4 by Jim Meyering.
    33#
    4 # Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
    5 # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     4# Copyright (C) 1993-2016 Free Software Foundation, Inc.
    65# This file is part of GNU Make.
    76#
     
    1918# this program.  If not, see <http://www.gnu.org/licenses/>.
    2019
    21 AC_DEFUN([pds_AC_DOS_PATHS],
    22   [
    23     AC_CACHE_CHECK([whether system uses MSDOS-style paths], [ac_cv_dos_paths],
    24       [
    25         AC_COMPILE_IFELSE([
     20AC_DEFUN([pds_AC_DOS_PATHS], [
     21  AC_CACHE_CHECK([whether system uses MSDOS-style paths], [ac_cv_dos_paths], [
     22    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    2623#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __EMX__ && !defined __MSYS__ && !defined __CYGWIN__
    2724neither MSDOS nor Windows nor OS2
    2825#endif
    29 ],
     26]])],
    3027        [ac_cv_dos_paths=yes],
    31         [ac_cv_dos_paths=no])
    32       ])
     28        [ac_cv_dos_paths=no])])
    3329
    34     if test x"$ac_cv_dos_paths" = xyes; then
    35       AC_DEFINE_UNQUOTED([HAVE_DOS_PATHS], 1,
    36                          [Define if the system uses DOS-style pathnames.])
    37     fi
    38   ])
     30  AS_IF([test x"$ac_cv_dos_paths" = xyes],
     31  [ AC_DEFINE_UNQUOTED([HAVE_DOS_PATHS], 1,
     32                       [Define if the system uses DOS-style pathnames.])])
     33])
  • vendor/gnumake/current/configh.dos.template

    r2596 r3138  
    11/* configh.dos -- hand-massaged config.h file for MS-DOS builds         -*-C-*-
    22
    3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
    4 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     3Copyright (C) 1994-2016 Free Software Foundation, Inc.
    54This file is part of GNU Make.
    65
     
    2625#if __DJGPP__ > 2 || __DJGPP_MINOR__ > 1
    2726
    28 /* Define to 1 if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
     27/* Define to 1 if 'sys_siglist' is declared by <signal.h> or <unistd.h>. */
    2928# define SYS_SIGLIST_DECLARED 1
    3029
    31 /* Define to 1 if the C library defines the variable `_sys_siglist'.  */
     30/* Define to 1 if the C library defines the variable '_sys_siglist'.  */
    3231# define HAVE_DECL_SYS_SIGLIST 1
    3332
     
    4241#define FILE_TIMESTAMP_HI_RES 0
    4342
    44 /* Define to 1 if you have `alloca', as a function or macro. */
     43/* Define to 1 if you have 'alloca', as a function or macro. */
    4544#define HAVE_ALLOCA 1
    4645
     
    4847#define HAVE_FDOPEN 1
    4948
    50 /* Define to 1 if you have the `getgroups' function. */
     49/* Define to 1 if you have the 'getgroups' function. */
    5150#define HAVE_GETGROUPS 1
    5251
     
    5756#define HAVE_MKSTEMP 1
    5857
    59 /* Define to 1 if you have the `mktemp' function. */
     58/* Define to 1 if you have the 'mktemp' function. */
    6059#define HAVE_MKTEMP 1
    6160
    62 /* Define to 1 if you have the `setlinebuf' function. */
     61/* Define to 1 if you have the 'setlinebuf' function. */
    6362#define HAVE_SETLINEBUF 1
    6463
    65 /* Define to 1 if you have the `setvbuf' function. */
     64/* Define to 1 if you have the 'setvbuf' function. */
    6665#define HAVE_SETVBUF 1
    6766
    6867#define SCCS_GET "get"
    6968
    70 /* Define to `unsigned long' or `unsigned long long'
     69/* Define to 'unsigned long' or 'unsigned long long'
    7170   if <inttypes.h> doesn't define.  */
    7271#define uintmax_t unsigned long long
     
    7877#define HAVE_SELECT 1
    7978
    80 /* Define to 1 if your compiler conforms to the ANSI C standard. */
    81 #define HAVE_ANSI_COMPILER 1
    82 
    83 /* Define to 1 if you have the <stdarg.h> header file. */
    84 #define HAVE_STDARG_H 1
    85 
    86 /* Define to 1 if you have the vprintf library function.  */
    87 #undef HAVE_VPRINTF
    88 #define HAVE_VPRINTF 1
    89 
    9079/* Define to 1 if you have the stricmp function.  */
    9180#define HAVE_STRICMP 1
     81
     82/* Define to 1 if you have the 'strncasecmp' function. */
     83#define HAVE_STRNCASECMP 1
    9284
    9385/* Name of the package */
     
    109101#define PACKAGE_VERSION "%VERSION%"
    110102
    111 /* Define to 1 if the C compiler supports function prototypes. */
    112 #define PROTOTYPES 1
     103/* Output sync sypport */
     104#define NO_OUTPUT_SYNC
    113105
    114106/* Version number of package */
  • vendor/gnumake/current/configure.bat

    r2596 r3138  
    11@echo off
    2 rem Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
    3 rem 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2rem Copyright (C) 1994-2016 Free Software Foundation, Inc.
    43rem This file is part of GNU Make.
    54rem
  • vendor/gnumake/current/debug.h

    r2596 r3138  
    11/* Debugging macros and interface.
    2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
    3 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1999-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
  • vendor/gnumake/current/default.c

    r2596 r3138  
    11/* Data base of default implicit rules for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
     18
     19#include <assert.h>
     20
    2021#include "filedef.h"
    2122#include "variable.h"
     
    3334
    3435/* This is the default list of suffixes for suffix rules.
    35    `.s' must come last, so that a `.o' file will be made from
    36    a `.c' or `.p' or ... file rather than from a .s file.  */
     36   '.s' must come last, so that a '.o' file will be made from
     37   a '.c' or '.p' or ... file rather than from a .s file.  */
    3738
    3839static char default_suffixes[]
    3940#ifdef VMS
    40   = ".exe .olb .ln .obj .c .cxx .cc .pas .p .for .f .r .y .l .mar \
    41 .s .ss .i .ii .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
    42 .w .ch .cweb .web .com .sh .elc .el";
     41  /* VMS should include all UNIX/POSIX + some VMS extensions */
     42  = ".out .exe .a .olb .hlb .tlb .mlb .ln .o .obj .c .cxx .cc .cpp .pas .p \
     43.for .f .r .y .l .ym .yl .mar .s .ss .i .ii .mod .sym .def .h .info .dvi \
     44.tex .texinfo .texi .txinfo .mem .hlp .brn .rnh .rno .rnt .rnx .w .ch .cweb \
     45.web .com .sh .elc .el";
    4346#elif defined(__EMX__)
    4447  = ".out .a .ln .o .c .cc .C .cpp .p .f .F .m .r .y .l .ym .yl .s .S \
     
    5356static struct pspec default_pattern_rules[] =
    5457  {
     58#ifdef VMS
    5559    { "(%)", "%",
    56         "$(AR) $(ARFLAGS) $@ $<" },
    57 
     60        "@if f$$search(\"$@\") .eqs. \"\" then $(LIBRARY)/CREATE/"
     61         "$(or "
     62          "$(patsubst %,TEXT,$(filter %.tlb %.TLB,$@)),"
     63          "$(patsubst %,HELP,$(filter %.hlb %.HLB,$@)),"
     64          "$(patsubst %,MACRO,$(filter %.mlb %.MLB,$@)),"
     65          "$(and "
     66           "$(patsubst %,SHARE,$(filter %.olb %.OLB,$@)),"
     67           "$(patsubst %,SHARE,$(filter %.exe %.EXE,$<))),"
     68          "OBJECT)"
     69         " $@\n"
     70        "$(AR) $(ARFLAGS) $@ $<" },
     71
     72#else
     73    { "(%)", "%",
     74        "$(AR) $(ARFLAGS) $@ $<" },
     75#endif
    5876    /* The X.out rules are only in BSD's default set because
    59        BSD Make has no null-suffix rules, so `foo.out' and
    60        `foo' are the same thing.  */
     77       BSD Make has no null-suffix rules, so 'foo.out' and
     78       'foo' are the same thing.  */
    6179#ifdef VMS
    6280    { "%.exe", "%",
    63         "copy $< $@" },
    64 #else
     81        "$(CP) $< $@" },
     82
     83#endif
    6584    { "%.out", "%",
    66         "@rm -f $@ \n cp $< $@" },
    67 #endif
     85        "@rm -f $@ \n cp $< $@" },
     86
    6887    /* Syntax is "ctangle foo.w foo.ch foo.c".  */
    6988    { "%.c", "%.w %.ch",
    70         "$(CTANGLE) $^ $@" },
     89        "$(CTANGLE) $^ $@" },
    7190    { "%.tex", "%.w %.ch",
    72         "$(CWEAVE) $^ $@" },
     91        "$(CWEAVE) $^ $@" },
    7392
    7493    { 0, 0, 0 }
     
    7897  {
    7998#ifdef VMS
     99
    80100    /* RCS.  */
    81101    { "%", "%$$5lv", /* Multinet style */
    82         "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
     102        "if f$$search(\"$@\") .nes. \"\" then +$(CHECKOUT,v)" },
    83103    { "%", "[.$$rcs]%$$5lv", /* Multinet style */
    84         "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
     104        "if f$$search(\"$@\") .nes. \"\" then +$(CHECKOUT,v)" },
    85105    { "%", "%_v", /* Normal style */
    86         "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
     106        "if f$$search(\"$@\") .nes. \"\" then +$(CHECKOUT,v)" },
    87107    { "%", "[.rcs]%_v", /* Normal style */
    88         "if f$$search($@) .nes. \"\" then +$(CHECKOUT,v)" },
     108        "if f$$search(\"$@\") .nes. \"\" then +$(CHECKOUT,v)" },
    89109
    90110    /* SCCS.  */
    91         /* ain't no SCCS on vms */
     111        /* ain't no SCCS on vms */
     112
    92113#else
    93114    /* RCS.  */
    94115    { "%", "%,v",
    95         "$(CHECKOUT,v)" },
     116        "$(CHECKOUT,v)" },
    96117    { "%", "RCS/%,v",
    97         "$(CHECKOUT,v)" },
     118        "$(CHECKOUT,v)" },
    98119    { "%", "RCS/%",
    99         "$(CHECKOUT,v)" },
     120        "$(CHECKOUT,v)" },
    100121
    101122    /* SCCS.  */
    102123    { "%", "s.%",
    103         "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
     124        "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
    104125    { "%", "SCCS/s.%",
    105         "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
     126        "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
    106127#endif /* !VMS */
    107128    { 0, 0, 0 }
    108129  };
    109130
    110 static char *default_suffix_rules[] =
     131static const char *default_suffix_rules[] =
    111132  {
    112133#ifdef VMS
     134    ".o",
     135    "$(LINK.obj) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     136    ".obj",
     137    "$(LINK.obj) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     138    ".s",
     139    "$(LINK.s) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     140    ".S",
     141    "$(LINK.S) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     142    ".c",
     143    "$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     144    ".cc",
     145    "$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     146    ".C",
     147    "$(LINK.C) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     148    ".cpp",
     149    "$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     150    ".f",
     151    "$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     152    ".m",
     153    "$(LINK.m) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     154    ".p",
     155    "$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     156    ".F",
     157    "$(LINK.F) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     158    ".r",
     159    "$(LINK.r) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     160    ".mod",
     161    "$(COMPILE.mod) -o $@ -e $@ $^",
     162
     163    ".def.sym",
     164    "$(COMPILE.def) -o $@ $<",
     165
     166    ".sh",
     167    "copy $< >$@",
     168
    113169    ".obj.exe",
    114170    "$(LINK.obj) $^ $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
    115171    ".mar.exe",
    116172    "$(COMPILE.mar) $^ \n $(LINK.obj) $(subst .mar,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
     173    ".s.o",
     174    "$(COMPILE.s) -o $@ $<",
    117175    ".s.exe",
    118176    "$(COMPILE.s) $^ \n $(LINK.obj) $(subst .s,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@",
     
    149207    ".c.obj",
    150208    "$(COMPILE.c) /obj=$@ $<",
     209    ".c.o",
     210    "$(COMPILE.c) /obj=$@ $<",
    151211    ".cc.ii",
    152212    "$(COMPILE.cc)/prep /list=$@ $<",
     
    157217    ".cc.obj",
    158218    "$(COMPILE.cc) /obj=$@ $<",
     219    ".cc.o",
     220    "$(COMPILE.cc) /obj=$@ $<",
    159221    ".cxx.obj",
     222    "$(COMPILE.cxx) /obj=$@ $<",
     223    ".cxx.o",
    160224    "$(COMPILE.cxx) /obj=$@ $<",
    161225    ".for.obj",
    162226    "$(COMPILE.for) /obj=$@ $<",
     227    ".for.o",
     228    "$(COMPILE.for) /obj=$@ $<",
    163229    ".pas.obj",
     230    "$(COMPILE.pas) /obj=$@ $<",
     231    ".pas.o",
    164232    "$(COMPILE.pas) /obj=$@ $<",
    165233
     
    174242    ".tex.dvi",
    175243    "$(TEX) $<",
     244
     245    ".cpp.o",
     246    "$(COMPILE.cpp) $(OUTPUT_OPTION) $<",
     247    ".f.o",
     248    "$(COMPILE.f) $(OUTPUT_OPTION) $<",
     249    ".m.o",
     250    "$(COMPILE.m) $(OUTPUT_OPTION) $<",
     251    ".p.o",
     252    "$(COMPILE.p) $(OUTPUT_OPTION) $<",
     253    ".r.o",
     254    "$(COMPILE.r) $(OUTPUT_OPTION) $<",
     255    ".mod.o",
     256    "$(COMPILE.mod) -o $@ $<",
     257
     258    ".c.ln",
     259    "$(LINT.c) -C$* $<",
     260    ".y.ln",
     261    "$(YACC.y) $< \n rename y_tab.c $@",
     262
     263    ".l.ln",
     264    "@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
    176265
    177266#else /* ! VMS */
     
    294383
    295384    ".w.c",
    296     "$(CTANGLE) $< - $@",       /* The `-' says there is no `.ch' file.  */
     385    "$(CTANGLE) $< - $@",       /* The '-' says there is no '.ch' file.  */
    297386
    298387    ".web.p",
     
    300389
    301390    ".w.tex",
    302     "$(CWEAVE) $< - $@",        /* The `-' says there is no `.ch' file.  */
     391    "$(CWEAVE) $< - $@",        /* The '-' says there is no '.ch' file.  */
    303392
    304393    ".web.tex",
     
    322411    "ARCH", "VAX",
    323412#endif
    324     "AR", "library/obj",
     413    "AR", "library",
     414    "LIBRARY", "library",
    325415    "ARFLAGS", "/replace",
    326416    "AS", "macro",
     
    332422#endif
    333423    "CD", "builtin_cd",
    334     "MAKE", "make",
    335     "ECHO", "write sys$$output \"",
     424    "ECHO", "builtin_echo",
    336425#ifdef GCC_IS_NATIVE
    337426    "C++", "gcc/plus",
     
    340429    "C++", "cxx",
    341430    "CXX", "cxx",
     431#ifndef __ia64
    342432    "CXXLD", "cxxlink",
     433    "CXXLINK", "cxxlink",
     434#else
     435    /* CXXLINK is not used on VMS/IA64 */
     436    "CXXLD", "link",
     437    "CXXLINK", "link",
     438#endif
    343439#endif
    344440    "CO", "co",
     
    376472#endif
    377473
     474    "LINK.o", "$(LD) $(LDFLAGS)",
    378475    "LINK.obj", "$(LD) $(LDFLAGS)",
    379476#ifndef GCC_IS_NATIVE
     
    382479#endif
    383480    "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
     481    "LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
     482    "COMPILE.m", "$(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
     483    "LINK.m", "$(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
    384484    "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
     485    "COMPILE.C", "$(COMPILE.cc)",
     486    "COMPILE.cpp", "$(COMPILE.cc)",
     487    "LINK.C", "$(LINK.cc)",
     488    "LINK.cpp", "$(LINK.cc)",
    385489    "YACC.y", "$(YACC) $(YFLAGS)",
    386490    "LEX.l", "$(LEX) $(LFLAGS)",
     491    "YACC.m", "$(YACC) $(YFLAGS)",
     492    "LEX.m", "$(LEX) $(LFLAGS) -t",
    387493    "COMPILE.for", "$(FC) $(FFLAGS) $(TARGET_ARCH)",
     494    "COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
     495    "LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
     496    "COMPILE.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
     497    "LINK.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
     498    "COMPILE.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -c",
     499    "LINK.r", "$(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
    388500    "COMPILE.pas", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
     501    "COMPILE.def", "$(M2C) $(M2FLAGS) $(DEFFLAGS) $(TARGET_ARCH)",
     502    "COMPILE.mod", "$(M2C) $(M2FLAGS) $(MODFLAGS) $(TARGET_ARCH)",
     503    "COMPILE.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
     504    "LINK.p", "$(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
    389505    "COMPILE.mar", "$(MACRO) $(MACROFLAGS)",
    390506    "COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
     507    "LINK.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)",
     508    "COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
     509    "PREPROCESS.S", "$(CC) -E $(CPPFLAGS)",
     510    "PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
     511    "PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
    391512    "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
    392513
    393514    "MV", "rename/new_version",
    394515    "CP", "copy",
     516    ".LIBPATTERNS", "%.olb lib%.a",
    395517
    396518#else /* !VMS */
     
    402524    "CC", "gcc",
    403525# ifdef __MSDOS__
    404     "CXX", "gpp",       /* g++ is an invalid name on MSDOS */
     526    "CXX", "gpp",       /* g++ is an invalid name on MSDOS */
    405527# else
    406528    "CXX", "gcc",
     
    420542
    421543    "CPP", "$(CC) -E",
    422 #ifdef  CRAY
     544#ifdef  CRAY
    423545    "CF77PPFLAGS", "-P",
    424546    "CF77PP", "/lib/cpp",
     
    426548    "CF", "cf77",
    427549    "FC", "$(CF)",
    428 #else   /* Not CRAY.  */
    429 #ifdef  _IBMR2
     550#else   /* Not CRAY.  */
     551#ifdef  _IBMR2
    430552    "FC", "xlf",
    431553#else
    432 #ifdef  __convex__
     554#ifdef  __convex__
    433555    "FC", "fc",
    434556#else
     
    440562    "F77", "$(FC)",
    441563    "F77FLAGS", "$(FFLAGS)",
    442 #endif  /* Cray.  */
     564#endif  /* Cray.  */
    443565    "GET", SCCS_GET,
    444566    "LD", "ld",
     
    450572    "LINT", "lint",
    451573    "M2C", "m2c",
    452 #ifdef  pyr
     574#ifdef  pyr
    453575    "PC", "pascal",
    454576#else
    455 #ifdef  CRAY
     577#ifdef  CRAY
    456578    "PC", "PASCAL",
    457579    "SEGLDR", "segldr",
    458580#else
    459581    "PC", "pc",
    460 #endif  /* CRAY.  */
    461 #endif  /* pyr.  */
     582#endif  /* CRAY.  */
     583#endif  /* pyr.  */
    462584#ifdef GCC_IS_NATIVE
    463585    "YACC", "bison -y",
    464586#else
    465     "YACC", "yacc",     /* Or "bison -y"  */
     587    "YACC", "yacc",     /* Or "bison -y"  */
    466588#endif
    467589    "MAKEINFO", "makeinfo",
     
    481603    "LINK.m", "$(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
    482604    "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
     605#ifndef HAVE_CASE_INSENSITIVE_FS
     606    /* On case-insensitive filesystems, treat *.C files as *.c files,
     607       to avoid erroneously compiling C sources as C++, which will
     608       probably fail.  */
    483609    "COMPILE.C", "$(COMPILE.cc)",
     610#else
     611    "COMPILE.C", "$(COMPILE.c)",
     612#endif
    484613    "COMPILE.cpp", "$(COMPILE.cc)",
    485614    "LINK.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
     615#ifndef HAVE_CASE_INSENSITIVE_FS
    486616    "LINK.C", "$(LINK.cc)",
     617#else
     618    "LINK.C", "$(LINK.c)",
     619#endif
    487620    "LINK.cpp", "$(LINK.cc)",
    488621    "YACC.y", "$(YACC) $(YFLAGS)",
     
    509642    "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
    510643
    511 #ifndef NO_MINUS_C_MINUS_O
     644#ifndef NO_MINUS_C_MINUS_O
    512645    "OUTPUT_OPTION", "-o $@",
    513646#endif
    514647
    515 #ifdef  SCCS_GET_MINUS_G
     648#ifdef  SCCS_GET_MINUS_G
    516649    "SCCS_OUTPUT_OPTION", "-G$@",
    517650#endif
    518651
    519 #ifdef _AMIGA
     652#if defined(_AMIGA)
    520653    ".LIBPATTERNS", "%.lib",
    521 #else
    522 #ifdef __MSDOS__
     654#elif defined(__MSDOS__)
    523655    ".LIBPATTERNS", "lib%.a $(DJDIR)/lib/lib%.a",
     656#elif defined(__APPLE__)
     657    ".LIBPATTERNS", "lib%.dylib lib%.a",
     658#elif defined(__CYGWIN__) || defined(WINDOWS32)
     659    ".LIBPATTERNS", "lib%.dll.a %.dll.a lib%.a %.lib lib%.dll %.dll",
    524660#else
    525661    ".LIBPATTERNS", "lib%.so lib%.a",
    526662#endif
    527 #endif
    528663
    529664#endif /* !VMS */
     665    /* Make this assignment to avoid undefined variable warnings.  */
     666    "GNUMAKEFLAGS", "",
    530667    0, 0
    531668  };
     
    538675{
    539676  suffix_file = enter_file (strcache_add (".SUFFIXES"));
     677  suffix_file->builtin = 1;
    540678
    541679  if (no_builtin_rules_flag)
     
    543681  else
    544682    {
    545       char *p = default_suffixes;
    546       suffix_file->deps = enter_prereqs(PARSE_FILE_SEQ (&p, struct dep, '\0',
    547                                                         NULL, 0),
    548                                         NULL);
     683      struct dep *d;
     684      const char *p = default_suffixes;
     685      suffix_file->deps = enter_prereqs (PARSE_SIMPLE_SEQ ((char **)&p, struct dep),
     686                                         NULL);
     687      for (d = suffix_file->deps; d; d = d->next)
     688        d->file->builtin = 1;
     689
    549690      define_variable_cname ("SUFFIXES", default_suffixes, o_default, 0);
    550691    }
     
    559700install_default_suffix_rules (void)
    560701{
    561   char **s;
     702  const char **s;
    562703
    563704  if (no_builtin_rules_flag)
     
    567708    {
    568709      struct file *f = enter_file (strcache_add (s[0]));
    569       /* Don't clobber cmds given in a makefile if there were any.  */
    570       if (f->cmds == 0)
    571         {
    572           f->cmds = xmalloc (sizeof (struct commands));
    573           f->cmds->fileinfo.filenm = 0;
    574           f->cmds->commands = s[1];
    575           f->cmds->command_lines = 0;
    576         }
     710      /* This function should run before any makefile is parsed.  */
     711      assert (f->cmds == 0);
     712      f->cmds = xmalloc (sizeof (struct commands));
     713      f->cmds->fileinfo.filenm = 0;
     714      f->cmds->commands = xstrdup (s[1]);
     715      f->cmds->command_lines = 0;
     716      f->cmds->recipe_prefix = RECIPEPREFIX_DEFAULT;
     717      f->builtin = 1;
    577718    }
    578719}
     
    607748    define_variable (s[0], strlen (s[0]), s[1], o_default, 1);
    608749}
     750
     751void
     752undefine_default_variables (void)
     753{
     754  const char **s;
     755
     756  for (s = default_variables; *s != 0; s += 2)
     757    undefine_variable_global (s[0], strlen (s[0]), o_default);
     758}
  • vendor/gnumake/current/dep.h

    r2596 r3138  
    11/* Definitions of dependency data structures for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 /* Flag bits for the second argument to `read_makefile'.
    20    These flags are saved in the `changed' field of each
    21    `struct dep' in the chain returned by `read_all_makefiles'.  */
    2217
    23 #define RM_NO_DEFAULT_GOAL      (1 << 0) /* Do not set default goal.  */
    24 #define RM_INCLUDED             (1 << 1) /* Search makefile search path.  */
    25 #define RM_DONTCARE             (1 << 2) /* No error if it doesn't exist.  */
    26 #define RM_NO_TILDE             (1 << 3) /* Don't expand ~ in file name.  */
    27 #define RM_NOFLAG               0
     18/* Structure used in chains of names, for parsing and globbing.  */
     19
     20#define NAMESEQ(_t)     \
     21    _t *next;           \
     22    const char *name
     23
     24struct nameseq
     25  {
     26    NAMESEQ (struct nameseq);
     27  };
     28
     29/* Flag bits for the second argument to 'read_makefile'.
     30   These flags are saved in the 'flags' field of each
     31   'struct goaldep' in the chain returned by 'read_all_makefiles'.  */
     32
     33#define RM_NO_DEFAULT_GOAL      (1 << 0) /* Do not set default goal.  */
     34#define RM_INCLUDED             (1 << 1) /* Search makefile search path.  */
     35#define RM_DONTCARE             (1 << 2) /* No error if it doesn't exist.  */
     36#define RM_NO_TILDE             (1 << 3) /* Don't expand ~ in file name.  */
     37#define RM_NOFLAG               0
    2838
    2939/* Structure representing one dependency of a file.
    30    Each struct file's `deps' points to a chain of these,
    31    chained through the `next'. `stem' is the stem for this
    32    dep line of static pattern rule or NULL.
     40   Each struct file's 'deps' points to a chain of these, through 'next'.
     41   'stem' is the stem for this dep line of static pattern rule or NULL.  */
    3342
    34    Note that the first two words of this match a struct nameseq.  */
     43#define DEP(_t)                                 \
     44    NAMESEQ (_t);                               \
     45    struct file *file;                          \
     46    const char *stem;                           \
     47    unsigned short flags : 8;                   \
     48    unsigned short changed : 1;                 \
     49    unsigned short ignore_mtime : 1;            \
     50    unsigned short staticpattern : 1;           \
     51    unsigned short need_2nd_expansion : 1
    3552
    3653struct dep
    3754  {
    38     struct dep *next;
    39     const char *name;
    40     const char *stem;
    41     struct file *file;
    42     unsigned int changed : 8;
    43     unsigned int ignore_mtime : 1;
    44     unsigned int staticpattern : 1;
    45     unsigned int need_2nd_expansion : 1;
    46     unsigned int dontcare : 1;
     55    DEP (struct dep);
    4756  };
    4857
     58/* Structure representing one goal.
     59   The goals to be built constitute a chain of these, chained through 'next'.
     60   'stem' is not used, but it's simpler to include and ignore it.  */
    4961
    50 /* Structure used in chains of names, for parsing and globbing.  */
    51 
    52 struct nameseq
     62struct goaldep
    5363  {
    54     struct nameseq *next;
    55     const char *name;
     64    DEP (struct goaldep);
     65    unsigned short error;
     66    floc floc;
    5667  };
    5768
     69/* Options for parsing lists of filenames.  */
    5870
    59 #define PARSEFS_NONE    (0x0000)
    60 #define PARSEFS_NOSTRIP (0x0001)
    61 #define PARSEFS_NOAR    (0x0002)
    62 #define PARSEFS_NOGLOB  (0x0004)
    63 #define PARSEFS_EXISTS  (0x0008)
    64 #define PARSEFS_NOCACHE (0x0010)
     71#define PARSEFS_NONE    0x0000
     72#define PARSEFS_NOSTRIP 0x0001
     73#define PARSEFS_NOAR    0x0002
     74#define PARSEFS_NOGLOB  0x0004
     75#define PARSEFS_EXISTS  0x0008
     76#define PARSEFS_NOCACHE 0x0010
    6577
    6678#define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
    6779            (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f))
     80#define PARSE_SIMPLE_SEQ(_s,_t) \
     81            (_t *)parse_file_seq ((_s),sizeof (_t),MAP_NUL,NULL,PARSEFS_NONE)
    6882
    6983#ifdef VMS
     
    7185#else
    7286void *parse_file_seq (char **stringp, unsigned int size,
    73                       int stopchar, const char *prefix, int flags);
     87                      int stopmap, const char *prefix, int flags);
    7488#endif
    7589
     
    8094#endif
    8195
    82 #define dep_name(d)     ((d)->name == 0 ? (d)->file->name : (d)->name)
     96#define dep_name(d)        ((d)->name ? (d)->name : (d)->file->name)
    8397
    84 #define alloc_dep()     (xcalloc (sizeof (struct dep)))
    85 #define free_ns(_n)     free (_n)
    86 #define free_dep(_d)    free_ns (_d)
     98#define alloc_seq_elt(_t)   xcalloc (sizeof (_t))
     99void free_ns_chain (struct nameseq *n);
     100
     101#if defined(MAKE_MAINTAINER_MODE) && defined(__GNUC__)
     102/* Use inline to get real type-checking.  */
     103#define SI static inline
     104SI struct nameseq *alloc_ns()      { return alloc_seq_elt (struct nameseq); }
     105SI struct dep *alloc_dep()         { return alloc_seq_elt (struct dep); }
     106SI struct goaldep *alloc_goaldep() { return alloc_seq_elt (struct goaldep); }
     107
     108SI void free_ns(struct nameseq *n)      { free (n); }
     109SI void free_dep(struct dep *d)         { free_ns ((struct nameseq *)d); }
     110SI void free_goaldep(struct goaldep *g) { free_dep ((struct dep *)g); }
     111
     112SI void free_dep_chain(struct dep *d)      { free_ns_chain((struct nameseq *)d); }
     113SI void free_goal_chain(struct goaldep *g) { free_dep_chain((struct dep *)g); }
     114#else
     115# define alloc_ns()          alloc_seq_elt (struct nameseq)
     116# define alloc_dep()         alloc_seq_elt (struct dep)
     117# define alloc_goaldep()     alloc_seq_elt (struct goaldep)
     118
     119# define free_ns(_n)         free (_n)
     120# define free_dep(_d)        free_ns (_d)
     121# define free_goaldep(_g)    free_dep (_g)
     122
     123# define free_dep_chain(_d)  free_ns_chain ((struct nameseq *)(_d))
     124# define free_goal_chain(_g) free_ns_chain ((struct nameseq *)(_g))
     125#endif
    87126
    88127struct dep *copy_dep_chain (const struct dep *d);
    89 void free_dep_chain (struct dep *d);
    90 void free_ns_chain (struct nameseq *n);
    91 struct dep *read_all_makefiles (const char **makefiles);
    92 void eval_buffer (char *buffer);
    93 int update_goal_chain (struct dep *goals);
     128
     129struct goaldep *read_all_makefiles (const char **makefiles);
     130void eval_buffer (char *buffer, const floc *floc);
     131enum update_status update_goal_chain (struct goaldep *goals);
  • vendor/gnumake/current/dir.c

    r2596 r3138  
    11/* Directory hashing for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018#include "hash.h"
    21 
    22 #ifdef  HAVE_DIRENT_H
     19#include "filedef.h"
     20#include "dep.h"
     21
     22#ifdef  HAVE_DIRENT_H
    2323# include <dirent.h>
    2424# define NAMLEN(dirent) strlen((dirent)->d_name)
     
    8888
    8989  /* First, transform the name part.  */
    90   for (i = 0; *filename != '\0' && i < 8 && *filename != '.'; ++i)
     90  for (i = 0; i < 8 && ! STOP_SET (*filename, MAP_DOT|MAP_NUL); ++i)
    9191    *df++ = tolower ((unsigned char)*filename++);
    9292
    9393  /* Now skip to the next dot.  */
    94   while (*filename != '\0' && *filename != '.')
     94  while (! STOP_SET (*filename, MAP_DOT|MAP_NUL))
    9595    ++filename;
    9696  if (*filename != '\0')
    9797    {
    9898      *df++ = *filename++;
    99       for (i = 0; *filename != '\0' && i < 3 && *filename != '.'; ++i)
    100         *df++ = tolower ((unsigned char)*filename++);
     99      for (i = 0; i < 3 && ! STOP_SET (*filename, MAP_DOT|MAP_NUL); ++i)
     100        *df++ = tolower ((unsigned char)*filename++);
    101101    }
    102102
    103103  /* Look for more dots.  */
    104   while (*filename != '\0' && *filename != '.')
     104  while (! STOP_SET (*filename, MAP_DOT|MAP_NUL))
    105105    ++filename;
    106106  if (*filename == '.')
     
    144144#ifdef VMS
    145145
     146static char *
     147downcase_inplace(char *filename)
     148{
     149  char *name;
     150  name = filename;
     151  while (*name != '\0')
     152    {
     153      *name = tolower ((unsigned char)*name);
     154      ++name;
     155    }
     156  return filename;
     157}
     158
     159#ifndef _USE_STD_STAT
     160/* VMS 8.2 fixed the VMS stat output to have unique st_dev and st_ino
     161   when _USE_STD_STAT is used on the compile line.
     162
     163   Prior to _USE_STD_STAT support, the st_dev is a pointer to thread
     164   static memory containing the device of the last filename looked up.
     165
     166   Todo: find out if the ino_t still needs to be faked on a directory.
     167 */
     168
     169/* Define this if the older VMS_INO_T is needed */
     170#define VMS_INO_T 1
     171
    146172static int
    147173vms_hash (const char *name)
    148174{
    149175  int h = 0;
    150   int g;
    151176
    152177  while (*name)
    153178    {
    154179      unsigned char uc = *name;
     180      int g;
    155181#ifdef HAVE_CASE_INSENSITIVE_FS
    156182      h = (h << 4) + (isupper (uc) ? tolower (uc) : uc);
     
    161187      g = h & 0xf0000000;
    162188      if (g)
    163         {
    164           h = h ^ (g >> 24);
    165           h = h ^ g;
    166         }
     189        {
     190          h = h ^ (g >> 24);
     191          h = h ^ g;
     192        }
    167193    }
    168194  return h;
     
    181207    return -1;
    182208  closedir (dir);
    183   s = strchr (name, ':');       /* find device */
     209  s = strchr (name, ':');       /* find device */
    184210  if (s)
    185211    {
     
    202228  return 0;
    203229}
     230
     231# define stat(__path, __sbuf) vmsstat_dir (__path, __sbuf)
     232
     233#endif /* _USE_STD_STAT */
    204234#endif /* VMS */
    205235
     
    207237/* Hash table of directories.  */
    208238
    209 #ifndef DIRECTORY_BUCKETS
     239#ifndef DIRECTORY_BUCKETS
    210240#define DIRECTORY_BUCKETS 199
    211241#endif
     
    213243struct directory_contents
    214244  {
    215     dev_t dev;                  /* Device and inode numbers of this dir.  */
     245    dev_t dev;                  /* Device and inode numbers of this dir.  */
    216246#ifdef WINDOWS32
    217247    /* Inode means nothing on WINDOWS32. Even file key information is
     
    221251     * unreliable. I'm open to suggestion on a better way to emulate inode.  */
    222252    char *path_key;
    223     int  ctime;
    224     int  mtime;        /* controls check for stale directory cache */
    225     int   fs_flags;     /* FS_FAT, FS_NTFS, ... */
     253    time_t ctime;
     254    time_t mtime;        /* controls check for stale directory cache */
     255    int fs_flags;     /* FS_FAT, FS_NTFS, ... */
    226256# define FS_FAT      0x1
    227257# define FS_NTFS     0x2
    228258# define FS_UNKNOWN  0x4
    229259#else
    230 # ifdef VMS
     260# ifdef VMS_INO_T
    231261    ino_t ino[3];
    232262# else
     
    234264# endif
    235265#endif /* WINDOWS32 */
    236     struct hash_table dirfiles; /* Files in this directory.  */
    237     DIR *dirstream;             /* Stream reading this directory.  */
     266    struct hash_table dirfiles; /* Files in this directory.  */
     267    DIR *dirstream;             /* Stream reading this directory.  */
    238268  };
    239269
     
    249279  hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) key->ctime;
    250280#else
    251 # ifdef VMS
     281# ifdef VMS_INO_T
    252282  hash = (((unsigned int) key->dev << 4)
    253           ^ ((unsigned int) key->ino[0]
    254              + (unsigned int) key->ino[1]
    255              + (unsigned int) key->ino[2]));
     283          ^ ((unsigned int) key->ino[0]
     284             + (unsigned int) key->ino[1]
     285             + (unsigned int) key->ino[2]));
    256286# else
    257287  hash = ((unsigned int) key->dev << 4) ^ (unsigned int) key->ino;
     
    272302  hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) ~key->ctime;
    273303#else
    274 # ifdef VMS
     304# ifdef VMS_INO_T
    275305  hash = (((unsigned int) key->dev << 4)
    276           ^ ~((unsigned int) key->ino[0]
    277               + (unsigned int) key->ino[1]
    278               + (unsigned int) key->ino[2]));
     306          ^ ~((unsigned int) key->ino[0]
     307              + (unsigned int) key->ino[1]
     308              + (unsigned int) key->ino[2]));
    279309# else
    280310  hash = ((unsigned int) key->dev << 4) ^ (unsigned int) ~key->ino;
     
    311341    return result;
    312342#else
    313 # ifdef VMS
     343# ifdef VMS_INO_T
    314344  result = MAKECMP(x->ino[0], y->ino[0]);
    315345  if (result)
     
    336366struct directory
    337367  {
    338     const char *name;                   /* Name of the directory.  */
     368    const char *name;                   /* Name of the directory.  */
    339369
    340370    /* The directory's contents.  This data may be shared by several
    341371       entries in the hash table, which refer to the same directory
    342        (identified uniquely by `dev' and `ino') under different names.  */
     372       (identified uniquely by 'dev' and 'ino') under different names.  */
    343373    struct directory_contents *contents;
    344374  };
     
    360390{
    361391  return_ISTRING_COMPARE (((const struct directory *) x)->name,
    362                           ((const struct directory *) y)->name);
     392                          ((const struct directory *) y)->name);
    363393}
    364394
     
    377407struct dirfile
    378408  {
    379     const char *name;           /* Name of the file.  */
    380     short length;
    381     short impossible;           /* This file is impossible.  */
     409    const char *name;           /* Name of the file.  */
     410    size_t length;
     411    short impossible;           /* This file is impossible.  */
    382412  };
    383413
     
    405435}
    406436
    407 #ifndef DIRFILE_BUCKETS
     437#ifndef DIRFILE_BUCKETS
    408438#define DIRFILE_BUCKETS 107
    409439#endif
     
    414444static struct directory *find_directory (const char *name);
    415445
    416 /* Find the directory named NAME and return its `struct directory'.  */
     446/* Find the directory named NAME and return its 'struct directory'.  */
    417447
    418448static struct directory *
    419449find_directory (const char *name)
    420450{
    421   const char *p;
    422451  struct directory *dir;
    423452  struct directory **dir_slot;
    424453  struct directory dir_key;
    425   int r;
    426 #ifdef WINDOWS32
    427   char* w32_path;
    428   char  fs_label[BUFSIZ];
    429   char  fs_type[BUFSIZ];
    430   unsigned long  fs_serno;
    431   unsigned long  fs_flags;
    432   unsigned long  fs_len;
    433 #endif
    434 #ifdef VMS
    435   if ((*name == '.') && (*(name+1) == 0))
    436     name = "[]";
    437   else
    438     name = vmsify (name,1);
    439 #endif
    440454
    441455  dir_key.name = name;
     
    445459  if (HASH_VACANT (dir))
    446460    {
     461      /* The directory was not found.  Create a new entry for it.  */
     462      const char *p = name + strlen (name);
    447463      struct stat st;
    448 
    449       /* The directory was not found.  Create a new entry for it.  */
    450 
    451       p = name + strlen (name);
     464      int r;
     465
    452466      dir = xmalloc (sizeof (struct directory));
    453467#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
    454       dir->name = strcache_add_len (downcase(name), p - name);
     468      /* Todo: Why is this only needed on VMS? */
     469      {
     470        char *lname = downcase_inplace (xstrdup (name));
     471        dir->name = strcache_add_len (lname, p - name);
     472        free (lname);
     473      }
    455474#else
    456475      dir->name = strcache_add_len (name, p - name);
     
    458477      hash_insert_at (&directories, dir, dir_slot);
    459478      /* The directory is not in the name hash table.
    460          Find its device and inode numbers, and look it up by them.  */
    461 
    462 #ifdef VMS
    463       r = vmsstat_dir (name, &st);
    464 #elif defined(WINDOWS32)
     479         Find its device and inode numbers, and look it up by them.  */
     480
     481#if defined(WINDOWS32)
    465482      {
    466483        char tem[MAXPATHLEN], *tstart, *tend;
     
    485502      if (r < 0)
    486503        {
    487         /* Couldn't stat the directory.  Mark this by
    488            setting the `contents' member to a nil pointer.  */
    489           dir->contents = 0;
    490         }
     504        /* Couldn't stat the directory.  Mark this by
     505           setting the 'contents' member to a nil pointer.  */
     506          dir->contents = 0;
     507        }
    491508      else
    492         {
    493           /* Search the contents hash table; device and inode are the key.  */
    494 
    495           struct directory_contents *dc;
    496           struct directory_contents **dc_slot;
    497           struct directory_contents dc_key;
    498 
    499           dc_key.dev = st.st_dev;
    500 #ifdef WINDOWS32
    501           dc_key.path_key = w32_path = w32ify (name, 1);
    502           dc_key.ctime = st.st_ctime;
    503 #else
    504 # ifdef VMS
    505           dc_key.ino[0] = st.st_ino[0];
    506           dc_key.ino[1] = st.st_ino[1];
    507           dc_key.ino[2] = st.st_ino[2];
     509        {
     510          /* Search the contents hash table; device and inode are the key.  */
     511
     512#ifdef WINDOWS32
     513          char *w32_path;
     514#endif
     515          struct directory_contents *dc;
     516          struct directory_contents **dc_slot;
     517          struct directory_contents dc_key;
     518
     519          dc_key.dev = st.st_dev;
     520#ifdef WINDOWS32
     521          dc_key.path_key = w32_path = w32ify (name, 1);
     522          dc_key.ctime = st.st_ctime;
     523#else
     524# ifdef VMS_INO_T
     525          dc_key.ino[0] = st.st_ino[0];
     526          dc_key.ino[1] = st.st_ino[1];
     527          dc_key.ino[2] = st.st_ino[2];
    508528# else
    509           dc_key.ino = st.st_ino;
     529          dc_key.ino = st.st_ino;
    510530# endif
    511531#endif
    512           dc_slot = (struct directory_contents **) hash_find_slot (&directory_contents, &dc_key);
    513           dc = *dc_slot;
    514 
    515           if (HASH_VACANT (dc))
    516             {
    517               /* Nope; this really is a directory we haven't seen before.  */
    518 
    519               dc = (struct directory_contents *)
    520                 xmalloc (sizeof (struct directory_contents));
    521 
    522               /* Enter it in the contents hash table.  */
    523               dc->dev = st.st_dev;
     532          dc_slot = (struct directory_contents **) hash_find_slot (&directory_contents, &dc_key);
     533          dc = *dc_slot;
     534
     535          if (HASH_VACANT (dc))
     536            {
     537              /* Nope; this really is a directory we haven't seen before.  */
     538#ifdef WINDOWS32
     539              char  fs_label[BUFSIZ];
     540              char  fs_type[BUFSIZ];
     541              unsigned long  fs_serno;
     542              unsigned long  fs_flags;
     543              unsigned long  fs_len;
     544#endif
     545              dc = (struct directory_contents *)
     546                xmalloc (sizeof (struct directory_contents));
     547
     548              /* Enter it in the contents hash table.  */
     549              dc->dev = st.st_dev;
    524550#ifdef WINDOWS32
    525551              dc->path_key = xstrdup (w32_path);
    526               dc->ctime = st.st_ctime;
     552              dc->ctime = st.st_ctime;
    527553              dc->mtime = st.st_mtime;
    528554
    529               /*
    530                * NTFS is the only WINDOWS32 filesystem that bumps mtime
    531                * on a directory when files are added/deleted from
    532                * a directory.
    533                */
     555              /* NTFS is the only WINDOWS32 filesystem that bumps mtime on a
     556                 directory when files are added/deleted from a directory.  */
    534557              w32_path[3] = '\0';
    535               if (GetVolumeInformation(w32_path,
    536                      fs_label, sizeof (fs_label),
    537                      &fs_serno, &fs_len,
    538                      &fs_flags, fs_type, sizeof (fs_type)) == FALSE)
     558              if (GetVolumeInformation (w32_path, fs_label, sizeof (fs_label),
     559                                        &fs_serno, &fs_len, &fs_flags, fs_type,
     560                                        sizeof (fs_type)) == FALSE)
    539561                dc->fs_flags = FS_UNKNOWN;
    540               else if (!strcmp(fs_type, "FAT"))
     562              else if (!strcmp (fs_type, "FAT"))
    541563                dc->fs_flags = FS_FAT;
    542               else if (!strcmp(fs_type, "NTFS"))
     564              else if (!strcmp (fs_type, "NTFS"))
    543565                dc->fs_flags = FS_NTFS;
    544566              else
    545567                dc->fs_flags = FS_UNKNOWN;
    546568#else
    547 # ifdef VMS
    548               dc->ino[0] = st.st_ino[0];
    549               dc->ino[1] = st.st_ino[1];
    550               dc->ino[2] = st.st_ino[2];
     569# ifdef VMS_INO_T
     570              dc->ino[0] = st.st_ino[0];
     571              dc->ino[1] = st.st_ino[1];
     572              dc->ino[2] = st.st_ino[2];
    551573# else
    552               dc->ino = st.st_ino;
     574              dc->ino = st.st_ino;
    553575# endif
    554576#endif /* WINDOWS32 */
    555               hash_insert_at (&directory_contents, dc, dc_slot);
    556               ENULLLOOP (dc->dirstream, opendir (name));
    557               if (dc->dirstream == 0)
     577              hash_insert_at (&directory_contents, dc, dc_slot);
     578              ENULLLOOP (dc->dirstream, opendir (name));
     579              if (dc->dirstream == 0)
    558580                /* Couldn't open the directory.  Mark this by setting the
    559                    `files' member to a nil pointer.  */
     581                   'files' member to a nil pointer.  */
    560582                dc->dirfiles.ht_vec = 0;
    561               else
    562                 {
    563                   hash_init (&dc->dirfiles, DIRFILE_BUCKETS,
    564                              dirfile_hash_1, dirfile_hash_2, dirfile_hash_cmp);
    565                   /* Keep track of how many directories are open.  */
    566                   ++open_directories;
    567                   if (open_directories == MAX_OPEN_DIRECTORIES)
    568                     /* We have too many directories open already.
    569                        Read the entire directory and then close it.  */
    570                     dir_contents_file_exists_p (dc, 0);
    571                 }
    572             }
    573 
    574           /* Point the name-hashed entry for DIR at its contents data.  */
    575           dir->contents = dc;
    576         }
     583              else
     584                {
     585                  hash_init (&dc->dirfiles, DIRFILE_BUCKETS,
     586                             dirfile_hash_1, dirfile_hash_2, dirfile_hash_cmp);
     587                  /* Keep track of how many directories are open.  */
     588                  ++open_directories;
     589                  if (open_directories == MAX_OPEN_DIRECTORIES)
     590                    /* We have too many directories open already.
     591                       Read the entire directory and then close it.  */
     592                    dir_contents_file_exists_p (dc, 0);
     593                }
     594            }
     595
     596          /* Point the name-hashed entry for DIR at its contents data.  */
     597          dir->contents = dc;
     598        }
    577599    }
    578600
     
    588610                            const char *filename)
    589611{
    590   unsigned int hash;
    591612  struct dirfile *df;
    592613  struct dirent *d;
     
    612633    _fnlwr (filename); /* lower case for FAT drives */
    613634#endif
    614 
    615 #ifdef VMS
    616   filename = vmsify (filename,0);
    617 #endif
    618 
    619   hash = 0;
    620635  if (filename != 0)
    621636    {
     
    623638
    624639      if (*filename == '\0')
    625         {
    626           /* Checking if the directory exists.  */
    627           return 1;
    628         }
     640        {
     641          /* Checking if the directory exists.  */
     642          return 1;
     643        }
    629644      dirfile_key.name = filename;
    630645      dirfile_key.length = strlen (filename);
     
    646661       */
    647662      if (dir->path_key)
    648         {
     663        {
    649664          if ((dir->fs_flags & FS_FAT) != 0)
    650             {
    651               dir->mtime = time ((time_t *) 0);
    652               rehash = 1;
    653             }
    654           else if (stat (dir->path_key, &st) == 0 && st.st_mtime > dir->mtime)
    655             {
    656               /* reset date stamp to show most recent re-process.  */
    657               dir->mtime = st.st_mtime;
    658               rehash = 1;
    659             }
     665            {
     666              dir->mtime = time ((time_t *) 0);
     667              rehash = 1;
     668            }
     669          else if (stat (dir->path_key, &st) == 0 && st.st_mtime > dir->mtime)
     670            {
     671              /* reset date stamp to show most recent re-process.  */
     672              dir->mtime = st.st_mtime;
     673              rehash = 1;
     674            }
    660675
    661676          /* If it has been already read in, all done.  */
    662           if (!rehash)
    663             return 0;
     677          if (!rehash)
     678            return 0;
    664679
    665680          /* make sure directory can still be opened; if not return.  */
     
    667682          if (!dir->dirstream)
    668683            return 0;
    669         }
     684        }
    670685      else
    671686#endif
    672         /* The directory has been all read in.  */
    673         return 0;
     687        /* The directory has been all read in.  */
     688        return 0;
    674689    }
    675690
     
    685700        {
    686701          if (errno)
    687             fatal (NILF, "INTERNAL: readdir: %s\n", strerror (errno));
     702            pfatal_with_name ("INTERNAL: readdir");
    688703          break;
    689704        }
    690705
    691706#if defined(VMS) && defined(HAVE_DIRENT_H)
    692       /* In VMS we get file versions too, which have to be stripped off */
     707      /* In VMS we get file versions too, which have to be stripped off.
     708         Some versions of VMS return versions on Unix files even when
     709         the feature option to strip them is set.  */
    693710      {
    694711        char *p = strrchr (d->d_name, ';');
     
    698715#endif
    699716      if (!REAL_DIR_ENTRY (d))
    700         continue;
     717        continue;
    701718
    702719      len = NAMLEN (d);
     
    711728      if (! rehash || HASH_VACANT (*dirfile_slot))
    712729#endif
    713         {
    714           df = xmalloc (sizeof (struct dirfile));
     730        {
     731          df = xmalloc (sizeof (struct dirfile));
    715732#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
    716           df->name = strcache_add_len (downcase(d->d_name), len);
    717 #else
    718           df->name = strcache_add_len (d->d_name, len);
    719 #endif
    720           df->length = len;
    721           df->impossible = 0;
    722           hash_insert_at (&dir->dirfiles, df, dirfile_slot);
    723         }
     733          /* TODO: Why is this only needed on VMS? */
     734          df->name = strcache_add_len (downcase_inplace (d->d_name), len);
     735#else
     736          df->name = strcache_add_len (d->d_name, len);
     737#endif
     738          df->length = len;
     739          df->impossible = 0;
     740          hash_insert_at (&dir->dirfiles, df, dirfile_slot);
     741        }
    724742      /* Check if the name matches the one we're searching for.  */
    725743      if (filename != 0 && patheq (d->d_name, filename))
     
    745763dir_file_exists_p (const char *dirname, const char *filename)
    746764{
     765#ifdef VMS
     766  if ((filename != NULL) && (dirname != NULL))
     767    {
     768      int want_vmsify;
     769      want_vmsify = (strpbrk (dirname, ":<[") != NULL);
     770      if (want_vmsify)
     771        filename = vmsify (filename, 0);
     772    }
     773#endif
    747774  return dir_contents_file_exists_p (find_directory (dirname)->contents,
    748                                      filename);
     775                                     filename);
    749776}
    750777
     
    759786  const char *slash;
    760787
    761 #ifndef NO_ARCHIVES
     788#ifndef NO_ARCHIVES
    762789  if (ar_name (name))
    763790    return ar_member_date (name) != (time_t) -1;
    764791#endif
    765792
     793  dirend = strrchr (name, '/');
    766794#ifdef VMS
    767   dirend = strrchr (name, ']');
    768795  if (dirend == 0)
    769     dirend = strrchr (name, ':');
     796    {
     797      dirend = strrchr (name, ']');
     798      dirend == NULL ? dirend : dirend++;
     799    }
    770800  if (dirend == 0)
    771     return dir_file_exists_p ("[]", name);
    772 #else /* !VMS */
    773   dirend = strrchr (name, '/');
     801    {
     802      dirend = strrchr (name, '>');
     803      dirend == NULL ? dirend : dirend++;
     804    }
     805  if (dirend == 0)
     806    {
     807      dirend = strrchr (name, ':');
     808      dirend == NULL ? dirend : dirend++;
     809    }
     810#endif /* VMS */
    774811#ifdef HAVE_DOS_PATHS
    775812  /* Forward and backslashes might be mixed.  We need the rightmost one.  */
    776813  {
    777     const char *bslash = strrchr(name, '\\');
     814    const char *bslash = strrchr (name, '\\');
    778815    if (!dirend || bslash > dirend)
    779816      dirend = bslash;
     
    786823#ifndef _AMIGA
    787824    return dir_file_exists_p (".", name);
    788 #else /* !VMS && !AMIGA */
     825#else /* !AMIGA */
    789826    return dir_file_exists_p ("", name);
    790827#endif /* AMIGA */
    791 #endif /* VMS */
    792828
    793829  slash = dirend;
     
    800836  /* d:/ and d: are *very* different...  */
    801837      if (dirend < name + 3 && name[1] == ':' &&
    802           (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
    803         dirend++;
     838          (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
     839        dirend++;
    804840#endif
    805841      p = alloca (dirend - name + 1);
     
    808844      dirname = p;
    809845    }
    810   return dir_file_exists_p (dirname, slash + 1);
    811 }
    812 
    813 
    814 /* Mark FILENAME as `impossible' for `file_impossible_p'.
     846#ifdef VMS
     847  if (*slash == '/')
     848    slash++;
     849#else
     850  slash++;
     851#endif
     852  return dir_file_exists_p (dirname, slash);
     853}
     854
     855
     856/* Mark FILENAME as 'impossible' for 'file_impossible_p'.
    815857   This means an attempt has been made to search for FILENAME
    816858   as an intermediate file, and it has failed.  */
     
    824866  struct dirfile *new;
    825867
     868  dirend = strrchr (p, '/');
    826869#ifdef VMS
    827   dirend = strrchr (p, ']');
    828   if (dirend == 0)
    829     dirend = strrchr (p, ':');
    830   dirend++;
    831   if (dirend == (char *)1)
    832     dir = find_directory ("[]");
    833 #else
    834   dirend = strrchr (p, '/');
    835 # ifdef HAVE_DOS_PATHS
     870  if (dirend == NULL)
     871    {
     872      dirend = strrchr (p, ']');
     873      dirend == NULL ? dirend : dirend++;
     874    }
     875  if (dirend == NULL)
     876    {
     877      dirend = strrchr (p, '>');
     878      dirend == NULL ? dirend : dirend++;
     879    }
     880  if (dirend == NULL)
     881    {
     882      dirend = strrchr (p, ':');
     883      dirend == NULL ? dirend : dirend++;
     884    }
     885#endif
     886#ifdef HAVE_DOS_PATHS
    836887  /* Forward and backslashes might be mixed.  We need the rightmost one.  */
    837888  {
    838     const char *bslash = strrchr(p, '\\');
     889    const char *bslash = strrchr (p, '\\');
    839890    if (!dirend || bslash > dirend)
    840891      dirend = bslash;
     
    843894      dirend = p + 1;
    844895  }
    845 # endif /* HAVE_DOS_PATHS */
     896#endif /* HAVE_DOS_PATHS */
    846897  if (dirend == 0)
    847 # ifdef _AMIGA
     898#ifdef _AMIGA
    848899    dir = find_directory ("");
    849 # else /* !VMS && !AMIGA */
     900#else /* !AMIGA */
    850901    dir = find_directory (".");
    851 # endif /* AMIGA */
    852 #endif /* VMS */
     902#endif /* AMIGA */
    853903  else
    854904    {
     
    856906      const char *slash = dirend;
    857907      if (dirend == p)
    858         dirname = "/";
     908        dirname = "/";
    859909      else
    860         {
     910        {
    861911          char *cp;
    862912#ifdef HAVE_DOS_PATHS
    863           /* d:/ and d: are *very* different...  */
    864           if (dirend < p + 3 && p[1] == ':' &&
    865               (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
    866             dirend++;
    867 #endif
    868           cp = alloca (dirend - p + 1);
    869           memcpy (cp, p, dirend - p);
    870           cp[dirend - p] = '\0';
     913          /* d:/ and d: are *very* different...  */
     914          if (dirend < p + 3 && p[1] == ':' &&
     915              (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
     916            dirend++;
     917#endif
     918          cp = alloca (dirend - p + 1);
     919          memcpy (cp, p, dirend - p);
     920          cp[dirend - p] = '\0';
    871921          dirname = cp;
    872         }
     922        }
    873923      dir = find_directory (dirname);
     924#ifdef VMS
     925      if (*slash == '/')
     926        filename = p = slash + 1;
     927      else
     928        filename = p = slash;
     929#else
    874930      filename = p = slash + 1;
     931#endif
    875932    }
    876933
     
    883940    {
    884941      hash_init (&dir->contents->dirfiles, DIRFILE_BUCKETS,
    885                 dirfile_hash_1, dirfile_hash_2, dirfile_hash_cmp);
     942                dirfile_hash_1, dirfile_hash_2, dirfile_hash_cmp);
    886943    }
    887944
     
    891948  new->length = strlen (filename);
    892949#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
    893   new->name = strcache_add_len (downcase(filename), new->length);
     950  /* todo: Why is this only needed on VMS? */
     951  new->name = strcache_add_len (downcase (filename), new->length);
    894952#else
    895953  new->name = strcache_add_len (filename, new->length);
     
    906964{
    907965  const char *dirend;
    908   const char *p = filename;
    909966  struct directory_contents *dir;
    910967  struct dirfile *dirfile;
    911968  struct dirfile dirfile_key;
    912 
    913969#ifdef VMS
    914   dirend = strrchr (filename, ']');
    915   if (dirend == 0)
    916     dir = find_directory ("[]")->contents;
    917 #else
     970  int want_vmsify = 0;
     971#endif
     972
    918973  dirend = strrchr (filename, '/');
     974#ifdef VMS
     975  if (dirend == NULL)
     976    {
     977      want_vmsify = (strpbrk (filename, "]>:^") != NULL);
     978      dirend = strrchr (filename, ']');
     979    }
     980  if (dirend == NULL && want_vmsify)
     981    dirend = strrchr (filename, '>');
     982  if (dirend == NULL && want_vmsify)
     983    dirend = strrchr (filename, ':');
     984#endif
    919985#ifdef HAVE_DOS_PATHS
    920986  /* Forward and backslashes might be mixed.  We need the rightmost one.  */
    921987  {
    922     const char *bslash = strrchr(filename, '\\');
     988    const char *bslash = strrchr (filename, '\\');
    923989    if (!dirend || bslash > dirend)
    924990      dirend = bslash;
     
    931997#ifdef _AMIGA
    932998    dir = find_directory ("")->contents;
    933 #else /* !VMS && !AMIGA */
     999#else /* !AMIGA */
    9341000    dir = find_directory (".")->contents;
    9351001#endif /* AMIGA */
    936 #endif /* VMS */
    9371002  else
    9381003    {
     
    9401005      const char *slash = dirend;
    9411006      if (dirend == filename)
    942         dirname = "/";
     1007        dirname = "/";
    9431008      else
    944         {
     1009        {
    9451010          char *cp;
    9461011#ifdef HAVE_DOS_PATHS
    947           /* d:/ and d: are *very* different...  */
    948           if (dirend < filename + 3 && filename[1] == ':' &&
    949               (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
    950             dirend++;
    951 #endif
    952           cp = alloca (dirend - filename + 1);
    953           memcpy (cp, p, dirend - p);
    954           cp[dirend - p] = '\0';
     1012          /* d:/ and d: are *very* different...  */
     1013          if (dirend < filename + 3 && filename[1] == ':' &&
     1014              (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
     1015            dirend++;
     1016#endif
     1017          cp = alloca (dirend - filename + 1);
     1018          memcpy (cp, filename, dirend - filename);
     1019          cp[dirend - filename] = '\0';
    9551020          dirname = cp;
    956         }
     1021        }
    9571022      dir = find_directory (dirname)->contents;
    958       p = filename = slash + 1;
     1023#ifdef VMS
     1024      if (*slash == '/')
     1025        filename = slash + 1;
     1026      else
     1027        filename = slash;
     1028#else
     1029      filename = slash + 1;
     1030#endif
    9591031    }
    9601032
     
    9641036
    9651037#ifdef __MSDOS__
    966   filename = dosify (p);
     1038  filename = dosify (filename);
    9671039#endif
    9681040#ifdef HAVE_CASE_INSENSITIVE_FS
    969   filename = downcase (p);
     1041  filename = downcase (filename);
    9701042#endif
    9711043#ifdef VMS
    972   filename = vmsify (p, 1);
     1044  if (want_vmsify)
     1045    filename = vmsify (filename, 1);
    9731046#endif
    9741047
     
    10131086      struct directory *dir = *dir_slot;
    10141087      if (! HASH_VACANT (dir))
    1015         {
    1016           if (dir->contents == 0)
    1017             printf (_("# %s: could not be stat'd.\n"), dir->name);
    1018           else if (dir->contents->dirfiles.ht_vec == 0)
    1019             {
    1020 #ifdef WINDOWS32
    1021               printf (_("# %s (key %s, mtime %d): could not be opened.\n"),
    1022                       dir->name, dir->contents->path_key,dir->contents->mtime);
     1088        {
     1089          if (dir->contents == 0)
     1090            printf (_("# %s: could not be stat'd.\n"), dir->name);
     1091          else if (dir->contents->dirfiles.ht_vec == 0)
     1092            {
     1093#ifdef WINDOWS32
     1094              printf (_("# %s (key %s, mtime %I64u): could not be opened.\n"),
     1095                      dir->name, dir->contents->path_key,
     1096                      (unsigned long long)dir->contents->mtime);
    10231097#else  /* WINDOWS32 */
    1024 #ifdef VMS
    1025               printf (_("# %s (device %d, inode [%d,%d,%d]): could not be opened.\n"),
    1026                       dir->name, dir->contents->dev,
    1027                       dir->contents->ino[0], dir->contents->ino[1],
    1028                       dir->contents->ino[2]);
    1029 #else
    1030               printf (_("# %s (device %ld, inode %ld): could not be opened.\n"),
    1031                       dir->name, (long int) dir->contents->dev,
    1032                       (long int) dir->contents->ino);
     1098#ifdef VMS_INO_T
     1099              printf (_("# %s (device %d, inode [%d,%d,%d]): could not be opened.\n"),
     1100                      dir->name, dir->contents->dev,
     1101                      dir->contents->ino[0], dir->contents->ino[1],
     1102                      dir->contents->ino[2]);
     1103#else
     1104              printf (_("# %s (device %ld, inode %ld): could not be opened.\n"),
     1105                      dir->name, (long int) dir->contents->dev,
     1106                      (long int) dir->contents->ino);
    10331107#endif
    10341108#endif /* WINDOWS32 */
    1035             }
    1036           else
    1037             {
    1038               unsigned int f = 0;
    1039               unsigned int im = 0;
    1040               struct dirfile **files_slot;
    1041               struct dirfile **files_end;
    1042 
    1043               files_slot = (struct dirfile **) dir->contents->dirfiles.ht_vec;
    1044               files_end = files_slot + dir->contents->dirfiles.ht_size;
    1045               for ( ; files_slot < files_end; files_slot++)
    1046                 {
    1047                   struct dirfile *df = *files_slot;
    1048                   if (! HASH_VACANT (df))
    1049                     {
    1050                       if (df->impossible)
    1051                         ++im;
    1052                       else
    1053                         ++f;
    1054                     }
    1055                 }
    1056 #ifdef WINDOWS32
    1057               printf (_("# %s (key %s, mtime %d): "),
    1058                       dir->name, dir->contents->path_key, dir->contents->mtime);
     1109            }
     1110          else
     1111            {
     1112              unsigned int f = 0;
     1113              unsigned int im = 0;
     1114              struct dirfile **files_slot;
     1115              struct dirfile **files_end;
     1116
     1117              files_slot = (struct dirfile **) dir->contents->dirfiles.ht_vec;
     1118              files_end = files_slot + dir->contents->dirfiles.ht_size;
     1119              for ( ; files_slot < files_end; files_slot++)
     1120                {
     1121                  struct dirfile *df = *files_slot;
     1122                  if (! HASH_VACANT (df))
     1123                    {
     1124                      if (df->impossible)
     1125                        ++im;
     1126                      else
     1127                        ++f;
     1128                    }
     1129                }
     1130#ifdef WINDOWS32
     1131              printf (_("# %s (key %s, mtime %I64u): "),
     1132                      dir->name, dir->contents->path_key,
     1133                      (unsigned long long)dir->contents->mtime);
    10591134#else  /* WINDOWS32 */
    1060 #ifdef VMS
    1061               printf (_("# %s (device %d, inode [%d,%d,%d]): "),
    1062                       dir->name, dir->contents->dev,
    1063                       dir->contents->ino[0], dir->contents->ino[1],
    1064                       dir->contents->ino[2]);
    1065 #else
    1066               printf (_("# %s (device %ld, inode %ld): "),
    1067                       dir->name,
    1068                       (long)dir->contents->dev, (long)dir->contents->ino);
     1135#ifdef VMS_INO_T
     1136              printf (_("# %s (device %d, inode [%d,%d,%d]): "),
     1137                      dir->name, dir->contents->dev,
     1138                      dir->contents->ino[0], dir->contents->ino[1],
     1139                      dir->contents->ino[2]);
     1140#else
     1141              printf (_("# %s (device %ld, inode %ld): "),
     1142                      dir->name,
     1143                      (long)dir->contents->dev, (long)dir->contents->ino);
    10691144#endif
    10701145#endif /* WINDOWS32 */
    1071               if (f == 0)
    1072                 fputs (_("No"), stdout);
    1073               else
    1074                 printf ("%u", f);
    1075               fputs (_(" files, "), stdout);
    1076               if (im == 0)
    1077                 fputs (_("no"), stdout);
    1078               else
    1079                 printf ("%u", im);
    1080               fputs (_(" impossibilities"), stdout);
    1081               if (dir->contents->dirstream == 0)
    1082                 puts (".");
    1083               else
    1084                 puts (_(" so far."));
    1085               files += f;
    1086               impossible += im;
    1087             }
    1088         }
     1146              if (f == 0)
     1147                fputs (_("No"), stdout);
     1148              else
     1149                printf ("%u", f);
     1150              fputs (_(" files, "), stdout);
     1151              if (im == 0)
     1152                fputs (_("no"), stdout);
     1153              else
     1154                printf ("%u", im);
     1155              fputs (_(" impossibilities"), stdout);
     1156              if (dir->contents->dirstream == 0)
     1157                puts (".");
     1158              else
     1159                puts (_(" so far."));
     1160              files += f;
     1161              impossible += im;
     1162            }
     1163        }
    10891164    }
    10901165
     
    11051180/* Hooks for globbing.  */
    11061181
    1107 #include <glob.h>
    1108 
    11091182/* Structure describing state of iterating through a directory hash table.  */
    11101183
     
    11561229      struct dirfile *df = *ds->dirfile_slot++;
    11571230      if (! HASH_VACANT (df) && !df->impossible)
    1158         {
    1159           /* The glob interface wants a `struct dirent', so mock one up.  */
    1160           struct dirent *d;
    1161           unsigned int len = df->length + 1;
     1231        {
     1232          /* The glob interface wants a 'struct dirent', so mock one up.  */
     1233          struct dirent *d;
     1234          unsigned int len = df->length + 1;
    11621235          unsigned int sz = sizeof (*d) - sizeof (d->d_name) + len;
    1163           if (sz > bufsz)
    1164             {
    1165               bufsz *= 2;
    1166               if (sz > bufsz)
    1167                 bufsz = sz;
    1168               buf = xrealloc (buf, bufsz);
    1169             }
    1170           d = (struct dirent *) buf;
     1236          if (sz > bufsz)
     1237            {
     1238              bufsz *= 2;
     1239              if (sz > bufsz)
     1240                bufsz = sz;
     1241              buf = xrealloc (buf, bufsz);
     1242            }
     1243          d = (struct dirent *) buf;
    11711244#ifdef __MINGW32__
    11721245# if __MINGW32_MAJOR_VERSION < 3 || (__MINGW32_MAJOR_VERSION == 3 && \
    1173                                      __MINGW32_MINOR_VERSION == 0)
    1174           d->d_name = xmalloc(len);
     1246                                     __MINGW32_MINOR_VERSION == 0)
     1247          d->d_name = xmalloc (len);
    11751248# endif
    11761249#endif
    1177           FAKE_DIR_ENTRY (d);
     1250          FAKE_DIR_ENTRY (d);
    11781251#ifdef _DIRENT_HAVE_D_NAMLEN
    1179           d->d_namlen = len - 1;
     1252          d->d_namlen = len - 1;
    11801253#endif
    11811254#ifdef _DIRENT_HAVE_D_TYPE
    1182           d->d_type = DT_UNKNOWN;
    1183 #endif
    1184           memcpy (d->d_name, df->name, len);
    1185           return d;
    1186         }
     1255          d->d_type = DT_UNKNOWN;
     1256#endif
     1257          memcpy (d->d_name, df->name, len);
     1258          return d;
     1259        }
    11871260    }
    11881261
    11891262  return 0;
    1190 }
    1191 
    1192 static void
    1193 ansi_free (void *p)
    1194 {
    1195   if (p)
    1196     free(p);
    11971263}
    11981264
     
    12001266 * macro for stat64().  If stat is a macro, make a local wrapper function to
    12011267 * invoke it.
     1268 *
     1269 * On MS-Windows, stat() "succeeds" for foo/bar/. where foo/bar is a
     1270 * regular file; fix that here.
    12021271 */
    1203 #ifndef stat
     1272#if !defined(stat) && !defined(WINDOWS32) || defined(VMS)
    12041273# ifndef VMS
     1274#  ifndef HAVE_SYS_STAT_H
    12051275int stat (const char *path, struct stat *sbuf);
     1276#  endif
     1277# else
     1278    /* We are done with the fake stat.  Go back to the real stat */
     1279#   ifdef stat
     1280#     undef stat
     1281#   endif
    12061282# endif
    12071283# define local_stat stat
     
    12111287{
    12121288  int e;
     1289#ifdef WINDOWS32
     1290  size_t plen = strlen (path);
     1291
     1292  /* Make sure the parent of "." exists and is a directory, not a
     1293     file.  This is because 'stat' on Windows normalizes the argument
     1294     foo/. => foo without checking first that foo is a directory.  */
     1295  if (plen > 1 && path[plen - 1] == '.'
     1296      && (path[plen - 2] == '/' || path[plen - 2] == '\\'))
     1297    {
     1298      char parent[MAXPATHLEN];
     1299
     1300      strncpy (parent, path, plen - 2);
     1301      parent[plen - 2] = '\0';
     1302      if (stat (parent, buf) < 0 || !_S_ISDIR (buf->st_mode))
     1303        return -1;
     1304    }
     1305#endif
    12131306
    12141307  EINTRLOOP (e, stat (path, buf));
     
    12221315  gl->gl_opendir = open_dirstream;
    12231316  gl->gl_readdir = read_dirstream;
    1224   gl->gl_closedir = ansi_free;
     1317  gl->gl_closedir = free;
    12251318  gl->gl_stat = local_stat;
    12261319  /* We don't bother setting gl_lstat, since glob never calls it.
     
    12321325{
    12331326  hash_init (&directories, DIRECTORY_BUCKETS,
    1234              directory_hash_1, directory_hash_2, directory_hash_cmp);
     1327             directory_hash_1, directory_hash_2, directory_hash_cmp);
    12351328  hash_init (&directory_contents, DIRECTORY_BUCKETS,
    1236              directory_contents_hash_1, directory_contents_hash_2,
     1329             directory_contents_hash_1, directory_contents_hash_2,
    12371330             directory_contents_hash_cmp);
    12381331}
  • vendor/gnumake/current/doc/Makefile.am

    r2596 r3138  
    11# -*-Makefile-*-, or close enough
    2 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    3 # 2010 Free Software Foundation, Inc.
     2# Copyright (C) 2000-2016 Free Software Foundation, Inc.
    43# This file is part of GNU Make.
    54#
     
    2423
    2524CLEANFILES = make*.html
    26 
    27 ## ----------------------------- ##
    28 ## Other documentation formats.  ##
    29 ## ----------------------------- ##
    30 
    31 html: make_1.html
    32 
    33 make_1.html: $(info_TEXINFOS) $(make_TEXINFOS)
    34         $(TEXI2HTML) $(TEXI2HTML_FLAGS) $(srcdir)/make.texi
    35 
    36 .PHONY: html
  • vendor/gnumake/current/doc/make.texi

    r2596 r3138  
    44
    55@include version.texi
    6 @set EDITION 0.71
    7 @set RCSID $Id: make.texi,v 1.66 2010/07/19 07:10:54 psmith Exp $
     6@set EDITION 0.74
    87
    98@settitle GNU @code{make}
     
    2827Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
    29281996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007,
    30 2008, 2009, 2010 Free Software Foundation, Inc.
     292008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software
     30Foundation, Inc.
    3131
    3232@quotation
    3333Permission is granted to copy, distribute and/or modify this document
    34 under the terms of the GNU Free Documentation License, Version 1.2 or
     34under the terms of the GNU Free Documentation License, Version 1.3 or
    3535any later version published by the Free Software Foundation; with no
    3636Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
     
    101101                                  based on their file names.
    102102* Archives::                    How @code{make} can update library archives.
     103* Extending make::              Using extensions to @code{make}.
     104* Integrating make::            Integrating @code{make} with other tools.
    103105* Features::                    Features GNU @code{make} has over other @code{make}s.
    104106* Missing::                     What GNU @code{make} lacks from other @code{make}s.
     
    110112                                  but nontrivial, makefile.
    111113
    112 * GNU Free Documentation License::  License for copying this manual
    113 * Concept Index::               Index of Concepts
    114 * Name Index::                  Index of Functions, Variables, & Directives
     114* GNU Free Documentation License::  License for copying this manual.
     115* Concept Index::               Index of Concepts.
     116* Name Index::                  Index of Functions, Variables, & Directives.
    115117
    116118@detailmenu
     
    119121Overview of @code{make}
    120122
    121 * Preparing::                   Preparing and running make
    122 * Reading::                     On reading this text
    123 * Bugs::                        Problems and bugs
     123* Preparing::                   Preparing and running @code{make}.
     124* Reading::                     On reading this text.
     125* Bugs::                        Problems and bugs.
    124126
    125127An Introduction to Makefiles
    126128
    127129* Rule Introduction::           What a rule looks like.
    128 * Simple Makefile::             A simple makefile
    129 * How Make Works::              How @code{make} processes this makefile
    130 * Variables Simplify::          Variables make makefiles simpler
    131 * make Deduces::                Letting @code{make} deduce the recipe
    132 * Combine By Prerequisite::     Another style of makefile
    133 * Cleanup::                     Rules for cleaning the directory
     130* Simple Makefile::             A simple makefile.
     131* How Make Works::              How @code{make} processes this makefile.
     132* Variables Simplify::          Variables make makefiles simpler.
     133* make Deduces::                Letting @code{make} deduce the recipes.
     134* Combine By Prerequisite::     Another style of makefile.
     135* Cleanup::                     Rules for cleaning the directory.
    134136
    135137Writing Makefiles
     
    144146* Reading Makefiles::           How makefiles are parsed.
    145147* Secondary Expansion::         How and when secondary expansion is performed.
     148
     149What Makefiles Contain
     150
     151* Splitting Lines::             Splitting long lines in makefiles
    146152
    147153Writing Rules
     
    171177Using Wildcard Characters in File Names
    172178
    173 * Wildcard Examples::           Several examples
     179* Wildcard Examples::           Several examples.
    174180* Wildcard Pitfall::            Problems to avoid.
    175181* Wildcard Function::           How to cause wildcard expansion where
     
    207213Recipe Syntax
    208214
    209 * Splitting Lines::             Breaking long recipe lines for readability.
     215* Splitting Recipe Lines::      Breaking long recipe lines for readability.
    210216* Variables in Recipes::        Using @code{make} variables in recipes.
    211217
    212218Recipe Execution
    213219
     220* One Shell::                   One shell for all lines in a recipe.
    214221* Choosing the Shell::          How @code{make} chooses the shell used
    215222                                  to run recipes.
     223
     224Parallel Execution
     225
     226* Parallel Output::             Handling output during parallel execution
     227* Parallel Input::              Handling input during parallel execution
    216228
    217229Recursive Use of @code{make}
     
    236248* Multi-Line::                  An alternate way to set a variable
    237249                                  to a multi-line string.
     250* Undefine Directive::          How to undefine a variable so that it appears
     251                                  as if it was never set.
    238252* Environment::                 Variable values can come from the environment.
    239253* Target-specific::             Variable values can be defined on a per-target
     
    263277* Conditional Functions::       Functions that implement conditions.
    264278* Foreach Function::            Repeat some text with controlled variation.
     279* File Function::               Write text to a file.
    265280* Call Function::               Expand a user-defined function.
    266281* Value Function::              Return the un-expanded value of a variable.
     
    268283* Origin Function::             Find where a variable got its value.
    269284* Flavor Function::             Find out the flavor of a variable.
     285* Make Control Functions::      Functions that control how make runs.
    270286* Shell Function::              Substitute the output of a shell command.
    271 * Make Control Functions::      Functions that control how make runs.
     287* Guile Function::              Use GNU Guile embedded scripting language.
    272288
    273289How to Run @code{make}
     
    290306
    291307* Using Implicit::              How to use an existing implicit rule
    292                                   to get the recipe for updating a file.
    293 * Catalogue of Rules::          A list of built-in implicit rules.
     308                                  to get the recipes for updating a file.
     309* Catalogue of Rules::          A list of built-in rules.
    294310* Implicit Variables::          How to change what predefined rules do.
    295311* Chained Rules::               How to use a chain of implicit rules.
     
    325341* Archive Symbols::             How to update archive symbol directories.
    326342
     343Extending GNU @code{make}
     344
     345* Guile Integration::           Using Guile as an embedded scripting language.
     346* Loading Objects::             Loading dynamic objects as extensions.
     347
     348GNU Guile Integration
     349
     350* Guile Types::                 Converting Guile types to @code{make} strings.
     351* Guile Interface::             Invoking @code{make} functions from Guile.
     352* Guile Example::               Example using Guile in @code{make}.
     353
     354Loading Dynamic Objects
     355
     356* load Directive::              Loading dynamic objects as extensions.
     357* Remaking Loaded Objects::     How loaded objects get remade.
     358* Loaded Object API::           Programmatic interface for loaded objects.
     359* Loaded Object Example::       Example of a loaded object
     360
     361Integrating GNU @code{make}
     362
     363* Job Slots::                   Share job slots with GNU @code{make}.
     364* Terminal Output::             Control output to terminals.
     365
     366Sharing Job Slots with GNU @code{make}
     367
     368* POSIX Jobserver::             Using the jobserver on POSIX systems.
     369* Windows Jobserver::           Using the jobserver on Windows systems.
     370
    327371@end detailmenu
    328372@end menu
     
    351395
    352396@menu
    353 * Preparing::                   Preparing and Running Make
    354 * Reading::                     On Reading this Text
    355 * Bugs::                        Problems and Bugs
     397* Preparing::                   Preparing and running @code{make}.
     398* Reading::                     On reading this text.
     399* Bugs::                        Problems and bugs.
    356400@end menu
    357401
     
    487531@menu
    488532* Rule Introduction::           What a rule looks like.
    489 * Simple Makefile::             A Simple Makefile
    490 * How Make Works::              How @code{make} Processes This Makefile
    491 * Variables Simplify::          Variables Make Makefiles Simpler
    492 * make Deduces::                Letting @code{make} Deduce the Recipes
    493 * Combine By Prerequisite::     Another Style of Makefile
    494 * Cleanup::                     Rules for Cleaning the Directory
     533* Simple Makefile::             A simple makefile.
     534* How Make Works::              How @code{make} processes this makefile.
     535* Variables Simplify::          Variables make makefiles simpler.
     536* make Deduces::                Letting @code{make} deduce the recipes.
     537* Combine By Prerequisite::     Another style of makefile.
     538* Cleanup::                     Rules for cleaning the directory.
    495539@end menu
    496540
     
    592636
    593637@noindent
    594 We split each long line into two lines using backslash-newline; this is
    595 like using one long line, but is easier to read.
     638We split each long line into two lines using backslash/newline; this is
     639like using one long line, but is easier to read.  @xref{Splitting Lines,
     640, Splitting Long Lines}.
    596641@cindex continuation lines
    597642@cindex @code{\} (backslash), for continuation lines
     
    10271072@end itemize
    10281073
     1074@menu
     1075* Splitting Lines::             Splitting long lines in makefiles
     1076@end menu
     1077
     1078@node Splitting Lines,  , Makefile Contents, Makefile Contents
     1079@subsection Splitting Long Lines
     1080@cindex splitting long lines
     1081@cindex long lines, splitting
     1082@cindex backslash (@code{\}), to quote newlines
     1083
     1084Makefiles use a ``line-based'' syntax in which the newline character
     1085is special and marks the end of a statement.  GNU @code{make} has no
     1086limit on the length of a statement line, up to the amount of memory in
     1087your computer.
     1088
     1089However, it is difficult to read lines which are too long to display
     1090without wrapping or scrolling.  So, you can format your makefiles for
     1091readability by adding newlines into the middle of a statement: you do
     1092this by escaping the internal newlines with a backslash (@code{\})
     1093character.  Where we need to make a distinction we will refer to
     1094``physical lines'' as a single line ending with a newline (regardless
     1095of whether it is escaped) and a ``logical line'' being a complete
     1096statement including all escaped newlines up to the first non-escaped
     1097newline.
     1098
     1099The way in which backslash/newline combinations are handled depends on
     1100whether the statement is a recipe line or a non-recipe line.  Handling
     1101of backslash/newline in a recipe line is discussed later
     1102(@pxref{Splitting Recipe Lines}).
     1103
     1104Outside of recipe lines, backslash/newlines are converted into a
     1105single space character.  Once that is done, all whitespace around the
     1106backslash/newline is condensed into a single space: this includes all
     1107whitespace preceding the backslash, all whitespace at the beginning of
     1108the line after the backslash/newline, and any consecutive
     1109backslash/newline combinations.
     1110
     1111If the @code{.POSIX} special target is defined then backslash/newline
     1112handling is modified slightly to conform to POSIX.2: first, whitespace
     1113preceding a backslash is not removed and second, consecutive
     1114backslash/newlines are not condensed.
     1115
    10291116@node Makefile Names, Include, Makefile Contents, Makefiles
    10301117@section What Name to Give Your Makefile
     
    12201307@node Remaking Makefiles, Overriding Makefiles, MAKEFILES Variable, Makefiles
    12211308@section How Makefiles Are Remade
    1222 
    12231309@cindex updating makefiles
    12241310@cindex remaking makefiles
     
    12421328you want to keep @code{make} from performing an implicit rule search
    12431329on them, perhaps for efficiency reasons, you can use any normal method
    1244 of preventing implicit rule lookup to do so.  For example, you can
     1330of preventing implicit rule look-up to do so.  For example, you can
    12451331write an explicit rule with the makefile as the target, and an empty
    12461332recipe (@pxref{Empty Recipes, ,Using Empty Recipes}).
     
    13061392another makefile.  You can often use the @samp{include} directive to
    13071393include one in the other, and add more targets or variable definitions.
    1308 However, it is illegal for two makefiles to give different recipes for
     1394However, it is invalid for two makefiles to give different recipes for
    13091395the same target.  But there is another way.
    13101396
     
    13801466@cindex ?=, expansion
    13811467@cindex +=, expansion
     1468@cindex !=, expansion
    13821469@cindex define, expansion
    13831470
     
    13881475@var{immediate} ?= @var{deferred}
    13891476@var{immediate} := @var{immediate}
     1477@var{immediate} ::= @var{immediate}
    13901478@var{immediate} += @var{deferred} or @var{immediate}
     1479@var{immediate} != @var{immediate}
    13911480
    13921481define @var{immediate}
     
    14061495endef
    14071496
     1497define @var{immediate} ::=
     1498  @var{immediate}
     1499endef
     1500
    14081501define @var{immediate} +=
    14091502  @var{deferred} or @var{immediate}
    14101503endef
     1504
     1505define @var{immediate} !=
     1506  @var{immediate}
     1507endef
    14111508@end example
    14121509
    14131510For the append operator, @samp{+=}, the right-hand side is considered
    14141511immediate if the variable was previously set as a simple variable
    1415 (@samp{:=}), and deferred otherwise.
     1512(@samp{:=} or @samp{::=}), and deferred otherwise.
     1513
     1514For the shell assignment operator, @samp{!=}, the right-hand side is
     1515evaluated immediately and handed to the shell.  The result is stored in the
     1516variable named on the left, and that variable becomes a simple variable
     1517(and will thus be re-evaluated on each reference).
    14161518
    14171519@subheading Conditional Directives
     
    14391541@example
    14401542@var{immediate} : @var{immediate} ; @var{deferred}
    1441         @var{deferred}
     1543        @var{deferred}
    14421544@end example
    14431545
     
    14881590without being recognized as a variable reference.  Now during the
    14891591secondary expansion the first word is expanded again but since it
    1490 contains no variable or function references it remains the static
    1491 value @file{onefile}, while the second word is now a normal reference
    1492 to the variable @var{TWOVAR}, which is expanded to the value
    1493 @file{twofile}.  The final result is that there are two prerequisites,
    1494 @file{onefile} and @file{twofile}.
     1592contains no variable or function references it remains the value
     1593@file{onefile}, while the second word is now a normal reference to the
     1594variable @var{TWOVAR}, which is expanded to the value @file{twofile}.
     1595The final result is that there are two prerequisites, @file{onefile}
     1596and @file{twofile}.
    14951597
    14961598Obviously, this is not a very interesting case since the same result
     
    16341736Search, ,Implicit Rule Search Algorithm}, is appended (after
    16351737expansion) to all the patterns in the prerequisites list.  As an
    1636 example:
     1738example:@refill
    16371739
    16381740@example
     
    16421744
    16431745%.o: $$(addsuffix /%.c,foo bar) foo.h
    1644 @end example
    1645 
    1646 The prerequisite list after the secondary expansion and directory
    1647 prefix reconstruction will be @file{/tmp/foo/foo.c /tmp/var/bar/foo.c
    1648 foo.h}.  If you are not interested in this reconstruction, you can use
    1649 @code{$$*} instead of @code{%} in the prerequisites list.
     1746        @@echo $^
     1747@end example
     1748
     1749The prerequisite list printed, after the secondary expansion and
     1750directory prefix reconstruction, will be @file{/tmp/foo/foo.c
     1751/tmp/bar/foo.c foo.h}.  If you are not interested in this
     1752reconstruction, you can use @code{$$*} instead of @code{%} in the
     1753prerequisites list.
    16501754
    16511755@node Rules, Recipes, Makefiles, Top
     
    16851789* Directory Search::            Searching other directories for source files.
    16861790* Phony Targets::               Using a target that is not a real file's name.
    1687 * Force Targets::               You can use a target without recipes
     1791* Force Targets::               You can use a target without a recipe
    16881792                                  or prerequisites to mark other targets
    16891793                                  as phony.
     
    19222026
    19232027@menu
    1924 * Wildcard Examples::           Several examples
     2028* Wildcard Examples::           Several examples.
    19252029* Wildcard Pitfall::            Problems to avoid.
    19262030* Wildcard Function::           How to cause wildcard expansion where
     
    21202224                                  for a specified class of names.
    21212225* Search Algorithm::            When and how search paths are applied.
    2122 * Recipes/Search::             How to write recipes that work together
     2226* Recipes/Search::              How to write recipes that work together
    21232227                                  with search paths.
    21242228* Implicit/Search::             How search paths affect implicit rules.
     
    24562560@samp{-l@var{name}} is seen, @code{make} will replace the percent in
    24572561each pattern in the list with @var{name} and perform the above directory
    2458 searches using each library filename.
     2562searches using each library file name.
    24592563
    24602564The default value for @code{.LIBPATTERNS} is @samp{lib%.so lib%.a},
     
    24932597
    24942598@findex .PHONY
    2495 The phony target will cease to work if anything ever does create a file
    2496 named @file{clean} in this directory.  Since it has no prerequisites, the
    2497 file @file{clean} would inevitably be considered up to date, and its
    2498 recipe would not be executed.  To avoid this problem, you can explicitly
    2499 declare the target to be phony, using the special target @code{.PHONY}
     2599In this example, the @file{clean} target will not work properly if a
     2600file named @file{clean} is ever created in this directory.  Since it
     2601has no prerequisites, @file{clean} would always be considered up to
     2602date and its recipe would not be executed.  To avoid this problem you
     2603can explicitly declare the target to be phony by making it a
     2604prerequisite of the special target @code{.PHONY}
    25002605(@pxref{Special Targets, ,Special Built-in Target Names}) as follows:
    2501 
    2502 @example
    2503 .PHONY : clean
    2504 @end example
    2505 
    2506 @noindent
    2507 Once this is done, @samp{make clean} will run the recipe regardless of
    2508 whether there is a file named @file{clean}.
    2509 
    2510 Since it knows that phony targets do not name actual files that could be
    2511 remade from other files, @code{make} skips the implicit rule search for
    2512 phony targets (@pxref{Implicit Rules}).  This is why declaring a target
    2513 phony is good for performance, even if you are not worried about the
    2514 actual file existing.
    2515 
    2516 Thus, you first write the line that states that @code{clean} is a
    2517 phony target, then you write the rule, like this:
    25182606
    25192607@example
     
    25252613@end example
    25262614
    2527 Another example of the usefulness of phony targets is in conjunction
    2528 with recursive invocations of @code{make} (for more information, see
    2529 @ref{Recursion, ,Recursive Use of @code{make}}).  In this case the
    2530 makefile will often contain a variable which lists a number of
    2531 subdirectories to be built.  One way to handle this is with one rule
    2532 whose recipe is a shell loop over the subdirectories, like this:
     2615@noindent
     2616Once this is done, @samp{make clean} will run the recipe regardless of
     2617whether there is a file named @file{clean}.
     2618
     2619Phony targets are also useful in conjunction with recursive
     2620invocations of @code{make} (@pxref{Recursion, ,Recursive Use of @code{make}}).
     2621In this situation the makefile will often contain a variable which
     2622lists a number of sub-directories to be built.  A simplistic way to
     2623handle this is to define one rule with a recipe that loops over the
     2624sub-directories, like this:
    25332625
    25342626@example
     
    25442636
    25452637There are problems with this method, however.  First, any error
    2546 detected in a submake is ignored by this rule, so it will continue
     2638detected in a sub-make is ignored by this rule, so it will continue
    25472639to build the rest of the directories even when one fails.  This can be
    25482640overcome by adding shell commands to note the error and exit, but then
     
    25532645one rule.
    25542646
    2555 By declaring the subdirectories as phony targets (you must do this as
    2556 the subdirectory obviously always exists; otherwise it won't be built)
    2557 you can remove these problems:
     2647By declaring the sub-directories as @code{.PHONY} targets (you must do
     2648this as the sub-directory obviously always exists; otherwise it won't
     2649be built) you can remove these problems:
    25582650
    25592651@example
     
    25722664@end example
    25732665
    2574 Here we've also declared that the @file{foo} subdirectory cannot be
    2575 built until after the @file{baz} subdirectory is complete; this kind of
     2666Here we've also declared that the @file{foo} sub-directory cannot be
     2667built until after the @file{baz} sub-directory is complete; this kind of
    25762668relationship declaration is particularly important when attempting
    25772669parallel builds.
     2670
     2671The implicit rule search (@pxref{Implicit Rules}) is skipped for
     2672@code{.PHONY} targets.  This is why declaring a target as
     2673@code{.PHONY} is good for performance, even if you are not worried
     2674about the actual file existing.
    25782675
    25792676A phony target should not be a prerequisite of a real target file; if it
     
    28172914is up to date.  Unfortunately, some hosts do not provide a way to set a
    28182915high resolution file time stamp, so commands like @samp{cp -p} that
    2819 explicitly set a file's time stamp must discard its subsecond part.
     2916explicitly set a file's time stamp must discard its sub-second part.
    28202917If a file is created by such a command, you should list it as a
    28212918prerequisite of @code{.LOW_RESOLUTION_TIME} so that @command{make}
     
    28312928@end example
    28322929
    2833 Since @samp{cp -p} discards the subsecond part of @file{src}'s time
     2930Since @samp{cp -p} discards the sub-second part of @file{src}'s time
    28342931stamp, @file{dst} is typically slightly older than @file{src} even when
    28352932it is up to date.  The @code{.LOW_RESOLUTION_TIME} line causes
     
    31333230for each target that does not.  If you have a list of files, only some of
    31343231which will match the pattern, you can use the @code{filter} function to
    3135 remove nonmatching file names (@pxref{Text Functions, ,Functions for String Substitution and Analysis}):
     3232remove non-matching file names (@pxref{Text Functions, ,Functions for String Substitution and Analysis}):
    31363233
    31373234@example
     
    32873384The compiler will do it for you.
    32883385
    3289 Note that such a prerequisite constitutes mentioning @file{main.o} in a
    3290 makefile, so it can never be considered an intermediate file by implicit
    3291 rule search.  This means that @code{make} won't ever remove the file
    3292 after using it; @pxref{Chained Rules, ,Chains of Implicit Rules}.
     3386Note that such a rule constitutes mentioning @file{main.o} in a
     3387makefile, so it can never be considered an intermediate file by
     3388implicit rule search.  This means that @code{make} won't ever remove
     3389the file after using it; @pxref{Chained Rules, ,Chains of Implicit
     3390Rules}.
    32933391
    32943392@cindex @code{make depend}
     
    33353433of @samp{-M}.  This omits prerequisites on system header files.
    33363434@xref{Preprocessor Options, , Options Controlling the Preprocessor,
    3337 gcc.info, Using GNU CC}, for details.
     3435gcc, Using GNU CC}, for details.
    33383436
    33393437@cindex @code{sed} (shell command)
     
    34643562
    34653563@menu
    3466 * Splitting Lines::             Breaking long recipe lines for readability.
     3564* Splitting Recipe Lines::      Breaking long recipe lines for readability.
    34673565* Variables in Recipes::        Using @code{make} variables in recipes.
    34683566@end menu
    34693567
    3470 @node Splitting Lines, Variables in Recipes, Recipe Syntax, Recipe Syntax
     3568@node Splitting Recipe Lines, Variables in Recipes, Recipe Syntax, Recipe Syntax
    34713569@subsection Splitting Recipe Lines
    34723570@cindex recipes, splitting
     
    34873585
    34883586However, in contrast to how they are treated in other places in a
    3489 makefile, backslash-newline pairs are @emph{not} removed from the
    3490 recipe.  Both the backslash and the newline characters are preserved
    3491 and passed to the shell.  How the backslash-newline is interpreted
    3492 depends on your shell.  If the first character of the next line after
    3493 the backslash-newline is the recipe prefix character (a tab by
    3494 default; @pxref{Special Variables}), then that character (and only
    3495 that character) is removed.  Whitespace is never added to the recipe.
     3587makefile (@pxref{Splitting Lines, , Splitting Long Lines}),
     3588backslash/newline pairs are @emph{not} removed from the recipe.  Both
     3589the backslash and the newline characters are preserved and passed to
     3590the shell.  How the backslash/newline is interpreted depends on your
     3591shell.  If the first character of the next line after the
     3592backslash/newline is the recipe prefix character (a tab by default;
     3593@pxref{Special Variables}), then that character (and only that
     3594character) is removed.  Whitespace is never added to the recipe.
    34963595
    34973596For example, the recipe for the all target in this makefile:
     
    35643663
    35653664Sometimes you want to split a long line inside of single quotes, but
    3566 you don't want the backslash-newline to appear in the quoted content.
     3665you don't want the backslash/newline to appear in the quoted content.
    35673666This is often the case when passing scripts to languages such as Perl,
    35683667where extraneous backslashes inside the script can change its meaning
     
    35713670@code{make} variable then use the variable in the recipe.  In this
    35723671situation the newline quoting rules for makefiles will be used, and
    3573 the backslash-newline will be removed.  If we rewrite our example
     3672the backslash/newline will be removed.  If we rewrite our example
    35743673above using this method:
    35753674
     
    35973696uses it.
    35983697
    3599 @node Variables in Recipes,  , Splitting Lines, Recipe Syntax
     3698@node Variables in Recipes,  , Splitting Recipe Lines, Recipe Syntax
    36003699@subsection Using Variables in Recipes
    36013700@cindex variable references in recipes
     
    37003799
    37013800When it is time to execute recipes to update a target, they are
    3702 executed by invoking a new subshell for each line of the recipe,
     3801executed by invoking a new sub-shell for each line of the recipe,
    37033802unless the @code{.ONESHELL} special target is in effect
    37043803(@pxref{One Shell, ,Using One Shell})  (In practice, @code{make} may
     
    37313830
    37323831@menu
    3733 * One Shell::                   One shell for all lines in a recipe
     3832* One Shell::                   One shell for all lines in a recipe.
    37343833* Choosing the Shell::          How @code{make} chooses the shell used
    37353834                                  to run recipes.
     
    39704069slots is one, which means serial execution (one thing at a time).
    39714070
    3972 One unpleasant consequence of running several recipes simultaneously is
    3973 that output generated by the recipes appears whenever each recipe
    3974 sends it, so messages from different recipes may be interspersed.
    3975 
    3976 Another problem is that two processes cannot both take input from the
    3977 same device; so to make sure that only one recipe tries to take input
    3978 from the terminal at once, @code{make} will invalidate the standard
    3979 input streams of all but one running recipe.  This means that
    3980 attempting to read from standard input will usually be a fatal error (a
    3981 @samp{Broken pipe} signal) for most child processes if there are
    3982 several.
    3983 @cindex broken pipe
    3984 @cindex standard input
    3985 
    3986 It is unpredictable which recipe will have a valid standard input stream
    3987 (which will come from the terminal, or wherever you redirect the standard
    3988 input of @code{make}).  The first recipe run will always get it first, and
    3989 the first recipe started after that one finishes will get it next, and so
    3990 on.
    3991 
    3992 We will change how this aspect of @code{make} works if we find a better
    3993 alternative.  In the mean time, you should not rely on any recipe using
    3994 standard input at all if you are using the parallel execution feature; but
    3995 if you are not using this feature, then standard input works normally in
    3996 all recipes.
    3997 
    3998 Finally, handling recursive @code{make} invocations raises issues.  For
    3999 more information on this, see
    4000 @ref{Options/Recursion, ,Communicating Options to a Sub-@code{make}}.
     4071Handling recursive @code{make} invocations raises issues for parallel
     4072execution.  For more information on this, see @ref{Options/Recursion,
     4073,Communicating Options to a Sub-@code{make}}.
    40014074
    40024075If a recipe fails (is killed by a signal or exits with a nonzero
    4003 status), and errors are not ignored for that recipe
    4004 (@pxref{Errors, ,Errors in Recipes}),
    4005 the remaining recipe lines to remake the same target will not be run.
    4006 If a recipe fails and the @samp{-k} or @samp{--keep-going}
    4007 option was not given
    4008 (@pxref{Options Summary, ,Summary of Options}),
    4009 @code{make} aborts execution.  If make
     4076status), and errors are not ignored for that recipe (@pxref{Errors,
     4077,Errors in Recipes}), the remaining recipe lines to remake the same
     4078target will not be run.  If a recipe fails and the @samp{-k} or
     4079@samp{--keep-going} option was not given (@pxref{Options Summary,
     4080,Summary of Options}), @code{make} aborts execution.  If make
    40104081terminates for any reason (including a signal) with child processes
    40114082running, it waits for them to finish before actually exiting.@refill
     
    40394110
    40404111By default, there is no load limit.
     4112
     4113@menu
     4114* Parallel Output::             Handling output during parallel execution
     4115* Parallel Input::              Handling input during parallel execution
     4116@end menu
     4117
     4118@node Parallel Output, Parallel Input, Parallel, Parallel
     4119@subsection Output During Parallel Execution
     4120@cindex output during parallel execution
     4121@cindex parallel execution, output during
     4122
     4123When running several recipes in parallel the output from each
     4124recipe appears as soon as it is generated, with the result that
     4125messages from different recipes may be interspersed, sometimes even
     4126appearing on the same line.  This can make reading the output very
     4127difficult.
     4128
     4129@cindex @code{--output-sync}
     4130@cindex @code{-O}
     4131To avoid this you can use the @samp{--output-sync} (@samp{-O}) option.
     4132This option instructs @code{make} to save the output from the commands
     4133it invokes and print it all once the commands are completed.
     4134Additionally, if there are multiple recursive @code{make} invocations
     4135running in parallel, they will communicate so that only one of them is
     4136generating output at a time.
     4137
     4138If working directory printing is enabled (@pxref{-w Option, ,The
     4139@samp{--print-directory} Option}), the enter/leave messages are
     4140printed around each output grouping.  If you prefer not to see these
     4141messages add the @samp{--no-print-directory} option to @code{MAKEFLAGS}.
     4142
     4143There are four levels of granularity when synchronizing output,
     4144specified by giving an argument to the option (e.g.,  @samp{-Oline} or
     4145@samp{--output-sync=recurse}).
     4146
     4147@table @code
     4148@item none
     4149This is the default: all output is sent directly as it is generated and
     4150no synchronization is performed.
     4151
     4152@item line
     4153Output from each individual line of the recipe is grouped and printed
     4154as soon as that line is complete.  If a recipe consists of multiple
     4155lines, they may be interspersed with lines from other recipes.
     4156
     4157@item target
     4158Output from the entire recipe for each target is grouped and printed
     4159once the target is complete.  This is the default if the
     4160@code{--output-sync} or @code{-O} option is given with no argument.
     4161
     4162@item recurse
     4163Output from each recursive invocation of @code{make} is grouped and
     4164printed once the recursive invocation is complete.
     4165
     4166@end table
     4167
     4168Regardless of the mode chosen, the total build time will be the same.
     4169The only difference is in how the output appears.
     4170
     4171The @samp{target} and @samp{recurse} modes both collect the output of
     4172the entire recipe of a target and display it uninterrupted when the
     4173recipe completes.  The difference between them is in how recipes that
     4174contain recursive invocations of @code{make} are treated
     4175(@pxref{Recursion, ,Recursive Use of @code{make}}).  For all recipes
     4176which have no recursive lines, the @samp{target} and @samp{recurse}
     4177modes behave identically.
     4178
     4179If the @samp{recurse} mode is chosen, recipes that contain recursive
     4180@code{make} invocations are treated the same as other targets: the
     4181output from the recipe, including the output from the recursive
     4182@code{make}, is saved and printed after the entire recipe is complete.
     4183This ensures output from all the targets built by a given recursive
     4184@code{make} instance are grouped together, which may make the output
     4185easier to understand.  However it also leads to long periods of time
     4186during the build where no output is seen, followed by large bursts of
     4187output.  If you are not watching the build as it proceeds, but instead
     4188viewing a log of the build after the fact, this may be the best option
     4189for you.
     4190
     4191If you are watching the output, the long gaps of quiet during the
     4192build can be frustrating.  The @samp{target} output synchronization
     4193mode detects when @code{make} is going to be invoked recursively,
     4194using the standard methods, and it will not synchronize the output of
     4195those lines.  The recursive @code{make} will perform the
     4196synchronization for its targets and the output from each will be
     4197displayed immediately when it completes.  Be aware that output from
     4198recursive lines of the recipe are not synchronized (for example if
     4199the recursive line prints a message before running @code{make}, that
     4200message will not be synchronized).
     4201
     4202The @samp{line} mode can be useful for front-ends that are watching
     4203the output of @code{make} to track when recipes are started and
     4204completed.
     4205
     4206Some programs invoked by @code{make} may behave differently if they
     4207determine they're writing output to a terminal versus a file (often
     4208described as ``interactive'' vs. ``non-interactive'' modes).  For
     4209example, many programs that can display colorized output will not do
     4210so if they determine they are not writing to a terminal.  If your
     4211makefile invokes a program like this then using the output
     4212synchronization options will cause the program to believe it's running
     4213in ``non-interactive'' mode even though the output will ultimately go
     4214to the terminal.
     4215
     4216@node Parallel Input,  , Parallel Output, Parallel
     4217@subsection Input During Parallel Execution
     4218@cindex input during parallel execution
     4219@cindex parallel execution, input during
     4220@cindex standard input
     4221
     4222Two processes cannot both take input from the same device at the same
     4223time.  To make sure that only one recipe tries to take input from the
     4224terminal at once, @code{make} will invalidate the standard input
     4225streams of all but one running recipe.  If another recipe attempts to
     4226read from standard input it will usually incur a fatal error (a
     4227@samp{Broken pipe} signal).
     4228@cindex broken pipe
     4229
     4230It is unpredictable which recipe will have a valid standard input stream
     4231(which will come from the terminal, or wherever you redirect the standard
     4232input of @code{make}).  The first recipe run will always get it first, and
     4233the first recipe started after that one finishes will get it next, and so
     4234on.
     4235
     4236We will change how this aspect of @code{make} works if we find a better
     4237alternative.  In the mean time, you should not rely on any recipe using
     4238standard input at all if you are using the parallel execution feature; but
     4239if you are not using this feature, then standard input works normally in
     4240all recipes.
    40414241
    40424242@node Errors, Interrupts, Parallel, Recipes
     
    41794379makefile.  This technique is useful when you want separate makefiles for
    41804380various subsystems that compose a larger system.  For example, suppose you
    4181 have a subdirectory @file{subdir} which has its own makefile, and you would
     4381have a sub-directory @file{subdir} which has its own makefile, and you would
    41824382like the containing directory's makefile to run @code{make} on the
    4183 subdirectory.  You can do it by writing this:
     4383sub-directory.  You can do it by writing this:
    41844384
    41854385@example
     
    42934493Variable values of the top-level @code{make} can be passed to the
    42944494sub-@code{make} through the environment by explicit request.  These
    4295 variables are defined in the sub-@code{make} as defaults, but do not
    4296 override what is specified in the makefile used by the sub-@code{make}
    4297 makefile unless you use the @samp{-e} switch (@pxref{Options Summary,
    4298 ,Summary of Options}).@refill
     4495variables are defined in the sub-@code{make} as defaults, but they do
     4496not override variables defined in the makefile used by
     4497the sub-@code{make} unless you use the @samp{-e} switch (@pxref{Options
     4498Summary, ,Summary of Options}).@refill
    42994499
    43004500To pass down, or @dfn{export}, a variable, @code{make} adds the
     
    45224722
    45234723If your operating system doesn't support the above communication, then
    4524 @samp{-j 1} is always put into @code{MAKEFLAGS} instead of the value you
    4525 specified.  This is because if the @w{@samp{-j}} option were passed down
    4526 to sub-@code{make}s, you would get many more jobs running in parallel
     4724no @samp{-j} is added to @code{MAKEFLAGS}, so that sub-@code{make}s
     4725run in non-parallel mode.  If the @w{@samp{-j}} option were passed down
     4726to sub-@code{make}s you would get many more jobs running in parallel
    45274727than you asked for.  If you give @samp{-j} with no numeric argument,
    45284728meaning to run as many jobs as possible in parallel, this is passed
     
    45564756see the error message @samp{Arg list too long}, this may be the problem.
    45574757@findex .POSIX
    4558 @cindex POSIX.2
     4758@cindex POSIX
    45594759(For strict compliance with POSIX.2, changing @code{MAKEOVERRIDES} does
    45604760not affect @code{MAKEFLAGS} if the special target @samp{.POSIX} appears
     
    46084808put in one of these variables, could have disastrous consequences and would
    46094809certainly have at least surprising and probably annoying effects.@refill
     4810
     4811If you'd like to run other implementations of @code{make} in addition
     4812to GNU @code{make}, and hence do not want to add GNU
     4813@code{make}-specific flags to the @code{MAKEFLAGS} variable, you can
     4814add them to the @code{GNUMAKEFLAGS} variable instead.  This variable
     4815is parsed just before @code{MAKEFLAGS}, in the same way as
     4816@code{MAKEFLAGS}.  When @code{make} constructs @code{MAKEFLAGS} to
     4817pass to a recursive @code{make} it will include all flags, even those
     4818taken from @code{GNUMAKEFLAGS}.  As a result, after parsing
     4819@code{GNUMAKEFLAGS} GNU @code{make} sets this variable to the empty
     4820string to avoid duplicating flags during recursion.
     4821
     4822It's best to use @code{GNUMAKEFLAGS} only with flags which won't
     4823materially change the behavior of your makefiles.  If your makefiles
     4824require GNU make anyway then simply use @code{MAKEFLAGS}.  Flags such
     4825as @samp{--no-print-directory} or @samp{--output-sync} may be
     4826appropriate for @code{GNUMAKEFLAGS}.
    46104827
    46114828@node -w Option,  , Options/Recursion, Recursion
     
    47174934In recipe execution, each line of a canned sequence is treated just as
    47184935if the line appeared on its own in the rule, preceded by a tab.  In
    4719 particular, @code{make} invokes a separate subshell for each line.  You
     4936particular, @code{make} invokes a separate sub-shell for each line.  You
    47204937can use the special prefix characters that affect command lines
    47214938(@samp{@@}, @samp{-}, and @samp{+}) on each line of a canned sequence.
     
    47664983
    47674984@findex .DEFAULT@r{, and empty recipes}
    4768 You may be wondering why you would want to define a recipe that
    4769 does nothing.  The only reason this is useful is to prevent a target
    4770 from getting implicit recipes (from implicit rules or the
    4771 @code{.DEFAULT} special target; @pxref{Implicit Rules} and
    4772 @pxref{Last Resort, ,Defining Last-Resort Default Rules}).@refill
    4773 
    4774 @c !!! another reason is for canonical stamp files:
    4775 @ignore
    4776 @example
    4777 foo: stamp-foo ;
    4778 stamp-foo: foo.in
    4779         create foo frm foo.in
    4780         touch $@
    4781 @end example
    4782 @end ignore
    4783 
    4784 You may be inclined to define empty recipes for targets that are
    4785 not actual files, but only exist so that their prerequisites can be
     4985You may be wondering why you would want to define a recipe that does
     4986nothing.  One reason this is useful is to prevent a target from
     4987getting implicit recipes (from implicit rules or the @code{.DEFAULT}
     4988special target; @pxref{Implicit Rules} and @pxref{Last Resort,
     4989,Defining Last-Resort Default Rules}).@refill
     4990
     4991Empty recipes can also be used to avoid errors for targets that will
     4992be created as a side-effect of another recipe: if the target does not
     4993exist the empty recipe ensures that @code{make} won't complain that it
     4994doesn't know how to build the target, and @code{make} will assume the
     4995target is out of date.
     4996
     4997You may be inclined to define empty recipes for targets that are not
     4998actual files, but only exist so that their prerequisites can be
    47864999remade.  However, this is not the best way to do that, because the
    4787 prerequisites may not be remade properly if the target file actually does exist.
    4788 @xref{Phony Targets, ,Phony Targets}, for a better way to do this.
     5000prerequisites may not be remade properly if the target file actually
     5001does exist.  @xref{Phony Targets, ,Phony Targets}, for a better way to
     5002do this.
    47895003
    47905004@node Using Variables, Conditionals, Recipes, Top
     
    48115025write output in, or anything else you can imagine.
    48125026
    4813 A variable name may be any sequence of characters not containing @samp{:},
    4814 @samp{#}, @samp{=}, or leading or trailing whitespace.  However,
    4815 variable names containing characters other than letters, numbers, and
    4816 underscores should be avoided, as they may be given special meanings in the
    4817 future, and with some shells they cannot be passed through the environment to a
    4818 sub-@code{make}
    4819 (@pxref{Variables/Recursion, ,Communicating Variables to a Sub-@code{make}}).
     5027A variable name may be any sequence of characters not containing
     5028@samp{:}, @samp{#}, @samp{=}, or whitespace.  However, variable names
     5029containing characters other than letters, numbers, and underscores
     5030should be considered carefully, as in some shells they cannot be
     5031passed through the environment to a sub-@code{make}
     5032(@pxref{Variables/Recursion, ,Communicating Variables to a
     5033Sub-@code{make}}).  Variable names beginning with @samp{.} and an
     5034uppercase letter may be given special meaning in future versions of
     5035@code{make}.
    48205036
    48215037Variable names are case-sensitive.  The names @samp{foo}, @samp{FOO},
     
    49415157expands to @samp{$(ugh)} which finally expands to @samp{Huh?}.@refill
    49425158
    4943 This flavor of variable is the only sort supported by other versions of
    4944 @code{make}.  It has its advantages and its disadvantages.  An advantage
    4945 (most would say) is that:
     5159This flavor of variable is the only sort supported by most other
     5160versions of @code{make}.  It has its advantages and its disadvantages.
     5161An advantage (most would say) is that:
    49465162
    49475163@example
     
    49795195@cindex variables, simply expanded
    49805196@cindex :=
     5197@cindex ::=
    49815198@dfn{Simply expanded variables} are defined by lines using @samp{:=}
    4982 (@pxref{Setting, ,Setting Variables}).
     5199or @samp{::=} (@pxref{Setting, ,Setting Variables}).  Both forms are
     5200equivalent in GNU @code{make}; however only the @samp{::=} form is
     5201described by the POSIX standard (support for @samp{::=} was added to
     5202the POSIX standard in 2012, so older versions of @code{make} won't
     5203accept this form either).
     5204
    49835205The value of a simply expanded variable is scanned
    49845206once and for all, expanding any references to other variables and
     
    52205442
    52215443References to recursively-expanded variables within a variable name are
    5222 reexpanded in the usual fashion.  For example:
     5444re-expanded in the usual fashion.  For example:
    52235445
    52245446@example
     
    53995621@cindex =
    54005622@cindex :=
     5623@cindex ::=
    54015624@cindex ?=
     5625@cindex !=
    54025626
    54035627To set a variable from the makefile, write a line starting with the
    5404 variable name followed by @samp{=} or @samp{:=}.  Whatever follows the
    5405 @samp{=} or @samp{:=} on the line becomes the value.  For example,
     5628variable name followed by @samp{=}, @samp{:=}, or @samp{::=}.  Whatever
     5629follows the @samp{=}, @samp{:=}, or @samp{::=} on the line becomes the
     5630value.  For example,
    54065631
    54075632@example
     
    54135638name and immediately after the @samp{=} is ignored.
    54145639
    5415 Variables defined with @samp{=} are @dfn{recursively expanded} variables.
    5416 Variables defined with @samp{:=} are @dfn{simply expanded} variables; these
    5417 definitions can contain variable references which will be expanded before
    5418 the definition is made.  @xref{Flavors, ,The Two Flavors of Variables}.
     5640Variables defined with @samp{=} are @dfn{recursively expanded}
     5641variables.  Variables defined with @samp{:=} or @samp{::=} are
     5642@dfn{simply expanded} variables; these definitions can contain
     5643variable references which will be expanded before the definition is
     5644made.  @xref{Flavors, ,The Two Flavors of Variables}.
    54195645
    54205646The variable name may contain function and variable references, which
     
    54225648
    54235649There is no limit on the length of the value of a variable except the
    5424 amount of swapping space on the computer.  When a variable definition is
    5425 long, it is a good idea to break it into several lines by inserting
    5426 backslash-newline at convenient places in the definition.  This will not
    5427 affect the functioning of @code{make}, but it will make the makefile easier
    5428 to read.
     5650amount of memory on the computer.  You can split the value of a
     5651variable into multiple physical lines for readability
     5652(@pxref{Splitting Lines, ,Splitting Long Lines}).
    54295653
    54305654Most variable names are considered to have the empty string as a value if
     
    54545678@end example
    54555679
     5680The shell assignment operator @samp{!=} can be used to execute a
     5681shell script and set a variable to its output.  This operator first
     5682evaluates the right-hand side, then passes that result to the shell
     5683for execution.  If the result of the execution ends in a newline, that
     5684one newline is removed; all other newlines are replaced by spaces.
     5685The resulting string is then placed into the named
     5686recursively-expanded variable.  For example:
     5687
     5688@example
     5689hash != printf '\043'
     5690file_list != find . -name '*.c'
     5691@end example
     5692
     5693If the result of the execution could produce a @code{$}, and you don't
     5694intend what follows that to be interpreted as a make variable or
     5695function reference, then you must replace every @code{$} with
     5696@code{$$} as part of the execution.  Alternatively, you can set a
     5697simply expanded variable to the result of running a program using the
     5698@code{shell} function call.  @xref{Shell Function, , The @code{shell}
     5699Function}.  For example:
     5700
     5701@example
     5702hash := $(shell printf '\043')
     5703var := $(shell find . -name "*.c")
     5704@end example
     5705
     5706As with the @code{shell} function, the exit status of the just-invoked
     5707shell script is stored in the @code{.SHELLSTATUS} variable.
     5708
     5709
    54565710@node Appending, Override Directive, Setting, Using Variables
    54575711@section Appending More Text to Variables
     
    54985752When you add to a variable's value with @samp{+=}, @code{make} acts
    54995753essentially as if you had included the extra text in the initial
    5500 definition of the variable.  If you defined it first with @samp{:=},
    5501 making it a simply-expanded variable, @samp{+=} adds to that
    5502 simply-expanded definition, and expands the new text before appending it
    5503 to the old value just as @samp{:=} does
    5504 (see @ref{Setting, ,Setting Variables}, for a full explanation of @samp{:=}).
    5505 In fact,
     5754definition of the variable.  If you defined it first with @samp{:=} or
     5755@samp{::=}, making it a simply-expanded variable, @samp{+=} adds to
     5756that simply-expanded definition, and expands the new text before
     5757appending it to the old value just as @samp{:=} does (see
     5758@ref{Setting, ,Setting Variables}, for a full explanation of
     5759@samp{:=} or @samp{::=}).  In fact,
    55065760
    55075761@example
     
    55615815The first line defines the @code{CFLAGS} variable with a reference to another
    55625816variable, @code{includes}.  (@code{CFLAGS} is used by the rules for C
    5563 compilation; @pxref{Catalogue of Rules, ,Catalogue of Implicit Rules}.)
     5817compilation; @pxref{Catalogue of Rules, ,Catalogue of Built-In Rules}.)
    55645818Using @samp{=} for the definition makes @code{CFLAGS} a recursively-expanded
    55655819variable, meaning @w{@samp{$(includes) -O}} is @emph{not} expanded when
     
    57175971since two commands separated by semicolon behave much like two separate
    57185972shell commands.  However, note that using two separate lines means
    5719 @code{make} will invoke the shell twice, running an independent subshell
     5973@code{make} will invoke the shell twice, running an independent sub-shell
    57205974for each line.  @xref{Execution, ,Recipe Execution}.
    57215975
     
    58436097
    58446098The @var{variable-assignment} can be any valid form of assignment;
    5845 recursive (@samp{=}), static (@samp{:=}), appending (@samp{+=}), or
    5846 conditional (@samp{?=}).  All variables that appear within the
    5847 @var{variable-assignment} are evaluated within the context of the
    5848 target: thus, any previously-defined target-specific variable values
    5849 will be in effect.  Note that this variable is actually distinct from
    5850 any ``global'' value: the two variables do not have to have the same
    5851 flavor (recursive vs.@: static).
     6099recursive (@samp{=}), simple (@samp{:=} or @samp{::=}), appending
     6100(@samp{+=}), or conditional (@samp{?=}).  All variables that appear
     6101within the @var{variable-assignment} are evaluated within the context
     6102of the target: thus, any previously-defined target-specific variable
     6103values will be in effect.  Note that this variable is actually
     6104distinct from any ``global'' value: the two variables do not have to
     6105have the same flavor (recursive vs.@: simple).
    58526106
    58536107Target-specific variables have the same priority as any other makefile
     
    59746228Due to the @code{private} modifier, @code{a.o} and @code{b.o} will not
    59756229inherit the @code{EXTRA_CFLAGS} variable assignment from the
    5976 @code{progs} target.
     6230@code{prog} target.
    59776231
    59786232@node Special Variables,  , Suppressing Inheritance, Using Variables
     
    60706324
    60716325Note that assigning more than one target name to @code{.DEFAULT_GOAL} is
    6072 illegal and will result in an error.
     6326invalid and will result in an error.
    60736327
    60746328@vindex MAKE_RESTARTS @r{(number of times @code{make} has restarted)}
     
    60796333this is not the same as recursion (counted by the @code{MAKELEVEL}
    60806334variable).  You should not set, modify, or export this variable.
     6335
     6336@vindex MAKE_TERMOUT @r{(whether stdout is a terminal)}
     6337@vindex MAKE_TERMERR @r{(whether stderr is a terminal)}
     6338@item MAKE_TERMOUT
     6339@itemx MAKE_TERMERR
     6340When @code{make} starts it will check whether stdout and stderr will
     6341show their output on a terminal.  If so, it will set
     6342@code{MAKE_TERMOUT} and @code{MAKE_TERMERR}, respectively, to the name
     6343of the terminal device (or @code{true} if this cannot be determined).
     6344If set these variables will be marked for export.  These variables
     6345will not be changed by @code{make} and they will not be modified if
     6346already set.
     6347
     6348These values can be used (particularly in combination with output
     6349synchronization (@pxref{Parallel Output, ,Output During Parallel
     6350Execution}) to determine whether @code{make} itself is writing to a
     6351terminal; they can be tested to decide whether to force recipe
     6352commands to generate colorized output for example.
     6353
     6354If you invoke a sub-@code{make} and redirect its stdout or stderr it
     6355is your responsibility to reset or unexport these variables as well,
     6356if your makefiles rely on them.
    60816357
    60826358@vindex .RECIPEPREFIX @r{(change the recipe prefix character)}
     
    61216397@item .FEATURES
    61226398Expands to a list of special features supported by this version of
    6123 @code{make}.  Possible values include:
     6399@code{make}.  Possible values include, but are not limited to:
    61246400
    61256401@table @samp
    61266402
    61276403@item archives
    6128 Supports @code{ar} (archive) files using special filename syntax.
     6404Supports @code{ar} (archive) files using special file name syntax.
    61296405@xref{Archives, ,Using @code{make} to Update Archive Files}.
    61306406
     
    61416417,Parallel Execution}.
    61426418
    6143 @item second-expansion
    6144 Supports secondary expansion of prerequisite lists.
     6419@item oneshell
     6420Supports the @code{.ONESHELL} special target.  @xref{One Shell, ,Using
     6421One Shell}.
    61456422
    61466423@item order-only
     
    61486425of Prerequisites}.
    61496426
     6427@item second-expansion
     6428Supports secondary expansion of prerequisite lists.
     6429
     6430@item shortest-stem
     6431Uses the ``shortest stem'' method of choosing which pattern, of
     6432multiple applicable options, will be used.  @xref{Pattern Match, ,How
     6433Patterns Match}.
     6434
    61506435@item target-specific
    61516436Supports target-specific and pattern-specific variable assignments.
    61526437@xref{Target-specific, ,Target-specific Variable Values}.
    61536438
     6439@item undefine
     6440Supports the @code{undefine} directive.  @xref{Undefine Directive}.
     6441
     6442@item guile
     6443Has GNU Guile available as an embedded extension language.
     6444@xref{Guile Integration, ,GNU Guile Integration}.
     6445
     6446@item load
     6447Supports dynamically loadable objects for creating custom extensions.
     6448@xref{Loading Objects, ,Loading Dynamic Objects}.
    61546449@end table
    61556450
     
    62926587
    62936588@example
    6294 @var{conditional-directive}
     6589@var{conditional-directive-one}
    62956590@var{text-if-one-is-true}
    6296 else @var{conditional-directive}
    6297 @var{text-if-true}
     6591else @var{conditional-directive-two}
     6592@var{text-if-two-is-true}
    62986593else
    6299 @var{text-if-false}
     6594@var{text-if-one-and-two-are-false}
    63006595endif
    63016596@end example
     
    63546649@item ifdef @var{variable-name}
    63556650The @code{ifdef} form takes the @emph{name} of a variable as its
    6356 argument, not a reference to a variable.  The value of that variable
    6357 has a non-empty value, the @var{text-if-true} is effective; otherwise,
    6358 the @var{text-if-false}, if any, is effective.  Variables that have
    6359 never been defined have an empty value.  The text @var{variable-name}
    6360 is expanded, so it could be a variable or function that expands
    6361 to the name of a variable.  For example:
     6651argument, not a reference to a variable.  If the value of that
     6652variable has a non-empty value, the @var{text-if-true} is effective;
     6653otherwise, the @var{text-if-false}, if any, is effective.  Variables
     6654that have never been defined have an empty value.  The text
     6655@var{variable-name} is expanded, so it could be a variable or function
     6656that expands to the name of a variable.  For example:
    63626657
    63636658@example
     
    64936788* Conditional Functions::       Functions that implement conditions.
    64946789* Foreach Function::            Repeat some text with controlled variation.
     6790* File Function::               Write text to a file.
    64956791* Call Function::               Expand a user-defined function.
    64966792* Value Function::              Return the un-expanded value of a variable.
     
    64986794* Origin Function::             Find where a variable got its value.
    64996795* Flavor Function::             Find out the flavor of a variable.
     6796* Make Control Functions::      Functions that control how make runs.
    65006797* Shell Function::              Substitute the output of a shell command.
    6501 * Make Control Functions::      Functions that control how make runs.
     6798* Guile Function::              Use GNU Guile embedded scripting language.
    65026799@end menu
    65036800
     
    65096806@cindex functions, syntax of
    65106807
    6511 A function call resembles a variable reference.  It looks like this:
     6808A function call resembles a variable reference.  It can appear
     6809anywhere a variable reference can appear, and it is expanded using the
     6810same rules as variable references.  A function call looks like this:
    65126811
    65136812@example
     
    65246823Here @var{function} is a function name; one of a short list of names
    65256824that are part of @code{make}.  You can also essentially create your own
    6526 functions by using the @code{call} builtin function.
     6825functions by using the @code{call} built-in function.
    65276826
    65286827The @var{arguments} are the arguments of the function.  They are
     
    71417440@end table
    71427441
    7143 @node Foreach Function, Call Function, Conditional Functions, Functions
     7442@node Foreach Function, File Function, Conditional Functions, Functions
    71447443@section The @code{foreach} Function
    71457444@findex foreach
     
    72037502Here we use the variable @code{find_files} this way.  We use plain @samp{=}
    72047503to define a recursively-expanding variable, so that its value contains an
    7205 actual function call to be reexpanded under the control of @code{foreach};
     7504actual function call to be re-expanded under the control of @code{foreach};
    72067505a simply-expanded variable would not do, since @code{wildcard} would be
    72077506called only once at the time of defining @code{find_files}.
     
    72217520
    72227521@smallexample
    7223 files := $(foreach Esta escrito en espanol!,b c ch,$(find_files))
     7522files := $(foreach Esta-escrito-en-espanol!,b c ch,$(find_files))
    72247523@end smallexample
    72257524
    72267525@noindent
    72277526might be useful if the value of @code{find_files} references the variable
    7228 whose name is @samp{Esta escrito en espanol!} (es un nombre bastante largo,
     7527whose name is @samp{Esta-escrito-en-espanol!} (es un nombre bastante largo,
    72297528no?), but it is more likely to be a mistake.
    72307529
    7231 @node Call Function, Value Function, Foreach Function, Functions
     7530@node File Function, Call Function, Foreach Function, Functions
     7531@section The @code{file} Function
     7532@findex file
     7533@cindex writing to a file
     7534@cindex file, writing to
     7535@cindex reading from a file
     7536@cindex file, reading from
     7537
     7538The @code{file} function allows the makefile to write to or read from
     7539a file.  Two modes of writing are supported: overwrite, where the text
     7540is written to the beginning of the file and any existing content is
     7541lost, and append, where the text is written to the end of the file,
     7542preserving the existing content.  In both cases the file is created if
     7543it does not exist.  It is a fatal error if the file cannot be opened
     7544for writing, or if the write operation fails.  The @code{file}
     7545function expands to the empty string when writing to a file.
     7546
     7547When reading from a file, the @code{file} function expands to the
     7548verbatim contents of the file, except that the final newline (if there
     7549is one) will be stripped.  Attempting to read from a non-existent file
     7550expands to the empty string.
     7551
     7552The syntax of the @code{file} function is:
     7553
     7554@example
     7555$(file @var{op} @var{filename}[,@var{text}])
     7556@end example
     7557
     7558When the @code{file} function is evaluated all its arguments are
     7559expanded first, then the file indicated by @var{filename} will be
     7560opened in the mode described by @var{op}.
     7561
     7562The operator @var{op} can be @code{>} to indicate the file will be
     7563overwritten with new content, @code{>>} to indicate the current
     7564contents of the file will be appended to, or @code{<} to indicate the
     7565contents of the file will be read in.  The @var{filename} specifies
     7566the file to be written to or read from.  There may optionally be
     7567whitespace between the operator and the file name.
     7568
     7569When reading files, it is an error to provide a @var{text} value.
     7570
     7571When writing files, @var{text} will be written to the file.  If
     7572@var{text} does not already end in a newline a final newline will be
     7573written (even if @var{text} is the empty string).  If the @var{text}
     7574argument is not given at all, nothing will be written.
     7575
     7576For example, the @code{file} function can be useful if your build
     7577system has a limited command line size and your recipe runs a command
     7578that can accept arguments from a file as well.  Many commands use the
     7579convention that an argument prefixed with an @code{@@} specifies a
     7580file containing more arguments.  Then you might write your recipe in
     7581this way:
     7582
     7583@example
     7584@group
     7585program: $(OBJECTS)
     7586        $(file >$@@.in,$^)
     7587        $(CMD) $(CMDFLAGS) @@$@@.in
     7588        @@rm $@@.in
     7589@end group
     7590@end example
     7591
     7592If the command required each argument to be on a separate line of the
     7593input file, you might write your recipe like this:
     7594
     7595@example
     7596@group
     7597program: $(OBJECTS)
     7598        $(file >$@@.in) $(foreach O,$^,$(file >>$@@.in,$O))
     7599        $(CMD) $(CMDFLAGS) @@$@@.in
     7600        @@rm $@@.in
     7601@end group
     7602@end example
     7603
     7604@node Call Function, Value Function, File Function, Functions
    72327605@section The @code{call} Function
    72337606@findex call
     
    72637636constant.)
    72647637
    7265 If @var{variable} is the name of a builtin function, the builtin function
     7638If @var{variable} is the name of a built-in function, the built-in function
    72667639is always invoked (even if a @code{make} variable by that name also
    72677640exists).
     
    72697642The @code{call} function expands the @var{param} arguments before
    72707643assigning them to temporary variables.  This means that @var{variable}
    7271 values containing references to builtin functions that have special
     7644values containing references to built-in functions that have special
    72727645expansion rules, like @code{foreach} or @code{if}, may not work as you
    72737646expect.
     
    73417714@end example
    73427715
    7343 Note that @var{variable} is the @emph{name} of a variable; not a
     7716Note that @var{variable} is the @emph{name} of a variable, not a
    73447717@emph{reference} to that variable.  Therefore you would not normally
    73457718use a @samp{$} or parentheses when writing it.  (You can, however, use
     
    74527825@end example
    74537826
    7454 Note that @var{variable} is the @emph{name} of a variable to inquire about;
     7827Note that @var{variable} is the @emph{name} of a variable to inquire about,
    74557828not a @emph{reference} to that variable.  Therefore you would not normally
    74567829use a @samp{$} or parentheses when writing it.  (You can, however, use a
     
    75457918@xref{Text Functions, , Functions for String Substitution and Analysis}.
    75467919
    7547 @node Flavor Function, Shell Function, Origin Function, Functions
     7920@node Flavor Function, Make Control Functions, Origin Function, Functions
    75487921@section The @code{flavor} Function
    75497922@findex flavor
     
    75517924@cindex flavor of variable
    75527925
    7553 The @code{flavor} function is unlike most other functions (and like
    7554 @code{origin} function) in that it does not operate on the values of
    7555 variables; it tells you something @emph{about} a variable.
    7556 Specifically, it tells you the flavor of a variable (@pxref{Flavors,
    7557 ,The Two Flavors of Variables}).
     7926The @code{flavor} function, like the @code{origin} function, does not
     7927operate on the values of variables but rather it tells you something
     7928@emph{about} a variable.  Specifically, it tells you the flavor of a
     7929variable (@pxref{Flavors, ,The Two Flavors of Variables}).
    75587930
    75597931The syntax of the @code{flavor} function is:
     
    75637935@end example
    75647936
    7565 Note that @var{variable} is the @emph{name} of a variable to inquire about;
     7937Note that @var{variable} is the @emph{name} of a variable to inquire about,
    75667938not a @emph{reference} to that variable.  Therefore you would not normally
    75677939use a @samp{$} or parentheses when writing it.  (You can, however, use a
     
    75867958@end table
    75877959
    7588 
    7589 @node Shell Function, Make Control Functions, Flavor Function, Functions
    7590 @section The @code{shell} Function
    7591 @findex shell
    7592 @cindex command expansion
    7593 @cindex backquotes
    7594 @cindex shell command, function for
    7595 
    7596 The @code{shell} function is unlike any other function other than the
    7597 @code{wildcard} function
    7598 (@pxref{Wildcard Function, ,The Function @code{wildcard}}) in that it
    7599 communicates with the world outside of @code{make}.
    7600 
    7601 The @code{shell} function performs the same function that backquotes
    7602 (@samp{`}) perform in most shells: it does @dfn{command expansion}.
    7603 This means that it takes as an argument a shell command and evaluates
    7604 to the output of the command.  The only processing @code{make} does on
    7605 the result is to convert each newline (or carriage-return / newline
    7606 pair) to a single space.  If there is a trailing (carriage-return
    7607 and) newline it will simply be removed.@refill
    7608 
    7609 The commands run by calls to the @code{shell} function are run when the
    7610 function calls are expanded (@pxref{Reading Makefiles, , How
    7611 @code{make} Reads a Makefile}).  Because this function involves
    7612 spawning a new shell, you should carefully consider the performance
    7613 implications of using the @code{shell} function within recursively
    7614 expanded variables vs.@: simply expanded variables (@pxref{Flavors, ,The
    7615 Two Flavors of Variables}).
    7616 
    7617 Here are some examples of the use of the @code{shell} function:
    7618 
    7619 @example
    7620 contents := $(shell cat foo)
    7621 @end example
    7622 
    7623 @noindent
    7624 sets @code{contents} to the contents of the file @file{foo}, with a space
    7625 (rather than a newline) separating each line.
    7626 
    7627 @example
    7628 files := $(shell echo *.c)
    7629 @end example
    7630 
    7631 @noindent
    7632 sets @code{files} to the expansion of @samp{*.c}.  Unless @code{make} is
    7633 using a very strange shell, this has the same result as
    7634 @w{@samp{$(wildcard *.c)}} (as long as at least one @samp{.c} file
    7635 exists).@refill
    7636 
    7637 @node Make Control Functions,  , Shell Function, Functions
     7960@node Make Control Functions, Shell Function, Flavor Function, Functions
    76387961@section Functions That Control Make
    76397962@cindex functions, for controlling make
     
    76968019result of the expansion of this function is the empty string.
    76978020@end table
     8021
     8022@node Shell Function, Guile Function, Make Control Functions, Functions
     8023@section The @code{shell} Function
     8024@findex shell
     8025@cindex command expansion
     8026@cindex backquotes
     8027@cindex shell command, function for
     8028
     8029The @code{shell} function is unlike any other function other than the
     8030@code{wildcard} function
     8031(@pxref{Wildcard Function, ,The Function @code{wildcard}}) in that it
     8032communicates with the world outside of @code{make}.
     8033
     8034The @code{shell} function performs the same function that backquotes
     8035(@samp{`}) perform in most shells: it does @dfn{command expansion}.
     8036This means that it takes as an argument a shell command and evaluates
     8037to the output of the command.  The only processing @code{make} does on
     8038the result is to convert each newline (or carriage-return / newline
     8039pair) to a single space.  If there is a trailing (carriage-return
     8040and) newline it will simply be removed.@refill
     8041
     8042The commands run by calls to the @code{shell} function are run when the
     8043function calls are expanded (@pxref{Reading Makefiles, , How
     8044@code{make} Reads a Makefile}).  Because this function involves
     8045spawning a new shell, you should carefully consider the performance
     8046implications of using the @code{shell} function within recursively
     8047expanded variables vs.@: simply expanded variables (@pxref{Flavors, ,The
     8048Two Flavors of Variables}).
     8049
     8050@vindex .SHELLSTATUS
     8051After the @code{shell} function or @samp{!=} assignment operator is
     8052used, its exit status is placed in the @code{.SHELLSTATUS} variable.
     8053
     8054Here are some examples of the use of the @code{shell} function:
     8055
     8056@example
     8057contents := $(shell cat foo)
     8058@end example
     8059
     8060@noindent
     8061sets @code{contents} to the contents of the file @file{foo}, with a space
     8062(rather than a newline) separating each line.
     8063
     8064@example
     8065files := $(shell echo *.c)
     8066@end example
     8067
     8068@noindent
     8069sets @code{files} to the expansion of @samp{*.c}.  Unless @code{make} is
     8070using a very strange shell, this has the same result as
     8071@w{@samp{$(wildcard *.c)}} (as long as at least one @samp{.c} file
     8072exists).@refill
     8073
     8074@node Guile Function,  , Shell Function, Functions
     8075@section The @code{guile} Function
     8076@findex guile
     8077@cindex Guile
     8078
     8079If GNU @code{make} is built with support for GNU Guile as an embedded
     8080extension language then the @code{guile} function will be available.
     8081The @code{guile} function takes one argument which is first expanded
     8082by @code{make} in the normal fashion, then passed to the GNU Guile
     8083evaluator.  The result of the evaluator is converted into a string and
     8084used as the expansion of the @code{guile} function in the makefile.
     8085See @ref{Guile Integration, ,GNU Guile Integration} for details on
     8086writing extensions to @code{make} in Guile.
     8087
     8088You can determine whether GNU Guile support is available by checking
     8089the @code{.FEATURES} variable for the word @var{guile}.
    76988090
    76998091@node Running, Implicit Rules, Functions, Top
     
    79198311@cindex @code{-n}
    79208312
    7921 ``No-op''.  The activity is to print what recipe would be used to make
    7922 the targets up to date, but not actually execute it.  Some recipes are
    7923 still executed, even with this flag (@pxref{MAKE Variable, ,How the @code{MAKE} Variable Works}).
     8313``No-op''.  Causes @code{make} to print the recipes that are needed to
     8314make the targets up to date, but not actually execute them.  Note that
     8315some recipes are still executed, even with this flag (@pxref{MAKE
     8316Variable, ,How the @code{MAKE} Variable Works}).  Also any recipes
     8317needed to update included makefiles are still executed
     8318(@pxref{Remaking Makefiles, ,How Makefiles Are Remade}).
    79248319
    79258320@item -t
     
    79308325@cindex @code{-t}
    79318326
    7932 ``Touch''.  The activity is to mark the targets as up to date without
    7933 actually changing them.  In other words, @code{make} pretends to compile
    7934 the targets but does not really change their contents.
     8327``Touch''.  Marks targets as up to date without actually changing
     8328them.  In other words, @code{make} pretends to update the targets but
     8329does not really change their contents; instead only their modified
     8330times are updated.
    79358331
    79368332@item -q
     
    79408336@cindex question mode
    79418337
    7942 ``Question''.  The activity is to find out silently whether the targets
    7943 are up to date already; but execute no recipe in either case.  In other
    7944 words, neither compilation nor output will occur.
     8338``Question''.  Silently check whether the targets are up to date, but
     8339do not execute recipes; the exit code shows whether any updates are
     8340needed.
    79458341
    79468342@item -W @var{file}
     
    81168512define either a recursively-expanded variable or a simply-expanded
    81178513variable.  The examples shown above make a recursively-expanded
    8118 variable; to make a simply-expanded variable, write @samp{:=} instead
    8119 of @samp{=}.  But, unless you want to include a variable reference or
    8120 function call in the @emph{value} that you specify, it makes no
    8121 difference which kind of variable you create.
     8514variable; to make a simply-expanded variable, write @samp{:=} or
     8515@samp{::=} instead of @samp{=}.  But, unless you want to include a
     8516variable reference or function call in the @emph{value} that you
     8517specify, it makes no difference which kind of variable you create.
    81228518
    81238519There is one way that the makefile can change a variable that you have
     
    82438639
    82448640@item j (@i{jobs})
    8245 Prints messages giving details on the invocation of specific subcommands.
     8641Prints messages giving details on the invocation of specific sub-commands.
    82468642
    82478643@item m (@i{makefile})
     
    82508646too.  Note that the @samp{all} option does enable this option.  This
    82518647option also enables @samp{basic} messages.
     8648
     8649@item n (@i{none})
     8650Disable all debugging currently enabled.  If additional debugging
     8651flags are encountered after this they will still take effect.
    82528652@end table
    82538653
     
    83678767are ignored.  @xref{Avoiding Compilation, ,Avoiding Recompilation of
    83688768Some Files}.@refill
     8769
     8770@item -O[@var{type}]
     8771@cindex @code{-O}
     8772@itemx --output-sync[=@var{type}]
     8773@cindex @code{--output-sync}
     8774@cindex output during parallel execution
     8775@cindex parallel execution, output during
     8776Ensure that the complete output from each recipe is printed in one
     8777uninterrupted sequence.  This option is only useful when using the
     8778@code{--jobs} option to run multiple recipes simultaneously
     8779(@pxref{Parallel, ,Parallel Execution})  Without this option output
     8780will be displayed as it is generated by the recipes.@refill
     8781
     8782With no type or the type @samp{target}, output from the entire recipe
     8783of each target is grouped together.  With the type @samp{line}, output
     8784from each line in the recipe is grouped together.  With the type
     8785@samp{recurse}, the output from an entire recursive make is grouped
     8786together.  With the type @samp{none}, no output synchronization is
     8787performed.  @xref{Parallel Output, ,Output During Parallel Execution}.
    83698788
    83708789@item -p
     
    83808799to remake any files, use @w{@samp{make -qp}}.  To print the data base
    83818800of predefined rules and variables, use @w{@samp{make -p -f /dev/null}}.
    8382 The data base output contains filename and linenumber information for
     8801The data base output contains file name and line number information for
    83838802recipe and variable definitions, so it can be a useful debugging tool
    83848803in complex environments.
     
    84558874@code{make}.  @xref{Instead of Execution, ,Instead of Executing Recipes}.
    84568875
     8876@item --trace
     8877@cindex @code{--trace}
     8878Show tracing information for @code{make} execution.  Prints the entire
     8879recipe to be executed, even for recipes that are normally silent (due
     8880to @code{.SILENT} or @samp{@@}).  Also prints the makefile name and
     8881line number where the recipe was defined, and information on why the
     8882target is being rebuilt.
     8883
    84578884@item -v
    84588885@cindex @code{-v}
     
    84738900see @ref{-w Option, ,The @samp{--print-directory} Option}.)
    84748901
    8475 @itemx --no-print-directory
     8902@item --no-print-directory
    84768903@cindex @code{--no-print-directory}
    84778904Disable printing of the working directory under @code{-w}.
     
    85518978* Using Implicit::              How to use an existing implicit rule
    85528979                                  to get the recipes for updating a file.
    8553 * Catalogue of Rules::          A list of built-in implicit rules.
     8980* Catalogue of Rules::          A list of built-in rules.
    85548981* Implicit Variables::          How to change what predefined rules do.
    85558982* Chained Rules::               How to use a chain of implicit rules.
    85568983* Pattern Rules::               How to define new implicit rules.
    8557 * Last Resort::                 How to define recipes for rules which
     8984* Last Resort::                 How to define a recipe for rules which
    85588985                                  cannot find any.
    85598986* Suffix Rules::                The old-fashioned style of implicit rule.
     
    86039030want @code{make} to use, and you know it will choose that one because you
    86049031know which possible prerequisite files are supposed to exist.
    8605 @xref{Catalogue of Rules, ,Catalogue of Implicit Rules},
     9032@xref{Catalogue of Rules, ,Catalogue of Built-In Rules},
    86069033for a catalogue of all the predefined implicit rules.
    86079034
     
    86339060rule to make an object file from a C source file is used instead,
    86349061because it appears before the Pascal rule in the list of predefined
    8635 implicit rules (@pxref{Catalogue of Rules, , Catalogue of Implicit
     9062implicit rules (@pxref{Catalogue of Rules, , Catalogue of Built-In
    86369063Rules}).
    86379064
     
    86419068
    86429069@node Catalogue of Rules, Implicit Variables, Using Implicit, Implicit Rules
    8643 @section Catalogue of Implicit Rules
     9070@section Catalogue of Built-In Rules
    86449071@cindex implicit rule, predefined
    86459072@cindex rule, implicit, predefined
     
    89879414Here is a table of some of the more common variables used as names of
    89889415programs in built-in rules:
    8989 makefiles.
    89909416
    89919417@table @code
     
    91429568@vindex LDFLAGS
    91439569Extra flags to give to compilers when they are supposed to invoke the linker,
    9144 @samp{ld}.
     9570@samp{ld}, such as @code{-L}.  Libraries (@code{-lfoo}) should be
     9571added to the @code{LDLIBS} variable instead.
     9572
     9573@item LDLIBS
     9574@vindex LDLIBS
     9575@vindex LOADLIBES
     9576Library flags or names given to compilers when they are supposed to
     9577invoke the linker, @samp{ld}.  @code{LOADLIBES} is a deprecated (but
     9578still supported) alternative to @code{LDLIBS}.  Non-library linker
     9579flags, such as @code{-L}, should go in the @code{LDFLAGS} variable.
    91459580
    91469581@item LFLAGS
     
    92759710* Pattern Examples::            Examples of pattern rules.
    92769711* Automatic Variables::         How to use automatic variables in the
    9277                                   recipes of implicit rules.
     9712                                  recipe of implicit rules.
    92789713* Pattern Match::               How patterns match.
    92799714* Match-Anything Rules::        Precautions you should take prior to
     
    93759810@noindent
    93769811defines a rule that can make any file @file{@var{x}} whatsoever from a
    9377 corresponding file @file{@var{x},v} in the subdirectory @file{RCS}.  Since
     9812corresponding file @file{@var{x},v} in the sub-directory @file{RCS}.  Since
    93789813the target is @samp{%}, this rule will apply to any file whatever, provided
    93799814the appropriate prerequisite file exists.  The double colon makes the rule
     
    974810183
    974910184If you do not mark the match-anything rule as terminal, then it is
    9750 nonterminal.  A nonterminal match-anything rule cannot apply to a file name
     10185non-terminal.  A non-terminal match-anything rule cannot apply to a file name
    975110186that indicates a specific type of data.  A file name indicates a specific
    975210187type of data if some non-match-anything implicit rule target matches it.
     
    975610191rule is actually applicable (which happens only if there is a file
    975710192@file{foo.y}), the fact that its target matches is enough to prevent
    9758 consideration of any nonterminal match-anything rules for the file
     10193consideration of any non-terminal match-anything rules for the file
    975910194@file{foo.c}.  Thus, @code{make} will not even consider trying to make
    976010195@file{foo.c} as an executable file from @file{foo.c.o}, @file{foo.c.c},
    976110196@file{foo.c.p}, etc.@refill
    976210197
    9763 The motivation for this constraint is that nonterminal match-anything
     10198The motivation for this constraint is that non-terminal match-anything
    976410199rules are used for making files containing specific types of data (such as
    976510200executable files) and a file name with a recognized suffix indicates some
     
    976710202
    976810203Special built-in dummy pattern rules are provided solely to recognize
    9769 certain file names so that nonterminal match-anything rules will not be
     10204certain file names so that non-terminal match-anything rules will not be
    977010205considered.  These dummy rules have no prerequisites and no recipes, and
    977110206they are ignored for all other purposes.  For example, the built-in
     
    998710422@item
    998810423If any rule in that list is @emph{not} a match-anything rule, then
    9989 remove all nonterminal match-anything rules from the list.
     10424remove all non-terminal match-anything rules from the list.
    999010425
    999110426@item
     
    1005610491prerequisites.  @xref{Automatic Variables}.
    1005710492
    10058 @node Archives, Features, Implicit Rules, Top
     10493@node Archives, Extending make, Implicit Rules, Top
    1005910494@chapter Using @code{make} to Update Archive Files
    1006010495@cindex archive
    1006110496
    10062 @dfn{Archive files} are files containing named subfiles called
     10497@dfn{Archive files} are files containing named sub-files called
    1006310498@dfn{members}; they are maintained with the program @code{ar} and their
    1006410499main use is as subroutine libraries for linking.
     
    1028310718@w{%.@var{x}}} and @samp{@w{%.a}: @w{%.@var{x}}}.@refill
    1028410719
    10285 @node Features, Missing, Archives, Top
     10720@node Extending make, Integrating make, Archives, Top
     10721@chapter Extending GNU @code{make}
     10722@cindex make extensions
     10723
     10724GNU @code{make} provides many advanced capabilities, including many
     10725useful functions.  However, it does not contain a complete programming
     10726language and so it has limitations.  Sometimes these limitations can be
     10727overcome through use of the @code{shell} function to invoke a separate
     10728program, although this can be inefficient.
     10729
     10730In cases where the built-in capabilities of GNU @code{make} are
     10731insufficient to your requirements there are two options for extending
     10732@code{make}.  On systems where it's provided, you can utilize GNU
     10733Guile as an embedded scripting language (@pxref{Guile Integration,,GNU
     10734Guile Integration}).  On systems which support dynamically loadable
     10735objects, you can write your own extension in any language (which can
     10736be compiled into such an object) and load it to provide extended
     10737capabilities (@pxref{load Directive, ,The @code{load} Directive}).
     10738
     10739@menu
     10740* Guile Integration::           Using Guile as an embedded scripting language.
     10741* Loading Objects::             Loading dynamic objects as extensions.
     10742@end menu
     10743
     10744@node Guile Integration, Loading Objects, Extending make, Extending make
     10745@section GNU Guile Integration
     10746@cindex Guile
     10747@cindex extensions, Guile
     10748
     10749GNU @code{make} may be built with support for GNU Guile as an embedded
     10750extension language.  Guile implements the Scheme language.  A review
     10751of GNU Guile and the Scheme language and its features is beyond the
     10752scope of this manual: see the documentation for GNU Guile and Scheme.
     10753
     10754You can determine if @code{make} contains support for Guile by
     10755examining the @code{.FEATURES} variable; it will contain the word
     10756@var{guile} if Guile support is available.
     10757
     10758The Guile integration provides one new @code{make} function: @code{guile}.
     10759The @code{guile} function takes one argument which is first expanded
     10760by @code{make} in the normal fashion, then passed to the GNU Guile
     10761evaluator.  The result of the evaluator is converted into a string and
     10762used as the expansion of the @code{guile} function in the makefile.
     10763
     10764In addition, GNU @code{make} exposes Guile procedures for use in Guile
     10765scripts.
     10766
     10767@menu
     10768* Guile Types::                 Converting Guile types to @code{make} strings.
     10769* Guile Interface::             Invoking @code{make} functions from Guile.
     10770* Guile Example::               Example using Guile in @code{make}.
     10771@end menu
     10772
     10773@node Guile Types, Guile Interface, Guile Integration, Guile Integration
     10774@subsection Conversion of Guile Types
     10775@cindex convert guile types
     10776@cindex guile, conversion of types
     10777@cindex types, conversion of
     10778
     10779There is only one ``data type'' in @code{make}: a string.  GNU Guile,
     10780on the other hand, provides a rich variety of different data types.
     10781An important aspect of the interface between @code{make} and GNU Guile
     10782is the conversion of Guile data types into @code{make} strings.
     10783
     10784This conversion is relevant in two places: when a makefile invokes the
     10785@code{guile} function to evaluate a Guile expression, the result of
     10786that evaluation must be converted into a make string so it can be
     10787further evaluated by @code{make}.  And secondly, when a Guile script
     10788invokes one of the procedures exported by @code{make} the argument
     10789provided to the procedure must be converted into a string.
     10790
     10791The conversion of Guile types into @code{make} strings is as below:
     10792
     10793@table @code
     10794@item #f
     10795False is converted into the empty string: in @code{make} conditionals
     10796the empty string is considered false.
     10797
     10798@item #t
     10799True is converted to the string @samp{#t}: in @code{make} conditionals
     10800any non-empty string is considered true.
     10801
     10802@item symbol
     10803@item number
     10804A symbol or number is converted into the string representation of that
     10805symbol or number.
     10806
     10807@item character
     10808A printable character is converted to the same character.
     10809
     10810@item string
     10811A string containing only printable characters is converted to the same
     10812string.
     10813
     10814@item list
     10815A list is converted recursively according to the above rules.  This
     10816implies that any structured list will be flattened (that is, a result
     10817of @samp{'(a b (c d) e)} will be converted to the @code{make} string
     10818@samp{a b c d e}).
     10819
     10820@item other
     10821Any other Guile type results in an error.  In future versions of
     10822@code{make}, other Guile types may be converted.
     10823
     10824@end table
     10825
     10826The translation of @samp{#f} (to the empty string) and @samp{#t} (to
     10827the non-empty string @samp{#t}) is designed to allow you to use Guile
     10828boolean results directly as @code{make} boolean conditions.  For
     10829example:
     10830
     10831@example
     10832$(if $(guile (access? "myfile" R_OK)),$(info myfile exists))
     10833@end example
     10834
     10835As a consequence of these conversion rules you must consider the
     10836result of your Guile script, as that result will be converted into a
     10837string and parsed by @code{make}.  If there is no natural result for
     10838the script (that is, the script exists solely for its side-effects),
     10839you should add @samp{#f} as the final expression in order to avoid
     10840syntax errors in your makefile.
     10841
     10842@node Guile Interface, Guile Example, Guile Types, Guile Integration
     10843@subsection Interfaces from Guile to @code{make}
     10844@cindex make interface to guile
     10845@cindex make procedures in guile
     10846
     10847In addition to the @code{guile} function available in makefiles,
     10848@code{make} exposes some procedures for use in your Guile scripts.  At
     10849startup @code{make} creates a new Guile module, @code{gnu make}, and
     10850exports these procedures as public interfaces from that module:
     10851
     10852@table @code
     10853@item gmk-expand
     10854@findex gmk-expand
     10855This procedure takes a single argument which is converted into a
     10856string.  The string is expanded by @code{make} using normal
     10857@code{make} expansion rules.  The result of the expansion is converted
     10858into a Guile string and provided as the result of the procedure.
     10859
     10860@item gmk-eval
     10861@findex gmk-eval
     10862This procedure takes a single argument which is converted into a
     10863string.  The string is evaluated by @code{make} as if it were a
     10864makefile.  This is the same capability available via the @code{eval}
     10865function (@pxref{Eval Function}).  The result of the @code{gmk-eval}
     10866procedure is always the empty string.
     10867
     10868Note that @code{gmk-eval} is not quite the same as using
     10869@code{gmk-expand} with the @code{eval} function: in the latter case
     10870the evaluated string will be expanded @emph{twice}; first by
     10871@code{gmk-expand}, then again by the @code{eval} function.
     10872
     10873@end table
     10874
     10875@node Guile Example,  , Guile Interface, Guile Integration
     10876@subsection Example Using Guile in @code{make}
     10877@cindex Guile example
     10878@cindex example using Guile
     10879
     10880Here is a very simple example using GNU Guile to manage writing to a
     10881file.  These Guile procedures simply open a file, allow writing to the
     10882file (one string per line), and close the file.  Note that because we
     10883cannot store complex values such as Guile ports in @code{make}
     10884variables, we'll keep the port as a global variable in the Guile
     10885interpreter.
     10886
     10887You can create Guile functions easily using @code{define}/@code{endef}
     10888to create a Guile script, then use the @code{guile} function to
     10889internalize it:
     10890
     10891@example
     10892@group
     10893define GUILEIO
     10894;; A simple Guile IO library for GNU make
     10895
     10896(define MKPORT #f)
     10897
     10898(define (mkopen name mode)
     10899  (set! MKPORT (open-file name mode))
     10900  #f)
     10901
     10902(define (mkwrite s)
     10903  (display s MKPORT)
     10904  (newline MKPORT)
     10905  #f)
     10906
     10907(define (mkclose)
     10908  (close-port MKPORT)
     10909  #f)
     10910
     10911#f
     10912endef
     10913
     10914# Internalize the Guile IO functions
     10915$(guile $(GUILEIO))
     10916@end group
     10917@end example
     10918
     10919If you have a significant amount of Guile support code, you might
     10920consider keeping it in a different file (e.g., @file{guileio.scm}) and
     10921then loading it in your makefile using the @code{guile} function:
     10922
     10923@example
     10924$(guile (load "guileio.scm"))
     10925@end example
     10926
     10927An advantage to this method is that when editing @file{guileio.scm},
     10928your editor will understand that this file contains Scheme syntax
     10929rather than makefile syntax.
     10930
     10931Now you can use these Guile functions to create files.  Suppose you
     10932need to operate on a very large list, which cannot fit on the command
     10933line, but the utility you're using accepts the list as input as well:
     10934
     10935@example
     10936@group
     10937prog: $(PREREQS)
     10938        @@$(guile (mkopen "tmp.out" "w")) \
     10939         $(foreach X,$^,$(guile (mkwrite "$(X)"))) \
     10940         $(guile (mkclose))
     10941        $(LINK) < tmp.out
     10942@end group
     10943@end example
     10944
     10945A more comprehensive suite of file manipulation procedures is possible
     10946of course.  You could, for example, maintain multiple output files at
     10947the same time by choosing a symbol for each one and using it as the
     10948key to a hash table, where the value is a port, then returning the
     10949symbol to be stored in a @code{make} variable.
     10950
     10951@node Loading Objects,  , Guile Integration, Extending make
     10952@section Loading Dynamic Objects
     10953@cindex loaded objects
     10954@cindex objects, loaded
     10955@cindex extensions, loading
     10956
     10957@cartouche
     10958@quotation Warning
     10959The @code{load} directive and extension capability is considered a
     10960``technology preview'' in this release of GNU make.  We encourage you
     10961to experiment with this feature and we appreciate any feedback on it.
     10962However we cannot guarantee to maintain backward-compatibility in the
     10963next release.  Consider using GNU Guile instead for extending GNU make
     10964(@pxref{Guile Function, ,The @code{guile} Function}).
     10965@end quotation
     10966@end cartouche
     10967
     10968Many operating systems provide a facility for dynamically loading
     10969compiled objects.  If your system provides this facility, GNU
     10970@code{make} can make use of it to load dynamic objects at runtime,
     10971providing new capabilities which may then be invoked by your makefile.
     10972
     10973The @code{load} directive is used to load a dynamic object.  Once the
     10974object is loaded, a ``setup'' function will be invoked to allow the
     10975object to initialize itself and register new facilities with GNU
     10976@code{make}.  A dynamic object might include new @code{make} functions,
     10977for example, and the ``setup'' function would register them with GNU
     10978@code{make}'s function handling system.
     10979
     10980@menu
     10981* load Directive::              Loading dynamic objects as extensions.
     10982* Remaking Loaded Objects::     How loaded objects get remade.
     10983* Loaded Object API::           Programmatic interface for loaded objects.
     10984* Loaded Object Example::       Example of a loaded object
     10985@end menu
     10986
     10987@node load Directive, Remaking Loaded Objects, Loading Objects, Loading Objects
     10988@subsection The @code{load} Directive
     10989@cindex load directive
     10990@cindex extensions, load directive
     10991
     10992Objects are loaded into GNU @code{make} by placing the @code{load}
     10993directive into your makefile.  The syntax of the @code{load} directive
     10994is as follows:
     10995
     10996@findex load
     10997@example
     10998load @var{object-file} @dots{}
     10999@end example
     11000
     11001or:
     11002
     11003@example
     11004load @var{object-file}(@var{symbol-name}) @dots{}
     11005@end example
     11006
     11007The file @var{object-file} is dynamically loaded by GNU @code{make}.
     11008If @var{object-file} does not include a directory path then it is
     11009first looked for in the current directory.  If it is not found there,
     11010or a directory path is included, then system-specific paths will be
     11011searched.  If the load fails for any reason, @code{make} will print a
     11012message and exit.
     11013
     11014If the load succeeds @code{make} will invoke an initializing function.
     11015
     11016If @var{symbol-name} is provided, it will be used as the name of the
     11017initializing function.
     11018
     11019If no @var{symbol-name} is provided, the initializing function name is
     11020created by taking the base file name of @var{object-file}, up to the
     11021first character which is not a valid symbol name character
     11022(alphanumerics and underscores are valid symbol name characters).  To
     11023this prefix will be appended the suffix @code{_gmk_setup}.
     11024
     11025More than one object file may be loaded with a single @code{load}
     11026directive, and both forms of @code{load} arguments may be used in the
     11027same directive.
     11028
     11029The initializing function will be provided the file name and line
     11030number of the invocation of the @code{load} operation.  It should
     11031return a value of type @code{int}, which must be @code{0} on failure
     11032and non-@code{0} on success.  If the return value is @code{-1}, then
     11033GNU make will @emph{not} attempt to rebuild the object file
     11034(@pxref{Remaking Loaded Objects, ,How Loaded Objects Are Remade}).
     11035
     11036For example:
     11037
     11038@example
     11039load ../mk_funcs.so
     11040@end example
     11041
     11042will load the dynamic object @file{../mk_funcs.so}.  After the object
     11043is loaded, @code{make} will invoke the function (assumed to be defined
     11044by the shared object) @code{mk_funcs_gmk_setup}.
     11045
     11046On the other hand:
     11047
     11048@example
     11049load ../mk_funcs.so(init_mk_func)
     11050@end example
     11051
     11052will load the dynamic object @file{../mk_funcs.so}.  After the object
     11053is loaded, @code{make} will invoke the function @code{init_mk_func}.
     11054
     11055Regardless of how many times an object file appears in a @code{load}
     11056directive, it will only be loaded (and its setup function will only
     11057be invoked) once.
     11058
     11059@vindex .LOADED
     11060After an object has been successfully loaded, its file name is
     11061appended to the @code{.LOADED} variable.
     11062
     11063@findex -load
     11064If you would prefer that failure to load a dynamic object not be
     11065reported as an error, you can use the @code{-load} directive instead
     11066of @code{load}.  GNU @code{make} will not fail and no message will be
     11067generated if an object fails to load.  The failed object is not added
     11068to the @code{.LOADED} variable, which can then be consulted to
     11069determine if the load was successful.
     11070
     11071@node Remaking Loaded Objects, Loaded Object API, load Directive, Loading Objects
     11072@subsection How Loaded Objects Are Remade
     11073@cindex updating loaded objects
     11074@cindex remaking loaded objects
     11075@cindex loaded objects, remaking of
     11076
     11077Loaded objects undergo the same re-make procedure as makefiles
     11078(@pxref{Remaking Makefiles, ,How Makefiles Are Remade}).  If any
     11079loaded object is recreated, then @code{make} will start from scratch
     11080and re-read all the makefiles, and reload the object files again.  It
     11081is not necessary for the loaded object to do anything special to
     11082support this.@refill
     11083
     11084It's up to the makefile author to provide the rules needed for
     11085rebuilding the loaded object.
     11086
     11087@node Loaded Object API, Loaded Object Example, Remaking Loaded Objects, Loading Objects
     11088@subsection Loaded Object Interface
     11089@cindex loaded object API
     11090@cindex interface for loaded objects
     11091
     11092@cartouche
     11093@quotation Warning
     11094For this feature to be useful your extensions will need to invoke
     11095various functions internal to GNU @code{make}.  The programming
     11096interfaces provided in this release should not be considered stable:
     11097functions may be added, removed, or change calling signatures or
     11098implementations in future versions of GNU @code{make}.
     11099@end quotation
     11100@end cartouche
     11101
     11102To be useful, loaded objects must be able to interact with GNU
     11103@code{make}.  This interaction includes both interfaces the loaded
     11104object provides to makefiles and also interfaces @code{make} provides
     11105to the loaded object to manipulate @code{make}'s operation.
     11106
     11107The interface between loaded objects and @code{make} is defined by the
     11108@file{gnumake.h} C header file.  All loaded objects written in C
     11109should include this header file.  Any loaded object not written in C
     11110will need to implement the interface defined in this header file.
     11111
     11112Typically, a loaded object will register one or more new GNU
     11113@code{make} functions using the @code{gmk_add_function} routine from
     11114within its setup function.  The implementations of these @code{make}
     11115functions may make use of the @code{gmk_expand} and @code{gmk_eval}
     11116routines to perform their tasks, then optionally return a string as
     11117the result of the function expansion.
     11118
     11119@subsubheading Loaded Object Licensing
     11120@cindex loaded object licensing
     11121@cindex plugin_is_GPL_compatible
     11122
     11123Every dynamic extension should define the global symbol
     11124@code{plugin_is_GPL_compatible} to assert that it has been licensed
     11125under a GPL-compatible license.  If this symbol does not exist,
     11126@code{make} emits a fatal error and exits when it tries to load your
     11127extension.
     11128
     11129The declared type of the symbol should be @code{int}. It does not need
     11130to be in any allocated section, though.  The code merely asserts that
     11131the symbol exists in the global scope. Something like this is enough:
     11132
     11133@example
     11134int plugin_is_GPL_compatible;
     11135@end example
     11136
     11137@subsubheading Data Structures
     11138
     11139@table @code
     11140@item gmk_floc
     11141This structure represents a filename/location pair.  It is provided
     11142when defining items, so GNU @code{make} can inform the user later
     11143where the definition occurred if necessary.
     11144@end table
     11145
     11146@subsubheading Registering Functions
     11147@findex gmk_add_function
     11148
     11149There is currently one way for makefiles to invoke operations provided
     11150by the loaded object: through the @code{make} function call
     11151interface.  A loaded object can register one or more new functions
     11152which may then be invoked from within the makefile in the same way as
     11153any other function.
     11154
     11155Use @code{gmk_add_function} to create a new @code{make} function.  Its
     11156arguments are as follows:
     11157
     11158@table @code
     11159@item name
     11160The function name.  This is what the makefile should use to invoke the
     11161function.  The name must be between 1 and 255 characters long and it
     11162may only contain alphanumeric, period (@samp{.}), dash (@samp{-}), and
     11163underscore (@samp{_}) characters.  It may not begin with a period.
     11164
     11165@item func_ptr
     11166A pointer to a function that @code{make} will invoke when it expands
     11167the function in a makefile.  This function must be defined by the
     11168loaded object.
     11169
     11170@item min_args
     11171The minimum number of arguments the function will accept.  Must be
     11172between 0 and 255.  GNU @code{make} will check this and fail before
     11173invoking @code{func_ptr} if the function was invoked with too few
     11174arguments.
     11175
     11176@item max_args
     11177The maximum number of arguments the function will accept.  Must be
     11178between 0 and 255.  GNU @code{make} will check this and fail before
     11179invoking @code{func_ptr} if the function was invoked with too few
     11180arguments.  If the value is 0, then any number of arguments is
     11181accepted.  If the value is greater than 0, then it must be greater
     11182than or equal to @code{min_args}.
     11183
     11184@item flags
     11185Flags that specify how this function will operate; the desired flags
     11186should be OR'd together.  If the @code{GMK_FUNC_NOEXPAND} flag is
     11187given then the function arguments will not be expanded before the
     11188function is called; otherwise they will be expanded first.
     11189@end table
     11190
     11191@subsubheading Registered Function Interface
     11192@findex gmk_func_ptr
     11193
     11194A function registered with @code{make} must match the
     11195@code{gmk_func_ptr} type.  It will be invoked with three parameters:
     11196@code{name} (the name of the function), @code{argc} (the number of
     11197arguments to the function), and @code{argv} (an array of pointers to
     11198arguments to the function).  The last pointer (that is,
     11199@code{argv[argc]}) will be null (@code{0}).
     11200
     11201The return value of the function is the result of expanding the
     11202function.  If the function expands to nothing the return value may be
     11203null.  Otherwise, it must be a pointer to a string created with
     11204@code{gmk_alloc}.  Once the function returns, @code{make} owns this
     11205string and will free it when appropriate; it cannot be accessed by the
     11206loaded object.
     11207
     11208@subsubheading GNU @code{make} Facilities
     11209
     11210There are some facilities exported by GNU @code{make} for use by
     11211loaded objects.  Typically these would be run from within the
     11212setup function and/or the functions registered via
     11213@code{gmk_add_function}, to retrieve or modify the data @code{make}
     11214works with.
     11215
     11216@table @code
     11217@item gmk_expand
     11218@findex gmk_expand
     11219This function takes a string and expands it using @code{make}
     11220expansion rules.  The result of the expansion is returned in a
     11221nil-terminated string buffer.  The caller is responsible for calling
     11222@code{gmk_free} with a pointer to the returned buffer when done.
     11223
     11224@item gmk_eval
     11225@findex gmk_eval
     11226This function takes a buffer and evaluates it as a segment of makefile
     11227syntax.  This function can be used to define new variables, new rules,
     11228etc.  It is equivalent to using the @code{eval} @code{make} function.
     11229@end table
     11230
     11231Note that there is a difference between @code{gmk_eval} and calling
     11232@code{gmk_expand} with a string using the @code{eval} function: in
     11233the latter case the string will be expanded @emph{twice}; once by
     11234@code{gmk_expand} and then again by the @code{eval} function.  Using
     11235@code{gmk_eval} the buffer is only expanded once, at most (as it's
     11236read by the @code{make} parser).
     11237
     11238@subsubheading Memory Management
     11239
     11240Some systems allow for different memory management schemes.  Thus you
     11241should never pass memory that you've allocated directly to any
     11242@code{make} function, nor should you attempt to directly free any
     11243memory returned to you by any @code{make} function.  Instead, use the
     11244@code{gmk_alloc} and @code{gmk_free} functions.
     11245
     11246In particular, the string returned to @code{make} by a function
     11247registered using @code{gmk_add_function} @emph{must} be allocated
     11248using @code{gmk_alloc}, and the string returned from the @code{make}
     11249@code{gmk_expand} function @emph{must} be freed (when no longer
     11250needed) using @code{gmk_free}.
     11251
     11252@table @code
     11253@item gmk_alloc
     11254@findex gmk_alloc
     11255Return a pointer to a newly-allocated buffer.  This function will
     11256always return a valid pointer; if not enough memory is available
     11257@code{make} will exit.
     11258
     11259@item gmk_free
     11260@findex gmk_free
     11261Free a buffer returned to you by @code{make}.  Once the
     11262@code{gmk_free} function returns the string will no longer be valid.
     11263@end table
     11264
     11265@node Loaded Object Example,  , Loaded Object API, Loading Objects
     11266@subsection Example Loaded Object
     11267@cindex loaded object example
     11268@cindex example of loaded objects
     11269
     11270Let's suppose we wanted to write a new GNU @code{make} function that
     11271would create a temporary file and return its name.  We would like our
     11272function to take a prefix as an argument.  First we can write the
     11273function in a file @file{mk_temp.c}:
     11274
     11275@example
     11276@group
     11277#include <stdlib.h>
     11278#include <stdlib.h>
     11279#include <stdio.h>
     11280#include <string.h>
     11281#include <unistd.h>
     11282#include <errno.h>
     11283
     11284#include <gnumake.h>
     11285
     11286int plugin_is_GPL_compatible;
     11287
     11288char *
     11289gen_tmpfile(const char *nm, int argc, char **argv)
     11290@{
     11291  int fd;
     11292
     11293  /* Compute the size of the filename and allocate space for it.  */
     11294  int len = strlen (argv[0]) + 6 + 1;
     11295  char *buf = gmk_alloc (len);
     11296
     11297  strcpy (buf, argv[0]);
     11298  strcat (buf, "XXXXXX");
     11299
     11300  fd = mkstemp(buf);
     11301  if (fd >= 0)
     11302    @{
     11303      /* Don't leak the file descriptor.  */
     11304      close (fd);
     11305      return buf;
     11306    @}
     11307
     11308  /* Failure.  */
     11309  fprintf (stderr, "mkstemp(%s) failed: %s\n", buf, strerror (errno));
     11310  gmk_free (buf);
     11311  return NULL;
     11312@}
     11313
     11314int
     11315mk_temp_gmk_setup ()
     11316@{
     11317  /* Register the function with make name "mk-temp".  */
     11318  gmk_add_function ("mk-temp", gen_tmpfile, 1, 1, 1);
     11319  return 1;
     11320@}
     11321@end group
     11322@end example
     11323
     11324Next, we will write a makefile that can build this shared object, load
     11325it, and use it:
     11326
     11327@example
     11328@group
     11329all:
     11330        @@echo Temporary file: $(mk-temp tmpfile.)
     11331
     11332load mk_temp.so
     11333
     11334mk_temp.so: mk_temp.c
     11335        $(CC) -shared -fPIC -o $@ $<
     11336@end group
     11337@end example
     11338
     11339On MS-Windows, due to peculiarities of how shared objects are
     11340produced, the compiler needs to scan the @dfn{import library} produced
     11341when building @code{make}, typically called
     11342@file{libgnumake-@var{version}.dll.a}, where @var{version} is the
     11343version of the load object API.  So the recipe to produce a shared
     11344object will look on Windows like this (assuming the API version is 1):
     11345
     11346@example
     11347@group
     11348mk_temp.dll: mk_temp.c
     11349        $(CC) -shared -o $@ $< -lgnumake-1
     11350@end group
     11351@end example
     11352
     11353Now when you run @code{make} you'll see something like:
     11354
     11355@example
     11356$ make
     11357cc -shared -fPIC -o mk_temp.so mk_temp.c
     11358Temporary filename: tmpfile.A7JEwd
     11359@end example
     11360
     11361@node Integrating make, Features, Extending make, Top
     11362@chapter Integrating GNU @code{make}
     11363@cindex make integration
     11364
     11365GNU @code{make} is often one component in a larger system of tools,
     11366including integrated development environments, compiler toolchains,
     11367and others.  The role of @code{make} is to start commands and
     11368determine whether they succeeded or not: no special integration is
     11369needed to accomplish that.  However, sometimes it is convenient to
     11370bind @code{make} more tightly with other parts of the system, both
     11371higher-level (tools that invoke @code{make}) and lower-level (tools
     11372that @code{make} invokes).
     11373
     11374@menu
     11375* Job Slots::                   Share job slots with GNU @code{make}.
     11376* Terminal Output::             Control output to terminals.
     11377@end menu
     11378
     11379@node Job Slots, Terminal Output, Integrating make, Integrating make
     11380@section Sharing Job Slots with GNU @code{make}
     11381@cindex job slots, sharing
     11382@cindex tools, sharing job slots
     11383
     11384GNU @code{make} has the ability to run multiple recipes in parallel
     11385(@pxref{Parallel, ,Parallel Execution}) and to cap the total number of
     11386parallel jobs even across recursive invocations of @code{make}
     11387(@pxref{Options/Recursion, ,Communicating Options to a
     11388Sub-@code{make}}).  Tools that @code{make} invokes which are also able
     11389to run multiple operations in parallel, either using multiple threads
     11390or multiple processes, can be enhanced to participate in GNU
     11391@code{make}'s job management facility to ensure that the total number
     11392of active threads/processes running on the system does not exceed the
     11393maximum number of slots provided to GNU @code{make}. @refill
     11394
     11395@cindex jobserver
     11396GNU @code{make} uses a method called the ``jobserver'' to control the
     11397number of active jobs across recursive invocations.  The actual
     11398implementation of the jobserver varies across different operating
     11399systems, but some fundamental aspects are always true.
     11400
     11401First, only command lines that @code{make} understands to be recursive
     11402invocations of @code{make} (@pxref{MAKE Variable, ,How the @code{MAKE}
     11403Variable Works}) will have access to the jobserver.  When writing
     11404makefiles you must be sure to mark the command as recursive (most
     11405commonly by prefixing the command line with the @code{+} indicator
     11406(@pxref{Recursion, ,Recursive Use of @code{make}}).
     11407
     11408Second, @code{make} will provide information necessary for accessing
     11409the jobserver through the environment to its children, in the
     11410@code{MAKEFLAGS} environment variable.  Tools which want to
     11411participate in the jobserver protocol will need to parse this
     11412environment variable, as described in subsequent sections.
     11413
     11414Third, every command @code{make} starts has one implicit job slot
     11415reserved for it before it starts.  Any tool which wants to participate
     11416in the jobserver protocol should assume it can always run one job
     11417without having to contact the jobserver at all.
     11418
     11419Finally, it's critical that tools that participate in the jobserver
     11420protocol return the exact number of slots they obtained from the
     11421jobserver back to the jobserver before they exit, even under error
     11422conditions.  Remember that the implicit job slot should @strong{not}
     11423be returned to the jobserver!  Returning too few slots means that
     11424those slots will be lost for the rest of the build process; returning
     11425too many slots means that extra slots will be available.  The
     11426top-level @code{make} command will print an error message at the end
     11427of the build if it detects an incorrect number of slots available in
     11428the jobserver.
     11429
     11430As an example, suppose you are implementing a linker which provides
     11431for multithreaded operation.  You would like to enhance the linker so
     11432that if it is invoked by GNU @code{make} it can participate in the
     11433jobserver protocol to control how many threads are used during link.
     11434First you will need to modify the linker to determine if the
     11435@code{MAKEFLAGS} environment variable is set.  Next you will need to
     11436parse the value of that variable to determine if the jobserver is
     11437available, and how to access it.  If it is available then you can
     11438access it to obtain job slots controlling how much parallelism your
     11439tool can use.  Once done your tool must return those job slots back to
     11440the jobserver.
     11441
     11442@menu
     11443* POSIX Jobserver::             Using the jobserver on POSIX systems.
     11444* Windows Jobserver::           Using the jobserver on Windows systems.
     11445@end menu
     11446
     11447@node POSIX Jobserver, Windows Jobserver, Job Slots, Job Slots
     11448@subsection POSIX Jobserver Interaction
     11449@cindex jobserver on POSIX
     11450
     11451On POSIX systems the jobserver is implemented as a simple UNIX pipe.
     11452The pipe will be pre-loaded with one single-character token for each
     11453available job.  To obtain an extra slot you must read a single
     11454character from the jobserver pipe; to release a slot you must write a
     11455single character back into the jobserver pipe.
     11456
     11457To access the pipe you must parse the @code{MAKEFLAGS} variable and
     11458look for the argument string @code{--jobserver-auth=R,W} where
     11459@samp{R} and @samp{W} are non-negative integers representing file
     11460descriptors: @samp{R} is the read file descriptor and @samp{W} is the
     11461write file descriptor.
     11462
     11463It's important that when you release the job slot, you write back the
     11464same character you read from the pipe for that slot.  Don't assume
     11465that all tokens are the same character; different characters may have
     11466different meanings to GNU @code{make}.  The order is not important,
     11467since @code{make} has no idea in what order jobs will complete anyway.
     11468
     11469There are various error conditions you must consider to ensure your
     11470implementation is robust:
     11471
     11472@itemize @bullet
     11473@item
     11474Usually you will have a command-line argument controlling the parallel
     11475operation of your tool.  Consider whether your tool should detect
     11476situations where both the jobserver and the command-line argument are
     11477specified, and how it should react.
     11478
     11479@item
     11480If your tool determines that the @code{--jobserver-auth} option is
     11481available in @code{MAKEFLAGS} but that the file descriptors specified
     11482are closed, this means that the calling @code{make} process did not
     11483think that your tool was a recursive @code{make} invocation (e.g., the
     11484command line was not prefixed with a @code{+} character).  You should
     11485notify your users of this situation.
     11486
     11487@item
     11488Your tool should also examine the first word of the @code{MAKEFLAGS}
     11489variable and look for the character @code{n}.  If this character is
     11490present then @code{make} was invoked with the @samp{-n} option and
     11491your tool should stop without performing any operations.
     11492
     11493@item
     11494Your tool should be sure to write back the tokens it read, even under
     11495error conditions.  This includes not only errors in your tool but also
     11496outside influences such as interrupts (@code{SIGINT}), etc.  You may
     11497want to install signal handlers to manage this write-back.
     11498@end itemize
     11499
     11500@node Windows Jobserver,  , POSIX Jobserver, Job Slots
     11501@subsection Windows Jobserver Interaction
     11502@cindex jobserver on Windows
     11503
     11504On Windows systems the jobserver is implemented as a named semaphore.
     11505The semaphore will be set with an initial count equal to the number of
     11506available slots; to obtain a slot you must wait on the semaphore (with
     11507or without a timeout).  To release a slot, release the semaphore.
     11508
     11509To access the semaphore you must parse the @code{MAKEFLAGS} variable and
     11510look for the argument string @code{--jobserver-auth=NAME} where
     11511@samp{NAME} is the name of the named semaphore.  Use this name with
     11512@code{OpenSemaphore} to create a handle to the semaphore.
     11513
     11514There are various error conditions you must consider to ensure your
     11515implementation is robust:
     11516
     11517@itemize @bullet
     11518@item
     11519Usually you will have a command-line argument controlling the parallel
     11520operation of your tool.  Consider whether your tool should detect
     11521situations where both the jobserver and the command-line argument are
     11522specified, and how it should react.
     11523
     11524@item
     11525Your tool should be sure to release the semaphore for the tokens it
     11526read, even under error conditions.  This includes not only errors in
     11527your tool but also outside influences such as interrupts
     11528(@code{SIGINT}), etc.  You may want to install signal handlers to
     11529manage this write-back.
     11530@end itemize
     11531
     11532@node Terminal Output,  , Job Slots, Integrating make
     11533@section Synchronized Terminal Output
     11534@cindex parallel output to terminal
     11535@cindex terminal, output to
     11536
     11537Normally GNU @code{make} will invoke all commands with access to the
     11538same standard and error outputs that @code{make} itself was started
     11539with.  A number of tools will detect whether the output is a terminal
     11540or not-a-terminal, and use this information to change the output
     11541style.  For example if the output goes to a terminal the tool may add
     11542control characters that set color, or even change the location of the
     11543cursor.  If the output is not going to a terminal then these special
     11544control characters are not emitted so that they don't corrupt log
     11545files, etc.
     11546
     11547The @code{--output-sync} (@pxref{Parallel Output, ,Output During
     11548Parallel Output}) option will defeat the terminal detection.  When
     11549output synchronization is enabled GNU @code{make} arranges for all
     11550command output to be written to a file, so that its output can be
     11551written as a block without interference from other commands.  This
     11552means that all tools invoked by @code{make} will believe that their
     11553output is not going to be displayed on a terminal, even when it will
     11554be (because @code{make} will display it there after the command is
     11555completed).
     11556
     11557In order to facilitate tools which would like to determine whether or
     11558not their output will be displayed on a terminal, GNU @code{make} will
     11559set the @code{MAKE_TERMOUT} and @code{MAKE_TERMERR} environment
     11560variables before invoking any commands.  Tools which would like to
     11561determine whether standard or error output (respectively) will be
     11562displayed on a terminal can check these environment variables to
     11563determine if they exist and contain a non-empty value.  If so the tool
     11564can assume that the output will (eventually) be displayed on a
     11565terminal.  If the variables are not set or have an empty value, then
     11566the tool should fall back to its normal methods of detecting whether
     11567output is going to a terminal or not.
     11568
     11569The content of the variables can be parsed to determine the type of
     11570terminal which will be used to display the output.
     11571
     11572Similarly, environments which invoke @code{make} and would like to
     11573capture the output and eventually display it on a terminal (or some
     11574display which can interpret terminal control characters) can set these
     11575variables before invoking @code{make}.  GNU @code{make} will not
     11576modify these environment variables if they already exist when it
     11577starts.
     11578
     11579@node Features, Missing, Integrating make, Top
    1028611580@chapter Features of GNU @code{make}
    1028711581@cindex features of GNU @code{make}
     
    1035011644
    1035111645@item
    10352 The arrangement of lines and backslash-newline combinations in
     11646The arrangement of lines and backslash/newline combinations in
    1035311647recipes is retained when the recipes are printed, so they appear as
    1035411648they do in the makefile, except for the stripping of initial
     
    1039311687
    1039411688@item
     11689A number of different build tools that support parallelism also
     11690support collecting output and displaying as a single block.
     11691@xref{Parallel Output, ,Output During Parallel Execution}.
     11692
     11693@item
    1039511694Modified variable references using pattern substitution come from
    1039611695SunOS 4.  @xref{Reference, ,Basics of Variable References}.
     
    1042111720@code{-include} directive.)  The same feature appears with the name
    1042211721@code{sinclude} in SGI @code{make} and perhaps others.
     11722
     11723@item
     11724The @code{!=} shell assignment operator exists in many BSD of
     11725@code{make} and is purposefully implemented here to behave identically
     11726to those implementations.
     11727
     11728@item
     11729Various build management tools are implemented using scripting
     11730languages such as Perl or Python and thus provide a natural embedded
     11731scripting language, similar to GNU @code{make}'s integration of GNU
     11732Guile.
    1042311733@end itemize
    1042411734
     
    1052411834@item
    1052511835Various new built-in implicit rules.
    10526 @xref{Catalogue of Rules, ,Catalogue of Implicit Rules}.
     11836@xref{Catalogue of Rules, ,Catalogue of Built-In Rules}.
    1052711837
    1052811838@item
    10529 The built-in variable @samp{MAKE_VERSION} gives the version number of
    10530 @code{make}.
    10531 @vindex MAKE_VERSION
     11839Load dynamic objects which can modify the behavior of @code{make}.
     11840@xref{Loading Objects, ,Loading Dynamic Objects}.
    1053211841@end itemize
    1053311842
     
    1055011859
    1055111860This feature was not put into GNU @code{make} because of the
    10552 nonmodularity of putting knowledge into @code{make} of the internal
     11861non-modularity of putting knowledge into @code{make} of the internal
    1055311862format of archive file symbol tables.
    1055411863@xref{Archive Symbols, ,Updating Archive Symbol Directories}.
     
    1064811957This appendix summarizes the directives, text manipulation functions,
    1064911958and special variables which GNU @code{make} understands.
    10650 @xref{Special Targets}, @ref{Catalogue of Rules, ,Catalogue of Implicit Rules},
     11959@xref{Special Targets}, @ref{Catalogue of Rules, ,Catalogue of Built-In Rules},
    1065111960and @ref{Options Summary, ,Summary of Options},
    1065211961for other summaries.
     
    1065811967@itemx define @var{variable} =
    1065911968@itemx define @var{variable} :=
     11969@itemx define @var{variable} ::=
    1066011970@itemx define @var{variable} +=
    1066111971@itemx define @var{variable} ?=
     
    1087212182@xref{Eval Function, ,The @code{eval} Function}.
    1087312183
     12184@item $(file @var{op} @var{filename},@var{text})
     12185Expand the arguments, then open the file @var{filename} using mode
     12186@var{op} and write @var{text} to that file.@*
     12187@xref{File Function, ,The @code{file} Function}.
     12188
    1087412189@item $(value @var{var})
    1087512190Evaluates to the contents of the variable @var{var}, with no expansion
     
    1097112286@code{MAKE} Variable Works}.
    1097212287
     12288@item MAKE_VERSION
     12289
     12290The built-in variable @samp{MAKE_VERSION} expands to the version
     12291number of the GNU @code{make} program.
     12292@vindex MAKE_VERSION
     12293
     12294@item MAKE_HOST
     12295
     12296The built-in variable @samp{MAKE_HOST} expands to a string
     12297representing the host that GNU @code{make} was built to run on.
     12298@vindex MAKE_HOST
     12299
    1097312300@item MAKELEVEL
    1097412301
     
    1098712314through the environment from its parent.
    1098812315
     12316@item GNUMAKEFLAGS
     12317
     12318Other flags parsed by @code{make}.  You can set this in the environment or
     12319a makefile to set @code{make} command-line flags.  GNU @code{make}
     12320never sets this variable itself.  This variable is only needed if
     12321you'd like to set GNU @code{make}-specific flags in a POSIX-compliant
     12322makefile.  This variable will be seen by GNU @code{make} and ignored
     12323by other @code{make} implementations.  It's not needed if you only use
     12324GNU @code{make}; just use @code{MAKEFLAGS} directly.
     12325@xref{Options/Recursion, ,Communicating Options to a Sub-@code{make}}.
     12326
    1098912327@item MAKECMDGOALS
    1099012328
     
    1099512333@item CURDIR
    1099612334
    10997 Set to the pathname of the current working directory (after all
    10998 @code{-C} options are processed, if any).  Setting this variable has no
    10999 effect on the operation of @code{make}.@*
     12335Set to the absolute pathname of the current working directory (after
     12336all @code{-C} options are processed, if any).  Setting this variable
     12337has no effect on the operation of @code{make}.@*
    1100012338@xref{Recursion, ,Recursive Use of @code{make}}.
    1100112339
     
    1102512363Error messages are all either prefixed with the name of the program
    1102612364(usually @samp{make}), or, if the error is found in a makefile, the name
    11027 of the file and linenumber containing the problem.
     12365of the file and line number containing the problem.
    1102812366
    1102912367In the table below, these common prefixes are left off.
     
    1103912377signal of some type).  @xref{Errors, ,Errors in Recipes}.
    1104012378
    11041 If no @code{***} is attached to the message, then the subprocess failed
     12379If no @code{***} is attached to the message, then the sub-process failed
    1104212380but the rule in the makefile was prefixed with the @code{-} special
    1104312381character, so @code{make} ignored the error.
     
    1107912417If you want that file to be built, you will need to add a rule to your
    1108012418makefile describing how that target can be built.  Other possible
    11081 sources of this problem are typos in the makefile (if that filename is
     12419sources of this problem are typos in the makefile (if that file name is
    1108212420wrong) or a corrupted source tree (if that file is not supposed to be
    1108312421built, but rather only a prerequisite).
     
    1111312451This means you've defined a normal (recursive) @code{make} variable
    1111412452@var{xxx} that, when it's expanded, will refer to itself (@var{xxx}).
    11115 This is not allowed; either use simply-expanded variables (@code{:=}) or
    11116 use the append operator (@code{+=}).  @xref{Using Variables, ,How to Use
    11117 Variables}.
     12453This is not allowed; either use simply-expanded variables (@samp{:=}
     12454or @samp{::=}) or use the append operator (@samp{+=}).  @xref{Using
     12455Variables, ,How to Use Variables}.
    1111812456
    1111912457@item Unterminated variable reference.  Stop.
     
    1113012468@itemx target pattern contains no `%'.  Stop.
    1113112469@itemx mixed implicit and static pattern rules.  Stop.
    11132 These are generated for malformed static pattern rules.  The first means
    11133 there's no pattern in the target section of the rule; the second means
    11134 there are multiple patterns in the target section; the third means
    11135 the target doesn't contain a pattern character (@code{%}); and the
    11136 fourth means that all three parts of the static pattern rule contain
    11137 pattern characters (@code{%})--only the first two parts should.
     12470These are generated for malformed static pattern rules.  The first
     12471means there's no pattern in the target section of the rule; the second
     12472means there are multiple patterns in the target section; the third
     12473means the target doesn't contain a pattern character (@code{%}); and
     12474the fourth means that all three parts of the static pattern rule
     12475contain pattern characters (@code{%})--only the first two parts
     12476should.  If you see these errors and you aren't trying to create a
     12477static pattern rule, check the value of any variables in your target
     12478and prerequisite lists to be sure they do not contain colons.
    1113812479@xref{Static Usage, ,Syntax of Static Pattern Rules}.
    1113912480
     
    1116812509
    1116912510Here is the makefile for the GNU @code{tar} program.  This is a
    11170 moderately complex makefile.
     12511moderately complex makefile.  The first line uses a @code{#!} setting
     12512to allow the makefile to be executed directly.
    1117112513
    1117212514Because it is the first target, the default goal is @samp{all}.  An
     
    1120412546@example
    1120512547@group
     12548#!/usr/bin/make -f
    1120612549# Generated automatically from Makefile.in by configure.
    1120712550# Un*x Makefile for GNU tar program.
  • vendor/gnumake/current/dosbuild.bat

    r2596 r3138  
    11@echo off
    2 rem Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
    3 rem 2008, 2009, 2010 Free Software Foundation, Inc.
     2rem Copyright (C) 1998-2016 Free Software Foundation, Inc.
    43rem This file is part of GNU Make.
    54rem
     
    2221@echo on
    2322gcc  -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g commands.c -o commands.o
     23gcc  -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g output.c -o output.o
    2424gcc  -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g job.c -o job.o
    2525gcc  -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g dir.c -o dir.o
     
    5353cd ..
    5454echo commands.o > respf.$$$
    55 for %%f in (job dir file misc main read remake rule implicit default variable) do echo %%f.o >> respf.$$$
     55for %%f in (job output dir file misc main read remake rule implicit default variable) do echo %%f.o >> respf.$$$
    5656for %%f in (expand function vpath hash strcache version ar arscan signame remote-stub getopt getopt1) do echo %%f.o >> respf.$$$
    5757echo glob/libglob.a >> respf.$$$
     58rem gcc  -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g guile.c -o guile.o
     59rem echo guile.o >> respf.$$$
    5860@echo Linking...
    5961@echo on
  • vendor/gnumake/current/expand.c

    r2596 r3138  
    11/* Variable expansion functions for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018
    2119#include <assert.h>
     
    2927/* Initially, any errors reported when expanding strings will be reported
    3028   against the file where the error appears.  */
    31 const struct floc **expanding_var = &reading_file;
     29const floc **expanding_var = &reading_file;
    3230
    3331/* The next two describe the variable output buffer.
     
    6462      unsigned int offset = ptr - variable_buffer;
    6563      variable_buffer_length = (newlen + 100 > 2 * variable_buffer_length
    66                                 ? newlen + 100
    67                                 : 2 * variable_buffer_length);
     64                                ? newlen + 100
     65                                : 2 * variable_buffer_length);
    6866      variable_buffer = xrealloc (variable_buffer, variable_buffer_length);
    6967      ptr = variable_buffer + offset;
     
    10098{
    10199  char *value;
    102   const struct floc *this_var;
    103   const struct floc **saved_varp;
     100  const floc *this_var;
     101  const floc **saved_varp;
    104102  struct variable_set_list *save = 0;
    105103  int set_reading = 0;
     
    125123      if (!v->exp_count)
    126124        /* Expanding V causes infinite recursion.  Lose.  */
    127         fatal (*expanding_var,
    128                _("Recursive variable `%s' references itself (eventually)"),
    129                v->name);
     125        OS (fatal, *expanding_var,
     126            _("Recursive variable '%s' references itself (eventually)"),
     127            v->name);
    130128      --v->exp_count;
    131129    }
     
    190188   a null byte is found.
    191189
    192    Write the results to LINE, which must point into `variable_buffer'.  If
     190   Write the results to LINE, which must point into 'variable_buffer'.  If
    193191   LINE is NULL, start at the beginning of the buffer.
    194192   Return a pointer to LINE, or to the beginning of the buffer if LINE is
     
    200198  struct variable *v;
    201199  const char *p, *p1;
    202   char *abuf = NULL;
     200  char *save;
    203201  char *o;
    204202  unsigned int line_offset;
    205203
    206204  if (!line)
    207     line = initialize_variable_output();
     205    line = initialize_variable_output ();
    208206  o = line;
    209207  line_offset = line - variable_buffer;
     
    215213    }
    216214
    217   /* If we want a subset of the string, allocate a temporary buffer for it.
    218      Most of the functions we use here don't work with length limits.  */
    219   if (length > 0 && string[length] != '\0')
    220     {
    221       abuf = xmalloc(length+1);
    222       memcpy(abuf, string, length);
    223       abuf[length] = '\0';
    224       string = abuf;
    225     }
    226   p = string;
     215  /* We need a copy of STRING: due to eval, it's possible that it will get
     216     freed as we process it (it might be the value of a variable that's reset
     217     for example).  Also having a nil-terminated string is handy.  */
     218  save = length < 0 ? xstrdup (string) : xstrndup (string, length);
     219  p = save;
    227220
    228221  while (1)
     
    230223      /* Copy all following uninteresting chars all at once to the
    231224         variable output buffer, and skip them.  Uninteresting chars end
    232         at the next $ or the end of the input.  */
     225        at the next $ or the end of the input.  */
    233226
    234227      p1 = strchr (p, '$');
     
    237230
    238231      if (p1 == 0)
    239         break;
     232        break;
    240233      p = p1 + 1;
    241234
     
    243236
    244237      switch (*p)
    245         {
    246         case '$':
    247           /* $$ seen means output one $ to the variable output buffer.  */
    248           o = variable_buffer_output (o, p, 1);
    249           break;
    250 
    251         case '(':
    252         case '{':
    253           /* $(...) or ${...} is the general case of substitution.  */
    254           {
    255             char openparen = *p;
    256             char closeparen = (openparen == '(') ? ')' : '}';
     238        {
     239        case '$':
     240        case '\0':
     241          /* $$ or $ at the end of the string means output one $ to the
     242             variable output buffer.  */
     243          o = variable_buffer_output (o, p1, 1);
     244          break;
     245
     246        case '(':
     247        case '{':
     248          /* $(...) or ${...} is the general case of substitution.  */
     249          {
     250            char openparen = *p;
     251            char closeparen = (openparen == '(') ? ')' : '}';
    257252            const char *begp;
    258             const char *beg = p + 1;
    259             char *op;
     253            const char *beg = p + 1;
     254            char *op;
    260255            char *abeg = NULL;
    261             const char *end, *colon;
    262 
    263             op = o;
    264             begp = p;
    265             if (handle_function (&op, &begp))
    266               {
    267                 o = op;
    268                 p = begp;
    269                 break;
    270               }
    271 
    272             /* Is there a variable reference inside the parens or braces?
    273                If so, expand it before expanding the entire reference.  */
    274 
    275             end = strchr (beg, closeparen);
    276             if (end == 0)
     256            const char *end, *colon;
     257
     258            op = o;
     259            begp = p;
     260            if (handle_function (&op, &begp))
     261              {
     262                o = op;
     263                p = begp;
     264                break;
     265              }
     266
     267            /* Is there a variable reference inside the parens or braces?
     268               If so, expand it before expanding the entire reference.  */
     269
     270            end = strchr (beg, closeparen);
     271            if (end == 0)
    277272              /* Unterminated variable reference.  */
    278               fatal (*expanding_var, _("unterminated variable reference"));
    279             p1 = lindex (beg, end, '$');
    280             if (p1 != 0)
    281               {
    282                 /* BEG now points past the opening paren or brace.
    283                    Count parens or braces until it is matched.  */
    284                 int count = 0;
    285                 for (p = beg; *p != '\0'; ++p)
    286                   {
    287                     if (*p == openparen)
    288                       ++count;
    289                     else if (*p == closeparen && --count < 0)
    290                       break;
    291                   }
    292                 /* If COUNT is >= 0, there were unmatched opening parens
    293                    or braces, so we go to the simple case of a variable name
    294                    such as `$($(a)'.  */
    295                 if (count < 0)
    296                   {
    297                     abeg = expand_argument (beg, p); /* Expand the name.  */
    298                     beg = abeg;
    299                     end = strchr (beg, '\0');
    300                   }
    301               }
    302             else
    303               /* Advance P to the end of this reference.  After we are
     273              O (fatal, *expanding_var, _("unterminated variable reference"));
     274            p1 = lindex (beg, end, '$');
     275            if (p1 != 0)
     276              {
     277                /* BEG now points past the opening paren or brace.
     278                   Count parens or braces until it is matched.  */
     279                int count = 0;
     280                for (p = beg; *p != '\0'; ++p)
     281                  {
     282                    if (*p == openparen)
     283                      ++count;
     284                    else if (*p == closeparen && --count < 0)
     285                      break;
     286                  }
     287                /* If COUNT is >= 0, there were unmatched opening parens
     288                   or braces, so we go to the simple case of a variable name
     289                   such as '$($(a)'.  */
     290                if (count < 0)
     291                  {
     292                    abeg = expand_argument (beg, p); /* Expand the name.  */
     293                    beg = abeg;
     294                    end = strchr (beg, '\0');
     295                  }
     296              }
     297            else
     298              /* Advance P to the end of this reference.  After we are
    304299                 finished expanding this one, P will be incremented to
    305300                 continue the scan.  */
    306               p = end;
    307 
    308             /* This is not a reference to a built-in function and
    309                any variable references inside are now expanded.
    310                Is the resultant text a substitution reference?  */
    311 
    312             colon = lindex (beg, end, ':');
    313             if (colon)
    314               {
    315                 /* This looks like a substitution reference: $(FOO:A=B).  */
    316                 const char *subst_beg, *subst_end, *replace_beg, *replace_end;
    317 
    318                 subst_beg = colon + 1;
    319                 subst_end = lindex (subst_beg, end, '=');
    320                 if (subst_end == 0)
    321                   /* There is no = in sight.  Punt on the substitution
    322                      reference and treat this as a variable name containing
    323                      a colon, in the code below.  */
    324                   colon = 0;
    325                 else
    326                   {
    327                     replace_beg = subst_end + 1;
    328                     replace_end = end;
    329 
    330                     /* Extract the variable name before the colon
    331                        and look up that variable.  */
    332                     v = lookup_variable (beg, colon - beg);
    333                     if (v == 0)
    334                       warn_undefined (beg, colon - beg);
     301              p = end;
     302
     303            /* This is not a reference to a built-in function and
     304               any variable references inside are now expanded.
     305               Is the resultant text a substitution reference?  */
     306
     307            colon = lindex (beg, end, ':');
     308            if (colon)
     309              {
     310                /* This looks like a substitution reference: $(FOO:A=B).  */
     311                const char *subst_beg = colon + 1;
     312                const char *subst_end = lindex (subst_beg, end, '=');
     313                if (subst_end == 0)
     314                  /* There is no = in sight.  Punt on the substitution
     315                     reference and treat this as a variable name containing
     316                     a colon, in the code below.  */
     317                  colon = 0;
     318                else
     319                  {
     320                    const char *replace_beg = subst_end + 1;
     321                    const char *replace_end = end;
     322
     323                    /* Extract the variable name before the colon
     324                       and look up that variable.  */
     325                    v = lookup_variable (beg, colon - beg);
     326                    if (v == 0)
     327                      warn_undefined (beg, colon - beg);
    335328
    336329                    /* If the variable is not empty, perform the
    337330                       substitution.  */
    338                     if (v != 0 && *v->value != '\0')
    339                       {
    340                         char *pattern, *replace, *ppercent, *rpercent;
    341                         char *value = (v->recursive
     331                    if (v != 0 && *v->value != '\0')
     332                      {
     333                        char *pattern, *replace, *ppercent, *rpercent;
     334                        char *value = (v->recursive
    342335                                       ? recursively_expand (v)
    343                                        : v->value);
     336                                       : v->value);
    344337
    345338                        /* Copy the pattern and the replacement.  Add in an
     
    359352                        /* Look for %.  Set the percent pointers properly
    360353                           based on whether we find one or not.  */
    361                         ppercent = find_percent (pattern);
    362                         if (ppercent)
     354                        ppercent = find_percent (pattern);
     355                        if (ppercent)
    363356                          {
    364357                            ++ppercent;
     
    367360                              ++rpercent;
    368361                          }
    369                         else
     362                        else
    370363                          {
    371364                            ppercent = pattern;
     
    378371                                                 ppercent, rpercent);
    379372
    380                         if (v->recursive)
    381                           free (value);
    382                       }
    383                   }
    384               }
    385 
    386             if (colon == 0)
    387               /* This is an ordinary variable reference.
    388                  Look up the value of the variable.  */
    389                 o = reference_variable (o, beg, end - beg);
    390 
    391           if (abeg)
    392             free (abeg);
    393           }
    394           break;
    395 
    396         case '\0':
    397           break;
    398 
    399         default:
    400           if (isblank ((unsigned char)p[-1]))
    401             break;
    402 
    403           /* A $ followed by a random char is a variable reference:
    404              $a is equivalent to $(a).  */
     373                        if (v->recursive)
     374                          free (value);
     375                      }
     376                  }
     377              }
     378
     379            if (colon == 0)
     380              /* This is an ordinary variable reference.
     381                 Look up the value of the variable.  */
     382                o = reference_variable (o, beg, end - beg);
     383
     384            free (abeg);
     385          }
     386          break;
     387
     388        default:
     389          if (ISSPACE (p[-1]))
     390            break;
     391
     392          /* A $ followed by a random char is a variable reference:
     393             $a is equivalent to $(a).  */
    405394          o = reference_variable (o, p, 1);
    406395
    407           break;
    408         }
     396          break;
     397        }
    409398
    410399      if (*p == '\0')
    411         break;
     400        break;
    412401
    413402      ++p;
    414403    }
    415404
    416   if (abuf)
    417     free (abuf);
     405  free (save);
    418406
    419407  variable_buffer_output (o, "", 1);
     
    423411
    424412/* Scan LINE for variable references and expansion-function calls.
    425    Build in `variable_buffer' the result of expanding the references and calls.
     413   Build in 'variable_buffer' the result of expanding the references and calls.
    426414   Return the address of the resulting string, which is null-terminated
    427415   and is valid only until the next time this function is called.  */
     
    430418variable_expand (const char *line)
    431419{
    432   return variable_expand_string(NULL, line, (long)-1);
     420  return variable_expand_string (NULL, line, (long)-1);
    433421}
    434422
     
    437425   The text starting at STR and ending at END is variable-expanded
    438426   into a null-terminated string that is returned as the value.
    439    This is done without clobbering `variable_buffer' or the current
     427   This is done without clobbering 'variable_buffer' or the current
    440428   variable-expansion that is in progress.  */
    441429
     
    447435
    448436  if (str == end)
    449     return xstrdup("");
     437    return xstrdup ("");
    450438
    451439  if (!end || *end == '\0')
     
    462450  r = allocated_variable_expand (tmp);
    463451
    464   if (alloc)
    465     free (alloc);
     452  free (alloc);
    466453
    467454  return r;
     
    477464  char *result;
    478465  struct variable_set_list *savev;
    479   const struct floc *savef;
     466  const floc *savef;
    480467
    481468  if (file == 0)
     
    506493static char *
    507494variable_append (const char *name, unsigned int length,
    508                  const struct variable_set_list *set)
     495                 const struct variable_set_list *set, int local)
    509496{
    510497  const struct variable *v;
    511498  char *buf = 0;
     499  /* If this set is local and the next is not a parent, then next is local.  */
     500  int nextlocal = local && set->next_is_parent == 0;
    512501
    513502  /* If there's nothing left to check, return the empty buffer.  */
     
    518507  v = lookup_variable_in_set (name, length, set->set);
    519508
    520   /* If there isn't one, look to see if there's one in a set above us.  */
    521   if (!v)
    522     return variable_append (name, length, set->next);
     509  /* If there isn't one, or this one is private, try the set above us.  */
     510  if (!v || (!local && v->private_var))
     511    return variable_append (name, length, set->next, nextlocal);
    523512
    524513  /* If this variable type is append, first get any upper values.
    525514     If not, initialize the buffer.  */
    526515  if (v->append)
    527     buf = variable_append (name, length, set->next);
     516    buf = variable_append (name, length, set->next, nextlocal);
    528517  else
    529518    buf = initialize_variable_output ();
     
    555544  variable_buffer = 0;
    556545
    557   val = variable_append (v->name, strlen (v->name), current_variable_set_list);
     546  val = variable_append (v->name, strlen (v->name),
     547                         current_variable_set_list, 1);
    558548  variable_buffer_output (val, "", 1);
    559549  val = variable_buffer;
  • vendor/gnumake/current/file.c

    r2596 r3138  
    11/* Target file management for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018
    2119#include <assert.h>
    2220
     21#include "filedef.h"
    2322#include "dep.h"
    24 #include "filedef.h"
    2523#include "job.h"
    2624#include "commands.h"
     
    5755{
    5856  return_ISTRING_COMPARE (((struct file const *) x)->hname,
    59                           ((struct file const *) y)->hname);
    60 }
    61 
    62 #ifndef FILE_BUCKETS
    63 #define FILE_BUCKETS    1007
    64 #endif
     57                          ((struct file const *) y)->hname);
     58}
     59
    6560static struct hash_table files;
    6661
     
    7873  struct file *f;
    7974  struct file file_key;
    80 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
     75#ifdef VMS
     76  int want_vmsify;
     77#ifndef WANT_CASE_SENSITIVE_TARGETS
    8178  char *lname;
     79#endif
    8280#endif
    8381
     
    8886     on the command line.  */
    8987#ifdef VMS
     88   want_vmsify = (strpbrk (name, "]>:^") != NULL);
    9089# ifndef WANT_CASE_SENSITIVE_TARGETS
    9190  if (*name != '.')
     
    103102  while (name[0] == '[' && name[1] == ']' && name[2] != '\0')
    104103      name += 2;
     104  while (name[0] == '<' && name[1] == '>' && name[2] != '\0')
     105      name += 2;
    105106#endif
    106107  while (name[0] == '.'
    107108#ifdef HAVE_DOS_PATHS
    108         && (name[1] == '/' || name[1] == '\\')
     109        && (name[1] == '/' || name[1] == '\\')
    109110#else
    110         && name[1] == '/'
     111        && name[1] == '/'
    111112#endif
    112         && name[2] != '\0')
     113        && name[2] != '\0')
    113114    {
    114115      name += 2;
    115116      while (*name == '/'
    116117#ifdef HAVE_DOS_PATHS
    117              || *name == '\\'
     118             || *name == '\\'
    118119#endif
    119              )
    120         /* Skip following slashes: ".//foo" is "foo", not "/foo".  */
    121         ++name;
     120             )
     121        /* Skip following slashes: ".//foo" is "foo", not "/foo".  */
     122        ++name;
    122123    }
    123124
    124125  if (*name == '\0')
    125     /* It was all slashes after a dot.  */
     126    {
     127      /* It was all slashes after a dot.  */
     128#if defined(_AMIGA)
     129      name = "";
     130#else
     131      name = "./";
     132#endif
    126133#if defined(VMS)
    127     name = "[]";
    128 #elif defined(_AMIGA)
    129     name = "";
    130 #else
    131     name = "./";
     134      /* TODO - This section is probably not needed. */
     135      if (want_vmsify)
     136        name = "[]";
    132137#endif
    133 
     138    }
    134139  file_key.hname = name;
    135140  f = hash_find_item (&files, &file_key);
     
    156161
    157162  assert (*name != '\0');
    158   assert (strcache_iscached (name));
     163  assert (! verify_flag || strcache_iscached (name));
    159164
    160165#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
     
    180185  f = *file_slot;
    181186  if (! HASH_VACANT (f) && !f->double_colon)
    182     return f;
     187    {
     188      f->builtin = 0;
     189      return f;
     190    }
    183191
    184192  new = xcalloc (sizeof (struct file));
    185193  new->name = new->hname = name;
    186   new->update_status = -1;
     194  new->update_status = us_none;
    187195
    188196  if (HASH_VACANT (f))
     
    204212
    205213/* Rehash FILE to NAME.  This is not as simple as resetting
    206    the `hname' member, since it must be put in a new hash bucket,
     214   the 'hname' member, since it must be put in a new hash bucket,
    207215   and possibly merged with an existing file called NAME.  */
    208216
     
    217225
    218226  /* If it's already that name, we're done.  */
     227  from_file->builtin = 0;
    219228  file_key.hname = to_hname;
    220229  if (! file_hash_cmp (from_file, &file_key))
     
    261270      else if (from_file->cmds != to_file->cmds)
    262271        {
     272          size_t l = strlen (from_file->name);
    263273          /* We have two sets of commands.  We will go with the
    264274             one given in the rule explicitly mentioning this name,
     
    266276          if (to_file->cmds->fileinfo.filenm != 0)
    267277            error (&from_file->cmds->fileinfo,
    268                    _("Recipe was specified for file `%s' at %s:%lu,"),
     278                   l + strlen (to_file->cmds->fileinfo.filenm) + INTSTR_LENGTH,
     279                   _("Recipe was specified for file '%s' at %s:%lu,"),
    269280                   from_file->name, to_file->cmds->fileinfo.filenm,
    270281                   to_file->cmds->fileinfo.lineno);
    271282          else
    272             error (&from_file->cmds->fileinfo,
    273                    _("Recipe for file `%s' was found by implicit rule search,"),
     283            error (&from_file->cmds->fileinfo, l,
     284                   _("Recipe for file '%s' was found by implicit rule search,"),
    274285                   from_file->name);
    275           error (&from_file->cmds->fileinfo,
    276                  _("but `%s' is now considered the same file as `%s'."),
     286          l += strlen (to_hname);
     287          error (&from_file->cmds->fileinfo, l,
     288                 _("but '%s' is now considered the same file as '%s'."),
    277289                 from_file->name, to_hname);
    278           error (&from_file->cmds->fileinfo,
    279                  _("Recipe for `%s' will be ignored in favor of the one for `%s'."),
     290          error (&from_file->cmds->fileinfo, l,
     291                 _("Recipe for '%s' will be ignored in favor of the one for '%s'."),
    280292                 to_hname, from_file->name);
    281293        }
     
    297309
    298310  if (to_file->double_colon && from_file->is_target && !from_file->double_colon)
    299     fatal (NILF, _("can't rename single-colon `%s' to double-colon `%s'"),
    300            from_file->name, to_hname);
     311    OSS (fatal, NILF, _("can't rename single-colon '%s' to double-colon '%s'"),
     312         from_file->name, to_hname);
    301313  if (!to_file->double_colon  && from_file->double_colon)
    302314    {
    303315      if (to_file->is_target)
    304         fatal (NILF, _("can't rename double-colon `%s' to single-colon `%s'"),
    305                from_file->name, to_hname);
     316        OSS (fatal, NILF,
     317             _("can't rename double-colon '%s' to single-colon '%s'"),
     318             from_file->name, to_hname);
    306319      else
    307320        to_file->double_colon = from_file->double_colon;
     
    322335  MERGE (cmd_target);
    323336  MERGE (phony);
     337  MERGE (loaded);
    324338  MERGE (ignore_vpath);
    325339#undef MERGE
    326340
     341  to_file->builtin = 0;
    327342  from_file->renamed = to_file;
    328343}
    329344
    330345/* Rename FILE to NAME.  This is not as simple as resetting
    331    the `name' member, since it must be put in a new hash bucket,
     346   the 'name' member, since it must be put in a new hash bucket,
    332347   and possibly merged with an existing file called NAME.  */
    333348
     
    368383    if (! HASH_VACANT (*file_slot))
    369384      {
    370         struct file *f = *file_slot;
     385        struct file *f = *file_slot;
    371386        /* Is this file eligible for automatic deletion?
    372387           Yes, IFF: it's marked intermediate, it's not secondary, it wasn't
    373388           given on the command line, and it's either a -include makefile or
    374389           it's not precious.  */
    375         if (f->intermediate && (f->dontcare || !f->precious)
    376             && !f->secondary && !f->cmd_target)
    377           {
    378             int status;
    379             if (f->update_status == -1)
    380               /* If nothing would have created this file yet,
    381                  don't print an "rm" command for it.  */
    382               continue;
    383             if (just_print_flag)
    384               status = 0;
    385             else
    386               {
    387                 status = unlink (f->name);
    388                 if (status < 0 && errno == ENOENT)
    389                   continue;
    390               }
    391             if (!f->dontcare)
    392               {
    393                 if (sig)
    394                   error (NILF, _("*** Deleting intermediate file `%s'"), f->name);
    395                 else
    396                   {
    397                     if (! doneany)
    398                       DB (DB_BASIC, (_("Removing intermediate files...\n")));
    399                     if (!silent_flag)
    400                       {
    401                         if (! doneany)
    402                           {
    403                             fputs ("rm ", stdout);
    404                             doneany = 1;
    405                           }
    406                         else
    407                           putchar (' ');
    408                         fputs (f->name, stdout);
    409                         fflush (stdout);
    410                       }
    411                   }
    412                 if (status < 0)
    413                   perror_with_name ("unlink: ", f->name);
    414               }
    415           }
     390        if (f->intermediate && (f->dontcare || !f->precious)
     391            && !f->secondary && !f->cmd_target)
     392          {
     393            int status;
     394            if (f->update_status == us_none)
     395              /* If nothing would have created this file yet,
     396                 don't print an "rm" command for it.  */
     397              continue;
     398            if (just_print_flag)
     399              status = 0;
     400            else
     401              {
     402                status = unlink (f->name);
     403                if (status < 0 && errno == ENOENT)
     404                  continue;
     405              }
     406            if (!f->dontcare)
     407              {
     408                if (sig)
     409                  OS (error, NILF,
     410                      _("*** Deleting intermediate file '%s'"), f->name);
     411                else
     412                  {
     413                    if (! doneany)
     414                      DB (DB_BASIC, (_("Removing intermediate files...\n")));
     415                    if (!silent_flag)
     416                      {
     417                        if (! doneany)
     418                          {
     419                            fputs ("rm ", stdout);
     420                            doneany = 1;
     421                          }
     422                        else
     423                          putchar (' ');
     424                        fputs (f->name, stdout);
     425                        fflush (stdout);
     426                      }
     427                  }
     428                if (status < 0)
     429                  perror_with_name ("unlink: ", f->name);
     430              }
     431          }
    416432      }
    417433
     
    430446split_prereqs (char *p)
    431447{
    432   struct dep *new = PARSE_FILE_SEQ (&p, struct dep, '|', NULL, 0);
     448  struct dep *new = PARSE_FILE_SEQ (&p, struct dep, MAP_PIPE, NULL,
     449                                    PARSEFS_NONE);
    433450
    434451  if (*p)
     
    439456
    440457      ++p;
    441       ood = PARSE_FILE_SEQ (&p, struct dep, '\0', NULL, 0);
     458      ood = PARSE_SIMPLE_SEQ (&p, struct dep);
    442459
    443460      if (! new)
     
    579596      if (d->staticpattern)
    580597        {
    581           char *o;
    582           d->name = o = variable_expand ("");
     598          char *o = variable_expand ("");
    583599          o = subst_expand (o, name, "%", "$*", 1, 2, 0);
    584600          *o = '\0';
    585601          free (name);
    586           d->name = name = xstrdup (d->name);
     602          d->name = name = xstrdup (variable_buffer);
    587603          d->staticpattern = 0;
    588604        }
     
    641657}
    642658
    643 /* For each dependency of each file, make the `struct dep' point
    644    at the appropriate `struct file' (which may have to be created).
     659/* For each dependency of each file, make the 'struct dep' point
     660   at the appropriate 'struct file' (which may have to be created).
    645661
    646662   Also mark the files depended on by .PRECIOUS, .PHONY, .SILENT,
     
    697713    for (d = f->deps; d != 0; d = d->next)
    698714      for (f2 = d->file; f2 != 0; f2 = f2->prev)
    699         f2->precious = 1;
     715        f2->precious = 1;
    700716
    701717  for (f = lookup_file (".LOW_RESOLUTION_TIME"); f != 0; f = f->prev)
    702718    for (d = f->deps; d != 0; d = d->next)
    703719      for (f2 = d->file; f2 != 0; f2 = f2->prev)
    704         f2->low_resolution_time = 1;
     720        f2->low_resolution_time = 1;
    705721
    706722  for (f = lookup_file (".PHONY"); f != 0; f = f->prev)
    707723    for (d = f->deps; d != 0; d = d->next)
    708724      for (f2 = d->file; f2 != 0; f2 = f2->prev)
    709         {
    710           /* Mark this file as phony nonexistent target.  */
    711           f2->phony = 1;
     725        {
     726          /* Mark this file as phony nonexistent target.  */
     727          f2->phony = 1;
    712728          f2->is_target = 1;
    713           f2->last_mtime = NONEXISTENT_MTIME;
    714           f2->mtime_before_update = NONEXISTENT_MTIME;
    715         }
     729          f2->last_mtime = NONEXISTENT_MTIME;
     730          f2->mtime_before_update = NONEXISTENT_MTIME;
     731        }
    716732
    717733  for (f = lookup_file (".INTERMEDIATE"); f != 0; f = f->prev)
     
    745761    {
    746762      if (f->deps == 0)
    747         ignore_errors_flag = 1;
     763        ignore_errors_flag = 1;
    748764      else
    749         for (d = f->deps; d != 0; d = d->next)
    750           for (f2 = d->file; f2 != 0; f2 = f2->prev)
    751             f2->command_flags |= COMMANDS_NOERROR;
     765        for (d = f->deps; d != 0; d = d->next)
     766          for (f2 = d->file; f2 != 0; f2 = f2->prev)
     767            f2->command_flags |= COMMANDS_NOERROR;
    752768    }
    753769
     
    756772    {
    757773      if (f->deps == 0)
    758         silent_flag = 1;
     774        silent_flag = 1;
    759775      else
    760         for (d = f->deps; d != 0; d = d->next)
    761           for (f2 = d->file; f2 != 0; f2 = f2->prev)
    762             f2->command_flags |= COMMANDS_SILENT;
     776        for (d = f->deps; d != 0; d = d->next)
     777          for (f2 = d->file; f2 != 0; f2 = f2->prev)
     778            f2->command_flags |= COMMANDS_SILENT;
    763779    }
    764780
     
    777793
    778794
    779 /* Set the `command_state' member of FILE and all its `also_make's.  */
     795/* Set the 'command_state' member of FILE and all its 'also_make's.  */
    780796
    781797void
     
    794810
    795811FILE_TIMESTAMP
    796 file_timestamp_cons (const char *fname, time_t s, int ns)
     812file_timestamp_cons (const char *fname, time_t stamp, long int ns)
    797813{
    798814  int offset = ORDINARY_MTIME_MIN + (FILE_TIMESTAMP_HI_RES ? ns : 0);
     815  FILE_TIMESTAMP s = stamp;
    799816  FILE_TIMESTAMP product = (FILE_TIMESTAMP) s << FILE_TIMESTAMP_LO_BITS;
    800817  FILE_TIMESTAMP ts = product + offset;
    801818
    802819  if (! (s <= FILE_TIMESTAMP_S (ORDINARY_MTIME_MAX)
    803         && product <= ts && ts <= ORDINARY_MTIME_MAX))
     820        && product <= ts && ts <= ORDINARY_MTIME_MAX))
    804821    {
    805822      char buf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
     823      const char *f = fname ? fname : _("Current time");
    806824      ts = s <= OLD_MTIME ? ORDINARY_MTIME_MIN : ORDINARY_MTIME_MAX;
    807825      file_timestamp_sprintf (buf, ts);
    808       error (NILF, _("%s: Timestamp out of range; substituting %s"),
    809              fname ? fname : _("Current time"), buf);
     826      OSS (error, NILF,
     827           _("%s: Timestamp out of range; substituting %s"), f, buf);
    810828    }
    811829
     
    832850    if (clock_gettime (CLOCK_REALTIME, &timespec) == 0)
    833851      {
    834         r = 1;
    835         s = timespec.tv_sec;
    836         ns = timespec.tv_nsec;
    837         goto got_time;
     852        r = 1;
     853        s = timespec.tv_sec;
     854        ns = timespec.tv_nsec;
     855        goto got_time;
    838856      }
    839857  }
     
    844862    if (gettimeofday (&timeval, 0) == 0)
    845863      {
    846         r = 1000;
    847         s = timeval.tv_sec;
    848         ns = timeval.tv_usec * 1000;
    849         goto got_time;
     864        r = 1000;
     865        s = timeval.tv_sec;
     866        ns = timeval.tv_usec * 1000;
     867        goto got_time;
    850868      }
    851869  }
     
    874892  if (tm)
    875893    sprintf (p, "%04d-%02d-%02d %02d:%02d:%02d",
    876              tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
    877              tm->tm_hour, tm->tm_min, tm->tm_sec);
     894             tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
     895             tm->tm_hour, tm->tm_min, tm->tm_sec);
    878896  else if (t < 0)
    879897    sprintf (p, "%ld", (long) t);
     
    927945  const struct file *f = item;
    928946
     947  /* If we're not using builtin targets, don't show them.
     948
     949     Ideally we'd be able to delete them altogether but currently there's no
     950     facility to ever delete a file once it's been added.  */
     951  if (no_builtin_rules_flag && f->builtin)
     952    return;
     953
    929954  putchar ('\n');
     955
     956  if (f->cmds && f->cmds->recipe_prefix != cmd_prefix)
     957    {
     958      fputs (".RECIPEPREFIX = ", stdout);
     959      cmd_prefix = f->cmds->recipe_prefix;
     960      if (cmd_prefix != RECIPEPREFIX_DEFAULT)
     961        putchar (cmd_prefix);
     962      putchar ('\n');
     963    }
     964
     965  if (f->variables != 0)
     966    print_target_variables (f);
     967
    930968  if (!f->is_target)
    931969    puts (_("# Not a target:"));
     
    941979  if (f->dontcare)
    942980    puts (_("#  A default, MAKEFILES, or -include/sinclude makefile."));
     981  if (f->builtin)
     982    puts (_("#  Builtin rule"));
    943983  puts (f->tried_implicit
    944984        ? _("#  Implicit rule search has been done.")
    945985        : _("#  Implicit rule search has not been done."));
    946986  if (f->stem != 0)
    947     printf (_("#  Implicit/static pattern stem: `%s'\n"), f->stem);
     987    printf (_("#  Implicit/static pattern stem: '%s'\n"), f->stem);
    948988  if (f->intermediate)
    949989    puts (_("#  File is an intermediate prerequisite."));
     
    953993      fputs (_("#  Also makes:"), stdout);
    954994      for (d = f->also_make; d != 0; d = d->next)
    955         printf (" %s", dep_name (d));
     995        printf (" %s", dep_name (d));
    956996      putchar ('\n');
    957997    }
     
    9811021    case cs_finished:
    9821022      switch (f->update_status)
    983         {
    984         case -1:
    985           break;
    986         case 0:
    987           puts (_("#  Successfully updated."));
    988           break;
    989         case 1:
    990           assert (question_flag);
    991           puts (_("#  Needs to be updated (-q is set)."));
    992           break;
    993         case 2:
    994           puts (_("#  Failed to be updated."));
    995           break;
    996         default:
    997           puts (_("#  Invalid value in `update_status' member!"));
    998           fflush (stdout);
    999           fflush (stderr);
    1000           abort ();
    1001         }
     1023        {
     1024        case us_none:
     1025          break;
     1026        case us_success:
     1027          puts (_("#  Successfully updated."));
     1028          break;
     1029        case us_question:
     1030          assert (question_flag);
     1031          puts (_("#  Needs to be updated (-q is set)."));
     1032          break;
     1033        case us_failed:
     1034          puts (_("#  Failed to be updated."));
     1035          break;
     1036        }
    10021037      break;
    10031038    default:
    1004       puts (_("#  Invalid value in `command_state' member!"));
     1039      puts (_("#  Invalid value in 'command_state' member!"));
    10051040      fflush (stdout);
    10061041      fflush (stderr);
     
    10331068
    10341069#define VERIFY_CACHED(_p,_n) \
    1035     do{\
    1036         if (_p->_n && _p->_n[0] && !strcache_iscached (_p->_n)) \
    1037           error (NULL, "%s: Field '%s' not cached: %s\n", _p->name, # _n, _p->_n); \
     1070    do{                                                                       \
     1071        if (_p->_n && _p->_n[0] && !strcache_iscached (_p->_n))               \
     1072          error (NULL, strlen (_p->name) + CSTRLEN (# _n) + strlen (_p->_n),  \
     1073                 _("%s: Field '%s' not cached: %s"), _p->name, # _n, _p->_n); \
    10381074    }while(0)
    10391075
  • vendor/gnumake/current/filedef.h

    r2596 r3138  
    11/* Definition of target file data structures for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    2018/* Structure that represents the info on one file
    2119   that the makefile says how to make.
    22    All of these are chained together through `next'.  */
     20   All of these are chained together through 'next'.  */
    2321
    2422#include "hash.h"
     
    2927    const char *hname;          /* Hashed filename */
    3028    const char *vpath;          /* VPATH/vpath pathname */
    31     struct dep *deps;           /* all dependencies, including duplicates */
    32     struct commands *cmds;      /* Commands to execute for this target.  */
    33     int command_flags;          /* Flags OR'd in for cmds; see commands.h.  */
    34     const char *stem;           /* Implicit stem, if an implicit
     29    struct dep *deps;           /* all dependencies, including duplicates */
     30    struct commands *cmds;      /* Commands to execute for this target.  */
     31    const char *stem;           /* Implicit stem, if an implicit
    3532                                   rule has been used */
    36     struct dep *also_make;      /* Targets that are made by making this.  */
    37     FILE_TIMESTAMP last_mtime;  /* File's modtime, if already known.  */
    38     FILE_TIMESTAMP mtime_before_update; /* File's modtime before any updating
    39                                            has been performed.  */
    40     struct file *prev;          /* Previous entry for same file name;
    41                                    used when there are multiple double-colon
    42                                    entries for the same file.  */
     33    struct dep *also_make;      /* Targets that are made by making this.  */
     34    struct file *prev;          /* Previous entry for same file name;
     35                                   used when there are multiple double-colon
     36                                   entries for the same file.  */
    4337    struct file *last;          /* Last entry for the same file name.  */
    4438
    4539    /* File that this file was renamed to.  After any time that a
    46        file could be renamed, call `check_renamed' (below).  */
     40       file could be renamed, call 'check_renamed' (below).  */
    4741    struct file *renamed;
    4842
     
    6256    struct file *double_colon;
    6357
    64     short int update_status;    /* Status of the last attempt to update,
    65                                    or -1 if none has been made.  */
    66 
    67     enum cmd_state              /* State of the commands.  */
    68       {         /* Note: It is important that cs_not_started be zero.  */
    69         cs_not_started,         /* Not yet started.  */
    70         cs_deps_running,        /* Dep commands running.  */
    71         cs_running,             /* Commands running.  */
    72         cs_finished             /* Commands finished.  */
     58    FILE_TIMESTAMP last_mtime;  /* File's modtime, if already known.  */
     59    FILE_TIMESTAMP mtime_before_update; /* File's modtime before any updating
     60                                           has been performed.  */
     61    unsigned int considered;    /* equal to 'considered' if file has been
     62                                   considered on current scan of goal chain */
     63    int command_flags;          /* Flags OR'd in for cmds; see commands.h.  */
     64    enum update_status          /* Status of the last attempt to update.  */
     65      {
     66        us_success = 0,         /* Successfully updated.  Must be 0!  */
     67        us_none,                /* No attempt to update has been made.  */
     68        us_question,            /* Needs to be updated (-q is is set).  */
     69        us_failed               /* Update failed.  */
     70      } update_status ENUM_BITFIELD (2);
     71    enum cmd_state              /* State of the commands.  */
     72      {
     73        cs_not_started = 0,     /* Not yet started.  Must be 0!  */
     74        cs_deps_running,        /* Dep commands running.  */
     75        cs_running,             /* Commands running.  */
     76        cs_finished             /* Commands finished.  */
    7377      } command_state ENUM_BITFIELD (2);
    7478
    75     unsigned int precious:1;    /* Non-0 means don't delete file on quit */
    76     unsigned int low_resolution_time:1; /* Nonzero if this file's time stamp
    77                                            has only one-second resolution.  */
     79    unsigned int builtin:1;     /* True if the file is a builtin rule. */
     80    unsigned int precious:1;    /* Non-0 means don't delete file on quit */
     81    unsigned int loaded:1;      /* True if the file is a loaded object. */
     82    unsigned int low_resolution_time:1; /* Nonzero if this file's time stamp
     83                                           has only one-second resolution.  */
    7884    unsigned int tried_implicit:1; /* Nonzero if have searched
    79                                       for implicit rule for making
    80                                       this file; don't search again.  */
    81     unsigned int updating:1;    /* Nonzero while updating deps of this file */
    82     unsigned int updated:1;     /* Nonzero if this file has been remade.  */
    83     unsigned int is_target:1;   /* Nonzero if file is described as target.  */
    84     unsigned int cmd_target:1;  /* Nonzero if file was given on cmd line.  */
    85     unsigned int phony:1;       /* Nonzero if this is a phony file
    86                                    i.e., a prerequisite of .PHONY.  */
     85                                      for implicit rule for making
     86                                      this file; don't search again.  */
     87    unsigned int updating:1;    /* Nonzero while updating deps of this file */
     88    unsigned int updated:1;     /* Nonzero if this file has been remade.  */
     89    unsigned int is_target:1;   /* Nonzero if file is described as target.  */
     90    unsigned int cmd_target:1;  /* Nonzero if file was given on cmd line.  */
     91    unsigned int phony:1;       /* Nonzero if this is a phony file
     92                                   i.e., a prerequisite of .PHONY.  */
    8793    unsigned int intermediate:1;/* Nonzero if this is an intermediate file.  */
    8894    unsigned int secondary:1;   /* Nonzero means remove_intermediates should
    8995                                   not delete it.  */
    90     unsigned int dontcare:1;    /* Nonzero if no complaint is to be made if
    91                                    this target cannot be remade.  */
     96    unsigned int dontcare:1;    /* Nonzero if no complaint is to be made if
     97                                   this target cannot be remade.  */
    9298    unsigned int ignore_vpath:1;/* Nonzero if we threw out VPATH name.  */
    9399    unsigned int pat_searched:1;/* Nonzero if we already searched for
    94100                                   pattern-specific variables.  */
    95     unsigned int considered:1;  /* equal to 'considered' if file has been
    96                                    considered on current scan of goal chain */
    97101    unsigned int no_diag:1;     /* True if the file failed to update and no
    98102                                   diagnostics has been issued (dontcare). */
     
    100104
    101105
    102 extern struct file *suffix_file, *default_file;
     106extern struct file *default_file;
    103107
    104108
     
    114118void notice_finished_file (struct file *file);
    115119void init_hash_files (void);
     120void verify_file_data_base (void);
    116121char *build_target_list (char *old_list);
    117122void print_prereqs (const struct dep *deps);
    118123void print_file_data_base (void);
     124int try_implicit_rule (struct file *file, unsigned int depth);
     125int stemlen_compare (const void *v1, const void *v2);
    119126
    120127#if FILE_TIMESTAMP_HI_RES
    121128# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
    122     file_timestamp_cons (fname, (st).st_mtime, (st).st_mtim.ST_MTIM_NSEC)
     129    file_timestamp_cons (fname, (st).st_mtime, (st).ST_MTIM_NSEC)
    123130#else
    124131# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
     
    135142
    136143#define FILE_TIMESTAMP_S(ts) (((ts) - ORDINARY_MTIME_MIN) \
    137                               >> FILE_TIMESTAMP_LO_BITS)
     144                              >> FILE_TIMESTAMP_LO_BITS)
    138145#define FILE_TIMESTAMP_NS(ts) ((int) (((ts) - ORDINARY_MTIME_MIN) \
    139                                       & ((1 << FILE_TIMESTAMP_LO_BITS) - 1)))
     146                                      & ((1 << FILE_TIMESTAMP_LO_BITS) - 1)))
    140147
    141148/* Upper bound on length of string "YYYY-MM-DD HH:MM:SS.NNNNNNNNN"
    142    representing a file timestamp.  The upper bound is not necessarily 19,
     149   representing a file timestamp.  The upper bound is not necessarily 29,
    143150   since the year might be less than -999 or greater than 9999.
    144151
     
    157164   + 1 + 1 + 4 + 25)
    158165
    159 FILE_TIMESTAMP file_timestamp_cons (char const *, time_t, int);
     166FILE_TIMESTAMP file_timestamp_cons (char const *, time_t, long int);
    160167FILE_TIMESTAMP file_timestamp_now (int *);
    161168void file_timestamp_sprintf (char *p, FILE_TIMESTAMP ts);
     
    188195#define ORDINARY_MTIME_MIN (OLD_MTIME + 1)
    189196#define ORDINARY_MTIME_MAX ((FILE_TIMESTAMP_S (NEW_MTIME) \
    190                              << FILE_TIMESTAMP_LO_BITS) \
    191                             + ORDINARY_MTIME_MIN + FILE_TIMESTAMPS_PER_S - 1)
    192 
    193 /* Modtime value to use for `infinitely new'.  We used to get the current time
    194    from the system and use that whenever we wanted `new'.  But that causes
     197                             << FILE_TIMESTAMP_LO_BITS) \
     198                            + ORDINARY_MTIME_MIN + FILE_TIMESTAMPS_PER_S - 1)
     199
     200/* Modtime value to use for 'infinitely new'.  We used to get the current time
     201   from the system and use that whenever we wanted 'new'.  But that causes
    195202   trouble when the machine running make and the machine holding a file have
    196    different ideas about what time it is; and can also lose for `force'
     203   different ideas about what time it is; and can also lose for 'force'
    197204   targets, which need to be considered newer than anything that depends on
    198205   them, even if said dependents' modtimes are in the future.  */
  • vendor/gnumake/current/function.c

    r2596 r3138  
    11/* Builtin function expansion for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018#include "filedef.h"
    2119#include "variable.h"
     
    3230struct function_table_entry
    3331  {
     32    union {
     33      char *(*func_ptr) (char *output, char **argv, const char *fname);
     34      gmk_func_ptr alloc_func_ptr;
     35    } fptr;
    3436    const char *name;
    3537    unsigned char len;
    3638    unsigned char minimum_args;
    3739    unsigned char maximum_args;
    38     char expand_args;
    39     char *(*func_ptr) (char *output, char **argv, const char *fname);
     40    unsigned char expand_args:1;
     41    unsigned char alloc_fn:1;
    4042  };
    4143
     
    8789      o = variable_buffer_output (o, t, strlen (t));
    8890      if (rlen > 0)
    89         o = variable_buffer_output (o, replace, rlen);
     91        o = variable_buffer_output (o, replace, rlen);
    9092      return o;
    9193    }
     
    9496    {
    9597      if (by_word && slen == 0)
    96         /* When matching by words, the empty string should match
    97            the end of each word, rather than the end of the whole text.  */
    98         p = end_of_token (next_token (t));
     98        /* When matching by words, the empty string should match
     99           the end of each word, rather than the end of the whole text.  */
     100        p = end_of_token (next_token (t));
    99101      else
    100         {
    101           p = strstr (t, subst);
    102           if (p == 0)
    103             {
    104               /* No more matches.  Output everything left on the end.  */
    105               o = variable_buffer_output (o, t, strlen (t));
    106               return o;
    107             }
    108         }
     102        {
     103          p = strstr (t, subst);
     104          if (p == 0)
     105            {
     106              /* No more matches.  Output everything left on the end.  */
     107              o = variable_buffer_output (o, t, strlen (t));
     108              return o;
     109            }
     110        }
    109111
    110112      /* Output everything before this occurrence of the string to replace.  */
    111113      if (p > t)
    112         o = variable_buffer_output (o, t, p - t);
     114        o = variable_buffer_output (o, t, p - t);
    113115
    114116      /* If we're substituting only by fully matched words,
    115         or only at the ends of words, check that this case qualifies.  */
     117        or only at the ends of words, check that this case qualifies.  */
    116118      if (by_word
    117           && ((p > text && !isblank ((unsigned char)p[-1]))
    118               || (p[slen] != '\0' && !isblank ((unsigned char)p[slen]))))
    119         /* Struck out.  Output the rest of the string that is
    120            no longer to be replaced.  */
    121         o = variable_buffer_output (o, subst, slen);
     119          && ((p > text && !ISSPACE (p[-1]))
     120              || ! STOP_SET (p[slen], MAP_SPACE|MAP_NUL)))
     121        /* Struck out.  Output the rest of the string that is
     122           no longer to be replaced.  */
     123        o = variable_buffer_output (o, subst, slen);
    122124      else if (rlen > 0)
    123         /* Output the replacement string.  */
    124         o = variable_buffer_output (o, replace, rlen);
     125        /* Output the replacement string.  */
     126        o = variable_buffer_output (o, replace, rlen);
    125127
    126128      /* Advance T past the string to be replaced.  */
     
    170172    /* With no % in the pattern, this is just a simple substitution.  */
    171173    return subst_expand (o, text, pattern, replace,
    172                         strlen (pattern), strlen (replace), 1);
     174                        strlen (pattern), strlen (replace), 1);
    173175
    174176  /* Record the length of PATTERN before and after the %
     
    183185      /* Is it big enough to match?  */
    184186      if (len < pattern_prepercent_len + pattern_postpercent_len)
    185         fail = 1;
     187        fail = 1;
    186188
    187189      /* Does the prefix match? */
    188190      if (!fail && pattern_prepercent_len > 0
    189           && (*t != *pattern
    190               || t[pattern_prepercent_len - 1] != pattern_percent[-2]
    191               || !strneq (t + 1, pattern + 1, pattern_prepercent_len - 1)))
    192         fail = 1;
     191          && (*t != *pattern
     192              || t[pattern_prepercent_len - 1] != pattern_percent[-2]
     193              || !strneq (t + 1, pattern + 1, pattern_prepercent_len - 1)))
     194        fail = 1;
    193195
    194196      /* Does the suffix match? */
    195197      if (!fail && pattern_postpercent_len > 0
    196           && (t[len - 1] != pattern_percent[pattern_postpercent_len - 1]
    197               || t[len - pattern_postpercent_len] != *pattern_percent
    198               || !strneq (&t[len - pattern_postpercent_len],
    199                           pattern_percent, pattern_postpercent_len - 1)))
    200         fail = 1;
     198          && (t[len - 1] != pattern_percent[pattern_postpercent_len - 1]
     199              || t[len - pattern_postpercent_len] != *pattern_percent
     200              || !strneq (&t[len - pattern_postpercent_len],
     201                          pattern_percent, pattern_postpercent_len - 1)))
     202        fail = 1;
    201203
    202204      if (fail)
    203         /* It didn't match.  Output the string.  */
    204         o = variable_buffer_output (o, t, len);
     205        /* It didn't match.  Output the string.  */
     206        o = variable_buffer_output (o, t, len);
    205207      else
    206         {
    207           /* It matched.  Output the replacement.  */
    208 
    209           /* Output the part of the replacement before the %.  */
    210           o = variable_buffer_output (o, replace, replace_prepercent_len);
    211 
    212           if (replace_percent != 0)
    213             {
    214               /* Output the part of the matched string that
    215                 matched the % in the pattern.  */
    216               o = variable_buffer_output (o, t + pattern_prepercent_len,
    217                                           len - (pattern_prepercent_len
    218                                                 + pattern_postpercent_len));
    219               /* Output the part of the replacement after the %.  */
    220               o = variable_buffer_output (o, replace_percent,
    221                                           replace_postpercent_len);
    222             }
    223         }
     208        {
     209          /* It matched.  Output the replacement.  */
     210
     211          /* Output the part of the replacement before the %.  */
     212          o = variable_buffer_output (o, replace, replace_prepercent_len);
     213
     214          if (replace_percent != 0)
     215            {
     216              /* Output the part of the matched string that
     217                matched the % in the pattern.  */
     218              o = variable_buffer_output (o, t + pattern_prepercent_len,
     219                                          len - (pattern_prepercent_len
     220                                                + pattern_postpercent_len));
     221              /* Output the part of the replacement after the %.  */
     222              o = variable_buffer_output (o, replace_percent,
     223                                          replace_postpercent_len);
     224            }
     225        }
    224226
    225227      /* Output a space, but not if the replacement is "".  */
    226228      if (fail || replace_prepercent_len > 0
    227           || (replace_percent != 0 && len + replace_postpercent_len > 0))
    228         {
    229           o = variable_buffer_output (o, " ", 1);
    230           doneany = 1;
    231         }
     229          || (replace_percent != 0 && len + replace_postpercent_len > 0))
     230        {
     231          o = variable_buffer_output (o, " ", 1);
     232          doneany = 1;
     233        }
    232234    }
    233235  if (doneany)
     
    271273lookup_function (const char *s)
    272274{
     275  struct function_table_entry function_table_entry_key;
    273276  const char *e = s;
    274277
    275   while (*e && ( (*e >= 'a' && *e <= 'z') || *e == '-'))
     278  while (STOP_SET (*e, MAP_USERFUNC))
    276279    e++;
    277   if (*e == '\0' || isblank ((unsigned char) *e))
    278     {
    279       struct function_table_entry function_table_entry_key;
    280       function_table_entry_key.name = s;
    281       function_table_entry_key.len = e - s;
    282 
    283       return hash_find_item (&function_table, &function_table_entry_key);
    284     }
    285   return 0;
     280
     281  if (e == s || !STOP_SET(*e, MAP_NUL|MAP_SPACE))
     282    return NULL;
     283
     284  function_table_entry_key.name = s;
     285  function_table_entry_key.len = e - s;
     286
     287  return hash_find_item (&function_table, &function_table_entry_key);
    286288}
    287289
     
    302304      percent = find_percent (new_chars);
    303305      if (percent == 0)
    304         return streq (new_chars, str);
     306        return streq (new_chars, str);
    305307      pattern = new_chars;
    306308    }
     
    337339    else if (*ptr == endparen)
    338340      {
    339         --count;
    340         if (count < 0)
    341           return NULL;
     341        --count;
     342        if (count < 0)
     343          return NULL;
    342344      }
    343345
     
    362364  unsigned int idx;
    363365
    364   chain = PARSE_FILE_SEQ (&line, struct nameseq, '\0', NULL,
    365                           /* We do not want parse_file_seq to strip `./'s.
     366  chain = PARSE_FILE_SEQ (&line, struct nameseq, MAP_NUL, NULL,
     367                          /* We do not want parse_file_seq to strip './'s.
    366368                             That would break examples like:
    367369                             $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)).  */
     
    436438      tp = find_next_token (&list1_iterator, &len1);
    437439      if (tp != 0)
    438         o = variable_buffer_output (o, tp, len1);
     440        o = variable_buffer_output (o, tp, len1);
    439441
    440442      pp = find_next_token (&list2_iterator, &len2);
    441443      if (pp != 0)
    442         o = variable_buffer_output (o, pp, len2);
     444        o = variable_buffer_output (o, pp, len2);
    443445
    444446      if (tp != 0 || pp != 0)
    445         {
    446           o = variable_buffer_output (o, " ", 1);
    447           doneany = 1;
    448         }
     447        {
     448          o = variable_buffer_output (o, " ", 1);
     449          doneany = 1;
     450        }
    449451    }
    450452  while (tp != 0 || pp != 0);
     
    469471      default:
    470472      case o_invalid:
    471         abort ();
    472         break;
     473        abort ();
     474        break;
    473475      case o_default:
    474         o = variable_buffer_output (o, "default", 7);
    475         break;
     476        o = variable_buffer_output (o, "default", 7);
     477        break;
    476478      case o_env:
    477         o = variable_buffer_output (o, "environment", 11);
    478         break;
     479        o = variable_buffer_output (o, "environment", 11);
     480        break;
    479481      case o_file:
    480         o = variable_buffer_output (o, "file", 4);
    481         break;
     482        o = variable_buffer_output (o, "file", 4);
     483        break;
    482484      case o_env_override:
    483         o = variable_buffer_output (o, "environment override", 20);
    484         break;
     485        o = variable_buffer_output (o, "environment override", 20);
     486        break;
    485487      case o_command:
    486         o = variable_buffer_output (o, "command line", 12);
    487         break;
     488        o = variable_buffer_output (o, "command line", 12);
     489        break;
    488490      case o_override:
    489         o = variable_buffer_output (o, "override", 8);
    490         break;
     491        o = variable_buffer_output (o, "override", 8);
     492        break;
    491493      case o_automatic:
    492         o = variable_buffer_output (o, "automatic", 9);
    493         break;
     494        o = variable_buffer_output (o, "automatic", 9);
     495        break;
    494496      }
    495497
     
    513515}
    514516
    515 #ifdef VMS
    516 # define IS_PATHSEP(c) ((c) == ']')
    517 #else
    518 # ifdef HAVE_DOS_PATHS
    519 #  define IS_PATHSEP(c) ((c) == '/' || (c) == '\\')
    520 # else
    521 #  define IS_PATHSEP(c) ((c) == '/')
    522 # endif
    523 #endif
    524 
    525517
    526518static char *
     
    533525  unsigned int len=0;
    534526
    535   int is_suffix = streq (funcname, "suffix");
     527  int is_suffix = funcname[0] == 's';
    536528  int is_notdir = !is_suffix;
     529  int stop = MAP_DIRSEP | (is_suffix ? MAP_DOT : 0);
     530#ifdef VMS
     531  /* For VMS list_iterator points to a comma separated list. To use the common
     532     [find_]next_token, create a local copy and replace the commas with
     533     spaces. Obviously, there is a problem if there is a ',' in the VMS filename
     534     (can only happen on ODS5), the same problem as with spaces in filenames,
     535     which seems to be present in make on all platforms. */
     536  char *vms_list_iterator = alloca(strlen(list_iterator) + 1);
     537  int i;
     538  for (i = 0; list_iterator[i]; i++)
     539    if (list_iterator[i] == ',')
     540      vms_list_iterator[i] = ' ';
     541    else
     542      vms_list_iterator[i] = list_iterator[i];
     543  vms_list_iterator[i] = list_iterator[i];
     544  while ((p2 = find_next_token((const char**) &vms_list_iterator, &len)) != 0)
     545#else
    537546  while ((p2 = find_next_token (&list_iterator, &len)) != 0)
    538     {
    539       const char *p = p2 + len;
    540 
    541 
    542       while (p >= p2 && (!is_suffix || *p != '.'))
    543         {
    544           if (IS_PATHSEP (*p))
    545             break;
    546           --p;
    547         }
     547#endif
     548    {
     549      const char *p = p2 + len - 1;
     550
     551      while (p >= p2 && ! STOP_SET (*p, stop))
     552        --p;
    548553
    549554      if (p >= p2)
    550         {
    551           if (is_notdir)
    552             ++p;
    553           else if (*p != '.')
    554             continue;
    555           o = variable_buffer_output (o, p, len - (p - p2));
    556         }
     555        {
     556          if (is_notdir)
     557            ++p;
     558          else if (*p != '.')
     559            continue;
     560          o = variable_buffer_output (o, p, len - (p - p2));
     561        }
    557562#ifdef HAVE_DOS_PATHS
    558563      /* Handle the case of "d:foo/bar".  */
    559       else if (streq (funcname, "notdir") && p2[0] && p2[1] == ':')
    560         {
    561           p = p2 + 2;
    562           o = variable_buffer_output (o, p, len - (p - p2));
    563         }
     564      else if (is_notdir && p2[0] && p2[1] == ':')
     565        {
     566          p = p2 + 2;
     567          o = variable_buffer_output (o, p, len - (p - p2));
     568        }
    564569#endif
    565570      else if (is_notdir)
    566         o = variable_buffer_output (o, p2, len);
     571        o = variable_buffer_output (o, p2, len);
    567572
    568573      if (is_notdir || p >= p2)
    569         {
    570           o = variable_buffer_output (o, " ", 1);
    571           doneany = 1;
    572         }
     574        {
     575#ifdef VMS
     576          if (vms_comma_separator)
     577            o = variable_buffer_output (o, ",", 1);
     578          else
     579#endif
     580          o = variable_buffer_output (o, " ", 1);
     581
     582          doneany = 1;
     583        }
    573584    }
    574585
     
    587598  const char *p3 = argv[0];
    588599  const char *p2;
    589   int doneany=0;
    590   unsigned int len=0;
    591 
    592   int is_basename= streq (funcname, "basename");
    593   int is_dir= !is_basename;
    594 
     600  int doneany = 0;
     601  unsigned int len = 0;
     602
     603  int is_basename = funcname[0] == 'b';
     604  int is_dir = !is_basename;
     605  int stop = MAP_DIRSEP | (is_basename ? MAP_DOT : 0) | MAP_NUL;
     606#ifdef VMS
     607  /* As in func_notdir_suffix ... */
     608  char *vms_p3 = alloca (strlen(p3) + 1);
     609  int i;
     610  for (i = 0; p3[i]; i++)
     611    if (p3[i] == ',')
     612      vms_p3[i] = ' ';
     613    else
     614      vms_p3[i] = p3[i];
     615  vms_p3[i] = p3[i];
     616  while ((p2 = find_next_token((const char**) &vms_p3, &len)) != 0)
     617#else
    595618  while ((p2 = find_next_token (&p3, &len)) != 0)
    596     {
    597       const char *p = p2 + len;
    598       while (p >= p2 && (!is_basename  || *p != '.'))
    599         {
    600           if (IS_PATHSEP (*p))
    601             break;
    602           --p;
    603         }
     619#endif
     620    {
     621      const char *p = p2 + len - 1;
     622      while (p >= p2 && ! STOP_SET (*p, stop))
     623        --p;
    604624
    605625      if (p >= p2 && (is_dir))
     
    614634      else if (is_dir)
    615635#ifdef VMS
    616         o = variable_buffer_output (o, "[]", 2);
     636        {
     637          extern int vms_report_unix_paths;
     638          if (vms_report_unix_paths)
     639            o = variable_buffer_output (o, "./", 2);
     640          else
     641            o = variable_buffer_output (o, "[]", 2);
     642        }
    617643#else
    618644#ifndef _AMIGA
     
    626652        o = variable_buffer_output (o, p2, len);
    627653
    628       o = variable_buffer_output (o, " ", 1);
     654#ifdef VMS
     655      if (vms_comma_separator)
     656        o = variable_buffer_output (o, ",", 1);
     657      else
     658#endif
     659        o = variable_buffer_output (o, " ", 1);
     660
    629661      doneany = 1;
    630662    }
     
    642674  int fixlen = strlen (argv[0]);
    643675  const char *list_iterator = argv[1];
    644   int is_addprefix = streq (funcname, "addprefix");
     676  int is_addprefix = funcname[3] == 'p';
    645677  int is_addsuffix = !is_addprefix;
    646678
     
    652684    {
    653685      if (is_addprefix)
    654         o = variable_buffer_output (o, argv[0], fixlen);
     686        o = variable_buffer_output (o, argv[0], fixlen);
    655687      o = variable_buffer_output (o, p, len);
    656688      if (is_addsuffix)
    657         o = variable_buffer_output (o, argv[0], fixlen);
     689        o = variable_buffer_output (o, argv[0], fixlen);
    658690      o = variable_buffer_output (o, " ", 1);
    659691      doneany = 1;
     
    671703{
    672704  o = subst_expand (o, argv[2], argv[0], argv[1], strlen (argv[0]),
    673                     strlen (argv[1]), 0);
     705                    strlen (argv[1]), 0);
    674706
    675707  return o;
     
    714746  char buf[20];
    715747
    716   while (find_next_token (&word_iterator, (unsigned int *) 0) != 0)
     748  while (find_next_token (&word_iterator, NULL) != 0)
    717749    ++i;
    718750
     
    731763strip_whitespace (const char **begpp, const char **endpp)
    732764{
    733   while (*begpp <= *endpp && isspace ((unsigned char)**begpp))
     765  while (*begpp <= *endpp && ISSPACE (**begpp))
    734766    (*begpp) ++;
    735   while (*endpp >= *begpp && isspace ((unsigned char)**endpp))
     767  while (*endpp >= *begpp && ISSPACE (**endpp))
    736768    (*endpp) --;
    737769  return (char *)*begpp;
     
    746778
    747779  for (; s <= end; ++s)
    748     if (!ISDIGIT (*s))  /* ISDIGIT only evals its arg once: see make.h.  */
     780    if (!ISDIGIT (*s))  /* ISDIGIT only evals its arg once: see makeint.h.  */
    749781      break;
    750782
    751783  if (s <= end || end - beg < 0)
    752     fatal (*expanding_var, "%s: '%s'", msg, beg);
     784    OSS (fatal, *expanding_var, "%s: '%s'", msg, beg);
    753785}
    754786
     
    763795
    764796  /* Check the first argument.  */
    765   check_numeric (argv[0], _("non-numeric first argument to `word' function"));
     797  check_numeric (argv[0], _("non-numeric first argument to 'word' function"));
    766798  i = atoi (argv[0]);
    767799
    768800  if (i == 0)
    769     fatal (*expanding_var,
    770            _("first argument to `word' function must be greater than 0"));
     801    O (fatal, *expanding_var,
     802       _("first argument to 'word' function must be greater than 0"));
    771803
    772804  end_p = argv[1];
     
    788820  /* Check the arguments.  */
    789821  check_numeric (argv[0],
    790                  _("non-numeric first argument to `wordlist' function"));
     822                 _("non-numeric first argument to 'wordlist' function"));
    791823  check_numeric (argv[1],
    792                  _("non-numeric second argument to `wordlist' function"));
     824                 _("non-numeric second argument to 'wordlist' function"));
    793825
    794826  start = atoi (argv[0]);
    795827  if (start < 1)
    796     fatal (*expanding_var,
    797            "invalid first argument to `wordlist' function: `%d'", start);
     828    ON (fatal, *expanding_var,
     829        "invalid first argument to 'wordlist' function: '%d'", start);
    798830
    799831  count = atoi (argv[1]) - start + 1;
     
    846878  struct variable *var;
    847879
     880  /* Clean up the variable name by removing whitespace.  */
     881  char *vp = next_token (varname);
     882  end_of_token (vp)[0] = '\0';
     883
    848884  push_new_variable_scope ();
    849   var = define_variable (varname, strlen (varname), "", o_automatic, 0);
     885  var = define_variable (vp, strlen (vp), "", o_automatic, 0);
    850886
    851887  /* loop through LIST,  put the value in VAR and expand BODY */
     
    904940    return result;
    905941  return_STRING_COMPARE (((struct a_word const *) x)->str,
    906                         ((struct a_word const *) y)->str);
     942                        ((struct a_word const *) y)->str);
    907943}
    908944
     
    913949  char *percent;
    914950  int length;
    915   int save_c;
    916951};
    917952
     
    927962
    928963  struct hash_table a_word_table;
    929   int is_filter = streq (funcname, "filter");
     964  int is_filter = funcname[CSTRLEN ("filter")] == '\0';
    930965  const char *pat_iterator = argv[0];
    931966  const char *word_iterator = argv[1];
     
    936971  unsigned int len;
    937972
    938   /* Chop ARGV[0] up into patterns to match against the words.  */
     973  /* Chop ARGV[0] up into patterns to match against the words.
     974     We don't need to preserve it because our caller frees all the
     975     argument memory anyway.  */
    939976
    940977  pattail = &pathead;
     
    947984
    948985      if (*pat_iterator != '\0')
    949         ++pat_iterator;
     986        ++pat_iterator;
    950987
    951988      pat->str = p;
    952       pat->length = len;
    953       pat->save_c = p[len];
    954989      p[len] = '\0';
    955990      pat->percent = find_percent (p);
    956991      if (pat->percent == 0)
    957         literals++;
     992        literals++;
     993
     994      /* find_percent() might shorten the string so LEN is wrong.  */
     995      pat->length = strlen (pat->str);
    958996    }
    959997  *pattail = 0;
     
    9701008
    9711009      if (*word_iterator != '\0')
    972         ++word_iterator;
     1010        ++word_iterator;
    9731011
    9741012      p[len] = '\0';
     
    9881026                 a_word_hash_cmp);
    9891027      for (wp = wordhead; wp != 0; wp = wp->next)
    990         {
    991           struct a_word *owp = hash_insert (&a_word_table, wp);
    992           if (owp)
    993             wp->chain = owp;
    994         }
     1028        {
     1029          struct a_word *owp = hash_insert (&a_word_table, wp);
     1030          if (owp)
     1031            wp->chain = owp;
     1032        }
    9951033    }
    9961034
     
    10011039      /* Run each pattern through the words, killing words.  */
    10021040      for (pp = pathead; pp != 0; pp = pp->next)
    1003         {
    1004           if (pp->percent)
    1005             for (wp = wordhead; wp != 0; wp = wp->next)
    1006               wp->matched |= pattern_matches (pp->str, pp->percent, wp->str);
    1007           else if (hashing)
    1008             {
    1009               struct a_word a_word_key;
    1010               a_word_key.str = pp->str;
    1011               a_word_key.length = pp->length;
    1012               wp = hash_find_item (&a_word_table, &a_word_key);
    1013               while (wp)
    1014                 {
    1015                   wp->matched |= 1;
    1016                   wp = wp->chain;
    1017                 }
    1018             }
    1019           else
    1020             for (wp = wordhead; wp != 0; wp = wp->next)
    1021               wp->matched |= (wp->length == pp->length
    1022                               && strneq (pp->str, wp->str, wp->length));
    1023         }
     1041        {
     1042          if (pp->percent)
     1043            for (wp = wordhead; wp != 0; wp = wp->next)
     1044              wp->matched |= pattern_matches (pp->str, pp->percent, wp->str);
     1045          else if (hashing)
     1046            {
     1047              struct a_word a_word_key;
     1048              a_word_key.str = pp->str;
     1049              a_word_key.length = pp->length;
     1050              wp = hash_find_item (&a_word_table, &a_word_key);
     1051              while (wp)
     1052                {
     1053                  wp->matched |= 1;
     1054                  wp = wp->chain;
     1055                }
     1056            }
     1057          else
     1058            for (wp = wordhead; wp != 0; wp = wp->next)
     1059              wp->matched |= (wp->length == pp->length
     1060                              && strneq (pp->str, wp->str, wp->length));
     1061        }
    10241062
    10251063      /* Output the words that matched (or didn't, for filter-out).  */
    10261064      for (wp = wordhead; wp != 0; wp = wp->next)
    1027         if (is_filter ? wp->matched : !wp->matched)
    1028           {
    1029             o = variable_buffer_output (o, wp->str, strlen (wp->str));
    1030             o = variable_buffer_output (o, " ", 1);
    1031             doneany = 1;
    1032           }
     1065        if (is_filter ? wp->matched : !wp->matched)
     1066          {
     1067            o = variable_buffer_output (o, wp->str, strlen (wp->str));
     1068            o = variable_buffer_output (o, " ", 1);
     1069            doneany = 1;
     1070          }
    10331071
    10341072      if (doneany)
    1035         /* Kill the last space.  */
    1036         --o;
    1037     }
    1038 
    1039   for (pp = pathead; pp != 0; pp = pp->next)
    1040     pp->str[pp->length] = pp->save_c;
     1073        /* Kill the last space.  */
     1074        --o;
     1075    }
    10411076
    10421077  if (hashing)
     
    10581093      const char *word_start;
    10591094
    1060       while (isspace ((unsigned char)*p))
    1061         ++p;
     1095      NEXT_TOKEN (p);
    10621096      word_start = p;
    1063       for (i=0; *p != '\0' && !isspace ((unsigned char)*p); ++p, ++i)
    1064         {}
     1097      for (i=0; *p != '\0' && !ISSPACE (*p); ++p, ++i)
     1098        {}
    10651099      if (!i)
    1066         break;
     1100        break;
    10671101      o = variable_buffer_output (o, word_start, i);
    10681102      o = variable_buffer_output (o, " ", 1);
     
    11041138  strcpy (p, *argvp);
    11051139
    1106   switch (*funcname) {
     1140  switch (*funcname)
     1141    {
    11071142    case 'e':
    1108       fatal (reading_file, "%s", msg);
     1143      OS (fatal, reading_file, "%s", msg);
    11091144
    11101145    case 'w':
    1111       error (reading_file, "%s", msg);
     1146      OS (error, reading_file, "%s", msg);
    11121147      break;
    11131148
    11141149    case 'i':
    1115       printf ("%s\n", msg);
    1116       fflush(stdout);
     1150      outputs (0, msg);
     1151      outputs (0, "\n");
    11171152      break;
    11181153
    11191154    default:
    1120       fatal (*expanding_var, "Internal error: func_error: '%s'", funcname);
    1121   }
     1155      OS (fatal, *expanding_var, "Internal error: func_error: '%s'", funcname);
     1156    }
    11221157
    11231158  /* The warning function expands to the empty string.  */
     
    11371172  char *p;
    11381173  unsigned int len;
    1139   int i;
    11401174
    11411175  /* Find the maximum number of words we'll have.  */
    11421176  t = argv[0];
    1143   wordi = 1;
    1144   while (*t != '\0')
    1145     {
    1146       char c = *(t++);
    1147 
    1148       if (! isspace ((unsigned char)c))
    1149         continue;
    1150 
     1177  wordi = 0;
     1178  while ((p = find_next_token (&t, NULL)) != 0)
     1179    {
     1180      ++t;
    11511181      ++wordi;
    1152 
    1153       while (isspace ((unsigned char)*t))
    1154         ++t;
    1155     }
    1156 
    1157   words = xmalloc (wordi * sizeof (char *));
     1182    }
     1183
     1184  words = xmalloc ((wordi == 0 ? 1 : wordi) * sizeof (char *));
    11581185
    11591186  /* Now assign pointers to each string in the array.  */
     
    11691196  if (wordi)
    11701197    {
     1198      int i;
     1199
    11711200      /* Now sort the list of words.  */
    11721201      qsort (words, wordi, sizeof (char *), alpha_compare);
     
    13121341{
    13131342  char *expansion;
    1314   int result;
    13151343
    13161344  while (1)
     
    13181346      const char *begp = *argv;
    13191347      const char *endp = begp + strlen (*argv) - 1;
     1348      int result;
    13201349
    13211350      /* An empty condition is always false.  */
     
    13791408  install_variable_buffer (&buf, &len);
    13801409
    1381   eval_buffer (argv[0]);
     1410  eval_buffer (argv[0], NULL);
    13821411
    13831412  restore_variable_buffer (buf, len);
     
    13951424  /* Copy its value into the output buffer without expanding it.  */
    13961425  if (v)
    1397     o = variable_buffer_output (o, v->value, strlen(v->value));
     1426    o = variable_buffer_output (o, v->value, strlen (v->value));
    13981427
    13991428  return o;
     
    14011430
    14021431/*
    1403   \r  is replaced on UNIX as well. Is this desirable?
     1432  \r is replaced on UNIX as well. Is this desirable?
    14041433 */
    14051434static void
    1406 fold_newlines (char *buffer, unsigned int *length)
     1435fold_newlines (char *buffer, unsigned int *length, int trim_newlines)
    14071436{
    14081437  char *dst = buffer;
    14091438  char *src = buffer;
    1410   char *last_nonnl = buffer -1;
     1439  char *last_nonnl = buffer - 1;
    14111440  src[*length] = 0;
    14121441  for (; *src != '\0'; ++src)
    14131442    {
    14141443      if (src[0] == '\r' && src[1] == '\n')
    1415         continue;
     1444        continue;
    14161445      if (*src == '\n')
    1417         {
    1418           *dst++ = ' ';
    1419         }
     1446        {
     1447          *dst++ = ' ';
     1448        }
    14201449      else
    1421         {
    1422           last_nonnl = dst;
    1423           *dst++ = *src;
    1424         }
    1425     }
     1450        {
     1451          last_nonnl = dst;
     1452          *dst++ = *src;
     1453        }
     1454    }
     1455
     1456  if (!trim_newlines && (last_nonnl < (dst - 2)))
     1457    last_nonnl = dst - 2;
     1458
    14261459  *(++last_nonnl) = '\0';
    14271460  *length = last_nonnl - buffer;
    14281461}
    14291462
    1430 
    1431 
    1432 int shell_function_pid = 0, shell_function_completed;
    1433 
     1463pid_t shell_function_pid = 0;
     1464static int shell_function_completed;
     1465
     1466void
     1467shell_completed (int exit_code, int exit_sig)
     1468{
     1469  char buf[256];
     1470
     1471  shell_function_pid = 0;
     1472  if (exit_sig == 0 && exit_code == 127)
     1473    shell_function_completed = -1;
     1474  else
     1475    shell_function_completed = 1;
     1476
     1477  sprintf (buf, "%d", exit_code);
     1478  define_variable_cname (".SHELLSTATUS", buf, o_override, 0);
     1479}
    14341480
    14351481#ifdef WINDOWS32
     
    14411487
    14421488
    1443 void
    1444 windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp)
     1489int
     1490windows32_openpipe (int *pipedes, int errfd, pid_t *pid_p, char **command_argv, char **envp)
    14451491{
    14461492  SECURITY_ATTRIBUTES saAttr;
    1447   HANDLE hIn;
    1448   HANDLE hErr;
     1493  HANDLE hIn = INVALID_HANDLE_VALUE;
     1494  HANDLE hErr = INVALID_HANDLE_VALUE;
    14491495  HANDLE hChildOutRd;
    14501496  HANDLE hChildOutWr;
    1451   HANDLE hProcess;
    1452 
     1497  HANDLE hProcess, tmpIn, tmpErr;
     1498  DWORD e;
     1499
     1500  /* Set status for return.  */
     1501  pipedes[0] = pipedes[1] = -1;
     1502  *pid_p = (pid_t)-1;
    14531503
    14541504  saAttr.nLength = sizeof (SECURITY_ATTRIBUTES);
     
    14561506  saAttr.lpSecurityDescriptor = NULL;
    14571507
    1458   if (DuplicateHandle (GetCurrentProcess(),
    1459                       GetStdHandle(STD_INPUT_HANDLE),
    1460                       GetCurrentProcess(),
    1461                       &hIn,
    1462                       0,
    1463                       TRUE,
    1464                       DUPLICATE_SAME_ACCESS) == FALSE) {
    1465     fatal (NILF, _("windows32_openpipe(): DuplicateHandle(In) failed (e=%ld)\n"),
    1466            GetLastError());
    1467 
    1468   }
    1469   if (DuplicateHandle(GetCurrentProcess(),
    1470                       GetStdHandle(STD_ERROR_HANDLE),
    1471                       GetCurrentProcess(),
    1472                       &hErr,
    1473                       0,
    1474                       TRUE,
    1475                       DUPLICATE_SAME_ACCESS) == FALSE) {
    1476     fatal (NILF, _("windows32_open_pipe(): DuplicateHandle(Err) failed (e=%ld)\n"),
    1477            GetLastError());
    1478   }
    1479 
    1480   if (!CreatePipe(&hChildOutRd, &hChildOutWr, &saAttr, 0))
    1481     fatal (NILF, _("CreatePipe() failed (e=%ld)\n"), GetLastError());
    1482 
    1483   hProcess = process_init_fd(hIn, hChildOutWr, hErr);
     1508  /* Standard handles returned by GetStdHandle can be NULL or
     1509     INVALID_HANDLE_VALUE if the parent process closed them.  If that
     1510     happens, we open the null device and pass its handle to
     1511     process_begin below as the corresponding handle to inherit.  */
     1512  tmpIn = GetStdHandle (STD_INPUT_HANDLE);
     1513  if (DuplicateHandle (GetCurrentProcess (), tmpIn,
     1514                       GetCurrentProcess (), &hIn,
     1515                       0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE)
     1516    {
     1517      e = GetLastError ();
     1518      if (e == ERROR_INVALID_HANDLE)
     1519        {
     1520          tmpIn = CreateFile ("NUL", GENERIC_READ,
     1521                              FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
     1522                              OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     1523          if (tmpIn != INVALID_HANDLE_VALUE
     1524              && DuplicateHandle (GetCurrentProcess (), tmpIn,
     1525                                  GetCurrentProcess (), &hIn,
     1526                                  0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE)
     1527            CloseHandle (tmpIn);
     1528        }
     1529      if (hIn == INVALID_HANDLE_VALUE)
     1530        {
     1531          ON (error, NILF,
     1532              _("windows32_openpipe: DuplicateHandle(In) failed (e=%ld)\n"), e);
     1533          return -1;
     1534        }
     1535    }
     1536  tmpErr = (HANDLE)_get_osfhandle (errfd);
     1537  if (DuplicateHandle (GetCurrentProcess (), tmpErr,
     1538                       GetCurrentProcess (), &hErr,
     1539                       0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE)
     1540    {
     1541      e = GetLastError ();
     1542      if (e == ERROR_INVALID_HANDLE)
     1543        {
     1544          tmpErr = CreateFile ("NUL", GENERIC_WRITE,
     1545                               FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
     1546                               OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     1547          if (tmpErr != INVALID_HANDLE_VALUE
     1548              && DuplicateHandle (GetCurrentProcess (), tmpErr,
     1549                                  GetCurrentProcess (), &hErr,
     1550                                  0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE)
     1551            CloseHandle (tmpErr);
     1552        }
     1553      if (hErr == INVALID_HANDLE_VALUE)
     1554        {
     1555          ON (error, NILF,
     1556              _("windows32_openpipe: DuplicateHandle(Err) failed (e=%ld)\n"), e);
     1557          return -1;
     1558        }
     1559    }
     1560
     1561  if (! CreatePipe (&hChildOutRd, &hChildOutWr, &saAttr, 0))
     1562    {
     1563      ON (error, NILF, _("CreatePipe() failed (e=%ld)\n"), GetLastError());
     1564      return -1;
     1565    }
     1566
     1567  hProcess = process_init_fd (hIn, hChildOutWr, hErr);
    14841568
    14851569  if (!hProcess)
    1486     fatal (NILF, _("windows32_openpipe(): process_init_fd() failed\n"));
     1570    {
     1571      O (error, NILF, _("windows32_openpipe(): process_init_fd() failed\n"));
     1572      return -1;
     1573    }
    14871574
    14881575  /* make sure that CreateProcess() has Path it needs */
    1489   sync_Path_environment();
    1490   /* `sync_Path_environment' may realloc `environ', so take note of
     1576  sync_Path_environment ();
     1577  /* 'sync_Path_environment' may realloc 'environ', so take note of
    14911578     the new value.  */
    14921579  envp = environ;
    14931580
    1494   if (!process_begin(hProcess, command_argv, envp, command_argv[0], NULL)) {
    1495     /* register process for wait */
    1496     process_register(hProcess);
    1497 
    1498     /* set the pid for returning to caller */
    1499     *pid_p = (pid_t) hProcess;
    1500 
    1501   /* set up to read data from child */
    1502   pipedes[0] = _open_osfhandle((intptr_t) hChildOutRd, O_RDONLY);
    1503 
    1504   /* this will be closed almost right away */
    1505   pipedes[1] = _open_osfhandle((intptr_t) hChildOutWr, O_APPEND);
    1506   } else {
    1507     /* reap/cleanup the failed process */
    1508         process_cleanup(hProcess);
    1509 
    1510     /* close handles which were duplicated, they weren't used */
    1511         CloseHandle(hIn);
    1512         CloseHandle(hErr);
    1513 
    1514         /* close pipe handles, they won't be used */
    1515         CloseHandle(hChildOutRd);
    1516         CloseHandle(hChildOutWr);
    1517 
    1518     /* set status for return */
    1519     pipedes[0] = pipedes[1] = -1;
    1520     *pid_p = (pid_t)-1;
    1521   }
     1581  if (! process_begin (hProcess, command_argv, envp, command_argv[0], NULL))
     1582    {
     1583      /* register process for wait */
     1584      process_register (hProcess);
     1585
     1586      /* set the pid for returning to caller */
     1587      *pid_p = (pid_t) hProcess;
     1588
     1589      /* set up to read data from child */
     1590      pipedes[0] = _open_osfhandle ((intptr_t) hChildOutRd, O_RDONLY);
     1591
     1592      /* this will be closed almost right away */
     1593      pipedes[1] = _open_osfhandle ((intptr_t) hChildOutWr, O_APPEND);
     1594      return 0;
     1595    }
     1596  else
     1597    {
     1598      /* reap/cleanup the failed process */
     1599      process_cleanup (hProcess);
     1600
     1601      /* close handles which were duplicated, they weren't used */
     1602      if (hIn != INVALID_HANDLE_VALUE)
     1603        CloseHandle (hIn);
     1604      if (hErr != INVALID_HANDLE_VALUE)
     1605        CloseHandle (hErr);
     1606
     1607      /* close pipe handles, they won't be used */
     1608      CloseHandle (hChildOutRd);
     1609      CloseHandle (hChildOutWr);
     1610
     1611      return -1;
     1612    }
    15221613}
    15231614#endif
     
    15291620{
    15301621  FILE *fpipe=0;
    1531   /* MSDOS can't fork, but it has `popen'.  */
     1622  /* MSDOS can't fork, but it has 'popen'.  */
    15321623  struct variable *sh = lookup_variable ("SHELL", 5);
    15331624  int e;
     
    15351626
    15361627  /* Make sure not to bother processing an empty line.  */
    1537   while (isblank ((unsigned char)*text))
    1538     ++text;
     1628  NEXT_TOKEN (text);
    15391629  if (*text == '\0')
    15401630    return 0;
     
    15441634      char buf[PATH_MAX + 7];
    15451635      /* This makes sure $SHELL value is used by $(shell), even
    1546         though the target environment is not passed to it.  */
     1636        though the target environment is not passed to it.  */
    15471637      sprintf (buf, "SHELL=%s", sh->value);
    15481638      putenv (buf);
     
    15631653      *pidp = -1;
    15641654      if (dos_status)
    1565         errno = EINTR;
     1655        errno = EINTR;
    15661656      else if (errno == 0)
    1567         errno = ENOMEM;
    1568       shell_function_completed = -1;
     1657        errno = ENOMEM;
     1658      if (fpipe)
     1659        pclose (fpipe);
     1660      shell_completed (127, 0);
    15691661    }
    15701662  else
     
    15731665      *pidp = 42; /* Yes, the Meaning of Life, the Universe, and Everything! */
    15741666      errno = e;
    1575       shell_function_completed = 1;
    15761667    }
    15771668  return fpipe;
     
    15861677
    15871678/* VMS can't do $(shell ...)  */
     1679
     1680char *
     1681func_shell_base (char *o, char **argv, int trim_newlines)
     1682{
     1683  fprintf (stderr, "This platform does not support shell\n");
     1684  die (MAKE_TROUBLE);
     1685  return NULL;
     1686}
     1687
    15881688#define func_shell 0
    15891689
    15901690#else
    15911691#ifndef _AMIGA
    1592 static char *
    1593 func_shell (char *o, char **argv, const char *funcname UNUSED)
     1692char *
     1693func_shell_base (char *o, char **argv, int trim_newlines)
    15941694{
    15951695  char *batch_filename = NULL;
    1596 
     1696  int errfd;
    15971697#ifdef __MSDOS__
    15981698  FILE *fpipe;
     
    16051705
    16061706#ifndef __MSDOS__
     1707#ifdef WINDOWS32
     1708  /* Reset just_print_flag.  This is needed on Windows when batch files
     1709     are used to run the commands, because we normally refrain from
     1710     creating batch files under -n.  */
     1711  int j_p_f = just_print_flag;
     1712  just_print_flag = 0;
     1713#endif
     1714
    16071715  /* Construct the argument list.  */
    16081716  command_argv = construct_command_argv (argv[0], NULL, NULL, 0,
    16091717                                         &batch_filename);
    16101718  if (command_argv == 0)
    1611     return o;
     1719    {
     1720#ifdef WINDOWS32
     1721      just_print_flag = j_p_f;
    16121722#endif
    1613 
    1614   /* Using a target environment for `shell' loses in cases like:
    1615      export var = $(shell echo foobie)
    1616      because target_environment hits a loop trying to expand $(var)
    1617      to put it in the environment.  This is even more confusing when
    1618      var was not explicitly exported, but just appeared in the
    1619      calling environment.
     1723      return o;
     1724    }
     1725#endif /* !__MSDOS__ */
     1726
     1727  /* Using a target environment for 'shell' loses in cases like:
     1728       export var = $(shell echo foobie)
     1729       bad := $(var)
     1730     because target_environment hits a loop trying to expand $(var) to put it
     1731     in the environment.  This is even more confusing when 'var' was not
     1732     explicitly exported, but just appeared in the calling environment.
    16201733
    16211734     See Savannah bug #10593.
    16221735
    1623   envp = target_environment (NILF);
     1736  envp = target_environment (NULL);
    16241737  */
    16251738
     
    16301743    {
    16311744      char *p = alloca (strlen (reading_file->filenm)+11+4);
    1632       sprintf (p, "%s:%lu: ", reading_file->filenm, reading_file->lineno);
     1745      sprintf (p, "%s:%lu: ", reading_file->filenm,
     1746               reading_file->lineno + reading_file->offset);
    16331747      error_prefix = p;
    16341748    }
    16351749  else
    16361750    error_prefix = "";
     1751
     1752  /* Set up the output in case the shell writes something.  */
     1753  output_start ();
     1754
     1755  errfd = (output_context && output_context->err >= 0
     1756           ? output_context->err : FD_STDERR);
    16371757
    16381758#if defined(__MSDOS__)
     
    16431763      return o;
    16441764    }
     1765
    16451766#elif defined(WINDOWS32)
    1646   windows32_openpipe (pipedes, &pid, command_argv, envp);
     1767  windows32_openpipe (pipedes, errfd, &pid, command_argv, envp);
     1768  /* Restore the value of just_print_flag.  */
     1769  just_print_flag = j_p_f;
     1770
    16471771  if (pipedes[0] < 0)
    16481772    {
    1649       /* open of the pipe failed, mark as failed execution */
    1650       shell_function_completed = -1;
    1651 
     1773      /* Open of the pipe failed, mark as failed execution. */
     1774      shell_completed (127, 0);
     1775      perror_with_name (error_prefix, "pipe");
    16521776      return o;
    16531777    }
    1654   else
     1778
    16551779#else
    16561780  if (pipe (pipedes) < 0)
     
    16601784    }
    16611785
    1662 # ifdef __EMX__
    1663   /* close some handles that are unnecessary for the child process */
     1786  /* Close handles that are unnecessary for the child process.  */
    16641787  CLOSE_ON_EXEC(pipedes[1]);
    16651788  CLOSE_ON_EXEC(pipedes[0]);
    1666   /* Never use fork()/exec() here! Use spawn() instead in exec_command() */
    1667   pid = child_execute_job (0, pipedes[1], command_argv, envp);
     1789
     1790  {
     1791    struct output out;
     1792    out.syncout = 1;
     1793    out.out = pipedes[1];
     1794    out.err = errfd;
     1795
     1796    pid = child_execute_job (&out, 1, command_argv, envp);
     1797  }
     1798
    16681799  if (pid < 0)
    1669     perror_with_name (error_prefix, "spawn");
    1670 # else /* ! __EMX__ */
    1671   pid = vfork ();
    1672   if (pid < 0)
    1673     perror_with_name (error_prefix, "fork");
    1674   else if (pid == 0)
    1675     child_execute_job (0, pipedes[1], command_argv, envp);
    1676   else
    1677 # endif
     1800    {
     1801      perror_with_name (error_prefix, "fork");
     1802      return o;
     1803    }
    16781804#endif
    1679     {
    1680       /* We are the parent.  */
    1681       char *buffer;
    1682       unsigned int maxlen, i;
    1683       int cc;
    1684 
    1685       /* Record the PID for reap_children.  */
    1686       shell_function_pid = pid;
     1805
     1806  {
     1807    char *buffer;
     1808    unsigned int maxlen, i;
     1809    int cc;
     1810
     1811    /* Record the PID for reap_children.  */
     1812    shell_function_pid = pid;
    16871813#ifndef  __MSDOS__
    1688       shell_function_completed = 0;
    1689 
    1690       /* Free the storage only the child needed.  */
    1691       free (command_argv[0]);
    1692       free (command_argv);
    1693 
    1694       /* Close the write side of the pipe.  We test for -1, since
    1695         pipedes[1] is -1 on MS-Windows, and some versions of MS
    1696          libraries barf when `close' is called with -1.  */
    1697       if (pipedes[1] >= 0)
    1698         close (pipedes[1]);
     1814    shell_function_completed = 0;
     1815
     1816    /* Free the storage only the child needed.  */
     1817    free (command_argv[0]);
     1818    free (command_argv);
     1819
     1820    /* Close the write side of the pipe.  We test for -1, since
     1821      pipedes[1] is -1 on MS-Windows, and some versions of MS
     1822       libraries barf when 'close' is called with -1.  */
     1823    if (pipedes[1] >= 0)
     1824      close (pipedes[1]);
    16991825#endif
    17001826
    1701       /* Set up and read from the pipe.  */
    1702 
    1703       maxlen = 200;
    1704       buffer = xmalloc (maxlen + 1);
    1705 
    1706       /* Read from the pipe until it gets EOF.  */
    1707       for (i = 0; ; i += cc)
    1708         {
    1709           if (i == maxlen)
    1710             {
    1711               maxlen += 512;
    1712               buffer = xrealloc (buffer, maxlen + 1);
    1713             }
    1714 
    1715           EINTRLOOP (cc, read (pipedes[0], &buffer[i], maxlen - i));
    1716           if (cc <= 0)
    1717             break;
    1718         }
    1719       buffer[i] = '\0';
    1720 
    1721       /* Close the read side of the pipe.  */
     1827    /* Set up and read from the pipe.  */
     1828
     1829    maxlen = 200;
     1830    buffer = xmalloc (maxlen + 1);
     1831
     1832    /* Read from the pipe until it gets EOF.  */
     1833    for (i = 0; ; i += cc)
     1834      {
     1835        if (i == maxlen)
     1836          {
     1837            maxlen += 512;
     1838            buffer = xrealloc (buffer, maxlen + 1);
     1839          }
     1840
     1841        EINTRLOOP (cc, read (pipedes[0], &buffer[i], maxlen - i));
     1842        if (cc <= 0)
     1843          break;
     1844      }
     1845    buffer[i] = '\0';
     1846
     1847    /* Close the read side of the pipe.  */
    17221848#ifdef  __MSDOS__
    1723       if (fpipe)
    1724         (void) pclose (fpipe);
     1849    if (fpipe)
     1850      {
     1851        int st = pclose (fpipe);
     1852        shell_completed (st, 0);
     1853      }
    17251854#else
    1726       (void) close (pipedes[0]);
     1855    (void) close (pipedes[0]);
    17271856#endif
    17281857
    1729       /* Loop until child_handler or reap_children()  sets
    1730          shell_function_completed to the status of our child shell.  */
    1731       while (shell_function_completed == 0)
    1732         reap_children (1, 0);
    1733 
    1734       if (batch_filename) {
    1735         DB (DB_VERBOSE, (_("Cleaning up temporary batch file %s\n"),
    1736                        batch_filename));
    1737         remove (batch_filename);
    1738         free (batch_filename);
     1858    /* Loop until child_handler or reap_children()  sets
     1859       shell_function_completed to the status of our child shell.  */
     1860    while (shell_function_completed == 0)
     1861      reap_children (1, 0);
     1862
     1863    if (batch_filename)
     1864      {
     1865        DB (DB_VERBOSE, (_("Cleaning up temporary batch file %s\n"),
     1866                         batch_filename));
     1867        remove (batch_filename);
     1868        free (batch_filename);
    17391869      }
    1740       shell_function_pid = 0;
    1741 
    1742       /* The child_handler function will set shell_function_completed
    1743          to 1 when the child dies normally, or to -1 if it
    1744          dies with status 127, which is most likely an exec fail.  */
    1745 
    1746       if (shell_function_completed == -1)
    1747         {
    1748           /* This likely means that the execvp failed, so we should just
    1749              write the error message in the pipe from the child.  */
    1750           fputs (buffer, stderr);
    1751           fflush (stderr);
    1752         }
    1753       else
    1754         {
    1755           /* The child finished normally.  Replace all newlines in its output
    1756              with spaces, and put that in the variable output buffer.  */
    1757           fold_newlines (buffer, &i);
    1758           o = variable_buffer_output (o, buffer, i);
    1759         }
    1760 
    1761       free (buffer);
    1762     }
    1763 
    1764   return o;
    1765 }
    1766 
    1767 #else   /* _AMIGA */
     1870    shell_function_pid = 0;
     1871
     1872    /* shell_completed() will set shell_function_completed to 1 when the
     1873       child dies normally, or to -1 if it dies with status 127, which is
     1874      most likely an exec fail.  */
     1875
     1876    if (shell_function_completed == -1)
     1877      {
     1878        /* This likely means that the execvp failed, so we should just
     1879           write the error message in the pipe from the child.  */
     1880        fputs (buffer, stderr);
     1881        fflush (stderr);
     1882      }
     1883    else
     1884      {
     1885        /* The child finished normally.  Replace all newlines in its output
     1886           with spaces, and put that in the variable output buffer.  */
     1887        fold_newlines (buffer, &i, trim_newlines);
     1888        o = variable_buffer_output (o, buffer, i);
     1889      }
     1890
     1891    free (buffer);
     1892  }
     1893
     1894  return o;
     1895}
     1896
     1897#else   /* _AMIGA */
    17681898
    17691899/* Do the Amiga version of func_shell.  */
    17701900
    1771 static char *
    1772 func_shell (char *o, char **argv, const char *funcname)
     1901char *
     1902func_shell_base (char *o, char **argv, int trim_newlines)
    17731903{
    17741904  /* Amiga can't fork nor spawn, but I can start a program with
     
    18001930
    18011931  /* Note the mktemp() is a security hole, but this only runs on Amiga.
    1802      Ideally we would use main.c:open_tmpfile(), but this uses a special
     1932     Ideally we would use output_tmpfile(), but this uses a special
    18031933     Open(), not fopen(), and I'm not familiar enough with the code to mess
    18041934     with it.  */
     
    18351965    {
    18361966      if (i == maxlen)
    1837         {
    1838           maxlen += 512;
    1839           buffer = xrealloc (buffer, maxlen + 1);
    1840         }
     1967        {
     1968          maxlen += 512;
     1969          buffer = xrealloc (buffer, maxlen + 1);
     1970        }
    18411971
    18421972      cc = Read (child_stdout, &buffer[i], maxlen - i);
    18431973      if (cc > 0)
    1844         i += cc;
     1974        i += cc;
    18451975    } while (cc > 0);
    18461976
    18471977  Close (child_stdout);
    18481978
    1849   fold_newlines (buffer, &i);
     1979  fold_newlines (buffer, &i, trim_newlines);
    18501980  o = variable_buffer_output (o, buffer, i);
    18511981  free (buffer);
     
    18531983}
    18541984#endif  /* _AMIGA */
     1985
     1986static char *
     1987func_shell (char *o, char **argv, const char *funcname UNUSED)
     1988{
     1989  return func_shell_base (o, argv, 1);
     1990}
    18551991#endif  /* !VMS */
    18561992
     
    18581994
    18591995/*
    1860   equality. Return is string-boolean, ie, the empty string is false.
     1996  equality. Return is string-boolean, i.e., the empty string is false.
    18611997 */
    18621998static char *
    1863 func_eq (char *o, char **argv, char *funcname)
     1999func_eq (char *o, char **argv, char *funcname UNUSED)
    18642000{
    18652001  int result = ! strcmp (argv[0], argv[1]);
     
    18732009 */
    18742010static char *
    1875 func_not (char *o, char **argv, char *funcname)
     2011func_not (char *o, char **argv, char *funcname UNUSED)
    18762012{
    18772013  const char *s = argv[0];
    18782014  int result = 0;
    1879   while (isspace ((unsigned char)*s))
    1880     s++;
     2015  NEXT_TOKEN (s);
    18812016  result = ! (*s);
    18822017  o = variable_buffer_output (o,  result ? "1" : "", result);
     
    18882023
    18892024#ifdef HAVE_DOS_PATHS
    1890 #define IS_ABSOLUTE(n) (n[0] && n[1] == ':')
    1891 #define ROOT_LEN 3
     2025# ifdef __CYGWIN__
     2026#  define IS_ABSOLUTE(n) ((n[0] && n[1] == ':') || STOP_SET (n[0], MAP_DIRSEP))
     2027# else
     2028#  define IS_ABSOLUTE(n) (n[0] && n[1] == ':')
     2029# endif
     2030# define ROOT_LEN 3
    18922031#else
    18932032#define IS_ABSOLUTE(n) (n[0] == '/')
     
    18952034#endif
    18962035
    1897 /* Return the absolute name of file NAME which does not contain any `.',
    1898    `..' components nor any repeated path separators ('/').   */
     2036/* Return the absolute name of file NAME which does not contain any '.',
     2037   '..' components nor any repeated path separators ('/').   */
    18992038
    19002039static char *
     
    19142053      /* It is unlikely we would make it until here but just to make sure. */
    19152054      if (!starting_directory)
    1916         return NULL;
     2055        return NULL;
    19172056
    19182057      strcpy (apath, starting_directory);
    19192058
    19202059#ifdef HAVE_DOS_PATHS
    1921       if (IS_PATHSEP(name[0]))
    1922         {
    1923           if (IS_PATHSEP(name[1]))
    1924             {
    1925               /* A UNC.  Don't prepend a drive letter.  */
    1926               apath[0] = name[0];
    1927               apath[1] = name[1];
    1928               root_len = 2;
    1929             }
    1930           /* We have /foo, an absolute file name except for the drive
    1931              letter.  Assume the missing drive letter is the current
    1932              drive, which we can get if we remove from starting_directory
    1933              everything past the root directory.  */
    1934           apath[root_len] = '\0';
    1935         }
     2060      if (STOP_SET (name[0], MAP_DIRSEP))
     2061        {
     2062          if (STOP_SET (name[1], MAP_DIRSEP))
     2063            {
     2064              /* A UNC.  Don't prepend a drive letter.  */
     2065              apath[0] = name[0];
     2066              apath[1] = name[1];
     2067              root_len = 2;
     2068            }
     2069          /* We have /foo, an absolute file name except for the drive
     2070             letter.  Assume the missing drive letter is the current
     2071             drive, which we can get if we remove from starting_directory
     2072             everything past the root directory.  */
     2073          apath[root_len] = '\0';
     2074        }
    19362075#endif
    19372076
     
    19402079  else
    19412080    {
     2081#if defined(__CYGWIN__) && defined(HAVE_DOS_PATHS)
     2082      if (STOP_SET (name[0], MAP_DIRSEP))
     2083        root_len = 1;
     2084#endif
    19422085      strncpy (apath, name, root_len);
    19432086      apath[root_len] = '\0';
     
    19462089      name += root_len;
    19472090#ifdef HAVE_DOS_PATHS
    1948       if (!IS_PATHSEP(apath[2]))
    1949         {
    1950           /* Convert d:foo into d:./foo and increase root_len.  */
    1951           apath[2] = '.';
    1952           apath[3] = '/';
    1953           dest++;
    1954           root_len++;
    1955           /* strncpy above copied one character too many.  */
    1956           name--;
    1957         }
     2091      if (! STOP_SET (apath[root_len - 1], MAP_DIRSEP))
     2092        {
     2093          /* Convert d:foo into d:./foo and increase root_len.  */
     2094          apath[2] = '.';
     2095          apath[3] = '/';
     2096          dest++;
     2097          root_len++;
     2098          /* strncpy above copied one character too many.  */
     2099          name--;
     2100        }
    19582101      else
    1959         apath[2] = '/'; /* make sure it's a forward slash */
     2102        apath[root_len - 1] = '/'; /* make sure it's a forward slash */
    19602103#endif
    19612104    }
     
    19662109
    19672110      /* Skip sequence of multiple path-separators.  */
    1968       while (IS_PATHSEP(*start))
    1969         ++start;
     2111      while (STOP_SET (*start, MAP_DIRSEP))
     2112        ++start;
    19702113
    19712114      /* Find end of path component.  */
    1972       for (end = start; *end != '\0' && !IS_PATHSEP(*end); ++end)
     2115      for (end = start; ! STOP_SET (*end, MAP_DIRSEP|MAP_NUL); ++end)
    19732116        ;
    19742117
     
    19762119
    19772120      if (len == 0)
    1978         break;
     2121        break;
    19792122      else if (len == 1 && start[0] == '.')
    1980         /* nothing */;
     2123        /* nothing */;
    19812124      else if (len == 2 && start[0] == '.' && start[1] == '.')
    1982         {
    1983           /* Back up to previous component, ignore if at root already.  */
    1984           if (dest > apath + root_len)
    1985             for (--dest; !IS_PATHSEP(dest[-1]); --dest);
    1986         }
     2125        {
     2126          /* Back up to previous component, ignore if at root already.  */
     2127          if (dest > apath + root_len)
     2128            for (--dest; ! STOP_SET (dest[-1], MAP_DIRSEP); --dest)
     2129              ;
     2130        }
    19872131      else
    1988         {
    1989           if (!IS_PATHSEP(dest[-1]))
     2132        {
     2133          if (! STOP_SET (dest[-1], MAP_DIRSEP))
    19902134            *dest++ = '/';
    19912135
    1992           if (dest + len >= apath_limit)
     2136          if (dest + len >= apath_limit)
    19932137            return NULL;
    19942138
    1995           dest = memcpy (dest, start, len);
     2139          dest = memcpy (dest, start, len);
    19962140          dest += len;
    1997           *dest = '\0';
    1998         }
     2141          *dest = '\0';
     2142        }
    19992143    }
    20002144
    20012145  /* Unless it is root strip trailing separator.  */
    2002   if (dest > apath + root_len && IS_PATHSEP(dest[-1]))
     2146  if (dest > apath + root_len && STOP_SET (dest[-1], MAP_DIRSEP))
    20032147    --dest;
    20042148
     
    20172161  int doneany = 0;
    20182162  unsigned int len = 0;
    2019 #ifndef HAVE_REALPATH
    2020   struct stat st;
    2021 #endif
    2022   PATH_VAR (in);
    2023   PATH_VAR (out);
    20242163
    20252164  while ((path = find_next_token (&p, &len)) != 0)
     
    20272166      if (len < GET_PATH_MAX)
    20282167        {
     2168          char *rp;
     2169          struct stat st;
     2170          PATH_VAR (in);
     2171          PATH_VAR (out);
     2172
    20292173          strncpy (in, path, len);
    20302174          in[len] = '\0';
    20312175
    2032           if (
    20332176#ifdef HAVE_REALPATH
    2034               realpath (in, out)
     2177          ENULLLOOP (rp, realpath (in, out));
    20352178#else
    2036               abspath (in, out) && stat (out, &st) == 0
     2179          rp = abspath (in, out);
    20372180#endif
    2038              )
     2181
     2182          if (rp)
    20392183            {
    2040               o = variable_buffer_output (o, out, strlen (out));
    2041               o = variable_buffer_output (o, " ", 1);
    2042               doneany = 1;
     2184              int r;
     2185              EINTRLOOP (r, stat (out, &st));
     2186              if (r == 0)
     2187                {
     2188                  o = variable_buffer_output (o, out, strlen (out));
     2189                  o = variable_buffer_output (o, " ", 1);
     2190                  doneany = 1;
     2191                }
    20432192            }
    20442193        }
     
    20482197  if (doneany)
    20492198    --o;
     2199
     2200  return o;
     2201}
     2202
     2203static char *
     2204func_file (char *o, char **argv, const char *funcname UNUSED)
     2205{
     2206  char *fn = argv[0];
     2207
     2208  if (fn[0] == '>')
     2209    {
     2210      FILE *fp;
     2211      const char *mode = "w";
     2212
     2213      /* We are writing a file.  */
     2214      ++fn;
     2215      if (fn[0] == '>')
     2216        {
     2217          mode = "a";
     2218          ++fn;
     2219        }
     2220      NEXT_TOKEN (fn);
     2221
     2222      if (fn[0] == '\0')
     2223        O (fatal, *expanding_var, _("file: missing filename"));
     2224
     2225      ENULLLOOP (fp, fopen (fn, mode));
     2226      if (fp == NULL)
     2227        OSS (fatal, reading_file, _("open: %s: %s"), fn, strerror (errno));
     2228
     2229      if (argv[1])
     2230        {
     2231          int l = strlen (argv[1]);
     2232          int nl = l == 0 || argv[1][l-1] != '\n';
     2233
     2234          if (fputs (argv[1], fp) == EOF || (nl && fputc ('\n', fp) == EOF))
     2235            OSS (fatal, reading_file, _("write: %s: %s"), fn, strerror (errno));
     2236        }
     2237      if (fclose (fp))
     2238        OSS (fatal, reading_file, _("close: %s: %s"), fn, strerror (errno));
     2239    }
     2240  else if (fn[0] == '<')
     2241    {
     2242      char *preo = o;
     2243      FILE *fp;
     2244
     2245      ++fn;
     2246      NEXT_TOKEN (fn);
     2247      if (fn[0] == '\0')
     2248        O (fatal, *expanding_var, _("file: missing filename"));
     2249
     2250      if (argv[1])
     2251        O (fatal, *expanding_var, _("file: too many arguments"));
     2252
     2253      ENULLLOOP (fp, fopen (fn, "r"));
     2254      if (fp == NULL)
     2255        {
     2256          if (errno == ENOENT)
     2257            return o;
     2258          OSS (fatal, reading_file, _("open: %s: %s"), fn, strerror (errno));
     2259        }
     2260
     2261      while (1)
     2262        {
     2263          char buf[1024];
     2264          size_t l = fread (buf, 1, sizeof (buf), fp);
     2265          if (l > 0)
     2266            o = variable_buffer_output (o, buf, l);
     2267
     2268          if (ferror (fp))
     2269            if (errno != EINTR)
     2270              OSS (fatal, reading_file, _("read: %s: %s"), fn, strerror (errno));
     2271          if (feof (fp))
     2272            break;
     2273        }
     2274      if (fclose (fp))
     2275        OSS (fatal, reading_file, _("close: %s: %s"), fn, strerror (errno));
     2276
     2277      /* Remove trailing newline.  */
     2278      if (o > preo && o[-1] == '\n')
     2279        if (--o > preo && o[-1] == '\r')
     2280          --o;
     2281    }
     2282  else
     2283    OS (fatal, *expanding_var, _("file: invalid file operation: %s"), fn);
    20502284
    20512285  return o;
     
    20602294  int doneany = 0;
    20612295  unsigned int len = 0;
    2062   PATH_VAR (in);
    2063   PATH_VAR (out);
    20642296
    20652297  while ((path = find_next_token (&p, &len)) != 0)
     
    20672299      if (len < GET_PATH_MAX)
    20682300        {
     2301          PATH_VAR (in);
     2302          PATH_VAR (out);
     2303
    20692304          strncpy (in, path, len);
    20702305          in[len] = '\0';
     
    21002335static char *func_call (char *o, char **argv, const char *funcname);
    21012336
     2337#define FT_ENTRY(_name, _min, _max, _exp, _func) \
     2338  { { (_func) }, STRING_SIZE_TUPLE(_name), (_min), (_max), (_exp), 0 }
    21022339
    21032340static struct function_table_entry function_table_init[] =
    21042341{
    2105  /* Name/size */                    /* MIN MAX EXP? Function */
    2106   { STRING_SIZE_TUPLE("abspath"),       0,  1,  1,  func_abspath},
    2107   { STRING_SIZE_TUPLE("addprefix"),     2,  2,  1,  func_addsuffix_addprefix},
    2108   { STRING_SIZE_TUPLE("addsuffix"),     2,  2,  1,  func_addsuffix_addprefix},
    2109   { STRING_SIZE_TUPLE("basename"),      0,  1,  1,  func_basename_dir},
    2110   { STRING_SIZE_TUPLE("dir"),           0,  1,  1,  func_basename_dir},
    2111   { STRING_SIZE_TUPLE("notdir"),        0,  1,  1,  func_notdir_suffix},
    2112   { STRING_SIZE_TUPLE("subst"),         3,  3,  1,  func_subst},
    2113   { STRING_SIZE_TUPLE("suffix"),        0,  1,  1,  func_notdir_suffix},
    2114   { STRING_SIZE_TUPLE("filter"),        2,  2,  1,  func_filter_filterout},
    2115   { STRING_SIZE_TUPLE("filter-out"),    2,  2,  1,  func_filter_filterout},
    2116   { STRING_SIZE_TUPLE("findstring"),    2,  2,  1,  func_findstring},
    2117   { STRING_SIZE_TUPLE("firstword"),     0,  1,  1,  func_firstword},
    2118   { STRING_SIZE_TUPLE("flavor"),        0,  1,  1,  func_flavor},
    2119   { STRING_SIZE_TUPLE("join"),          2,  2,  1,  func_join},
    2120   { STRING_SIZE_TUPLE("lastword"),      0,  1,  1,  func_lastword},
    2121   { STRING_SIZE_TUPLE("patsubst"),      3,  3,  1,  func_patsubst},
    2122   { STRING_SIZE_TUPLE("realpath"),      0,  1,  1,  func_realpath},
    2123   { STRING_SIZE_TUPLE("shell"),         0,  1,  1,  func_shell},
    2124   { STRING_SIZE_TUPLE("sort"),          0,  1,  1,  func_sort},
    2125   { STRING_SIZE_TUPLE("strip"),         0,  1,  1,  func_strip},
    2126   { STRING_SIZE_TUPLE("wildcard"),      0,  1,  1,  func_wildcard},
    2127   { STRING_SIZE_TUPLE("word"),          2,  2,  1,  func_word},
    2128   { STRING_SIZE_TUPLE("wordlist"),      3,  3,  1,  func_wordlist},
    2129   { STRING_SIZE_TUPLE("words"),         0,  1,  1,  func_words},
    2130   { STRING_SIZE_TUPLE("origin"),        0,  1,  1,  func_origin},
    2131   { STRING_SIZE_TUPLE("foreach"),       3,  3,  0,  func_foreach},
    2132   { STRING_SIZE_TUPLE("call"),          1,  0,  1,  func_call},
    2133   { STRING_SIZE_TUPLE("info"),          0,  1,  1,  func_error},
    2134   { STRING_SIZE_TUPLE("error"),         0,  1,  1,  func_error},
    2135   { STRING_SIZE_TUPLE("warning"),       0,  1,  1,  func_error},
    2136   { STRING_SIZE_TUPLE("if"),            2,  3,  0,  func_if},
    2137   { STRING_SIZE_TUPLE("or"),            1,  0,  0,  func_or},
    2138   { STRING_SIZE_TUPLE("and"),           1,  0,  0,  func_and},
    2139   { STRING_SIZE_TUPLE("value"),         0,  1,  1,  func_value},
    2140   { STRING_SIZE_TUPLE("eval"),          0,  1,  1,  func_eval},
     2342 /*         Name            MIN MAX EXP? Function */
     2343  FT_ENTRY ("abspath",       0,  1,  1,  func_abspath),
     2344  FT_ENTRY ("addprefix",     2,  2,  1,  func_addsuffix_addprefix),
     2345  FT_ENTRY ("addsuffix",     2,  2,  1,  func_addsuffix_addprefix),
     2346  FT_ENTRY ("basename",      0,  1,  1,  func_basename_dir),
     2347  FT_ENTRY ("dir",           0,  1,  1,  func_basename_dir),
     2348  FT_ENTRY ("notdir",        0,  1,  1,  func_notdir_suffix),
     2349  FT_ENTRY ("subst",         3,  3,  1,  func_subst),
     2350  FT_ENTRY ("suffix",        0,  1,  1,  func_notdir_suffix),
     2351  FT_ENTRY ("filter",        2,  2,  1,  func_filter_filterout),
     2352  FT_ENTRY ("filter-out",    2,  2,  1,  func_filter_filterout),
     2353  FT_ENTRY ("findstring",    2,  2,  1,  func_findstring),
     2354  FT_ENTRY ("firstword",     0,  1,  1,  func_firstword),
     2355  FT_ENTRY ("flavor",        0,  1,  1,  func_flavor),
     2356  FT_ENTRY ("join",          2,  2,  1,  func_join),
     2357  FT_ENTRY ("lastword",      0,  1,  1,  func_lastword),
     2358  FT_ENTRY ("patsubst",      3,  3,  1,  func_patsubst),
     2359  FT_ENTRY ("realpath",      0,  1,  1,  func_realpath),
     2360  FT_ENTRY ("shell",         0,  1,  1,  func_shell),
     2361  FT_ENTRY ("sort",          0,  1,  1,  func_sort),
     2362  FT_ENTRY ("strip",         0,  1,  1,  func_strip),
     2363  FT_ENTRY ("wildcard",      0,  1,  1,  func_wildcard),
     2364  FT_ENTRY ("word",          2,  2,  1,  func_word),
     2365  FT_ENTRY ("wordlist",      3,  3,  1,  func_wordlist),
     2366  FT_ENTRY ("words",         0,  1,  1,  func_words),
     2367  FT_ENTRY ("origin",        0,  1,  1,  func_origin),
     2368  FT_ENTRY ("foreach",       3,  3,  0,  func_foreach),
     2369  FT_ENTRY ("call",          1,  0,  1,  func_call),
     2370  FT_ENTRY ("info",          0,  1,  1,  func_error),
     2371  FT_ENTRY ("error",         0,  1,  1,  func_error),
     2372  FT_ENTRY ("warning",       0,  1,  1,  func_error),
     2373  FT_ENTRY ("if",            2,  3,  0,  func_if),
     2374  FT_ENTRY ("or",            1,  0,  0,  func_or),
     2375  FT_ENTRY ("and",           1,  0,  0,  func_and),
     2376  FT_ENTRY ("value",         0,  1,  1,  func_value),
     2377  FT_ENTRY ("eval",          0,  1,  1,  func_eval),
     2378  FT_ENTRY ("file",          1,  2,  1,  func_file),
    21412379#ifdef EXPERIMENTAL
    2142   { STRING_SIZE_TUPLE("eq"),            2,  2,  1,  func_eq},
    2143   { STRING_SIZE_TUPLE("not"),           0,  1,  1,  func_not},
     2380  FT_ENTRY ("eq",            2,  2,  1,  func_eq),
     2381  FT_ENTRY ("not",           0,  1,  1,  func_not),
    21442382#endif
    21452383};
     
    21552393                         const struct function_table_entry *entry_p)
    21562394{
     2395  char *p;
     2396
    21572397  if (argc < (int)entry_p->minimum_args)
    2158     fatal (*expanding_var,
    2159            _("insufficient number of arguments (%d) to function `%s'"),
     2398    fatal (*expanding_var, strlen (entry_p->name),
     2399           _("insufficient number of arguments (%d) to function '%s'"),
    21602400           argc, entry_p->name);
    21612401
    2162   /* I suppose technically some function could do something with no
    2163      arguments, but so far none do, so just test it for all functions here
     2402  /* I suppose technically some function could do something with no arguments,
     2403     but so far no internal ones do, so just test it for all functions here
    21642404     rather than in each one.  We can change it later if necessary.  */
    21652405
    2166   if (!argc)
     2406  if (!argc && !entry_p->alloc_fn)
    21672407    return o;
    21682408
    2169   if (!entry_p->func_ptr)
    2170     fatal (*expanding_var,
    2171            _("unimplemented on this platform: function `%s'"), entry_p->name);
    2172 
    2173   return entry_p->func_ptr (o, argv, entry_p->name);
     2409  if (!entry_p->fptr.func_ptr)
     2410    OS (fatal, *expanding_var,
     2411        _("unimplemented on this platform: function '%s'"), entry_p->name);
     2412
     2413  if (!entry_p->alloc_fn)
     2414    return entry_p->fptr.func_ptr (o, argv, entry_p->name);
     2415
     2416  /* This function allocates memory and returns it to us.
     2417     Write it to the variable buffer, then free it.  */
     2418
     2419  p = entry_p->fptr.alloc_func_ptr (entry_p->name, argc, argv);
     2420  if (p)
     2421    {
     2422      o = variable_buffer_output (o, p, strlen (p));
     2423      free (p);
     2424    }
     2425
     2426  return o;
    21742427}
    21752428
     
    22022455     whitespace after the name).  */
    22032456
    2204   beg = next_token (beg + entry_p->len);
     2457  beg += entry_p->len;
     2458  NEXT_TOKEN (beg);
    22052459
    22062460  /* Find the end of the function invocation, counting nested use of
     
    22182472
    22192473  if (count >= 0)
    2220     fatal (*expanding_var,
    2221            _("unterminated call to function `%s': missing `%c'"),
    2222            entry_p->name, closeparen);
     2474    fatal (*expanding_var, strlen (entry_p->name),
     2475           _("unterminated call to function '%s': missing '%c'"),
     2476           entry_p->name, closeparen);
    22232477
    22242478  *stringp = end;
     
    22862540    for (argvp=argv; *argvp != 0; ++argvp)
    22872541      free (*argvp);
    2288   if (abeg)
     2542  else
    22892543    free (abeg);
    22902544
     
    23032557  static int max_args = 0;
    23042558  char *fname;
    2305   char *cp;
    23062559  char *body;
    23072560  int flen;
     
    23112564  struct variable *v;
    23122565
    2313   /* There is no way to define a variable with a space in the name, so strip
    2314      leading and trailing whitespace as a favor to the user.  */
    2315   fname = argv[0];
    2316   while (*fname != '\0' && isspace ((unsigned char)*fname))
    2317     ++fname;
    2318 
    2319   cp = fname + strlen (fname) - 1;
    2320   while (cp > fname && isspace ((unsigned char)*cp))
    2321     --cp;
    2322   cp[1] = '\0';
     2566  /* Clean up the name of the variable to be invoked.  */
     2567  fname = next_token (argv[0]);
     2568  end_of_token (fname)[0] = '\0';
    23232569
    23242570  /* Calling nothing is a no-op */
     
    23992645
    24002646void
     2647define_new_function (const floc *flocp, const char *name,
     2648                     unsigned int min, unsigned int max, unsigned int flags,
     2649                     gmk_func_ptr func)
     2650{
     2651  const char *e = name;
     2652  struct function_table_entry *ent;
     2653  size_t len;
     2654
     2655  while (STOP_SET (*e, MAP_USERFUNC))
     2656    e++;
     2657  len = e - name;
     2658
     2659  if (len == 0)
     2660    O (fatal, flocp, _("Empty function name"));
     2661  if (*name == '.' || *e != '\0')
     2662    OS (fatal, flocp, _("Invalid function name: %s"), name);
     2663  if (len > 255)
     2664    OS (fatal, flocp, _("Function name too long: %s"), name);
     2665  if (min > 255)
     2666    ONS (fatal, flocp,
     2667         _("Invalid minimum argument count (%u) for function %s"), min, name);
     2668  if (max > 255 || (max && max < min))
     2669    ONS (fatal, flocp,
     2670         _("Invalid maximum argument count (%u) for function %s"), max, name);
     2671
     2672  ent = xmalloc (sizeof (struct function_table_entry));
     2673  ent->name = name;
     2674  ent->len = len;
     2675  ent->minimum_args = min;
     2676  ent->maximum_args = max;
     2677  ent->expand_args = ANY_SET(flags, GMK_FUNC_NOEXPAND) ? 0 : 1;
     2678  ent->alloc_fn = 1;
     2679  ent->fptr.alloc_func_ptr = func;
     2680
     2681  hash_insert (&function_table, ent);
     2682}
     2683
     2684void
    24012685hash_init_function_table (void)
    24022686{
    24032687  hash_init (&function_table, FUNCTION_TABLE_ENTRIES * 2,
    2404              function_table_entry_hash_1, function_table_entry_hash_2,
    2405              function_table_entry_hash_cmp);
     2688             function_table_entry_hash_1, function_table_entry_hash_2,
     2689             function_table_entry_hash_cmp);
    24062690  hash_load (&function_table, function_table_init,
    2407              FUNCTION_TABLE_ENTRIES, sizeof (struct function_table_entry));
    2408 }
     2691             FUNCTION_TABLE_ENTRIES, sizeof (struct function_table_entry));
     2692}
  • vendor/gnumake/current/getloadavg.c

    r2596 r3138  
    11/* Get the system load averages.
    2 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
    3 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
    4 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1985-2016 Free Software Foundation, Inc.
    53
    64GNU Make is free software; you can redistribute it and/or modify it under the
     
    8785
    8886/* Exclude all the code except the test program at the end
    89    if the system has its own `getloadavg' function.
    90 
    91    The declaration of `errno' is needed by the test program
     87   if the system has its own 'getloadavg' function.
     88
     89   The declaration of 'errno' is needed by the test program
    9290   as well as the function itself, so it comes first.  */
    9391
     
    748746  /* This call can return -1 for an error, but with good args
    749747     it's not supposed to fail.  The first argument is for no
    750      apparent reason of type `long int *'.  */
     748     apparent reason of type 'long int *'.  */
    751749  dg_sys_info ((long int *) &load_info,
    752750               DG_SYS_INFO_LOAD_INFO_TYPE,
     
    991989
    992990#ifdef TEST
    993 #include "make.h"
     991#include "makeint.h"
    994992
    995993int
  • vendor/gnumake/current/getopt.c

    r2596 r3138  
    44before changing it!
    55
    6 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
    7 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    8 2010 Free Software Foundation, Inc.
     6Copyright (C) 1987-2016 Free Software Foundation, Inc.
    97
    108NOTE: The canonical source of this file is maintained with the GNU C Library.
     
    8482
    8583
    86 /* This version of `getopt' appears to the caller like standard Unix `getopt'
     84/* This version of `getopt' appears to the caller like standard Unix 'getopt'
    8785   but it behaves differently for the user, since it allows the user
    8886   to intersperse the options with the other arguments.
     
    662660        {
    663661          if (opterr)
    664             fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
     662            fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
    665663                     argv[0], argv[optind]);
    666664          nextchar += strlen (nextchar);
     
    686684                    /* --option */
    687685                    fprintf (stderr,
    688                      _("%s: option `--%s' doesn't allow an argument\n"),
     686                     _("%s: option '--%s' doesn't allow an argument\n"),
    689687                     argv[0], pfound->name);
    690688                   else
    691689                    /* +option or -option */
    692690                    fprintf (stderr,
    693                      _("%s: option `%c%s' doesn't allow an argument\n"),
     691                     _("%s: option '%c%s' doesn't allow an argument\n"),
    694692                     argv[0], argv[optind - 1][0], pfound->name);
    695693
     
    708706                  if (opterr)
    709707                    fprintf (stderr,
    710                            _("%s: option `%s' requires an argument\n"),
     708                           _("%s: option '%s' requires an argument\n"),
    711709                           argv[0], argv[optind - 1]);
    712710                  nextchar += strlen (nextchar);
     
    737735              if (argv[optind][1] == '-')
    738736                /* --option */
    739                 fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
     737                fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
    740738                         argv[0], nextchar);
    741739              else
    742740                /* +option or -option */
    743                 fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
     741                fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
    744742                         argv[0], argv[optind][0], nextchar);
    745743            }
     
    847845          {
    848846            if (opterr)
    849               fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
     847              fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
    850848                       argv[0], argv[optind]);
    851849            nextchar += strlen (nextchar);
     
    866864                    if (opterr)
    867865                      fprintf (stderr, _("\
    868 %s: option `-W %s' doesn't allow an argument\n"),
     866%s: option '-W %s' doesn't allow an argument\n"),
    869867                               argv[0], pfound->name);
    870868
     
    881879                    if (opterr)
    882880                      fprintf (stderr,
    883                                _("%s: option `%s' requires an argument\n"),
     881                               _("%s: option '%s' requires an argument\n"),
    884882                               argv[0], argv[optind - 1]);
    885883                    nextchar += strlen (nextchar);
     
    10081006
    10091007        case 'c':
    1010           printf ("option c with value `%s'\n", optarg);
     1008          printf ("option c with value '%s'\n", optarg);
    10111009          break;
    10121010
  • vendor/gnumake/current/getopt.h

    r2596 r3138  
    11/* Declarations for getopt.
    2 Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
    3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
    4 Software Foundation, Inc.
     2Copyright (C) 1989-2016 Free Software Foundation, Inc.
    53
    64NOTE: The canonical source of this file is maintained with the GNU C Library.
  • vendor/gnumake/current/getopt1.c

    r2596 r3138  
    11/* getopt_long and getopt_long_only entry points for GNU getopt.
    2 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1987-1994, 1996-2016 Free Software Foundation, Inc.
    53
    64NOTE: The canonical source of this file is maintained with the GNU C Library.
     
    152150
    153151        case 'c':
    154           printf ("option c with value `%s'\n", optarg);
     152          printf ("option c with value '%s'\n", optarg);
    155153          break;
    156154
    157155        case 'd':
    158           printf ("option d with value `%s'\n", optarg);
     156          printf ("option d with value '%s'\n", optarg);
    159157          break;
    160158
  • vendor/gnumake/current/gettext.h

    r2596 r3138  
    11/* Convenience header for conditional use of GNU <libintl.h>.
    2 Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1995-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
  • vendor/gnumake/current/glob/ChangeLog

    r2596 r3138  
     12013-10-20  Paul Smith  <psmith@gnu.org>
     2
     3        * glob.c (glob): Cherry-pick a471e96a5352a5f0bde6d32dd36d33524811a2b1
     4        from git://sourceware.org/git/glibc.git to fix SV 18123,
     5        https://sourceware.org/bugzilla/show_bug.cgi?id=10278
     6
    172008-09-28  Juan Manuel Guerrero  <juan.guerrero@gmx.de>
    28
  • vendor/gnumake/current/glob/glob.c

    r2596 r3138  
    378378      return -1;
    379379    }
     380
     381  /* POSIX requires all slashes to be matched.  This means that with
     382     a trailing slash we must match only directories.  */
     383  if (pattern[0] && pattern[strlen (pattern) - 1] == '/')
     384    flags |= GLOB_ONLYDIR;
    380385
    381386  if (flags & GLOB_BRACE)
  • vendor/gnumake/current/glob/glob.h

    r1989 r3138  
    5757/* This is a guess.  */
    5858/*hb
    59  *      Conflicts with DECCs aready defined type __size_t.
     59 *      Conflicts with DECCs already defined type __size_t.
    6060 *      Defining an own type with a name beginning with '__' is no good.
    6161 *      Anyway if DECC is used and __SIZE_T is defined then __size_t is
  • vendor/gnumake/current/hash.c

    r2596 r3138  
    1515this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1616
    17 #include "make.h"
     17#include "makeint.h"
    1818#include "hash.h"
    1919
    20 #define CALLOC(t, n) ((t *) calloc (sizeof (t), (n)))
     20#define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n)))
    2121#define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
    2222#define REALLOC(o, t, n) ((t *) xrealloc ((o), sizeof (t) * (n)))
     
    2727
    2828/* Implement double hashing with open addressing.  The table size is
    29    always a power of two.  The secondary (`increment') hash function
     29   always a power of two.  The secondary ('increment') hash function
    3030   is forced to return an odd-value, in order to be relatively prime
    3131   to the table size.  This guarantees that the increment can
     
    4949      fprintf (stderr, _("can't allocate %lu bytes for hash table: memory exhausted"),
    5050               ht->ht_size * (unsigned long) sizeof (struct token *));
    51       exit (1);
     51      exit (MAKE_TROUBLE);
    5252    }
    5353
     
    6262}
    6363
    64 /* Load an array of items into `ht'.  */
     64/* Load an array of items into 'ht'.  */
    6565
    6666void
     
    7676}
    7777
    78 /* Returns the address of the table slot matching `key'.  If `key' is
     78/* Returns the address of the table slot matching 'key'.  If 'key' is
    7979   not found, return the address of an empty slot suitable for
    80    inserting `key'.  The caller is responsible for incrementing
     80   inserting 'key'.  The caller is responsible for incrementing
    8181   ht_fill on insertion.  */
    8282
  • vendor/gnumake/current/hash.h

    r2596 r3138  
    2929# undef __P
    3030# define __P(protos)    ()
    31 /* We can get away without defining `const' here only because in this file
    32    it is used only inside the prototype for `fnmatch', which is elided in
    33    non-ANSI C where `const' is problematical.  */
     31/* We can get away without defining 'const' here only because in this file
     32   it is used only inside the prototype for 'fnmatch', which is elided in
     33   non-ANSI C where 'const' is problematical.  */
    3434#endif /* C++ or ANSI C.  */
    3535
     
    4242{
    4343  void **ht_vec;
     44  hash_func_t ht_hash_1;        /* primary hash function */
     45  hash_func_t ht_hash_2;        /* secondary hash function */
     46  hash_cmp_func_t ht_compare;   /* comparison function */
    4447  unsigned long ht_size;        /* total number of slots (power of 2) */
    4548  unsigned long ht_capacity;    /* usable slots, limited by loading-factor */
     
    4952  unsigned long ht_lookups;     /* # of queries */
    5053  unsigned int ht_rehashes;     /* # of times we've expanded table */
    51   hash_func_t ht_hash_1;        /* primary hash function */
    52   hash_func_t ht_hash_2;        /* secondary hash function */
    53   hash_cmp_func_t ht_compare;   /* comparison function */
    5454};
    5555
  • vendor/gnumake/current/implicit.c

    r2596 r3138  
    11/* Implicit rule searching for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018#include "filedef.h"
    2119#include "rule.h"
     
    3937try_implicit_rule (struct file *file, unsigned int depth)
    4038{
    41   DBF (DB_IMPLICIT, _("Looking for an implicit rule for `%s'.\n"));
     39  DBF (DB_IMPLICIT, _("Looking for an implicit rule for '%s'.\n"));
    4240
    4341  /* The order of these searches was previously reversed.  My logic now is
     
    5553    {
    5654      DBF (DB_IMPLICIT,
    57            _("Looking for archive-member implicit rule for `%s'.\n"));
     55           _("Looking for archive-member implicit rule for '%s'.\n"));
    5856      if (pattern_search (file, 1, depth, 0))
    5957        return 1;
     
    7775
    7876  /* Skip any leading whitespace.  */
    79   while (isblank ((unsigned char)*p))
    80     ++p;
     77  NEXT_TOKEN (p);
    8178
    8279  beg = p;
     
    222219
    223220  /* List of dependencies found recursively.  */
    224   struct patdeps *deplist
    225     = xmalloc (max_pattern_deps * sizeof (struct patdeps));
     221  unsigned int max_deps = max_pattern_deps;
     222  struct patdeps *deplist = xmalloc (max_deps * sizeof (struct patdeps));
    226223  struct patdeps *pat = deplist;
    227 
    228   /* All the prerequisites actually found for a rule, after expansion.  */
    229   struct dep *deps;
    230224
    231225  /* Names of possible dependencies are constructed in this buffer.  */
     
    254248
    255249  /* Nonzero if we have matched a pattern-rule target
    256      that is not just `%'.  */
     250     that is not just '%'.  */
    257251  int specific_rule_matched = 0;
    258 
    259   struct dep dep_simple;
    260252
    261253  unsigned int ri;  /* uninit checks OK */
     
    276268         but not counting any slash at the end.  (foo/bar/ counts as
    277269         bar/ in directory foo/, not empty in directory foo/bar/.)  */
     270      lastslash = strrchr (filename, '/');
    278271#ifdef VMS
    279       lastslash = strrchr (filename, ']');
    280       if (lastslash == 0)
     272      if (lastslash == NULL)
     273        lastslash = strrchr (filename, ']');
     274      if (lastslash == NULL)
     275        lastslash = strrchr (filename, '>');
     276      if (lastslash == NULL)
    281277        lastslash = strrchr (filename, ':');
    282 #else
    283       lastslash = strrchr (filename, '/');
     278#endif
    284279#ifdef HAVE_DOS_PATHS
    285280      /* Handle backslashes (possibly mixed with forward slashes)
     
    293288      }
    294289#endif
    295 #endif
    296290      if (lastslash != 0 && lastslash[1] == '\0')
    297291        lastslash = 0;
     
    325319          const char *target = rule->targets[ti];
    326320          const char *suffix = rule->suffixes[ti];
    327           int check_lastslash;
     321          char check_lastslash;
    328322
    329323          /* Rules that can match any filename and are not terminal
     
    349343            {
    350344#ifdef VMS
    351               check_lastslash = (strchr (target, ']') == 0
    352                                  && strchr (target, ':') == 0);
     345              check_lastslash = strpbrk (target, "/]>:") == NULL;
    353346#else
    354347              check_lastslash = strchr (target, '/') == 0;
     348#endif
    355349#ifdef HAVE_DOS_PATHS
    356350              /* Didn't find it yet: check for DOS-type directories.  */
     
    360354                  check_lastslash = !(b || (target[0] && target[1] == ':'));
    361355                }
    362 #endif
    363356#endif
    364357            }
     
    405398             that rule will be in TRYRULES more than once.  */
    406399          tryrules[nrules].rule = rule;
    407           tryrules[nrules].matches = ti;
     400          tryrules[nrules].matches = ti;
    408401          tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0);
    409402          tryrules[nrules].order = nrules;
    410           tryrules[nrules].checked_lastslash = check_lastslash;
     403          tryrules[nrules].checked_lastslash = check_lastslash;
    411404          ++nrules;
    412405        }
     
    447440        {
    448441          struct dep *dep;
    449           int check_lastslash;
     442          char check_lastslash;
    450443          unsigned int failed = 0;
    451444          int file_variables_set = 0;
     
    491484            }
    492485
    493           DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
     486          if (stemlen > GET_PATH_MAX)
     487            {
     488              DBS (DB_IMPLICIT, (_("Stem too long: '%.*s'.\n"),
     489                                 (int) stemlen, stem));
     490              continue;
     491            }
     492
     493          DBS (DB_IMPLICIT, (_("Trying pattern rule with stem '%.*s'.\n"),
    494494                             (int) stemlen, stem));
    495495
     
    533533              if (! dep->need_2nd_expansion)
    534534                {
    535                   dep_simple = *dep;
    536                   dep_simple.next = 0;
    537535                  p = strchr (nptr, '%');
    538536                  if (p == 0)
    539                     dep_simple.name = nptr;
     537                    strcpy (depname, nptr);
    540538                  else
    541539                    {
     
    551549                      o += stemlen;
    552550                      strcpy (o, p + 1);
    553                       dep_simple.name = strcache_add (depname);
    554                     }
    555                   dl = &dep_simple;
     551                    }
     552
     553                  /* Parse the expanded string.  It might have wildcards.  */
     554                  p = depname;
     555                  dl = PARSE_SIMPLE_SEQ (&p, struct dep);
     556                  for (d = dl; d != NULL; d = d->next)
     557                    {
     558                      ++deps_found;
     559                      d->ignore_mtime = dep->ignore_mtime;
     560                    }
    556561
    557562                  /* We've used up this dep, so next time get a new one.  */
    558563                  nptr = 0;
    559                   ++deps_found;
    560564                }
    561565
     
    573577                  int add_dir = 0;
    574578                  unsigned int len;
     579                  struct dep **dptr;
    575580
    576581                  nptr = get_next_word (nptr, &len);
     
    615620                    }
    616621
     622                  /* Set up for the next word.  */
     623                  nptr += len;
     624
    617625                  /* Initialize and set file variables if we haven't already
    618626                     done so. */
     
    633641                  /* Perform the 2nd expansion.  */
    634642                  p = variable_expand_for_file (depname, file);
    635 
    636                   /* Parse the expanded string. */
    637                   dl = PARSE_FILE_SEQ (&p, struct dep, order_only ? '\0' : '|',
    638                                        add_dir ? dir : NULL, 0);
    639 
    640                   for (d = dl; d != NULL; d = d->next)
    641                     {
    642                       ++deps_found;
    643                       if (order_only)
    644                         d->ignore_mtime = 1;
    645                     }
    646 
    647                   /* Set up for the next word.  */
    648                   nptr += len;
     643                  dptr = &dl;
     644
     645                  /* Parse the results into a deps list.  */
     646                  do
     647                    {
     648                      /* Parse the expanded string. */
     649                      struct dep *dp = PARSE_FILE_SEQ (&p, struct dep,
     650                                                       order_only ? MAP_NUL : MAP_PIPE,
     651                                                       add_dir ? dir : NULL, PARSEFS_NONE);
     652                      *dptr = dp;
     653
     654                      for (d = dp; d != NULL; d = d->next)
     655                        {
     656                          ++deps_found;
     657                          if (order_only)
     658                            d->ignore_mtime = 1;
     659                          dptr = &d->next;
     660                        }
     661
     662                      /* If we stopped due to an order-only token, note it.  */
     663                      if (*p == '|')
     664                        {
     665                          order_only = 1;
     666                          ++p;
     667                        }
     668                    }
     669                  while (*p != '\0');
    649670                }
    650671
     
    652673                 2nd expansion), reset it and realloc the arrays.  */
    653674
    654               if (deps_found > max_pattern_deps)
     675              if (deps_found > max_deps)
    655676                {
    656677                  unsigned int l = pat - deplist;
     678                  /* This might have changed due to recursion.  */
     679                  max_pattern_deps = MAX(max_pattern_deps, deps_found);
     680                  max_deps = max_pattern_deps;
    657681                  deplist = xrealloc (deplist,
    658                                       deps_found * sizeof (struct patdeps));
     682                                      max_deps * sizeof (struct patdeps));
    659683                  pat = deplist + l;
    660                   max_pattern_deps = deps_found;
    661684                }
    662685
     
    674697                      DBS (DB_IMPLICIT,
    675698                           (is_rule
    676                             ? _("Rejecting impossible rule prerequisite `%s'.\n")
    677                             : _("Rejecting impossible implicit prerequisite `%s'.\n"),
     699                            ? _("Rejecting impossible rule prerequisite '%s'.\n")
     700                            : _("Rejecting impossible implicit prerequisite '%s'.\n"),
    678701                            d->name));
    679702                      tryrules[ri].rule = 0;
     
    688711                  DBS (DB_IMPLICIT,
    689712                       (is_rule
    690                         ? _("Trying rule prerequisite `%s'.\n")
    691                         : _("Trying implicit prerequisite `%s'.\n"), d->name));
     713                        ? _("Trying rule prerequisite '%s'.\n")
     714                        : _("Trying implicit prerequisite '%s'.\n"), d->name));
    692715
    693716                  /* If this prereq is also explicitly mentioned for FILE,
     
    728751                      {
    729752                        DBS (DB_IMPLICIT,
    730                              (_("Found prerequisite `%s' as VPATH `%s'\n"),
     753                             (_("Found prerequisite '%s' as VPATH '%s'\n"),
    731754                              d->name, vname));
    732755                        (pat++)->name = d->name;
     
    742765                    {
    743766                      DBS (DB_IMPLICIT,
    744                            (_("Looking for a rule with intermediate file `%s'.\n"),
     767                           (_("Looking for a rule with intermediate file '%s'.\n"),
    745768                            d->name));
    746769
     
    758781                          int_file->name = d->name;
    759782                          pat->file = int_file;
     783                          int_file = 0;
    760784                          (pat++)->name = d->name;
    761                           int_file = 0;
    762785                          continue;
    763786                        }
     
    780803
    781804              /* Free the ns chain.  */
    782               if (dl != &dep_simple)
    783                 free_dep_chain (dl);
     805              free_dep_chain (dl);
    784806
    785807              if (failed)
     
    791813          file->stem = 0;
    792814
    793           /* This rule is no longer `in use' for recursive searches.  */
     815          /* This rule is no longer 'in use' for recursive searches.  */
    794816          rule->in_use = 0;
    795817
     
    798820            break;
    799821
    800           /* This pattern rule does not apply. If some of its dependencies
    801              succeeded, free the data structure describing them.  */
    802           /* free_idep_chain (deps); */
    803           deps = 0;
     822          /* This pattern rule does not apply.  Keep looking.  */
    804823        }
    805824
     
    847866          /* We don't want to delete an intermediate file that happened
    848867             to be a prerequisite of some (other) target. Mark it as
    849              precious.  */
     868             secondary.  We don't want it to be precious as that disables
     869             DELETE_ON_ERROR etc.  */
    850870          if (f != 0)
    851             f->precious = 1;
     871            f->secondary = 1;
    852872          else
    853873            f = enter_file (imf->name);
     
    893913             the rule that found it was a terminal one, then we want to mark
    894914             the found file so that it will not have implicit rule search done
    895              for it.  If we are not entering a `struct file' for it now, we
    896              indicate this with the `changed' flag.  */
     915             for it.  If we are not entering a 'struct file' for it now, we
     916             indicate this with the 'changed' flag.  */
    897917          if (dep->file == 0)
    898918            dep->changed = 1;
     
    938958
    939959  /* If this rule builds other targets, too, put the others into FILE's
    940      `also_make' member.  */
     960     'also_make' member.  */
    941961
    942962  if (rule->num > 1)
  • vendor/gnumake/current/job.c

    r2596 r3138  
    11/* Job execution and handling for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018
    2119#include <assert.h>
     
    2624#include "commands.h"
    2725#include "variable.h"
    28 #include "debug.h"
     26#include "os.h"
    2927
    3028#include <string.h>
     
    3432#include <windows.h>
    3533
    36 char *default_shell = "sh.exe";
     34const char *default_shell = "sh.exe";
    3735int no_default_sh_exe = 1;
    3836int batch_mode_shell = 1;
     
    4139#elif defined (_AMIGA)
    4240
    43 char default_shell[] = "";
     41const char *default_shell = "";
    4442extern int MyExecute (char **);
    4543int batch_mode_shell = 0;
     
    5149   to search the $PATH for it (since MSDOS doesn't have standard
    5250   directories we could trust).  */
    53 char *default_shell = "command.com";
     51const char *default_shell = "command.com";
    5452int batch_mode_shell = 0;
    5553
    5654#elif defined (__EMX__)
    5755
    58 char *default_shell = "/bin/sh";
     56const char *default_shell = "/bin/sh";
    5957int batch_mode_shell = 0;
    6058
     
    6260
    6361# include <descrip.h>
    64 char default_shell[] = "";
     62# include <stsdef.h>
     63const char *default_shell = "";
    6564int batch_mode_shell = 0;
    6665
    67 #elif defined (__riscos__)
    68 
    69 char default_shell[] = "";
    70 int batch_mode_shell = 0;
     66#define strsignal vms_strsignal
     67char * vms_strsignal (int status);
     68
     69#ifndef C_FACILITY_NO
     70# define C_FACILITY_NO 0x350000
     71#endif
     72#ifndef VMS_POSIX_EXIT_MASK
     73# define VMS_POSIX_EXIT_MASK (C_FACILITY_NO | 0xA000)
     74#endif
    7175
    7276#else
    7377
    74 char default_shell[] = "/bin/sh";
     78const char *default_shell = "/bin/sh";
    7579int batch_mode_shell = 0;
    7680
     
    109113# include "w32err.h"
    110114# include "pathstuff.h"
     115# define WAIT_NOHANG 1
    111116#endif /* WINDOWS32 */
    112117
     
    120125
    121126#ifdef HAVE_WAITPID
    122 # define WAIT_NOHANG(status)    waitpid (-1, (status), WNOHANG)
    123 #else   /* Don't have waitpid.  */
     127# define WAIT_NOHANG(status)    waitpid (-1, (status), WNOHANG)
     128#else   /* Don't have waitpid.  */
    124129# ifdef HAVE_WAIT3
    125130#  ifndef wait3
    126131extern int wait3 ();
    127132#  endif
    128 #  define WAIT_NOHANG(status)   wait3 ((status), WNOHANG, (struct rusage *) 0)
     133#  define WAIT_NOHANG(status)   wait3 ((status), WNOHANG, (struct rusage *) 0)
    129134# endif /* Have wait3.  */
    130135#endif /* Have waitpid.  */
     
    134139#endif
    135140
    136 #ifndef HAVE_UNION_WAIT
     141#ifndef HAVE_UNION_WAIT
    137142
    138143# define WAIT_T int
     
    154159# endif
    155160
    156 #else   /* Have `union wait'.  */
     161#else   /* Have 'union wait'.  */
    157162
    158163# define WAIT_T union wait
     
    173178# endif
    174179
    175 #endif  /* Don't have `union wait'.  */
     180#endif  /* Don't have 'union wait'.  */
    176181
    177182#if !defined(HAVE_UNISTD_H) && !defined(WINDOWS32)
     
    203208}
    204209
     210#ifndef HAVE_GETLOADAVG
    205211int getloadavg (double loadavg[], int nelem);
    206 int start_remote_job (char **argv, char **envp, int stdin_fd, int *is_remote,
    207                       int *id_ptr, int *used_stdin);
    208 int start_remote_job_p (int);
    209 int remote_status (int *exit_code_ptr, int *signal_ptr, int *coredump_ptr,
    210                    int block);
    211 
    212 RETSIGTYPE child_handler (int);
     212#endif
     213
    213214static void free_child (struct child *);
    214215static void start_job_command (struct child *child);
     
    226227unsigned int job_slots_used = 0;
    227228
    228 /* Nonzero if the `good' standard input is in use.  */
     229/* Nonzero if the 'good' standard input is in use.  */
    229230
    230231static int good_stdin_used = 0;
     
    245246
    246247unsigned int jobserver_tokens = 0;
     248
    247249
    248250
    249251#ifdef WINDOWS32
    250252/*
    251  * The macro which references this function is defined in make.h.
     253 * The macro which references this function is defined in makeint.h.
    252254 */
    253255int
    254 w32_kill(pid_t pid, int sig)
     256w32_kill (pid_t pid, int sig)
    255257{
    256   return ((process_kill((HANDLE)pid, sig) == TRUE) ? 0 : -1);
     258  return ((process_kill ((HANDLE)pid, sig) == TRUE) ? 0 : -1);
    257259}
    258260
     
    267269  const char *error_string = NULL;
    268270  char temp_path[MAXPATHLEN]; /* need to know its length */
    269   unsigned path_size = GetTempPath(sizeof temp_path, temp_path);
     271  unsigned path_size = GetTempPath (sizeof temp_path, temp_path);
    270272  int path_is_dot = 0;
    271   unsigned uniq = 1;
     273  /* The following variable is static so we won't try to reuse a name
     274     that was generated a little while ago, because that file might
     275     not be on disk yet, since we use FILE_ATTRIBUTE_TEMPORARY below,
     276     which tells the OS it doesn't need to flush the cache to disk.
     277     If the file is not yet on disk, we might think the name is
     278     available, while it really isn't.  This happens in parallel
     279     builds, where Make doesn't wait for one job to finish before it
     280     launches the next one.  */
     281  static unsigned uniq = 0;
     282  static int second_loop = 0;
    272283  const unsigned sizemax = strlen (base) + strlen (ext) + 10;
    273284
     
    278289    }
    279290
     291  ++uniq;
     292  if (uniq >= 0x10000 && !second_loop)
     293    {
     294      /* If we already had 64K batch files in this
     295         process, make a second loop through the numbers,
     296         looking for free slots, i.e. files that were
     297         deleted in the meantime.  */
     298      second_loop = 1;
     299      uniq = 1;
     300    }
    280301  while (path_size > 0 &&
    281302         path_size + sizemax < sizeof temp_path &&
    282          uniq < 0x10000)
     303         !(uniq >= 0x10000 && second_loop))
    283304    {
    284305      unsigned size = sprintf (temp_path + path_size,
     
    297318      if (h == INVALID_HANDLE_VALUE)
    298319        {
    299           const DWORD er = GetLastError();
     320          const DWORD er = GetLastError ();
    300321
    301322          if (er == ERROR_FILE_EXISTS || er == ERROR_ALREADY_EXISTS)
    302             ++uniq;
     323            {
     324              ++uniq;
     325              if (uniq == 0x10000 && !second_loop)
     326                {
     327                  second_loop = 1;
     328                  uniq = 1;
     329                }
     330            }
    303331
    304332          /* the temporary path is not guaranteed to exist */
     
    336364  if (error_string == NULL)
    337365    error_string = _("Cannot create a temporary file\n");
    338   fatal (NILF, error_string);
     366  O (fatal, NILF, error_string);
    339367
    340368  /* not reached */
     
    376404
    377405  i = 0;
    378   while (known_os2shells[i] != NULL) {
    379     if (strcasecmp (name, known_os2shells[i]) == 0)
    380       return 0; /* not a unix shell */
    381     i++;
    382   }
     406  while (known_os2shells[i] != NULL)
     407    {
     408      if (strcasecmp (name, known_os2shells[i]) == 0)
     409        return 0; /* not a unix shell */
     410      i++;
     411    }
    383412
    384413  /* in doubt assume a unix like shell */
     
    391420is_bourne_compatible_shell (const char *path)
    392421{
    393   /* list of known unix (Bourne-like) shells */
    394   const char *unix_shells[] = {
     422  /* List of known POSIX (or POSIX-ish) shells. */
     423  static const char *unix_shells[] = {
    395424    "sh",
    396425    "bash",
     
    402431    NULL
    403432  };
    404   unsigned i, len;
     433  const char **s;
    405434
    406435  /* find the rightmost '/' or '\\' */
     
    415444    name = path;
    416445
    417   if (*name == '/' || *name == '\\') name++;
     446  if (*name == '/' || *name == '\\')
     447    ++name;
    418448
    419449  /* this should be able to deal with extensions on Windows-like systems */
    420   for (i = 0; unix_shells[i] != NULL; i++) {
    421     len = strlen(unix_shells[i]);
     450  for (s = unix_shells; *s != NULL; ++s)
     451    {
    422452#if defined(WINDOWS32) || defined(__MSDOS__)
    423     if ((strncasecmp (name, unix_shells[i], len) == 0) &&
    424       (strlen(name) >= len && (name[len] == '\0' || name[len] == '.')))
     453      unsigned int len = strlen (*s);
     454      if ((strlen (name) >= len && STOP_SET (name[len], MAP_DOT|MAP_NUL))
     455          && strncasecmp (name, *s, len) == 0)
    425456#else
    426     if ((strncmp (name, unix_shells[i], len) == 0) &&
    427       (strlen(name) >= len && name[len] == '\0'))
    428 #endif
    429         return 1; /* a known unix-style shell */
    430   }
     457      if (strcmp (name, *s) == 0)
     458#endif
     459        return 1; /* a known unix-style shell */
     460    }
    431461
    432462  /* if not on the list, assume it's not a Bourne-like shell */
     
    441471
    442472static void
    443 child_error (const char *target_name,
     473child_error (struct child *child,
    444474             int exit_code, int exit_sig, int coredump, int ignored)
    445475{
     476  const char *pre = "*** ";
     477  const char *post = "";
     478  const char *dump = "";
     479  const struct file *f = child->file;
     480  const floc *flocp = &f->cmds->fileinfo;
     481  const char *nm;
     482  size_t l;
     483
    446484  if (ignored && silent_flag)
    447485    return;
    448486
    449 #ifdef VMS
    450   if (!(exit_code & 1))
    451       error (NILF,
    452              (ignored ? _("*** [%s] Error 0x%x (ignored)")
    453               : _("*** [%s] Error 0x%x")),
    454              target_name, exit_code);
    455 #else
     487  if (exit_sig && coredump)
     488    dump = _(" (core dumped)");
     489
     490  if (ignored)
     491    {
     492      pre = "";
     493      post = _(" (ignored)");
     494    }
     495
     496  if (! flocp->filenm)
     497    nm = _("<builtin>");
     498  else
     499    {
     500      char *a = alloca (strlen (flocp->filenm) + 1 + 11 + 1);
     501      sprintf (a, "%s:%lu", flocp->filenm, flocp->lineno + flocp->offset);
     502      nm = a;
     503    }
     504
     505  l = strlen (pre) + strlen (nm) + strlen (f->name) + strlen (post);
     506
     507  OUTPUT_SET (&child->output);
     508
     509  show_goal_error ();
     510
    456511  if (exit_sig == 0)
    457     error (NILF, ignored ? _("[%s] Error %d (ignored)") :
    458            _("*** [%s] Error %d"),
    459            target_name, exit_code);
     512    error (NILF, l + INTSTR_LENGTH,
     513           _("%s[%s: %s] Error %d%s"), pre, nm, f->name, exit_code, post);
    460514  else
    461     error (NILF, "*** [%s] %s%s",
    462            target_name, strsignal (exit_sig),
    463            coredump ? _(" (core dumped)") : "");
    464 #endif /* VMS */
     515    {
     516      const char *s = strsignal (exit_sig);
     517      error (NILF, l + strlen (s) + strlen (dump),
     518             "%s[%s: %s] %s%s%s", pre, nm, f->name, s, dump, post);
     519    }
     520
     521  OUTPUT_UNSET ();
    465522}
    466523
     
    469526/* Handle a dead child.  This handler may or may not ever be installed.
    470527
    471    If we're using the jobserver feature, we need it.  First, installing it
    472    ensures the read will interrupt on SIGCHLD.  Second, we close the dup'd
    473    read FD to ensure we don't enter another blocking read without reaping all
    474    the dead children.  In this case we don't need the dead_children count.
     528   If we're using the jobserver feature without pselect(), we need it.
     529   First, installing it ensures the read will interrupt on SIGCHLD.  Second,
     530   we close the dup'd read FD to ensure we don't enter another blocking read
     531   without reaping all the dead children.  In this case we don't need the
     532   dead_children count.
    475533
    476534   If we don't have either waitpid or wait3, then make is unreliable, but we
     
    484542  ++dead_children;
    485543
    486   if (job_rfd >= 0)
    487     {
    488       close (job_rfd);
    489       job_rfd = -1;
    490     }
     544  jobserver_signal ();
    491545
    492546#ifdef __EMX__
     
    494548  signal (SIGCHLD, SIG_DFL);
    495549#endif
    496 
    497   /* This causes problems if the SIGCHLD interrupts a printf().
    498   DB (DB_JOBS, (_("Got a SIGCHLD; %u unreaped children.\n"), dead_children));
    499   */
    500550}
    501551
    502 extern int shell_function_pid, shell_function_completed;
     552extern pid_t shell_function_pid;
    503553
    504554/* Reap all dead children, storing the returned status and the new command
    505    state (`cs_finished') in the `file' member of the `struct child' for the
     555   state ('cs_finished') in the 'file' member of the 'struct child' for the
    506556   dead child, and removing the child from the chain.  In addition, if BLOCK
    507557   nonzero, we block in this function until we've reaped at least one
     
    514564#ifndef WINDOWS32
    515565  WAIT_T status;
     566#endif
    516567  /* Initially, assume we have some.  */
    517568  int reap_more = 1;
    518 #endif
    519569
    520570#ifdef WAIT_NOHANG
     
    535585         && (block || REAP_MORE))
    536586    {
    537       int remote = 0;
     587      unsigned int remote = 0;
    538588      pid_t pid;
    539589      int exit_code, exit_sig, coredump;
    540       register struct child *lastc, *c;
     590      struct child *lastc, *c;
    541591      int child_failed;
    542592      int any_remote, any_local;
     
    544594
    545595      if (err && block)
    546         {
     596        {
    547597          static int printed = 0;
    548598
    549           /* We might block for a while, so let the user know why.
     599          /* We might block for a while, so let the user know why.
    550600             Only print this message once no matter how many jobs are left.  */
    551           fflush (stdout);
     601          fflush (stdout);
    552602          if (!printed)
    553             error (NILF, _("*** Waiting for unfinished jobs...."));
     603            O (error, NILF, _("*** Waiting for unfinished jobs...."));
    554604          printed = 1;
    555         }
     605        }
    556606
    557607      /* We have one less dead child to reap.  As noted in
    558         child_handler() above, this count is completely unimportant for
    559         all modern, POSIX-y systems that support wait3() or waitpid().
    560         The rest of this comment below applies only to early, broken
    561         pre-POSIX systems.  We keep the count only because... it's there...
    562 
    563         The test and decrement are not atomic; if it is compiled into:
    564                 register = dead_children - 1;
    565                 dead_children = register;
    566         a SIGCHLD could come between the two instructions.
    567         child_handler increments dead_children.
    568         The second instruction here would lose that increment.  But the
    569         only effect of dead_children being wrong is that we might wait
    570         longer than necessary to reap a child, and lose some parallelism;
    571         and we might print the "Waiting for unfinished jobs" message above
    572         when not necessary.  */
     608        child_handler() above, this count is completely unimportant for
     609        all modern, POSIX-y systems that support wait3() or waitpid().
     610        The rest of this comment below applies only to early, broken
     611        pre-POSIX systems.  We keep the count only because... it's there...
     612
     613        The test and decrement are not atomic; if it is compiled into:
     614                register = dead_children - 1;
     615                dead_children = register;
     616        a SIGCHLD could come between the two instructions.
     617        child_handler increments dead_children.
     618        The second instruction here would lose that increment.  But the
     619        only effect of dead_children being wrong is that we might wait
     620        longer than necessary to reap a child, and lose some parallelism;
     621        and we might print the "Waiting for unfinished jobs" message above
     622        when not necessary.  */
    573623
    574624      if (dead_children > 0)
    575         --dead_children;
     625        --dead_children;
    576626
    577627      any_remote = 0;
    578628      any_local = shell_function_pid != 0;
    579629      for (c = children; c != 0; c = c->next)
    580         {
    581           any_remote |= c->remote;
    582           any_local |= ! c->remote;
    583           DB (DB_JOBS, (_("Live child %p (%s) PID %s %s\n"),
     630        {
     631          any_remote |= c->remote;
     632          any_local |= ! c->remote;
     633          DB (DB_JOBS, (_("Live child %p (%s) PID %s %s\n"),
    584634                        c, c->file->name, pid2str (c->pid),
    585635                        c->remote ? _(" (remote)") : ""));
    586636#ifdef VMS
    587           break;
    588 #endif
    589         }
     637          break;
     638#endif
     639        }
    590640
    591641      /* First, check for remote children.  */
    592642      if (any_remote)
    593         pid = remote_status (&exit_code, &exit_sig, &coredump, 0);
     643        pid = remote_status (&exit_code, &exit_sig, &coredump, 0);
    594644      else
    595         pid = 0;
     645        pid = 0;
    596646
    597647      if (pid > 0)
    598         /* We got a remote child.  */
    599         remote = 1;
     648        /* We got a remote child.  */
     649        remote = 1;
    600650      else if (pid < 0)
    601         {
     651        {
    602652          /* A remote status command failed miserably.  Punt.  */
    603         remote_status_lose:
    604           pfatal_with_name ("remote_status");
    605         }
     653        remote_status_lose:
     654          pfatal_with_name ("remote_status");
     655        }
    606656      else
    607         {
    608           /* No remote children.  Check for local children.  */
     657        {
     658          /* No remote children.  Check for local children.  */
    609659#if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32)
    610           if (any_local)
    611             {
     660          if (any_local)
     661            {
    612662#ifdef VMS
    613               vmsWaitForChildren (&status);
    614               pid = c->pid;
     663              /* Todo: This needs more untangling multi-process support */
     664              /* Just do single child process support now */
     665              vmsWaitForChildren (&status);
     666              pid = c->pid;
     667
     668              /* VMS failure status can not be fully translated */
     669              status = $VMS_STATUS_SUCCESS (c->cstatus) ? 0 : (1 << 8);
     670
     671              /* A Posix failure can be exactly translated */
     672              if ((c->cstatus & VMS_POSIX_EXIT_MASK) == VMS_POSIX_EXIT_MASK)
     673                status = (c->cstatus >> 3 & 255) << 8;
    615674#else
    616675#ifdef WAIT_NOHANG
    617               if (!block)
    618                 pid = WAIT_NOHANG (&status);
    619               else
    620 #endif
    621                 EINTRLOOP(pid, wait (&status));
     676              if (!block)
     677                pid = WAIT_NOHANG (&status);
     678              else
     679#endif
     680                EINTRLOOP (pid, wait (&status));
    622681#endif /* !VMS */
    623             }
    624           else
    625             pid = 0;
    626 
    627           if (pid < 0)
    628             {
     682            }
     683          else
     684            pid = 0;
     685
     686          if (pid < 0)
     687            {
    629688              /* The wait*() failed miserably.  Punt.  */
    630               pfatal_with_name ("wait");
    631             }
    632           else if (pid > 0)
    633             {
    634               /* We got a child exit; chop the status word up.  */
    635               exit_code = WEXITSTATUS (status);
    636               exit_sig = WIFSIGNALED (status) ? WTERMSIG (status) : 0;
    637               coredump = WCOREDUMP (status);
     689              pfatal_with_name ("wait");
     690            }
     691          else if (pid > 0)
     692            {
     693              /* We got a child exit; chop the status word up.  */
     694              exit_code = WEXITSTATUS (status);
     695              exit_sig = WIFSIGNALED (status) ? WTERMSIG (status) : 0;
     696              coredump = WCOREDUMP (status);
    638697
    639698              /* If we have started jobs in this second, remove one.  */
    640699              if (job_counter)
    641700                --job_counter;
    642             }
    643           else
    644             {
    645               /* No local children are dead.  */
     701            }
     702          else
     703            {
     704              /* No local children are dead.  */
    646705              reap_more = 0;
    647706
    648               if (!block || !any_remote)
     707              if (!block || !any_remote)
    649708                break;
    650709
     
    659718              /* We got a remote child.  */
    660719              remote = 1;
    661             }
     720            }
    662721#endif /* !__MSDOS__, !Amiga, !WINDOWS32.  */
    663722
    664723#ifdef __MSDOS__
    665           /* Life is very different on MSDOS.  */
    666           pid = dos_pid - 1;
    667           status = dos_status;
    668           exit_code = WEXITSTATUS (status);
    669           if (exit_code == 0xff)
    670             exit_code = -1;
    671           exit_sig = WIFSIGNALED (status) ? WTERMSIG (status) : 0;
    672           coredump = 0;
     724          /* Life is very different on MSDOS.  */
     725          pid = dos_pid - 1;
     726          status = dos_status;
     727          exit_code = WEXITSTATUS (status);
     728          if (exit_code == 0xff)
     729            exit_code = -1;
     730          exit_sig = WIFSIGNALED (status) ? WTERMSIG (status) : 0;
     731          coredump = 0;
    673732#endif /* __MSDOS__ */
    674733#ifdef _AMIGA
    675           /* Same on Amiga */
    676           pid = amiga_pid - 1;
    677           status = amiga_status;
    678           exit_code = amiga_status;
    679           exit_sig = 0;
    680           coredump = 0;
     734          /* Same on Amiga */
     735          pid = amiga_pid - 1;
     736          status = amiga_status;
     737          exit_code = amiga_status;
     738          exit_sig = 0;
     739          coredump = 0;
    681740#endif /* _AMIGA */
    682741#ifdef WINDOWS32
    683742          {
    684743            HANDLE hPID;
    685             int werr;
    686744            HANDLE hcTID, hcPID;
     745            DWORD dwWaitStatus = 0;
    687746            exit_code = 0;
    688747            exit_sig = 0;
     
    701760                    fprintf (stderr,
    702761                             "Determine main thread ID (Error %ld: %s)\n",
    703                              e, map_windows32_error_to_string(e));
     762                             e, map_windows32_error_to_string (e));
    704763                  }
    705764                else
     
    708767
    709768            /* wait for anything to finish */
    710             hPID = process_wait_for_any();
     769            hPID = process_wait_for_any (block, &dwWaitStatus);
    711770            if (hPID)
    712771              {
    713 
    714772                /* was an error found on this process? */
    715                 werr = process_last_err(hPID);
     773                int werr = process_last_err (hPID);
    716774
    717775                /* get exit data */
    718                 exit_code = process_exit_code(hPID);
     776                exit_code = process_exit_code (hPID);
    719777
    720778                if (werr)
    721                   fprintf(stderr, "make (e=%d): %s",
    722                           exit_code, map_windows32_error_to_string(exit_code));
     779                  fprintf (stderr, "make (e=%d): %s", exit_code,
     780                           map_windows32_error_to_string (exit_code));
    723781
    724782                /* signal */
    725                 exit_sig = process_signal(hPID);
     783                exit_sig = process_signal (hPID);
    726784
    727785                /* cleanup process */
    728                 process_cleanup(hPID);
     786                process_cleanup (hPID);
    729787
    730788                coredump = 0;
    731789              }
     790            else if (dwWaitStatus == WAIT_FAILED)
     791              {
     792                /* The WaitForMultipleObjects() failed miserably.  Punt.  */
     793                pfatal_with_name ("WaitForMultipleObjects");
     794              }
     795            else if (dwWaitStatus == WAIT_TIMEOUT)
     796              {
     797                /* No child processes are finished.  Give up waiting. */
     798                reap_more = 0;
     799                break;
     800              }
     801
    732802            pid = (pid_t) hPID;
    733803          }
    734804#endif /* WINDOWS32 */
    735         }
    736 
    737       /* Check if this is the child of the `shell' function.  */
     805        }
     806
     807      /* Check if this is the child of the 'shell' function.  */
    738808      if (!remote && pid == shell_function_pid)
    739         {
    740           /* It is.  Leave an indicator for the `shell' function.  */
    741           if (exit_sig == 0 && exit_code == 127)
    742             shell_function_completed = -1;
    743           else
    744             shell_function_completed = 1;
    745           break;
    746         }
    747 
    748       child_failed = exit_sig != 0 || exit_code != 0;
     809        {
     810          shell_completed (exit_code, exit_sig);
     811          break;
     812        }
    749813
    750814      /* Search for a child matching the deceased one.  */
    751815      lastc = 0;
    752816      for (c = children; c != 0; lastc = c, c = c->next)
    753         if (c->remote == remote && c->pid == pid)
    754           break;
     817        if (c->pid == pid && c->remote == remote)
     818          break;
    755819
    756820      if (c == 0)
     
    759823        continue;
    760824
     825      /* Determine the failure status: 0 for success, 1 for updating target in
     826         question mode, 2 for anything else.  */
     827      if (exit_sig == 0 && exit_code == 0)
     828        child_failed = MAKE_SUCCESS;
     829      else if (exit_sig == 0 && exit_code == 1 && question_flag && c->recursive)
     830        child_failed = MAKE_TROUBLE;
     831      else
     832        child_failed = MAKE_FAILURE;
     833
    761834      DB (DB_JOBS, (child_failed
    762835                    ? _("Reaping losing child %p PID %s %s\n")
     
    764837                    c, pid2str (c->pid), c->remote ? _(" (remote)") : ""));
    765838
    766       if (c->sh_batch_file) {
    767         DB (DB_JOBS, (_("Cleaning up temp batch file %s\n"),
    768                       c->sh_batch_file));
    769 
    770         /* just try and remove, don't care if this fails */
    771         remove (c->sh_batch_file);
    772 
    773         /* all done with memory */
    774         free (c->sh_batch_file);
    775         c->sh_batch_file = NULL;
    776       }
     839      if (c->sh_batch_file)
     840        {
     841          int rm_status;
     842
     843          DB (DB_JOBS, (_("Cleaning up temp batch file %s\n"),
     844                        c->sh_batch_file));
     845
     846          errno = 0;
     847          rm_status = remove (c->sh_batch_file);
     848          if (rm_status)
     849            DB (DB_JOBS, (_("Cleaning up temp batch file %s failed (%d)\n"),
     850                          c->sh_batch_file, errno));
     851
     852          /* all done with memory */
     853          free (c->sh_batch_file);
     854          c->sh_batch_file = NULL;
     855        }
    777856
    778857      /* If this child had the good stdin, say it is now free.  */
     
    788867          static int delete_on_error = -1;
    789868
    790           if (!dontcare)
    791             child_error (c->file->name, exit_code, exit_sig, coredump, 0);
    792 
    793           c->file->update_status = 2;
     869          if (!dontcare && child_failed == MAKE_FAILURE)
     870            child_error (c, exit_code, exit_sig, coredump, 0);
     871
     872          c->file->update_status = child_failed == MAKE_FAILURE ? us_failed : us_question;
    794873          if (delete_on_error == -1)
    795874            {
     
    805884            {
    806885              /* The commands failed, but we don't care.  */
    807               child_error (c->file->name,
    808                            exit_code, exit_sig, coredump, 1);
     886              child_error (c, exit_code, exit_sig, coredump, 1);
    809887              child_failed = 0;
    810888            }
     
    819897                     the target was not completely remade.  So we treat
    820898                     this as if a command had failed.  */
    821                   c->file->update_status = 2;
     899                  c->file->update_status = us_failed;
    822900                }
    823901              else
    824902                {
     903#ifndef NO_OUTPUT_SYNC
     904                  /* If we're sync'ing per line, write the previous line's
     905                     output before starting the next one.  */
     906                  if (output_sync == OUTPUT_SYNC_LINE)
     907                    output_dump (&c->output);
     908#endif
    825909                  /* Check again whether to start remotely.
    826910                     Whether or not we want to changes over time.
     
    840924                }
    841925
    842               if (c->file->update_status != 0)
     926              if (c->file->update_status != us_success)
    843927                /* We failed to start the commands.  */
    844928                delete_child_targets (c);
     
    848932               without an unignored error.  Now the target has been
    849933               successfully updated.  */
    850             c->file->update_status = 0;
     934            c->file->update_status = us_success;
    851935        }
    852936
    853       /* When we get here, all the commands for C->file are finished
    854          (or aborted) and C->file->update_status contains 0 or 2.  But
    855          C->file->command_state is still cs_running if all the commands
     937      /* When we get here, all the commands for c->file are finished.  */
     938
     939#ifndef NO_OUTPUT_SYNC
     940      /* Synchronize any remaining parallel output.  */
     941      output_dump (&c->output);
     942#endif
     943
     944      /* At this point c->file->update_status is success or failed.  But
     945         c->file->command_state is still cs_running if all the commands
    856946         ran; notice_finish_file looks for cs_running to tell it that
    857947         it's interesting to check the file's modtime again now.  */
     
    892982          /* fatal_error_signal will die with the right signal.  */
    893983          !handling_fatal_signal)
    894         die (2);
     984        die (child_failed);
    895985
    896986      /* Only block for one child.  */
     
    907997free_child (struct child *child)
    908998{
     999  output_close (&child->output);
     1000
    9091001  if (!jobserver_tokens)
    910     fatal (NILF, "INTERNAL: Freeing child %p (%s) but no tokens left!\n",
    911            child, child->file->name);
     1002    ONS (fatal, NILF, "INTERNAL: Freeing child %p (%s) but no tokens left!\n",
     1003         child, child->file->name);
    9121004
    9131005  /* If we're using the jobserver and this child is not the only outstanding
    9141006     job, put a token back into the pipe for it.  */
    9151007
    916   if (job_fds[1] >= 0 && jobserver_tokens > 1)
    917     {
    918       char token = '+';
    919       int r;
    920 
    921       /* Write a job token back to the pipe.  */
    922 
    923       EINTRLOOP (r, write (job_fds[1], &token, 1));
    924       if (r != 1)
    925         pfatal_with_name (_("write jobserver"));
    926 
     1008  if (jobserver_enabled () && jobserver_tokens > 1)
     1009    {
     1010      jobserver_release (1);
    9271011      DB (DB_JOBS, (_("Released token for child %p (%s).\n"),
    9281012                    child, child->file->name));
     
    9381022      register unsigned int i;
    9391023      for (i = 0; i < child->file->cmds->ncommand_lines; ++i)
    940         free (child->command_lines[i]);
     1024        free (child->command_lines[i]);
    9411025      free (child->command_lines);
    9421026    }
     
    9461030      register char **ep = child->environment;
    9471031      while (*ep != 0)
    948         free (*ep++);
     1032        free (*ep++);
    9491033      free (child->environment);
    9501034    }
     
    9801064#endif
    9811065
    982 #ifdef MAKE_JOBSERVER
    983 RETSIGTYPE
    984 job_noop (int sig UNUSED)
    985 {
    986 }
    987 /* Set the child handler action flags to FLAGS.  */
    988 static void
    989 set_child_handler_action_flags (int set_handler, int set_alarm)
    990 {
    991   struct sigaction sa;
    992 
    993 #ifdef __EMX__
    994   /* The child handler must be turned off here.  */
    995   signal (SIGCHLD, SIG_DFL);
    996 #endif
    997 
    998   memset (&sa, '\0', sizeof sa);
    999   sa.sa_handler = child_handler;
    1000   sa.sa_flags = set_handler ? 0 : SA_RESTART;
    1001 #if defined SIGCHLD
    1002   sigaction (SIGCHLD, &sa, NULL);
    1003 #endif
    1004 #if defined SIGCLD && SIGCLD != SIGCHLD
    1005   sigaction (SIGCLD, &sa, NULL);
    1006 #endif
    1007 #if defined SIGALRM
    1008   if (set_alarm)
    1009     {
    1010       /* If we're about to enter the read(), set an alarm to wake up in a
    1011          second so we can check if the load has dropped and we can start more
    1012          work.  On the way out, turn off the alarm and set SIG_DFL.  */
    1013       alarm (set_handler ? 1 : 0);
    1014       sa.sa_handler = set_handler ? job_noop : SIG_DFL;
    1015       sa.sa_flags = 0;
    1016       sigaction (SIGALRM, &sa, NULL);
    1017     }
    1018 #endif
    1019 }
    1020 #endif
    1021 
    10221066
    10231067/* Start a job to run the commands specified in CHILD.
     
    10251069
    10261070   NOTE: On return fatal signals are blocked!  The caller is responsible
    1027    for calling `unblock_sigs', once the new child is safely on the chain so
     1071   for calling 'unblock_sigs', once the new child is safely on the chain so
    10281072   it can be cleaned up in the event of a fatal signal.  */
    10291073
     
    10311075start_job_command (struct child *child)
    10321076{
    1033 #if !defined(_AMIGA) && !defined(WINDOWS32)
    1034   static int bad_stdin = -1;
    1035 #endif
     1077  int flags;
    10361078  char *p;
    1037   /* Must be volatile to silence bogus GCC warning about longjmp/vfork.  */
    1038   volatile int flags;
    10391079#ifdef VMS
    10401080  char *argv;
     
    10501090     the flags specified globally for this target.  */
    10511091  flags = (child->file->command_flags
    1052            | child->file->cmds->lines_flags[child->command_line - 1]);
     1092           | child->file->cmds->lines_flags[child->command_line - 1]);
    10531093
    10541094  p = child->command_ptr;
     
    10581098    {
    10591099      if (*p == '@')
    1060         flags |= COMMANDS_SILENT;
     1100        flags |= COMMANDS_SILENT;
    10611101      else if (*p == '+')
    1062         flags |= COMMANDS_RECURSE;
     1102        flags |= COMMANDS_RECURSE;
    10631103      else if (*p == '-')
    1064         child->noerror = 1;
    1065       else if (!isblank ((unsigned char)*p))
    1066         break;
     1104        child->noerror = 1;
     1105      /* Don't skip newlines.  */
     1106      else if (!ISBLANK (*p))
     1107        break;
    10671108      ++p;
    10681109    }
     1110
     1111  child->recursive = ((flags & COMMANDS_RECURSE) != 0);
    10691112
    10701113  /* Update the file's command flags with any new ones we found.  We only
     
    10741117     order to really fix this, we'll have to keep a lines_flags for every
    10751118     actual line, after expansion.  */
    1076   child->file->cmds->lines_flags[child->command_line - 1]
    1077     |= flags & COMMANDS_RECURSE;
     1119  child->file->cmds->lines_flags[child->command_line - 1] |= flags & COMMANDS_RECURSE;
     1120
     1121  /* POSIX requires that a recipe prefix after a backslash-newline should
     1122     be ignored.  Remove it now so the output is correct.  */
     1123  {
     1124    char prefix = child->file->cmds->recipe_prefix;
     1125    char *p1, *p2;
     1126    p1 = p2 = p;
     1127    while (*p1 != '\0')
     1128      {
     1129        *(p2++) = *p1;
     1130        if (p1[0] == '\n' && p1[1] == prefix)
     1131          ++p1;
     1132        ++p1;
     1133      }
     1134    *p2 = *p1;
     1135  }
    10781136
    10791137  /* Figure out an argument list from this command line.  */
    1080 
    10811138  {
    10821139    char *end = 0;
    10831140#ifdef VMS
     1141    /* Skip any leading whitespace */
     1142    while (*p)
     1143      {
     1144        if (!ISSPACE (*p))
     1145          {
     1146            if (*p != '\\')
     1147              break;
     1148            if ((p[1] != '\n') && (p[1] != 'n') && (p[1] != 't'))
     1149              break;
     1150          }
     1151        p++;
     1152      }
     1153
    10841154    argv = p;
     1155    /* Although construct_command_argv contains some code for VMS, it was/is
     1156       not called/used.  Please note, for VMS argv is a string (not an array
     1157       of strings) which contains the complete command line, which for
     1158       multi-line variables still includes the newlines.  So detect newlines
     1159       and set 'end' (which is used for child->command_ptr) instead of
     1160       (re-)writing construct_command_argv */
     1161    if (!one_shell)
     1162      {
     1163        char *s = p;
     1164        int instring = 0;
     1165        while (*s)
     1166          {
     1167            if (*s == '"')
     1168              instring = !instring;
     1169            else if (*s == '\\' && !instring && *(s+1) != 0)
     1170              s++;
     1171            else if (*s == '\n' && !instring)
     1172              {
     1173                end = s;
     1174                break;
     1175              }
     1176            ++s;
     1177          }
     1178      }
    10851179#else
    10861180    argv = construct_command_argv (p, &end, child->file,
    1087                                    child->file->cmds->lines_flags[child->command_line - 1],
    1088                                    &child->sh_batch_file);
     1181                                   child->file->cmds->lines_flags[child->command_line - 1],
     1182                                   &child->sh_batch_file);
    10891183#endif
    10901184    if (end == NULL)
     
    10921186    else
    10931187      {
    1094         *end++ = '\0';
    1095         child->command_ptr = end;
     1188        *end++ = '\0';
     1189        child->command_ptr = end;
    10961190      }
    10971191  }
    10981192
    1099   /* If -q was given, say that updating `failed' if there was any text on the
    1100      command line, or `succeeded' otherwise.  The exit status of 1 tells the
    1101      user that -q is saying `something to do'; the exit status for a random
     1193  /* If -q was given, say that updating 'failed' if there was any text on the
     1194     command line, or 'succeeded' otherwise.  The exit status of 1 tells the
     1195     user that -q is saying 'something to do'; the exit status for a random
    11021196     error is 2.  */
    11031197  if (argv != 0 && question_flag && !(flags & COMMANDS_RECURSE))
     
    11071201      free (argv);
    11081202#endif
    1109       child->file->update_status = 1;
    1110       notice_finished_file (child->file);
    1111       return;
     1203#ifdef VMS
     1204      /* On VMS, argv[0] can be a null string here */
     1205      if (argv[0] != 0)
     1206        {
     1207#endif
     1208          child->file->update_status = us_question;
     1209          notice_finished_file (child->file);
     1210          return;
     1211#ifdef VMS
     1212        }
     1213#endif
    11121214    }
    11131215
     
    11151217    {
    11161218      /* Go on to the next command.  It might be the recursive one.
    1117         We construct ARGV only to find the end of the command line.  */
     1219        We construct ARGV only to find the end of the command line.  */
    11181220#ifndef VMS
    11191221      if (argv)
     
    11341236      /* This line has no commands.  Go to the next.  */
    11351237      if (job_next_command (child))
    1136         start_job_command (child);
     1238        start_job_command (child);
    11371239      else
    1138         {
    1139           /* No more commands.  Make sure we're "running"; we might not be if
     1240        {
     1241          /* No more commands.  Make sure we're "running"; we might not be if
    11401242             (e.g.) all commands were skipped due to -n.  */
    11411243          set_command_state (child->file, cs_running);
    1142           child->file->update_status = 0;
    1143           notice_finished_file (child->file);
    1144         }
     1244          child->file->update_status = us_success;
     1245          notice_finished_file (child->file);
     1246        }
     1247
     1248      OUTPUT_UNSET();
    11451249      return;
    11461250    }
    11471251
    1148   /* Print out the command.  If silent, we call `message' with null so it
    1149      can log the working directory before the command's own error messages
    1150      appear.  */
    1151 
    1152   message (0, (just_print_flag || (!(flags & COMMANDS_SILENT) && !silent_flag))
    1153            ? "%s" : (char *) 0, p);
     1252  /* Are we going to synchronize this command's output?  Do so if either we're
     1253     in SYNC_RECURSE mode or this command is not recursive.  We'll also check
     1254     output_sync separately below in case it changes due to error.  */
     1255  child->output.syncout = output_sync && (output_sync == OUTPUT_SYNC_RECURSE
     1256                                          || !(flags & COMMANDS_RECURSE));
     1257
     1258  OUTPUT_SET (&child->output);
     1259
     1260#ifndef NO_OUTPUT_SYNC
     1261  if (! child->output.syncout)
     1262    /* We don't want to sync this command: to avoid misordered
     1263       output ensure any already-synced content is written.  */
     1264    output_dump (&child->output);
     1265#endif
     1266
     1267  /* Print the command if appropriate.  */
     1268  if (just_print_flag || trace_flag
     1269      || (!(flags & COMMANDS_SILENT) && !silent_flag))
     1270    OS (message, 0, "%s", p);
    11541271
    11551272  /* Tell update_goal_chain that a command has been started on behalf of
     
    11711288  if (
    11721289#if defined __MSDOS__ || defined (__EMX__)
    1173       unixy_shell       /* the test is complicated and we already did it */
     1290      unixy_shell       /* the test is complicated and we already did it */
    11741291#else
    1175       (argv[0] && is_bourne_compatible_shell(argv[0]))
     1292      (argv[0] && is_bourne_compatible_shell (argv[0]))
    11761293#endif
    11771294      && (argv[1] && argv[1][0] == '-'
    1178         &&
    1179             ((argv[1][1] == 'c' && argv[1][2] == '\0')
    1180           ||
    1181              (argv[1][1] == 'e' && argv[1][2] == 'c' && argv[1][3] == '\0')))
     1295        &&
     1296            ((argv[1][1] == 'c' && argv[1][2] == '\0')
     1297          ||
     1298             (argv[1][1] == 'e' && argv[1][2] == 'c' && argv[1][3] == '\0')))
    11821299      && (argv[2] && argv[2][0] == ':' && argv[2][1] == '\0')
    11831300      && argv[3] == NULL)
     
    12001317    }
    12011318
     1319  /* We're sure we're going to invoke a command: set up the output.  */
     1320  output_start ();
     1321
    12021322  /* Flush the output streams so they won't have things written twice.  */
    12031323
     
    12051325  fflush (stderr);
    12061326
    1207 #ifndef VMS
    1208 #if !defined(WINDOWS32) && !defined(_AMIGA) && !defined(__MSDOS__)
    1209 
    1210   /* Set up a bad standard input that reads from a broken pipe.  */
    1211 
    1212   if (bad_stdin == -1)
    1213     {
    1214       /* Make a file descriptor that is the read end of a broken pipe.
    1215          This will be used for some children's standard inputs.  */
    1216       int pd[2];
    1217       if (pipe (pd) == 0)
    1218         {
    1219           /* Close the write side.  */
    1220           (void) close (pd[1]);
    1221           /* Save the read side.  */
    1222           bad_stdin = pd[0];
    1223 
    1224           /* Set the descriptor to close on exec, so it does not litter any
    1225              child's descriptor table.  When it is dup2'd onto descriptor 0,
    1226              that descriptor will not close on exec.  */
    1227           CLOSE_ON_EXEC (bad_stdin);
    1228         }
    1229     }
    1230 
    1231 #endif /* !WINDOWS32 && !_AMIGA && !__MSDOS__ */
    1232 
    1233   /* Decide whether to give this child the `good' standard input
    1234      (one that points to the terminal or whatever), or the `bad' one
     1327  /* Decide whether to give this child the 'good' standard input
     1328     (one that points to the terminal or whatever), or the 'bad' one
    12351329     that points to the read side of a broken pipe.  */
    12361330
     
    12381332  if (child->good_stdin)
    12391333    good_stdin_used = 1;
    1240 
    1241 #endif /* !VMS */
    12421334
    12431335  child->deleted = 0;
     
    12571349      int is_remote, id, used_stdin;
    12581350      if (start_remote_job (argv, child->environment,
    1259                             child->good_stdin ? 0 : bad_stdin,
    1260                             &is_remote, &id, &used_stdin))
     1351                            child->good_stdin ? 0 : get_bad_stdin (),
     1352                            &is_remote, &id, &used_stdin))
    12611353        /* Don't give up; remote execution may fail for various reasons.  If
    12621354           so, simply run the job locally.  */
    1263         goto run_local;
     1355        goto run_local;
    12641356      else
    1265         {
    1266           if (child->good_stdin && !used_stdin)
    1267             {
    1268               child->good_stdin = 0;
    1269               good_stdin_used = 0;
    1270             }
    1271           child->remote = is_remote;
    1272           child->pid = id;
    1273         }
     1357        {
     1358          if (child->good_stdin && !used_stdin)
     1359            {
     1360              child->good_stdin = 0;
     1361              good_stdin_used = 0;
     1362            }
     1363          child->remote = is_remote;
     1364          child->pid = id;
     1365        }
    12741366    }
    12751367  else
     
    12861378
    12871379#ifdef VMS
    1288       if (!child_execute_job (argv, child)) {
    1289         /* Fork failed!  */
    1290         perror_with_name ("vfork", "");
    1291         goto error;
    1292       }
     1380      if (!child_execute_job (child, argv))
     1381        {
     1382          /* Fork failed!  */
     1383          perror_with_name ("fork", "");
     1384          goto error;
     1385        }
    12931386
    12941387#else
     
    12961389      parent_environ = environ;
    12971390
    1298 # ifdef __EMX__
    1299       /* If we aren't running a recursive command and we have a jobserver
    1300          pipe, close it before exec'ing.  */
    1301       if (!(flags & COMMANDS_RECURSE) && job_fds[0] >= 0)
    1302         {
    1303           CLOSE_ON_EXEC (job_fds[0]);
    1304           CLOSE_ON_EXEC (job_fds[1]);
    1305         }
    1306       if (job_rfd >= 0)
    1307         CLOSE_ON_EXEC (job_rfd);
    1308 
    1309       /* Never use fork()/exec() here! Use spawn() instead in exec_command() */
    1310       child->pid = child_execute_job (child->good_stdin ? 0 : bad_stdin, 1,
    1311                                       argv, child->environment);
     1391      jobserver_pre_child (flags & COMMANDS_RECURSE);
     1392
     1393      child->pid = child_execute_job (&child->output, child->good_stdin, argv, child->environment);
     1394
     1395      environ = parent_environ; /* Restore value child may have clobbered.  */
     1396      jobserver_post_child (flags & COMMANDS_RECURSE);
     1397
    13121398      if (child->pid < 0)
    1313         {
    1314           /* spawn failed!  */
    1315           unblock_sigs ();
    1316           perror_with_name ("spawn", "");
    1317           goto error;
    1318         }
    1319 
    1320       /* undo CLOSE_ON_EXEC() after the child process has been started */
    1321       if (!(flags & COMMANDS_RECURSE) && job_fds[0] >= 0)
    1322         {
    1323           fcntl (job_fds[0], F_SETFD, 0);
    1324           fcntl (job_fds[1], F_SETFD, 0);
    1325         }
    1326       if (job_rfd >= 0)
    1327         fcntl (job_rfd, F_SETFD, 0);
    1328 
    1329 #else  /* !__EMX__ */
    1330 
    1331       child->pid = vfork ();
    1332       environ = parent_environ; /* Restore value child may have clobbered.  */
    1333       if (child->pid == 0)
    1334         {
    1335           /* We are the child side.  */
    1336           unblock_sigs ();
    1337 
    1338           /* If we aren't running a recursive command and we have a jobserver
    1339              pipe, close it before exec'ing.  */
    1340           if (!(flags & COMMANDS_RECURSE) && job_fds[0] >= 0)
    1341             {
    1342               close (job_fds[0]);
    1343               close (job_fds[1]);
    1344             }
    1345           if (job_rfd >= 0)
    1346             close (job_rfd);
    1347 
    1348 #ifdef SET_STACK_SIZE
    1349           /* Reset limits, if necessary.  */
    1350           if (stack_limit.rlim_cur)
    1351             setrlimit (RLIMIT_STACK, &stack_limit);
    1352 #endif
    1353 
    1354           child_execute_job (child->good_stdin ? 0 : bad_stdin, 1,
    1355                              argv, child->environment);
    1356         }
    1357       else if (child->pid < 0)
    1358         {
    1359           /* Fork failed!  */
    1360           unblock_sigs ();
    1361           perror_with_name ("vfork", "");
    1362           goto error;
    1363         }
    1364 # endif  /* !__EMX__ */
     1399        {
     1400          /* Fork failed!  */
     1401          unblock_sigs ();
     1402          perror_with_name ("fork", "");
     1403          goto error;
     1404        }
    13651405#endif /* !VMS */
    13661406    }
    13671407
    1368 #else   /* __MSDOS__ or Amiga or WINDOWS32 */
     1408#else   /* __MSDOS__ or Amiga or WINDOWS32 */
    13691409#ifdef __MSDOS__
    13701410  {
     
    13741414    dos_status = 0;
    13751415
    1376     /* We call `system' to do the job of the SHELL, since stock DOS
    1377        shell is too dumb.  Our `system' knows how to handle long
     1416    /* We call 'system' to do the job of the SHELL, since stock DOS
     1417       shell is too dumb.  Our 'system' knows how to handle long
    13781418       command lines even if pipes/redirection is needed; it will only
    13791419       call COMMAND.COM when its internal commands are used.  */
    13801420    if (execute_by_shell)
    13811421      {
    1382         char *cmdline = argv[0];
    1383         /* We don't have a way to pass environment to `system',
    1384            so we need to save and restore ours, sigh...  */
    1385         char **parent_environ = environ;
    1386 
    1387         environ = child->environment;
    1388 
    1389         /* If we have a *real* shell, tell `system' to call
    1390            it to do everything for us.  */
    1391         if (unixy_shell)
    1392           {
    1393             /* A *real* shell on MSDOS may not support long
    1394                command lines the DJGPP way, so we must use `system'.  */
    1395             cmdline = argv[2];  /* get past "shell -c" */
    1396           }
    1397 
    1398         dos_command_running = 1;
    1399         proc_return = system (cmdline);
    1400         environ = parent_environ;
    1401         execute_by_shell = 0;   /* for the next time */
     1422        char *cmdline = argv[0];
     1423        /* We don't have a way to pass environment to 'system',
     1424           so we need to save and restore ours, sigh...  */
     1425        char **parent_environ = environ;
     1426
     1427        environ = child->environment;
     1428
     1429        /* If we have a *real* shell, tell 'system' to call
     1430           it to do everything for us.  */
     1431        if (unixy_shell)
     1432          {
     1433            /* A *real* shell on MSDOS may not support long
     1434               command lines the DJGPP way, so we must use 'system'.  */
     1435            cmdline = argv[2];  /* get past "shell -c" */
     1436          }
     1437
     1438        dos_command_running = 1;
     1439        proc_return = system (cmdline);
     1440        environ = parent_environ;
     1441        execute_by_shell = 0;   /* for the next time */
    14021442      }
    14031443    else
    14041444      {
    1405         dos_command_running = 1;
    1406         proc_return = spawnvpe (P_WAIT, argv[0], argv, child->environment);
     1445        dos_command_running = 1;
     1446        proc_return = spawnvpe (P_WAIT, argv[0], argv, child->environment);
    14071447      }
    14081448
     
    14331473     DeleteFile (amiga_bname);        /* Ignore errors.  */
    14341474  }
    1435 #endif  /* Amiga */
     1475#endif  /* Amiga */
    14361476#ifdef WINDOWS32
    14371477  {
    14381478      HANDLE hPID;
    14391479      char* arg0;
     1480      int outfd = FD_STDOUT;
     1481      int errfd = FD_STDERR;
    14401482
    14411483      /* make UNC paths safe for CreateProcess -- backslash format */
     
    14471489
    14481490      /* make sure CreateProcess() has Path it needs */
    1449       sync_Path_environment();
    1450 
    1451       hPID = process_easy(argv, child->environment);
     1491      sync_Path_environment ();
     1492
     1493#ifndef NO_OUTPUT_SYNC
     1494      /* Divert child output if output_sync in use.  */
     1495      if (child->output.syncout)
     1496        {
     1497          if (child->output.out >= 0)
     1498            outfd = child->output.out;
     1499          if (child->output.err >= 0)
     1500            errfd = child->output.err;
     1501        }
     1502#else
     1503      outfd = errfd = -1;
     1504#endif
     1505      hPID = process_easy (argv, child->environment, outfd, errfd);
    14521506
    14531507      if (hPID != INVALID_HANDLE_VALUE)
    14541508        child->pid = (pid_t) hPID;
    1455       else {
    1456         int i;
    1457         unblock_sigs();
    1458         fprintf(stderr,
    1459                 _("process_easy() failed to launch process (e=%ld)\n"),
    1460                 process_last_err(hPID));
    1461         for (i = 0; argv[i]; i++)
    1462           fprintf(stderr, "%s ", argv[i]);
    1463         fprintf(stderr, _("\nCounted %d args in failed launch\n"), i);
    1464         goto error;
    1465       }
     1509      else
     1510        {
     1511          int i;
     1512          unblock_sigs ();
     1513          fprintf (stderr,
     1514                   _("process_easy() failed to launch process (e=%ld)\n"),
     1515                   process_last_err (hPID));
     1516          for (i = 0; argv[i]; i++)
     1517            fprintf (stderr, "%s ", argv[i]);
     1518          fprintf (stderr, _("\nCounted %d args in failed launch\n"), i);
     1519          goto error;
     1520        }
    14661521  }
    14671522#endif /* WINDOWS32 */
    1468 #endif  /* __MSDOS__ or Amiga or WINDOWS32 */
     1523#endif  /* __MSDOS__ or Amiga or WINDOWS32 */
    14691524
    14701525  /* Bump the number of jobs started in this second.  */
     
    14821537#endif
    14831538
     1539  OUTPUT_UNSET();
    14841540  return;
    14851541
    14861542 error:
    1487   child->file->update_status = 2;
     1543  child->file->update_status = us_failed;
    14881544  notice_finished_file (child->file);
    1489   return;
     1545  OUTPUT_UNSET();
    14901546}
    14911547
    14921548/* Try to start a child running.
    14931549   Returns nonzero if the child was started (and maybe finished), or zero if
    1494    the load was too high and the child was put on the `waiting_jobs' chain.  */
     1550   the load was too high and the child was put on the 'waiting_jobs' chain.  */
    14951551
    14961552static int
     
    15101566      && ((job_slots_used > 0 && load_too_high ())
    15111567#ifdef WINDOWS32
    1512           || (process_used_slots () >= MAXIMUM_WAIT_OBJECTS)
    1513 #endif
    1514           ))
     1568          || (process_used_slots () >= MAXIMUM_WAIT_OBJECTS)
     1569#endif
     1570          ))
    15151571    {
    15161572      /* Put this child on the chain of children waiting for the load average
     
    15401596    case cs_not_started:
    15411597      /* All the command lines turned out to be empty.  */
    1542       f->update_status = 0;
     1598      f->update_status = us_success;
    15431599      /* FALLTHROUGH */
    15441600
     
    15561612}
    15571613
    1558 /* Create a `struct child' for FILE and start its commands running.  */
     1614/* Create a 'struct child' for FILE and start its commands running.  */
    15591615
    15601616void
     
    15761632  chop_commands (cmds);
    15771633
     1634  /* Start the command sequence, record it in a new
     1635     'struct child', and add that to the chain.  */
     1636
     1637  c = xcalloc (sizeof (struct child));
     1638  output_init (&c->output);
     1639
     1640  c->file = file;
     1641  c->sh_batch_file = NULL;
     1642
     1643  /* Cache dontcare flag because file->dontcare can be changed once we
     1644     return. Check dontcare inheritance mechanism for details.  */
     1645  c->dontcare = file->dontcare;
     1646
     1647  /* Start saving output in case the expansion uses $(info ...) etc.  */
     1648  OUTPUT_SET (&c->output);
     1649
    15781650  /* Expand the command lines and store the results in LINES.  */
    15791651  lines = xmalloc (cmds->ncommand_lines * sizeof (char *));
     
    15811653    {
    15821654      /* Collapse backslash-newline combinations that are inside variable
    1583         or function references.  These are left alone by the parser so
    1584         that they will appear in the echoing of commands (where they look
    1585         nice); and collapsed by construct_command_argv when it tokenizes.
    1586         But letting them survive inside function invocations loses because
    1587         we don't want the functions to see them as part of the text.  */
     1655        or function references.  These are left alone by the parser so
     1656        that they will appear in the echoing of commands (where they look
     1657        nice); and collapsed by construct_command_argv when it tokenizes.
     1658        But letting them survive inside function invocations loses because
     1659        we don't want the functions to see them as part of the text.  */
    15881660
    15891661      char *in, *out, *ref;
    15901662
    15911663      /* IN points to where in the line we are scanning.
    1592         OUT points to where in the line we are writing.
    1593         When we collapse a backslash-newline combination,
    1594         IN gets ahead of OUT.  */
     1664        OUT points to where in the line we are writing.
     1665        When we collapse a backslash-newline combination,
     1666        IN gets ahead of OUT.  */
    15951667
    15961668      in = out = cmds->command_lines[i];
    15971669      while ((ref = strchr (in, '$')) != 0)
    1598         {
    1599           ++ref;                /* Move past the $.  */
    1600 
    1601           if (out != in)
    1602             /* Copy the text between the end of the last chunk
    1603                we processed (where IN points) and the new chunk
    1604                we are about to process (where REF points).  */
    1605             memmove (out, in, ref - in);
    1606 
    1607           /* Move both pointers past the boring stuff.  */
    1608           out += ref - in;
    1609           in = ref;
    1610 
    1611           if (*ref == '(' || *ref == '{')
    1612             {
    1613               char openparen = *ref;
    1614               char closeparen = openparen == '(' ? ')' : '}';
    1615               int count;
    1616               char *p;
    1617 
    1618               *out++ = *in++;   /* Copy OPENPAREN.  */
    1619               /* IN now points past the opening paren or brace.
    1620                  Count parens or braces until it is matched.  */
    1621               count = 0;
    1622               while (*in != '\0')
    1623                 {
    1624                   if (*in == closeparen && --count < 0)
    1625                     break;
    1626                   else if (*in == '\\' && in[1] == '\n')
    1627                     {
    1628                       /* We have found a backslash-newline inside a
    1629                          variable or function reference.  Eat it and
    1630                          any following whitespace.  */
    1631 
    1632                       int quoted = 0;
    1633                       for (p = in - 1; p > ref && *p == '\\'; --p)
    1634                         quoted = !quoted;
    1635 
    1636                       if (quoted)
    1637                         /* There were two or more backslashes, so this is
    1638                            not really a continuation line.  We don't collapse
    1639                            the quoting backslashes here as is done in
    1640                            collapse_continuations, because the line will
    1641                            be collapsed again after expansion.  */
    1642                         *out++ = *in++;
    1643                       else
    1644                         {
    1645                           /* Skip the backslash, newline and
    1646                              any following whitespace.  */
    1647                           in = next_token (in + 2);
    1648 
    1649                           /* Discard any preceding whitespace that has
    1650                              already been written to the output.  */
    1651                           while (out > ref
    1652                                  && isblank ((unsigned char)out[-1]))
    1653                             --out;
    1654 
    1655                           /* Replace it all with a single space.  */
    1656                           *out++ = ' ';
    1657                         }
    1658                     }
    1659                   else
    1660                     {
    1661                       if (*in == openparen)
    1662                         ++count;
    1663 
    1664                       *out++ = *in++;
    1665                     }
    1666                 }
    1667             }
    1668         }
     1670        {
     1671          ++ref;                /* Move past the $.  */
     1672
     1673          if (out != in)
     1674            /* Copy the text between the end of the last chunk
     1675               we processed (where IN points) and the new chunk
     1676               we are about to process (where REF points).  */
     1677            memmove (out, in, ref - in);
     1678
     1679          /* Move both pointers past the boring stuff.  */
     1680          out += ref - in;
     1681          in = ref;
     1682
     1683          if (*ref == '(' || *ref == '{')
     1684            {
     1685              char openparen = *ref;
     1686              char closeparen = openparen == '(' ? ')' : '}';
     1687              char *outref;
     1688              int count;
     1689              char *p;
     1690
     1691              *out++ = *in++;   /* Copy OPENPAREN.  */
     1692              outref = out;
     1693              /* IN now points past the opening paren or brace.
     1694                 Count parens or braces until it is matched.  */
     1695              count = 0;
     1696              while (*in != '\0')
     1697                {
     1698                  if (*in == closeparen && --count < 0)
     1699                    break;
     1700                  else if (*in == '\\' && in[1] == '\n')
     1701                    {
     1702                      /* We have found a backslash-newline inside a
     1703                         variable or function reference.  Eat it and
     1704                         any following whitespace.  */
     1705
     1706                      int quoted = 0;
     1707                      for (p = in - 1; p > ref && *p == '\\'; --p)
     1708                        quoted = !quoted;
     1709
     1710                      if (quoted)
     1711                        /* There were two or more backslashes, so this is
     1712                           not really a continuation line.  We don't collapse
     1713                           the quoting backslashes here as is done in
     1714                           collapse_continuations, because the line will
     1715                           be collapsed again after expansion.  */
     1716                        *out++ = *in++;
     1717                      else
     1718                        {
     1719                          /* Skip the backslash, newline, and whitespace.  */
     1720                          in += 2;
     1721                          NEXT_TOKEN (in);
     1722
     1723                          /* Discard any preceding whitespace that has
     1724                             already been written to the output.  */
     1725                          while (out > outref && ISBLANK (out[-1]))
     1726                            --out;
     1727
     1728                          /* Replace it all with a single space.  */
     1729                          *out++ = ' ';
     1730                        }
     1731                    }
     1732                  else
     1733                    {
     1734                      if (*in == openparen)
     1735                        ++count;
     1736
     1737                      *out++ = *in++;
     1738                    }
     1739                }
     1740            }
     1741        }
    16691742
    16701743      /* There are no more references in this line to worry about.
    1671         Copy the remaining uninteresting text to the output.  */
     1744        Copy the remaining uninteresting text to the output.  */
    16721745      if (out != in)
    1673         memmove (out, in, strlen (in) + 1);
     1746        memmove (out, in, strlen (in) + 1);
    16741747
    16751748      /* Finally, expand the line.  */
     1749      cmds->fileinfo.offset = i;
    16761750      lines[i] = allocated_variable_expand_for_file (cmds->command_lines[i],
    1677                                                      file);
    1678     }
    1679 
    1680   /* Start the command sequence, record it in a new
    1681      `struct child', and add that to the chain.  */
    1682 
    1683   c = xcalloc (sizeof (struct child));
    1684   c->file = file;
     1751                                                     file);
     1752    }
     1753
     1754  cmds->fileinfo.offset = 0;
    16851755  c->command_lines = lines;
    1686   c->sh_batch_file = NULL;
    1687 
    1688   /* Cache dontcare flag because file->dontcare can be changed once we
    1689      return. Check dontcare inheritance mechanism for details.  */
    1690   c->dontcare = file->dontcare;
    16911756
    16921757  /* Fetch the first command line to be run.  */
     
    17131778     this is where the old parallel job code waits, so...  */
    17141779
    1715   else if (job_fds[0] >= 0)
     1780  else if (jobserver_enabled ())
    17161781    while (1)
    17171782      {
    1718         char token;
    1719         int got_token;
    1720         int saved_errno;
     1783        int got_token;
    17211784
    17221785        DB (DB_JOBS, ("Need a job token; we %shave children\n",
     
    17271790          break;
    17281791
    1729         /* Read a token.  As long as there's no token available we'll block.
    1730            We enable interruptible system calls before the read(2) so that if
    1731            we get a SIGCHLD while we're waiting, we'll return with EINTR and
    1732            we can process the death(s) and return tokens to the free pool.
    1733 
    1734            Once we return from the read, we immediately reinstate restartable
    1735            system calls.  This allows us to not worry about checking for
    1736            EINTR on all the other system calls in the program.
    1737 
    1738            There is one other twist: there is a span between the time
    1739            reap_children() does its last check for dead children and the time
    1740            the read(2) call is entered, below, where if a child dies we won't
    1741            notice.  This is extremely serious as it could cause us to
    1742            deadlock, given the right set of events.
    1743 
    1744            To avoid this, we do the following: before we reap_children(), we
    1745            dup(2) the read FD on the jobserver pipe.  The read(2) call below
    1746            uses that new FD.  In the signal handler, we close that FD.  That
    1747            way, if a child dies during the section mentioned above, the
    1748            read(2) will be invoked with an invalid FD and will return
    1749            immediately with EBADF.  */
    1750 
    1751         /* Make sure we have a dup'd FD.  */
    1752         if (job_rfd < 0)
    1753           {
    1754             DB (DB_JOBS, ("Duplicate the job FD\n"));
    1755             job_rfd = dup (job_fds[0]);
    1756           }
     1792        /* Prepare for jobserver token acquisition.  */
     1793        jobserver_pre_acquire ();
    17571794
    17581795        /* Reap anything that's currently waiting.  */
     
    17601797
    17611798        /* Kick off any jobs we have waiting for an opportunity that
    1762            can run now (ie waiting for load). */
     1799           can run now (i.e., waiting for load). */
    17631800        start_waiting_jobs ();
    17641801
    1765         /* If our "free" slot has become available, use it; we don't need an
    1766            actual token.  */
     1802        /* If our "free" slot is available, use it; we don't need a token.  */
    17671803        if (!jobserver_tokens)
    17681804          break;
     
    17711807           waiting for a token. */
    17721808        if (!children)
    1773           fatal (NILF, "INTERNAL: no children as we go to sleep on read\n");
    1774 
    1775         /* Set interruptible system calls, and read() for a job token.  */
    1776         set_child_handler_action_flags (1, waiting_jobs != NULL);
    1777         got_token = read (job_rfd, &token, 1);
    1778         saved_errno = errno;
    1779         set_child_handler_action_flags (0, waiting_jobs != NULL);
     1809          O (fatal, NILF, "INTERNAL: no children as we go to sleep on read\n");
     1810
     1811        /* Get a token.  */
     1812        got_token = jobserver_acquire (waiting_jobs != NULL);
    17801813
    17811814        /* If we got one, we're done here.  */
    1782         if (got_token == 1)
     1815        if (got_token == 1)
    17831816          {
    17841817            DB (DB_JOBS, (_("Obtained token for child %p (%s).\n"),
     
    17861819            break;
    17871820          }
    1788 
    1789         /* If the error _wasn't_ expected (EINTR or EBADF), punt.  Otherwise,
    1790            go back and reap_children(), and try again.  */
    1791         errno = saved_errno;
    1792         if (errno != EINTR && errno != EBADF)
    1793           pfatal_with_name (_("read jobs pipe"));
    1794         if (errno == EBADF)
    1795           DB (DB_JOBS, ("Read returned EBADF.\n"));
    17961821      }
    17971822#endif
    17981823
    17991824  ++jobserver_tokens;
     1825
     1826  /* Trace the build.
     1827     Use message here so that changes to working directories are logged.  */
     1828  if (trace_flag)
     1829    {
     1830      char *newer = allocated_variable_expand_for_file ("$?", c->file);
     1831      const char *nm;
     1832
     1833      if (! cmds->fileinfo.filenm)
     1834        nm = _("<builtin>");
     1835      else
     1836        {
     1837          char *n = alloca (strlen (cmds->fileinfo.filenm) + 1 + 11 + 1);
     1838          sprintf (n, "%s:%lu", cmds->fileinfo.filenm, cmds->fileinfo.lineno);
     1839          nm = n;
     1840        }
     1841
     1842      if (newer[0] == '\0')
     1843        OSS (message, 0,
     1844             _("%s: target '%s' does not exist"), nm, c->file->name);
     1845      else
     1846        OSSS (message, 0,
     1847              _("%s: update target '%s' due to: %s"), nm, c->file->name, newer);
     1848
     1849      free (newer);
     1850    }
    18001851
    18011852  /* The job is now primed.  Start it running.
    18021853     (This will notice if there is in fact no recipe.)  */
    1803   if (cmds->fileinfo.filenm)
    1804     DB (DB_BASIC, (_("Invoking recipe from %s:%lu to update target `%s'.\n"),
    1805                    cmds->fileinfo.filenm, cmds->fileinfo.lineno,
    1806                    c->file->name));
    1807   else
    1808     DB (DB_BASIC, (_("Invoking builtin recipe to update target `%s'.\n"),
    1809                    c->file->name));
    1810 
    1811 
    18121854  start_waiting_job (c);
    18131855
    18141856  if (job_slots == 1 || not_parallel)
    18151857    /* Since there is only one job slot, make things run linearly.
    1816        Wait for the child to die, setting the state to `cs_finished'.  */
     1858       Wait for the child to die, setting the state to 'cs_finished'.  */
    18171859    while (file->command_state == cs_running)
    18181860      reap_children (1, 0);
    18191861
     1862  OUTPUT_UNSET ();
    18201863  return;
    18211864}
     
    18321875      /* There are no more lines in the expansion of this line.  */
    18331876      if (child->command_line == child->file->cmds->ncommand_lines)
    1834         {
    1835           /* There are no more lines to be expanded.  */
    1836           child->command_ptr = 0;
    1837           return 0;
    1838         }
     1877        {
     1878          /* There are no more lines to be expanded.  */
     1879          child->command_ptr = 0;
     1880          child->file->cmds->fileinfo.offset = 0;
     1881          return 0;
     1882        }
    18391883      else
    1840         /* Get the next line to run.  */
    1841         child->command_ptr = child->command_lines[child->command_line++];
    1842     }
     1884        /* Get the next line to run.  */
     1885        child->command_ptr = child->command_lines[child->command_line++];
     1886    }
     1887
     1888  child->file->cmds->fileinfo.offset = child->command_line - 1;
    18431889  return 1;
    18441890}
     
    19111957      /* Complain only once for the same error.  */
    19121958      if (lossage == -1 || errno != lossage)
    1913         {
    1914           if (errno == 0)
    1915             /* An errno value of zero means getloadavg is just unsupported.  */
    1916             error (NILF,
    1917                    _("cannot enforce load limits on this operating system"));
    1918           else
    1919             perror_with_name (_("cannot enforce load limit: "), "getloadavg");
    1920         }
     1959        {
     1960          if (errno == 0)
     1961            /* An errno value of zero means getloadavg is just unsupported.  */
     1962            O (error, NILF,
     1963               _("cannot enforce load limits on this operating system"));
     1964          else
     1965            perror_with_name (_("cannot enforce load limit: "), "getloadavg");
     1966        }
    19211967      lossage = errno;
    19221968      load = 0;
     
    19682014
    19692015      /* Try to start that job.  We break out of the loop as soon
    1970         as start_waiting_job puts one back on the waiting list.  */
     2016        as start_waiting_job puts one back on the waiting list.  */
    19712017    }
    19722018  while (start_waiting_job (job) && waiting_jobs != 0);
     
    19812027# if defined __EMX__
    19822028int
    1983 child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp)
     2029child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
    19842030{
    19852031  int pid;
    1986   /* stdin_fd == 0 means: nothing to do for stdin;
    1987      stdout_fd == 1 means: nothing to do for stdout */
    1988   int save_stdin = (stdin_fd != 0) ? dup (0) : 0;
    1989   int save_stdout = (stdout_fd != 1) ? dup (1): 1;
    1990 
    1991   /* < 0 only if dup() failed */
    1992   if (save_stdin < 0)
    1993     fatal (NILF, _("no more file handles: could not duplicate stdin\n"));
    1994   if (save_stdout < 0)
    1995     fatal (NILF, _("no more file handles: could not duplicate stdout\n"));
    1996 
    1997   /* Close unnecessary file handles for the child.  */
    1998   if (save_stdin != 0)
    1999     CLOSE_ON_EXEC (save_stdin);
    2000   if (save_stdout != 1)
    2001     CLOSE_ON_EXEC (save_stdout);
    2002 
    2003   /* Connect the pipes to the child process.  */
    2004   if (stdin_fd != 0)
    2005     (void) dup2 (stdin_fd, 0);
    2006   if (stdout_fd != 1)
    2007     (void) dup2 (stdout_fd, 1);
    2008 
    2009   /* stdin_fd and stdout_fd must be closed on exit because we are
    2010      still in the parent process */
    2011   if (stdin_fd != 0)
    2012     CLOSE_ON_EXEC (stdin_fd);
    2013   if (stdout_fd != 1)
    2014     CLOSE_ON_EXEC (stdout_fd);
     2032  int fdin = good_stdin ? FD_STDIN : get_bad_stdin ();
     2033  int fdout = FD_STDOUT;
     2034  int fderr = FD_STDERR;
     2035  int save_fdin = -1;
     2036  int save_fdout = -1;
     2037  int save_fderr = -1;
     2038
     2039  /* Divert child output if we want to capture output.  */
     2040  if (out && out->syncout)
     2041    {
     2042      if (out->out >= 0)
     2043        fdout = out->out;
     2044      if (out->err >= 0)
     2045        fderr = out->err;
     2046    }
     2047
     2048  /* For each FD which needs to be redirected first make a dup of the standard
     2049     FD to save and mark it close on exec so our child won't see it.  Then
     2050     dup2() the standard FD to the redirect FD, and also mark the redirect FD
     2051     as close on exec. */
     2052  if (fdin != FD_STDIN)
     2053    {
     2054      save_fdin = dup (FD_STDIN);
     2055      if (save_fdin < 0)
     2056        O (fatal, NILF, _("no more file handles: could not duplicate stdin\n"));
     2057      CLOSE_ON_EXEC (save_fdin);
     2058
     2059      dup2 (fdin, FD_STDIN);
     2060      CLOSE_ON_EXEC (fdin);
     2061    }
     2062
     2063  if (fdout != FD_STDOUT)
     2064    {
     2065      save_fdout = dup (FD_STDOUT);
     2066      if (save_fdout < 0)
     2067        O (fatal, NILF,
     2068           _("no more file handles: could not duplicate stdout\n"));
     2069      CLOSE_ON_EXEC (save_fdout);
     2070
     2071      dup2 (fdout, FD_STDOUT);
     2072      CLOSE_ON_EXEC (fdout);
     2073    }
     2074
     2075  if (fderr != FD_STDERR)
     2076    {
     2077      if (fderr != fdout)
     2078        {
     2079          save_fderr = dup (FD_STDERR);
     2080          if (save_fderr < 0)
     2081            O (fatal, NILF,
     2082               _("no more file handles: could not duplicate stderr\n"));
     2083          CLOSE_ON_EXEC (save_fderr);
     2084        }
     2085
     2086      dup2 (fderr, FD_STDERR);
     2087      CLOSE_ON_EXEC (fderr);
     2088    }
    20152089
    20162090  /* Run the command.  */
    20172091  pid = exec_command (argv, envp);
    20182092
    2019   /* Restore stdout/stdin of the parent and close temporary FDs.  */
    2020   if (stdin_fd != 0)
    2021     {
    2022       if (dup2 (save_stdin, 0) != 0)
    2023         fatal (NILF, _("Could not restore stdin\n"));
     2093  /* Restore stdout/stdin/stderr of the parent and close temporary FDs.  */
     2094  if (save_fdin >= 0)
     2095    {
     2096      if (dup2 (save_fdin, FD_STDIN) != FD_STDIN)
     2097        O (fatal, NILF, _("Could not restore stdin\n"));
    20242098      else
    2025         close (save_stdin);
    2026     }
    2027 
    2028   if (stdout_fd != 1)
    2029     {
    2030       if (dup2 (save_stdout, 1) != 1)
    2031         fatal (NILF, _("Could not restore stdout\n"));
     2099        close (save_fdin);
     2100    }
     2101
     2102  if (save_fdout >= 0)
     2103    {
     2104      if (dup2 (save_fdout, FD_STDOUT) != FD_STDOUT)
     2105        O (fatal, NILF, _("Could not restore stdout\n"));
    20322106      else
    2033         close (save_stdout);
     2107        close (save_fdout);
     2108    }
     2109
     2110  if (save_fderr >= 0)
     2111    {
     2112      if (dup2 (save_fderr, FD_STDERR) != FD_STDERR)
     2113        O (fatal, NILF, _("Could not restore stderr\n"));
     2114      else
     2115        close (save_fderr);
    20342116    }
    20352117
     
    20392121#elif !defined (_AMIGA) && !defined (__MSDOS__) && !defined (VMS)
    20402122
    2041 /* UNIX:
    2042    Replace the current process with one executing the command in ARGV.
    2043    STDIN_FD and STDOUT_FD are used as the process's stdin and stdout; ENVP is
    2044    the environment of the new program.  This function does not return.  */
    2045 void
    2046 child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp)
     2123/* POSIX:
     2124   Create a child process executing the command in ARGV.
     2125   ENVP is the environment of the new program.  Returns the PID or -1.  */
     2126int
     2127child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
    20472128{
    2048   if (stdin_fd != 0)
    2049     (void) dup2 (stdin_fd, 0);
    2050   if (stdout_fd != 1)
    2051     (void) dup2 (stdout_fd, 1);
    2052   if (stdin_fd != 0)
    2053     (void) close (stdin_fd);
    2054   if (stdout_fd != 1)
    2055     (void) close (stdout_fd);
     2129  int r;
     2130  int pid;
     2131  int fdin = good_stdin ? FD_STDIN : get_bad_stdin ();
     2132  int fdout = FD_STDOUT;
     2133  int fderr = FD_STDERR;
     2134
     2135  /* Divert child output if we want to capture it.  */
     2136  if (out && out->syncout)
     2137    {
     2138      if (out->out >= 0)
     2139        fdout = out->out;
     2140      if (out->err >= 0)
     2141        fderr = out->err;
     2142    }
     2143
     2144  pid = vfork();
     2145  if (pid != 0)
     2146    return pid;
     2147
     2148  /* We are the child.  */
     2149  unblock_sigs ();
     2150
     2151#ifdef SET_STACK_SIZE
     2152  /* Reset limits, if necessary.  */
     2153  if (stack_limit.rlim_cur)
     2154    setrlimit (RLIMIT_STACK, &stack_limit);
     2155#endif
     2156
     2157  /* For any redirected FD, dup2() it to the standard FD.
     2158     They are all marked close-on-exec already.  */
     2159  if (fdin != FD_STDIN)
     2160    EINTRLOOP (r, dup2 (fdin, FD_STDIN));
     2161  if (fdout != FD_STDOUT)
     2162    EINTRLOOP (r, dup2 (fdout, FD_STDOUT));
     2163  if (fderr != FD_STDERR)
     2164    EINTRLOOP (r, dup2 (fderr, FD_STDERR));
    20562165
    20572166  /* Run the command.  */
     
    20872196  HANDLE hPID;
    20882197  HANDLE hWaitPID;
    2089   int err = 0;
    20902198  int exit_code = EXIT_FAILURE;
    20912199
    20922200  /* make sure CreateProcess() has Path it needs */
    2093   sync_Path_environment();
     2201  sync_Path_environment ();
    20942202
    20952203  /* launch command */
    2096   hPID = process_easy(argv, envp);
     2204  hPID = process_easy (argv, envp, -1, -1);
    20972205
    20982206  /* make sure launch ok */
     
    21002208    {
    21012209      int i;
    2102       fprintf(stderr,
    2103               _("process_easy() failed to launch process (e=%ld)\n"),
    2104               process_last_err(hPID));
     2210      fprintf (stderr, _("process_easy() failed to launch process (e=%ld)\n"),
     2211               process_last_err (hPID));
    21052212      for (i = 0; argv[i]; i++)
    2106           fprintf(stderr, "%s ", argv[i]);
    2107       fprintf(stderr, _("\nCounted %d args in failed launch\n"), i);
    2108       exit(EXIT_FAILURE);
     2213          fprintf (stderr, "%s ", argv[i]);
     2214      fprintf (stderr, _("\nCounted %d args in failed launch\n"), i);
     2215      exit (EXIT_FAILURE);
    21092216    }
    21102217
    21112218  /* wait and reap last child */
    2112   hWaitPID = process_wait_for_any();
     2219  hWaitPID = process_wait_for_any (1, 0);
    21132220  while (hWaitPID)
    21142221    {
    21152222      /* was an error found on this process? */
    2116       err = process_last_err(hWaitPID);
     2223      int err = process_last_err (hWaitPID);
    21172224
    21182225      /* get exit data */
    2119       exit_code = process_exit_code(hWaitPID);
     2226      exit_code = process_exit_code (hWaitPID);
    21202227
    21212228      if (err)
    2122           fprintf(stderr, "make (e=%d, rc=%d): %s",
    2123                   err, exit_code, map_windows32_error_to_string(err));
     2229          fprintf (stderr, "make (e=%d, rc=%d): %s",
     2230                   err, exit_code, map_windows32_error_to_string (err));
    21242231
    21252232      /* cleanup process */
    2126       process_cleanup(hWaitPID);
     2233      process_cleanup (hWaitPID);
    21272234
    21282235      /* expect to find only last pid, warn about other pids reaped */
     
    21302237          break;
    21312238      else
    2132         {
    2133           char *pidstr = xstrdup (pid2str ((pid_t)hWaitPID));
    2134 
    2135           fprintf(stderr,
    2136                   _("make reaped child pid %s, still waiting for pid %s\n"),
    2137                   pidstr, pid2str ((pid_t)hPID));
    2138           free (pidstr);
    2139         }
     2239        {
     2240          char *pidstr = xstrdup (pid2str ((pid_t)hWaitPID));
     2241
     2242          fprintf (stderr,
     2243                   _("make reaped child pid %s, still waiting for pid %s\n"),
     2244                   pidstr, pid2str ((pid_t)hPID));
     2245          free (pidstr);
     2246        }
    21402247    }
    21412248
    21422249  /* return child's exit code as our exit code */
    2143   exit(exit_code);
     2250  exit (exit_code);
    21442251
    21452252#else  /* !WINDOWS32 */
     
    21532260
    21542261# ifdef __EMX__
    2155 
    21562262  /* Run the program.  */
    21572263  pid = spawnvpe (P_NOWAIT, argv[0], argv, envp);
    2158 
    21592264  if (pid >= 0)
    21602265    return pid;
     
    21652270
    21662271# else
    2167 
    21682272  /* Run the program.  */
    21692273  environ = envp;
     
    21752279    {
    21762280    case ENOENT:
    2177       error (NILF, _("%s: Command not found"), argv[0]);
     2281      /* We are in the child: don't use the output buffer.
     2282         It's not right to run fprintf() here!  */
     2283      if (makelevel == 0)
     2284        fprintf (stderr, _("%s: %s: Command not found\n"), program, argv[0]);
     2285      else
     2286        fprintf (stderr, _("%s[%u]: %s: Command not found\n"),
     2287                 program, makelevel, argv[0]);
    21782288      break;
    21792289    case ENOEXEC:
    21802290      {
    2181         /* The file is not executable.  Try it as a shell script.  */
    2182         extern char *getenv ();
    2183         char *shell;
    2184         char **new_argv;
    2185         int argc;
     2291        /* The file is not executable.  Try it as a shell script.  */
     2292        const char *shell;
     2293        char **new_argv;
     2294        int argc;
    21862295        int i=1;
    21872296
    21882297# ifdef __EMX__
    21892298        /* Do not use $SHELL from the environment */
    2190         struct variable *p = lookup_variable ("SHELL", 5);
    2191         if (p)
    2192           shell = p->value;
     2299        struct variable *p = lookup_variable ("SHELL", 5);
     2300        if (p)
     2301          shell = p->value;
    21932302        else
    21942303          shell = 0;
    21952304# else
    2196         shell = getenv ("SHELL");
     2305        shell = getenv ("SHELL");
    21972306# endif
    2198         if (shell == 0)
    2199           shell = default_shell;
    2200 
    2201         argc = 1;
    2202         while (argv[argc] != 0)
    2203           ++argc;
     2307        if (shell == 0)
     2308          shell = default_shell;
     2309
     2310        argc = 1;
     2311        while (argv[argc] != 0)
     2312          ++argc;
    22042313
    22052314# ifdef __EMX__
     
    22082317# endif
    22092318
    2210         new_argv = alloca ((1 + argc + 1) * sizeof (char *));
    2211         new_argv[0] = shell;
     2319        new_argv = alloca ((1 + argc + 1) * sizeof (char *));
     2320        new_argv[0] = (char *)shell;
    22122321
    22132322# ifdef __EMX__
     
    22212330
    22222331        new_argv[i] = argv[0];
    2223         while (argc > 0)
    2224           {
    2225             new_argv[i + argc] = argv[argc];
    2226             --argc;
    2227           }
     2332        while (argc > 0)
     2333          {
     2334            new_argv[i + argc] = argv[argc];
     2335            --argc;
     2336          }
    22282337
    22292338# ifdef __EMX__
    2230         pid = spawnvpe (P_NOWAIT, shell, new_argv, envp);
    2231         if (pid >= 0)
     2339        pid = spawnvpe (P_NOWAIT, shell, new_argv, envp);
     2340        if (pid >= 0)
    22322341          break;
    22332342# else
    2234         execvp (shell, new_argv);
     2343        execvp (shell, new_argv);
    22352344# endif
    2236         if (errno == ENOENT)
    2237           error (NILF, _("%s: Shell program not found"), shell);
    2238         else
    2239           perror_with_name ("execvp: ", shell);
    2240         break;
     2345        if (errno == ENOENT)
     2346          OS (error, NILF, _("%s: Shell program not found"), shell);
     2347        else
     2348          perror_with_name ("execvp: ", shell);
     2349        break;
    22412350      }
    22422351
     
    22442353    case EINVAL:
    22452354      /* this nasty error was driving me nuts :-( */
    2246       error (NILF, _("spawnvpe: environment space might be exhausted"));
     2355      O (error, NILF, _("spawnvpe: environment space might be exhausted"));
    22472356      /* FALLTHROUGH */
    22482357# endif
     
    22622371}
    22632372#else /* On Amiga */
    2264 void exec_command (char **argv)
     2373void
     2374exec_command (char **argv)
    22652375{
    22662376  MyExecute (argv);
     
    22782388/* Figure out the argument list necessary to run LINE as a command.  Try to
    22792389   avoid using a shell.  This routine handles only ' quoting, and " quoting
    2280    when no backslash, $ or ` characters are seen in the quotes.  Starting
     2390   when no backslash, $ or ' characters are seen in the quotes.  Starting
    22812391   quotes may be escaped with a backslash.  If any of the characters in
    2282    sh_chars[] is seen, or any of the builtin commands listed in sh_cmds[]
     2392   sh_chars is seen, or any of the builtin commands listed in sh_cmds
    22832393   is the first word of a line, the shell is used.
    22842394
     
    22952405
    22962406static char **
    2297 construct_command_argv_internal (char *line, char **restp, char *shell,
    2298                                  char *shellflags, char *ifs, int flags,
    2299                                  char **batch_filename_ptr)
     2407construct_command_argv_internal (char *line, char **restp, const char *shell,
     2408                                 const char *shellflags, const char *ifs,
     2409                                 int flags, char **batch_filename UNUSED)
    23002410{
    23012411#ifdef __MSDOS__
    23022412  /* MSDOS supports both the stock DOS shell and ports of Unixy shells.
    2303      We call `system' for anything that requires ``slow'' processing,
     2413     We call 'system' for anything that requires ''slow'' processing,
    23042414     because DOS shells are too dumb.  When $SHELL points to a real
    2305      (unix-style) shell, `system' just calls it to do everything.  When
    2306      $SHELL points to a DOS shell, `system' does most of the work
     2415     (unix-style) shell, 'system' just calls it to do everything.  When
     2416     $SHELL points to a DOS shell, 'system' does most of the work
    23072417     internally, calling the shell only for its internal commands.
    23082418     However, it looks on the $PATH first, so you can e.g. have an
    2309      external command named `mkdir'.
    2310 
    2311      Since we call `system', certain characters and commands below are
     2419     external command named 'mkdir'.
     2420
     2421     Since we call 'system', certain characters and commands below are
    23122422     actually not specific to COMMAND.COM, but to the DJGPP implementation
    2313      of `system'.  In particular:
     2423     of 'system'.  In particular:
    23142424
    23152425       The shell wildcard characters are in DOS_CHARS because they will
    2316        not be expanded if we call the child via `spawnXX'.
    2317 
    2318        The `;' is in DOS_CHARS, because our `system' knows how to run
     2426       not be expanded if we call the child via 'spawnXX'.
     2427
     2428       The ';' is in DOS_CHARS, because our 'system' knows how to run
    23192429       multiple commands on a single line.
    23202430
     
    23222432       won't have to tell one from another and have one more set of
    23232433       commands and special characters.  */
    2324   static char sh_chars_dos[] = "*?[];|<>%^&()";
    2325   static char *sh_cmds_dos[] = { "break", "call", "cd", "chcp", "chdir", "cls",
    2326                                  "copy", "ctty", "date", "del", "dir", "echo",
    2327                                  "erase", "exit", "for", "goto", "if", "md",
    2328                                  "mkdir", "path", "pause", "prompt", "rd",
    2329                                  "rmdir", "rem", "ren", "rename", "set",
    2330                                  "shift", "time", "type", "ver", "verify",
    2331                                  "vol", ":", 0 };
    2332 
    2333   static char sh_chars_sh[]  = "#;\"*?[]&|<>(){}$`^";
    2334   static char *sh_cmds_sh[]  = { "cd", "echo", "eval", "exec", "exit", "login",
    2335                                  "logout", "set", "umask", "wait", "while",
    2336                                  "for", "case", "if", ":", ".", "break",
    2337                                  "continue", "export", "read", "readonly",
    2338                                  "shift", "times", "trap", "switch", "unset",
    2339                                  "ulimit", 0 };
    2340 
    2341   char *sh_chars;
    2342   char **sh_cmds;
     2434  static const char *sh_chars_dos = "*?[];|<>%^&()";
     2435  static const char *sh_cmds_dos[] =
     2436    { "break", "call", "cd", "chcp", "chdir", "cls", "copy", "ctty", "date",
     2437      "del", "dir", "echo", "erase", "exit", "for", "goto", "if", "md",
     2438      "mkdir", "path", "pause", "prompt", "rd", "rmdir", "rem", "ren",
     2439      "rename", "set", "shift", "time", "type", "ver", "verify", "vol", ":",
     2440      0 };
     2441
     2442  static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^";
     2443  static const char *sh_cmds_sh[] =
     2444    { "cd", "echo", "eval", "exec", "exit", "login", "logout", "set", "umask",
     2445      "wait", "while", "for", "case", "if", ":", ".", "break", "continue",
     2446      "export", "read", "readonly", "shift", "times", "trap", "switch",
     2447      "unset", "ulimit", 0 };
     2448
     2449  const char *sh_chars;
     2450  const char **sh_cmds;
     2451
    23432452#elif defined (__EMX__)
    2344   static char sh_chars_dos[] = "*?[];|<>%^&()";
    2345   static char *sh_cmds_dos[] = { "break", "call", "cd", "chcp", "chdir", "cls",
    2346                                  "copy", "ctty", "date", "del", "dir", "echo",
    2347                                  "erase", "exit", "for", "goto", "if", "md",
    2348                                  "mkdir", "path", "pause", "prompt", "rd",
    2349                                  "rmdir", "rem", "ren", "rename", "set",
    2350                                  "shift", "time", "type", "ver", "verify",
    2351                                  "vol", ":", 0 };
    2352 
    2353   static char sh_chars_os2[] = "*?[];|<>%^()\"'&";
    2354   static char *sh_cmds_os2[] = { "call", "cd", "chcp", "chdir", "cls", "copy",
    2355                              "date", "del", "detach", "dir", "echo",
    2356                              "endlocal", "erase", "exit", "for", "goto", "if",
    2357                              "keys", "md", "mkdir", "move", "path", "pause",
    2358                              "prompt", "rd", "rem", "ren", "rename", "rmdir",
    2359                              "set", "setlocal", "shift", "start", "time",
    2360                              "type", "ver", "verify", "vol", ":", 0 };
    2361 
    2362   static char sh_chars_sh[]  = "#;\"*?[]&|<>(){}$`^~'";
    2363   static char *sh_cmds_sh[]  = { "echo", "cd", "eval", "exec", "exit", "login",
    2364                                  "logout", "set", "umask", "wait", "while",
    2365                                  "for", "case", "if", ":", ".", "break",
    2366                                  "continue", "export", "read", "readonly",
    2367                                  "shift", "times", "trap", "switch", "unset",
    2368                                  0 };
    2369   char *sh_chars;
    2370   char **sh_cmds;
     2453  static const char *sh_chars_dos = "*?[];|<>%^&()";
     2454  static const char *sh_cmds_dos[] =
     2455    { "break", "call", "cd", "chcp", "chdir", "cls", "copy", "ctty", "date",
     2456      "del", "dir", "echo", "erase", "exit", "for", "goto", "if", "md",
     2457      "mkdir", "path", "pause", "prompt", "rd", "rmdir", "rem", "ren",
     2458      "rename", "set", "shift", "time", "type", "ver", "verify", "vol", ":",
     2459      0 };
     2460
     2461  static const char *sh_chars_os2 = "*?[];|<>%^()\"'&";
     2462  static const char *sh_cmds_os2[] =
     2463    { "call", "cd", "chcp", "chdir", "cls", "copy", "date", "del", "detach",
     2464      "dir", "echo", "endlocal", "erase", "exit", "for", "goto", "if", "keys",
     2465      "md", "mkdir", "move", "path", "pause", "prompt", "rd", "rem", "ren",
     2466      "rename", "rmdir", "set", "setlocal", "shift", "start", "time", "type",
     2467      "ver", "verify", "vol", ":", 0 };
     2468
     2469  static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^~'";
     2470  static const char *sh_cmds_sh[] =
     2471    { "echo", "cd", "eval", "exec", "exit", "login", "logout", "set", "umask",
     2472      "wait", "while", "for", "case", "if", ":", ".", "break", "continue",
     2473      "export", "read", "readonly", "shift", "times", "trap", "switch",
     2474      "unset", 0 };
     2475
     2476  const char *sh_chars;
     2477  const char **sh_cmds;
    23712478
    23722479#elif defined (_AMIGA)
    2373   static char sh_chars[] = "#;\"|<>()?*$`";
    2374   static char *sh_cmds[] = { "cd", "eval", "if", "delete", "echo", "copy",
    2375                              "rename", "set", "setenv", "date", "makedir",
    2376                              "skip", "else", "endif", "path", "prompt",
    2377                              "unset", "unsetenv", "version",
    2378                              0 };
     2480  static const char *sh_chars = "#;\"|<>()?*$`";
     2481  static const char *sh_cmds[] =
     2482    { "cd", "eval", "if", "delete", "echo", "copy", "rename", "set", "setenv",
     2483      "date", "makedir", "skip", "else", "endif", "path", "prompt", "unset",
     2484      "unsetenv", "version", 0 };
     2485
    23792486#elif defined (WINDOWS32)
    2380   static char sh_chars_dos[] = "\"|&<>";
    2381   static char *sh_cmds_dos[] = { "assoc", "break", "call", "cd", "chcp",
    2382                                  "chdir", "cls", "color", "copy", "ctty",
    2383                                  "date", "del", "dir", "echo", "echo.",
    2384                                  "endlocal", "erase", "exit", "for", "ftype",
    2385                                  "goto", "if", "if", "md", "mkdir", "path",
    2386                                  "pause", "prompt", "rd", "rem", "ren",
    2387                                  "rename", "rmdir", "set", "setlocal",
    2388                                  "shift", "time", "title", "type", "ver",
    2389                                  "verify", "vol", ":", 0 };
    2390   static char sh_chars_sh[] = "#;\"*?[]&|<>(){}$`^";
    2391   static char *sh_cmds_sh[] = { "cd", "eval", "exec", "exit", "login",
    2392                              "logout", "set", "umask", "wait", "while", "for",
    2393                              "case", "if", ":", ".", "break", "continue",
    2394                              "export", "read", "readonly", "shift", "times",
    2395                              "trap", "switch", "test",
     2487  /* We used to have a double quote (") in sh_chars_dos[] below, but
     2488     that caused any command line with quoted file names be run
     2489     through a temporary batch file, which introduces command-line
     2490     limit of 4K charcaters imposed by cmd.exe.  Since CreateProcess
     2491     can handle quoted file names just fine, removing the quote lifts
     2492     the limit from a very frequent use case, because using quoted
     2493     file names is commonplace on MS-Windows.  */
     2494  static const char *sh_chars_dos = "|&<>";
     2495  static const char *sh_cmds_dos[] =
     2496    { "assoc", "break", "call", "cd", "chcp", "chdir", "cls", "color", "copy",
     2497      "ctty", "date", "del", "dir", "echo", "echo.", "endlocal", "erase",
     2498      "exit", "for", "ftype", "goto", "if", "if", "md", "mkdir", "move",
     2499      "path", "pause", "prompt", "rd", "rem", "ren", "rename", "rmdir",
     2500      "set", "setlocal", "shift", "time", "title", "type", "ver", "verify",
     2501      "vol", ":", 0 };
     2502
     2503  static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^";
     2504  static const char *sh_cmds_sh[] =
     2505    { "cd", "eval", "exec", "exit", "login", "logout", "set", "umask", "wait",
     2506      "while", "for", "case", "if", ":", ".", "break", "continue", "export",
     2507      "read", "readonly", "shift", "times", "trap", "switch", "test",
    23962508#ifdef BATCH_MODE_ONLY_SHELL
    2397                  "echo",
    2398 #endif
    2399                  0 };
    2400   char*  sh_chars;
    2401   char** sh_cmds;
     2509      "echo",
     2510#endif
     2511      0 };
     2512
     2513  const char *sh_chars;
     2514  const char **sh_cmds;
    24022515#elif defined(__riscos__)
    2403   static char sh_chars[] = "";
    2404   static char *sh_cmds[] = { 0 };
     2516  static const char *sh_chars = "";
     2517  static const char *sh_cmds[] = { 0 };
    24052518#else  /* must be UNIX-ish */
    2406   static char sh_chars[] = "#;\"*?[]&|<>(){}$`^~!";
    2407   static char *sh_cmds[] = { ".", ":", "break", "case", "cd", "continue",
    2408                              "eval", "exec", "exit", "export", "for", "if",
    2409                              "login", "logout", "read", "readonly", "set",
    2410                              "shift", "switch", "test", "times", "trap",
    2411                              "ulimit", "umask", "unset", "wait", "while", 0 };
     2519  static const char *sh_chars = "#;\"*?[]&|<>(){}$`^~!";
     2520  static const char *sh_cmds[] =
     2521    { ".", ":", "break", "case", "cd", "continue", "eval", "exec", "exit",
     2522      "export", "for", "if", "login", "logout", "read", "readonly", "set",
     2523      "shift", "switch", "test", "times", "trap", "ulimit", "umask", "unset",
     2524      "wait", "while", 0 };
     2525
    24122526# ifdef HAVE_DOS_PATHS
    24132527  /* This is required if the MSYS/Cygwin ports (which do not define
    24142528     WINDOWS32) are compiled with HAVE_DOS_PATHS defined, which uses
    2415      sh_chars_sh[] directly (see below).  */
    2416   static char *sh_chars_sh = sh_chars;
    2417 # endif  /* HAVE_DOS_PATHS */
     2529     sh_chars_sh directly (see below).  The value must be identical
     2530     to that of sh_chars immediately above.  */
     2531  static const char *sh_chars_sh =  "#;\"*?[]&|<>(){}$`^~!";
     2532# endif  /* HAVE_DOS_PATHS */
    24182533#endif
    24192534  int i;
    24202535  char *p;
     2536#ifndef NDEBUG
     2537  char *end;
     2538#endif
    24212539  char *ap;
    2422   char *end;
     2540  const char *cap;
     2541  const char *cp;
    24232542  int instring, word_has_equals, seen_nonequals, last_argument_was_empty;
    24242543  char **new_argv = 0;
     
    24272546  int slow_flag = 0;
    24282547
    2429   if (!unixy_shell) {
    2430     sh_cmds = sh_cmds_dos;
    2431     sh_chars = sh_chars_dos;
    2432   } else {
    2433     sh_cmds = sh_cmds_sh;
    2434     sh_chars = sh_chars_sh;
    2435   }
     2548  if (!unixy_shell)
     2549    {
     2550      sh_cmds = sh_cmds_dos;
     2551      sh_chars = sh_chars_dos;
     2552    }
     2553  else
     2554    {
     2555      sh_cmds = sh_cmds_sh;
     2556      sh_chars = sh_chars_sh;
     2557    }
    24362558#endif /* WINDOWS32 */
    24372559
     
    24392561    *restp = NULL;
    24402562
    2441   /* Make sure not to bother processing an empty line.  */
    2442   while (isblank ((unsigned char)*line))
     2563  /* Make sure not to bother processing an empty line but stop at newline.  */
     2564  while (ISBLANK (*line))
    24432565    ++line;
    24442566  if (*line == '\0')
    24452567    return 0;
     2568
     2569  if (shellflags == 0)
     2570    shellflags = posix_pedantic ? "-ec" : "-c";
    24462571
    24472572  /* See if it is safe to parse commands internally.  */
     
    24562581    slow_flag = strcmp ((s1 ? s1 : ""), (s2 ? s2 : ""));
    24572582
    2458     if (s1)
    2459       free (s1);
    2460     if (s2)
    2461       free (s2);
     2583    free (s1);
     2584    free (s2);
    24622585  }
    24632586  if (slow_flag)
     
    24692592      extern int _is_unixy_shell (const char *_path);
    24702593
    2471       DB (DB_BASIC, (_("$SHELL changed (was `%s', now `%s')\n"),
     2594      DB (DB_BASIC, (_("$SHELL changed (was '%s', now '%s')\n"),
    24722595                     default_shell, shell));
    24732596      unixy_shell = _is_unixy_shell (shell);
     
    24992622#endif /* not WINDOWS32 */
    25002623
    2501   if (ifs != 0)
    2502     for (ap = ifs; *ap != '\0'; ++ap)
    2503       if (*ap != ' ' && *ap != '\t' && *ap != '\n')
    2504         goto slow;
    2505 
    2506   if (shellflags != 0)
     2624  if (ifs)
     2625    for (cap = ifs; *cap != '\0'; ++cap)
     2626      if (*cap != ' ' && *cap != '\t' && *cap != '\n')
     2627        goto slow;
     2628
     2629  if (shellflags)
    25072630    if (shellflags[0] != '-'
    25082631        || ((shellflags[1] != 'c' || shellflags[2] != '\0')
     
    25172640  /* All the args can fit in a buffer as big as LINE is.   */
    25182641  ap = new_argv[0] = argstr = xmalloc (i);
     2642#ifndef NDEBUG
    25192643  end = ap + i;
     2644#endif
    25202645
    25212646  /* I is how many complete arguments have been found.  */
     
    25272652
    25282653      if (instring)
    2529         {
    2530           /* Inside a string, just copy any char except a closing quote
    2531              or a backslash-newline combination.  */
    2532           if (*p == instring)
    2533             {
    2534               instring = 0;
    2535               if (ap == new_argv[0] || *(ap-1) == '\0')
    2536                 last_argument_was_empty = 1;
    2537             }
    2538           else if (*p == '\\' && p[1] == '\n')
     2654        {
     2655          /* Inside a string, just copy any char except a closing quote
     2656             or a backslash-newline combination.  */
     2657          if (*p == instring)
     2658            {
     2659              instring = 0;
     2660              if (ap == new_argv[0] || *(ap-1) == '\0')
     2661                last_argument_was_empty = 1;
     2662            }
     2663          else if (*p == '\\' && p[1] == '\n')
    25392664            {
    25402665              /* Backslash-newline is handled differently depending on what
    25412666                 kind of string we're in: inside single-quoted strings you
    2542                  keep them; in double-quoted strings they disappear.
    2543                  For DOS/Windows/OS2, if we don't have a POSIX shell,
    2544                  we keep the pre-POSIX behavior of removing the
    2545                  backslash-newline.  */
     2667                 keep them; in double-quoted strings they disappear.  For
     2668                 DOS/Windows/OS2, if we don't have a POSIX shell, we keep the
     2669                 pre-POSIX behavior of removing the backslash-newline.  */
    25462670              if (instring == '"'
    25472671#if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32)
    2548                   || !unixy_shell
    2549 #endif
    2550                   )
     2672                  || !unixy_shell
     2673#endif
     2674                  )
    25512675                ++p;
    25522676              else
     
    25562680                }
    25572681            }
    2558           else if (*p == '\n' && restp != NULL)
    2559             {
    2560               /* End of the command line.  */
    2561               *restp = p;
    2562               goto end_of_line;
    2563             }
    2564           /* Backslash, $, and ` are special inside double quotes.
    2565              If we see any of those, punt.
    2566              But on MSDOS, if we use COMMAND.COM, double and single
    2567              quotes have the same effect.  */
    2568           else if (instring == '"' && strchr ("\\$`", *p) != 0 && unixy_shell)
    2569             goto slow;
    2570           else
    2571             *ap++ = *p;
    2572         }
     2682          else if (*p == '\n' && restp != NULL)
     2683            {
     2684              /* End of the command line.  */
     2685              *restp = p;
     2686              goto end_of_line;
     2687            }
     2688          /* Backslash, $, and ` are special inside double quotes.
     2689             If we see any of those, punt.
     2690             But on MSDOS, if we use COMMAND.COM, double and single
     2691             quotes have the same effect.  */
     2692          else if (instring == '"' && strchr ("\\$`", *p) != 0 && unixy_shell)
     2693            goto slow;
     2694#ifdef WINDOWS32
     2695          /* Quoted wildcard characters must be passed quoted to the
     2696             command, so give up the fast route.  */
     2697          else if (instring == '"' && strchr ("*?", *p) != 0 && !unixy_shell)
     2698            goto slow;
     2699          else if (instring == '"' && strncmp (p, "\\\"", 2) == 0)
     2700            *ap++ = *++p;
     2701#endif
     2702          else
     2703            *ap++ = *p;
     2704        }
    25732705      else if (strchr (sh_chars, *p) != 0)
    2574         /* Not inside a string, but it's a special char.  */
    2575         goto slow;
     2706        /* Not inside a string, but it's a special char.  */
     2707        goto slow;
    25762708      else if (one_shell && *p == '\n')
    2577         /* In .ONESHELL mode \n is a separator like ; or && */
    2578         goto slow;
     2709        /* In .ONESHELL mode \n is a separator like ; or && */
     2710        goto slow;
    25792711#ifdef  __MSDOS__
    25802712      else if (*p == '.' && p[1] == '.' && p[2] == '.' && p[3] != '.')
    2581         /* `...' is a wildcard in DJGPP.  */
    2582         goto slow;
     2713        /* '...' is a wildcard in DJGPP.  */
     2714        goto slow;
    25832715#endif
    25842716      else
    2585         /* Not a special char.  */
    2586         switch (*p)
    2587           {
    2588           case '=':
    2589             /* Equals is a special character in leading words before the
    2590                first word with no equals sign in it.  This is not the case
    2591                with sh -k, but we never get here when using nonstandard
    2592                shell flags.  */
    2593             if (! seen_nonequals && unixy_shell)
    2594               goto slow;
    2595             word_has_equals = 1;
    2596             *ap++ = '=';
    2597             break;
    2598 
    2599           case '\\':
    2600             /* Backslash-newline has special case handling, ref POSIX.
     2717        /* Not a special char.  */
     2718        switch (*p)
     2719          {
     2720          case '=':
     2721            /* Equals is a special character in leading words before the
     2722               first word with no equals sign in it.  This is not the case
     2723               with sh -k, but we never get here when using nonstandard
     2724               shell flags.  */
     2725            if (! seen_nonequals && unixy_shell)
     2726              goto slow;
     2727            word_has_equals = 1;
     2728            *ap++ = '=';
     2729            break;
     2730
     2731          case '\\':
     2732            /* Backslash-newline has special case handling, ref POSIX.
    26012733               We're in the fastpath, so emulate what the shell would do.  */
    2602             if (p[1] == '\n')
    2603               {
    2604                 /* Throw out the backslash and newline.  */
     2734            if (p[1] == '\n')
     2735              {
     2736                /* Throw out the backslash and newline.  */
    26052737                ++p;
    26062738
    2607                 /* If there's nothing in this argument yet, skip any
    2608                    whitespace before the start of the next word.  */
     2739                /* At the beginning of the argument, skip any whitespace other
     2740                   than newline before the start of the next word.  */
    26092741                if (ap == new_argv[i])
    2610                   p = next_token (p + 1) - 1;
    2611               }
    2612             else if (p[1] != '\0')
     2742                  while (ISBLANK (p[1]))
     2743                    ++p;
     2744              }
     2745#ifdef WINDOWS32
     2746            /* Backslash before whitespace is not special if our shell
     2747               is not Unixy.  */
     2748            else if (ISSPACE (p[1]) && !unixy_shell)
     2749              {
     2750                *ap++ = *p;
     2751                break;
     2752              }
     2753#endif
     2754            else if (p[1] != '\0')
    26132755              {
    26142756#ifdef HAVE_DOS_PATHS
     
    26312773#endif
    26322774                  if (p[1] != '\\' && p[1] != '\''
    2633                       && !isspace ((unsigned char)p[1])
     2775                      && !ISSPACE (p[1])
    26342776                      && strchr (sh_chars_sh, p[1]) == 0)
    26352777                    /* back up one notch, to copy the backslash */
     
    26402782                *ap++ = *++p;
    26412783              }
    2642             break;
    2643 
    2644           case '\'':
    2645           case '"':
    2646             instring = *p;
    2647             break;
    2648 
    2649           case '\n':
    2650             if (restp != NULL)
    2651               {
    2652                 /* End of the command line.  */
    2653                 *restp = p;
    2654                 goto end_of_line;
    2655               }
    2656             else
    2657               /* Newlines are not special.  */
    2658               *ap++ = '\n';
    2659             break;
    2660 
    2661           case ' ':
    2662           case '\t':
    2663             /* We have the end of an argument.
    2664                Terminate the text of the argument.  */
    2665             *ap++ = '\0';
    2666             new_argv[++i] = ap;
    2667             last_argument_was_empty = 0;
    2668 
    2669             /* Update SEEN_NONEQUALS, which tells us if every word
    2670                heretofore has contained an `='.  */
    2671             seen_nonequals |= ! word_has_equals;
    2672             if (word_has_equals && ! seen_nonequals)
    2673               /* An `=' in a word before the first
    2674                 word without one is magical.  */
    2675               goto slow;
    2676             word_has_equals = 0; /* Prepare for the next word.  */
    2677 
    2678             /* If this argument is the command name,
    2679                see if it is a built-in shell command.
    2680                If so, have the shell handle it.  */
    2681             if (i == 1)
    2682               {
    2683                 register int j;
    2684                 for (j = 0; sh_cmds[j] != 0; ++j)
     2784            break;
     2785
     2786          case '\'':
     2787          case '"':
     2788            instring = *p;
     2789            break;
     2790
     2791          case '\n':
     2792            if (restp != NULL)
     2793              {
     2794                /* End of the command line.  */
     2795                *restp = p;
     2796                goto end_of_line;
     2797              }
     2798            else
     2799              /* Newlines are not special.  */
     2800              *ap++ = '\n';
     2801            break;
     2802
     2803          case ' ':
     2804          case '\t':
     2805            /* We have the end of an argument.
     2806               Terminate the text of the argument.  */
     2807            *ap++ = '\0';
     2808            new_argv[++i] = ap;
     2809            last_argument_was_empty = 0;
     2810
     2811            /* Update SEEN_NONEQUALS, which tells us if every word
     2812               heretofore has contained an '='.  */
     2813            seen_nonequals |= ! word_has_equals;
     2814            if (word_has_equals && ! seen_nonequals)
     2815              /* An '=' in a word before the first
     2816                word without one is magical.  */
     2817              goto slow;
     2818            word_has_equals = 0; /* Prepare for the next word.  */
     2819
     2820            /* If this argument is the command name,
     2821               see if it is a built-in shell command.
     2822               If so, have the shell handle it.  */
     2823            if (i == 1)
     2824              {
     2825                register int j;
     2826                for (j = 0; sh_cmds[j] != 0; ++j)
    26852827                  {
    26862828                    if (streq (sh_cmds[j], new_argv[0]))
    26872829                      goto slow;
    2688 # ifdef __EMX__
     2830#if defined(__EMX__) || defined(WINDOWS32)
    26892831                    /* Non-Unix shells are case insensitive.  */
    26902832                    if (!unixy_shell
    26912833                        && strcasecmp (sh_cmds[j], new_argv[0]) == 0)
    26922834                      goto slow;
    2693 # endif
     2835#endif
    26942836                  }
    2695               }
    2696 
    2697             /* Ignore multiple whitespace chars.  */
    2698             p = next_token (p) - 1;
    2699             break;
    2700 
    2701           default:
    2702             *ap++ = *p;
    2703             break;
    2704           }
     2837              }
     2838
     2839            /* Skip whitespace chars, but not newlines.  */
     2840            while (ISBLANK (p[1]))
     2841              ++p;
     2842            break;
     2843
     2844          default:
     2845            *ap++ = *p;
     2846            break;
     2847          }
    27052848    }
    27062849 end_of_line:
     
    27212864      register int j;
    27222865      for (j = 0; sh_cmds[j] != 0; ++j)
    2723         if (streq (sh_cmds[j], new_argv[0]))
    2724           goto slow;
     2866        if (streq (sh_cmds[j], new_argv[0]))
     2867          goto slow;
    27252868    }
    27262869
     
    27462889
    27472890#ifdef __MSDOS__
    2748   execute_by_shell = 1; /* actually, call `system' if shell isn't unixy */
     2891  execute_by_shell = 1; /* actually, call 'system' if shell isn't unixy */
    27492892#endif
    27502893
     
    27612904    {
    27622905      if (*ptr == '\\' && ptr[1] == '\n')
    2763         ptr += 2;
     2906        ptr += 2;
    27642907      else if (*ptr == '@') /* Kludge: multiline commands */
    27652908      {
    2766         ptr += 2;
    2767         *dptr++ = '\n';
     2909        ptr += 2;
     2910        *dptr++ = '\n';
    27682911      }
    27692912      else
    2770         *dptr++ = *ptr++;
     2913        *dptr++ = *ptr++;
    27712914    }
    27722915    *dptr = 0;
     
    27762919    new_argv[1] = 0;
    27772920  }
    2778 #else   /* Not Amiga  */
     2921#else   /* Not Amiga  */
    27792922#ifdef WINDOWS32
    27802923  /*
     
    27892932
    27902933  /* Make sure not to bother processing an empty line.  */
    2791   while (isspace ((unsigned char)*line))
    2792     ++line;
     2934  NEXT_TOKEN (line);
    27932935  if (*line == '\0')
    27942936    return 0;
     
    28012943       argument list.  */
    28022944
     2945    char *new_line;
    28032946    unsigned int shell_len = strlen (shell);
    28042947    unsigned int line_len = strlen (line);
    2805     unsigned int sflags_len = strlen (shellflags);
     2948    unsigned int sflags_len = shellflags ? strlen (shellflags) : 0;
     2949#ifdef WINDOWS32
    28062950    char *command_ptr = NULL; /* used for batch_mode_shell mode */
    2807     char *new_line;
     2951#endif
    28082952
    28092953# ifdef __EMX__ /* is this necessary? */
    2810     if (!unixy_shell)
     2954    if (!unixy_shell && shellflags)
    28112955      shellflags[0] = '/'; /* "/c" */
    28122956# endif
    28132957
    28142958    /* In .ONESHELL mode we are allowed to throw the entire current
    2815         recipe string at a single shell and trust that the user
    2816         has configured the shell and shell flags, and formatted
    2817         the string, appropriately. */
     2959        recipe string at a single shell and trust that the user
     2960        has configured the shell and shell flags, and formatted
     2961        the string, appropriately. */
    28182962    if (one_shell)
    28192963      {
    2820         /* If the shell is Bourne compatible, we must remove and ignore
    2821            interior special chars [@+-] because they're meaningless to
    2822            the shell itself. If, however, we're in .ONESHELL mode and
    2823            have changed SHELL to something non-standard, we should
    2824            leave those alone because they could be part of the
    2825            script. In this case we must also leave in place
    2826            any leading [@+-] for the same reason.  */
    2827 
    2828         /* Remove and ignore interior prefix chars [@+-] because they're
    2829              meaningless given a single shell. */
     2964        /* If the shell is Bourne compatible, we must remove and ignore
     2965           interior special chars [@+-] because they're meaningless to
     2966           the shell itself. If, however, we're in .ONESHELL mode and
     2967           have changed SHELL to something non-standard, we should
     2968           leave those alone because they could be part of the
     2969           script. In this case we must also leave in place
     2970           any leading [@+-] for the same reason.  */
     2971
     2972        /* Remove and ignore interior prefix chars [@+-] because they're
     2973             meaningless given a single shell. */
    28302974#if defined __MSDOS__ || defined (__EMX__)
    2831         if (unixy_shell)     /* the test is complicated and we already did it */
     2975        if (unixy_shell)     /* the test is complicated and we already did it */
    28322976#else
    2833         if (is_bourne_compatible_shell(shell))
     2977        if (is_bourne_compatible_shell (shell)
     2978#ifdef WINDOWS32
     2979            /* If we didn't find any sh.exe, don't behave is if we did!  */
     2980            && !no_default_sh_exe
     2981#endif
     2982            )
    28342983#endif
    28352984          {
     
    28432992                int esc = 0;
    28442993
    2845                 /* This is the start of a new recipe line.
    2846                    Skip whitespace and prefix characters.  */
    2847                 while (isblank (*f) || *f == '-' || *f == '@' || *f == '+')
     2994                /* This is the start of a new recipe line.  Skip whitespace
     2995                   and prefix characters but not newlines.  */
     2996                while (ISBLANK (*f) || *f == '-' || *f == '@' || *f == '+')
    28482997                  ++f;
    28492998
     
    28673016            *t = '\0';
    28683017          }
    2869 
    2870         new_argv = xmalloc (4 * sizeof (char *));
    2871         new_argv[0] = xstrdup(shell);
    2872         new_argv[1] = xstrdup(shellflags);
    2873         new_argv[2] = line;
    2874         new_argv[3] = NULL;
    2875         return new_argv;
     3018#ifdef WINDOWS32
     3019        else    /* non-Posix shell (cmd.exe etc.) */
     3020          {
     3021            const char *f = line;
     3022            char *t = line;
     3023            char *tstart = t;
     3024            int temp_fd;
     3025            FILE* batch = NULL;
     3026            int id = GetCurrentProcessId ();
     3027            PATH_VAR(fbuf);
     3028
     3029            /* Generate a file name for the temporary batch file.  */
     3030            sprintf (fbuf, "make%d", id);
     3031            *batch_filename = create_batch_file (fbuf, 0, &temp_fd);
     3032            DB (DB_JOBS, (_("Creating temporary batch file %s\n"),
     3033                          *batch_filename));
     3034
     3035            /* Create a FILE object for the batch file, and write to it the
     3036               commands to be executed.  Put the batch file in TEXT mode.  */
     3037            _setmode (temp_fd, _O_TEXT);
     3038            batch = _fdopen (temp_fd, "wt");
     3039            fputs ("@echo off\n", batch);
     3040            DB (DB_JOBS, (_("Batch file contents:\n\t@echo off\n")));
     3041
     3042            /* Copy the recipe, removing and ignoring interior prefix chars
     3043               [@+-]: they're meaningless in .ONESHELL mode.  */
     3044            while (*f != '\0')
     3045              {
     3046                /* This is the start of a new recipe line.  Skip whitespace
     3047                   and prefix characters but not newlines.  */
     3048                while (ISBLANK (*f) || *f == '-' || *f == '@' || *f == '+')
     3049                  ++f;
     3050
     3051                /* Copy until we get to the next logical recipe line.  */
     3052                while (*f != '\0')
     3053                  {
     3054                    /* Remove the escaped newlines in the command, and the
     3055                       blanks that follow them.  Windows shells cannot handle
     3056                       escaped newlines.  */
     3057                    if (*f == '\\' && f[1] == '\n')
     3058                      {
     3059                        f += 2;
     3060                        while (ISBLANK (*f))
     3061                          ++f;
     3062                      }
     3063                    *(t++) = *(f++);
     3064                    /* On an unescaped newline, we're done with this
     3065                       line.  */
     3066                    if (f[-1] == '\n')
     3067                      break;
     3068                  }
     3069                /* Write another line into the batch file.  */
     3070                if (t > tstart)
     3071                  {
     3072                    char c = *t;
     3073                    *t = '\0';
     3074                    fputs (tstart, batch);
     3075                    DB (DB_JOBS, ("\t%s", tstart));
     3076                    tstart = t;
     3077                    *t = c;
     3078                  }
     3079              }
     3080            DB (DB_JOBS, ("\n"));
     3081            fclose (batch);
     3082
     3083            /* Create an argv list for the shell command line that
     3084               will run the batch file.  */
     3085            new_argv = xmalloc (2 * sizeof (char *));
     3086            new_argv[0] = xstrdup (*batch_filename);
     3087            new_argv[1] = NULL;
     3088            return new_argv;
     3089          }
     3090#endif /* WINDOWS32 */
     3091        /* Create an argv list for the shell command line.  */
     3092        {
     3093          int n = 0;
     3094
     3095          new_argv = xmalloc ((4 + sflags_len/2) * sizeof (char *));
     3096          new_argv[n++] = xstrdup (shell);
     3097
     3098          /* Chop up the shellflags (if any) and assign them.  */
     3099          if (! shellflags)
     3100            new_argv[n++] = xstrdup ("");
     3101          else
     3102            {
     3103              const char *s = shellflags;
     3104              char *t;
     3105              unsigned int len;
     3106              while ((t = find_next_token (&s, &len)) != 0)
     3107                new_argv[n++] = xstrndup (t, len);
     3108            }
     3109
     3110          /* Set the command to invoke.  */
     3111          new_argv[n++] = line;
     3112          new_argv[n++] = NULL;
     3113        }
     3114        return new_argv;
    28763115      }
    28773116
    2878     new_line = alloca (shell_len + 1 + sflags_len + 1
    2879                              + (line_len*2) + 1);
     3117    new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1
     3118                        + (line_len*2) + 1);
    28803119    ap = new_line;
    2881     memcpy (ap, shell, shell_len);
    2882     ap += shell_len;
     3120    /* Copy SHELL, escaping any characters special to the shell.  If
     3121       we don't escape them, construct_command_argv_internal will
     3122       recursively call itself ad nauseam, or until stack overflow,
     3123       whichever happens first.  */
     3124    for (cp = shell; *cp != '\0'; ++cp)
     3125      {
     3126        if (strchr (sh_chars, *cp) != 0)
     3127          *(ap++) = '\\';
     3128        *(ap++) = *cp;
     3129      }
    28833130    *(ap++) = ' ';
    2884     memcpy (ap, shellflags, sflags_len);
     3131    if (shellflags)
     3132      memcpy (ap, shellflags, sflags_len);
    28853133    ap += sflags_len;
    28863134    *(ap++) = ' ';
     3135#ifdef WINDOWS32
    28873136    command_ptr = ap;
     3137#endif
    28883138    for (p = line; *p != '\0'; ++p)
    28893139      {
    2890         if (restp != NULL && *p == '\n')
    2891           {
    2892             *restp = p;
    2893             break;
    2894           }
    2895         else if (*p == '\\' && p[1] == '\n')
    2896           {
    2897             /* POSIX says we keep the backslash-newline.  If we don't have a
     3140        if (restp != NULL && *p == '\n')
     3141          {
     3142            *restp = p;
     3143            break;
     3144          }
     3145        else if (*p == '\\' && p[1] == '\n')
     3146          {
     3147            /* POSIX says we keep the backslash-newline.  If we don't have a
    28983148               POSIX shell on DOS/Windows/OS2, mimic the pre-POSIX behavior
    28993149               and remove the backslash/newline.  */
     
    29033153# define PRESERVE_BSNL  1
    29043154#endif
    2905             if (PRESERVE_BSNL)
    2906               {
    2907                 *(ap++) = '\\';
    2908                 /* Only non-batch execution needs another backslash,
    2909                    because it will be passed through a recursive
    2910                    invocation of this function.  */
    2911                 if (!batch_mode_shell)
    2912                   *(ap++) = '\\';
    2913                 *(ap++) = '\n';
    2914               }
    2915             ++p;
    2916             continue;
    2917           }
     3155            if (PRESERVE_BSNL)
     3156              {
     3157                *(ap++) = '\\';
     3158                /* Only non-batch execution needs another backslash,
     3159                   because it will be passed through a recursive
     3160                   invocation of this function.  */
     3161                if (!batch_mode_shell)
     3162                  *(ap++) = '\\';
     3163                *(ap++) = '\n';
     3164              }
     3165            ++p;
     3166            continue;
     3167          }
    29183168
    29193169        /* DOS shells don't know about backslash-escaping.  */
    2920         if (unixy_shell && !batch_mode_shell &&
     3170        if (unixy_shell && !batch_mode_shell &&
    29213171            (*p == '\\' || *p == '\'' || *p == '"'
    2922              || isspace ((unsigned char)*p)
     3172             || ISSPACE (*p)
    29233173             || strchr (sh_chars, *p) != 0))
    2924           *ap++ = '\\';
     3174          *ap++ = '\\';
    29253175#ifdef __MSDOS__
    29263176        else if (unixy_shell && strneq (p, "...", 3))
    29273177          {
    2928             /* The case of `...' wildcard again.  */
     3178            /* The case of '...' wildcard again.  */
    29293179            strcpy (ap, "\\.\\.\\");
    29303180            ap += 5;
     
    29323182          }
    29333183#endif
    2934         *ap++ = *p;
     3184        *ap++ = *p;
    29353185      }
    29363186    if (ap == new_line + shell_len + sflags_len + 2)
    2937       /* Line was empty.  */
    2938       return 0;
     3187      {
     3188        /* Line was empty.  */
     3189        free (new_line);
     3190        return 0;
     3191      }
    29393192    *ap = '\0';
    29403193
     
    29433196       command line (e.g. Cygnus GNUWIN32 sh.exe on WIN32 systems).  In these
    29443197       cases, run commands via a script file.  */
    2945     if (just_print_flag && !(flags & COMMANDS_RECURSE)) {
    2946       /* Need to allocate new_argv, although it's unused, because
    2947         start_job_command will want to free it and its 0'th element.  */
    2948       new_argv = xmalloc(2 * sizeof (char *));
    2949       new_argv[0] = xstrdup ("");
    2950       new_argv[1] = NULL;
    2951     } else if ((no_default_sh_exe || batch_mode_shell) && batch_filename_ptr) {
    2952       int temp_fd;
    2953       FILE* batch = NULL;
    2954       int id = GetCurrentProcessId();
    2955       PATH_VAR(fbuf);
    2956 
    2957       /* create a file name */
    2958       sprintf(fbuf, "make%d", id);
    2959       *batch_filename_ptr = create_batch_file (fbuf, unixy_shell, &temp_fd);
    2960 
    2961       DB (DB_JOBS, (_("Creating temporary batch file %s\n"),
    2962                     *batch_filename_ptr));
    2963 
    2964       /* Create a FILE object for the batch file, and write to it the
    2965          commands to be executed.  Put the batch file in TEXT mode.  */
    2966       _setmode (temp_fd, _O_TEXT);
    2967       batch = _fdopen (temp_fd, "wt");
    2968       if (!unixy_shell)
    2969         fputs ("@echo off\n", batch);
    2970       fputs (command_ptr, batch);
    2971       fputc ('\n', batch);
    2972       fclose (batch);
    2973       DB (DB_JOBS, (_("Batch file contents:%s\n\t%s\n"),
    2974                     !unixy_shell ? "\n\t@echo off" : "", command_ptr));
    2975 
    2976       /* create argv */
    2977       new_argv = xmalloc(3 * sizeof (char *));
    2978       if (unixy_shell) {
    2979         new_argv[0] = xstrdup (shell);
    2980         new_argv[1] = *batch_filename_ptr; /* only argv[0] gets freed later */
    2981       } else {
    2982         new_argv[0] = xstrdup (*batch_filename_ptr);
     3198    if (just_print_flag && !(flags & COMMANDS_RECURSE))
     3199      {
     3200        /* Need to allocate new_argv, although it's unused, because
     3201           start_job_command will want to free it and its 0'th element.  */
     3202        new_argv = xmalloc (2 * sizeof (char *));
     3203        new_argv[0] = xstrdup ("");
    29833204        new_argv[1] = NULL;
    29843205      }
    2985       new_argv[2] = NULL;
    2986     } else
     3206    else if ((no_default_sh_exe || batch_mode_shell) && batch_filename)
     3207      {
     3208        int temp_fd;
     3209        FILE* batch = NULL;
     3210        int id = GetCurrentProcessId ();
     3211        PATH_VAR (fbuf);
     3212
     3213        /* create a file name */
     3214        sprintf (fbuf, "make%d", id);
     3215        *batch_filename = create_batch_file (fbuf, unixy_shell, &temp_fd);
     3216
     3217        DB (DB_JOBS, (_("Creating temporary batch file %s\n"),
     3218                      *batch_filename));
     3219
     3220        /* Create a FILE object for the batch file, and write to it the
     3221           commands to be executed.  Put the batch file in TEXT mode.  */
     3222        _setmode (temp_fd, _O_TEXT);
     3223        batch = _fdopen (temp_fd, "wt");
     3224        if (!unixy_shell)
     3225          fputs ("@echo off\n", batch);
     3226        fputs (command_ptr, batch);
     3227        fputc ('\n', batch);
     3228        fclose (batch);
     3229        DB (DB_JOBS, (_("Batch file contents:%s\n\t%s\n"),
     3230                      !unixy_shell ? "\n\t@echo off" : "", command_ptr));
     3231
     3232        /* create argv */
     3233        new_argv = xmalloc (3 * sizeof (char *));
     3234        if (unixy_shell)
     3235          {
     3236            new_argv[0] = xstrdup (shell);
     3237            new_argv[1] = *batch_filename; /* only argv[0] gets freed later */
     3238          }
     3239        else
     3240          {
     3241            new_argv[0] = xstrdup (*batch_filename);
     3242            new_argv[1] = NULL;
     3243          }
     3244        new_argv[2] = NULL;
     3245      }
     3246    else
    29873247#endif /* WINDOWS32 */
    29883248
    29893249    if (unixy_shell)
    2990       new_argv = construct_command_argv_internal (new_line, 0, 0, 0, 0, flags, 0);
     3250      new_argv = construct_command_argv_internal (new_line, 0, 0, 0, 0,
     3251                                                  flags, 0);
    29913252
    29923253#ifdef __EMX__
    29933254    else if (!unixy_shell)
    29943255      {
    2995         /* new_line is local, must not be freed therefore
     3256        /* new_line is local, must not be freed therefore
    29963257           We use line here instead of new_line because we run the shell
    29973258           manually.  */
     
    30733334#else
    30743335    else
    3075       fatal (NILF, _("%s (line %d) Bad shell context (!unixy && !batch_mode_shell)\n"),
     3336      fatal (NILF, CSTRLEN (__FILE__) + INTSTR_LENGTH,
     3337             _("%s (line %d) Bad shell context (!unixy && !batch_mode_shell)\n"),
    30763338            __FILE__, __LINE__);
    30773339#endif
     3340
     3341    free (new_line);
    30783342  }
    3079 #endif  /* ! AMIGA */
     3343#endif  /* ! AMIGA */
    30803344
    30813345  return new_argv;
     
    30853349/* Figure out the argument list necessary to run LINE as a command.  Try to
    30863350   avoid using a shell.  This routine handles only ' quoting, and " quoting
    3087    when no backslash, $ or ` characters are seen in the quotes.  Starting
     3351   when no backslash, $ or ' characters are seen in the quotes.  Starting
    30883352   quotes may be escaped with a backslash.  If any of the characters in
    3089    sh_chars[] is seen, or any of the builtin commands listed in sh_cmds[]
     3353   sh_chars is seen, or any of the builtin commands listed in sh_cmds
    30903354   is the first word of a line, the shell is used.
    30913355
     
    30983362char **
    30993363construct_command_argv (char *line, char **restp, struct file *file,
    3100                         int cmd_flags, char **batch_filename_ptr)
     3364                        int cmd_flags, char **batch_filename)
    31013365{
    31023366  char *shell, *ifs, *shellflags;
     
    31113375  for (;;)
    31123376    {
    3113       while ((*cptr != 0)
    3114              && (isspace ((unsigned char)*cptr)))
    3115         cptr++;
     3377      while ((*cptr != 0) && (ISSPACE (*cptr)))
     3378        cptr++;
    31163379      if (*cptr == 0)
    3117         break;
    3118       while ((*cptr != 0)
    3119              && (!isspace((unsigned char)*cptr)))
    3120         cptr++;
     3380        break;
     3381      while ((*cptr != 0) && (!ISSPACE (*cptr)))
     3382        cptr++;
    31213383      argc++;
    31223384    }
     
    31303392  for (;;)
    31313393    {
    3132       while ((*cptr != 0)
    3133              && (isspace ((unsigned char)*cptr)))
    3134         cptr++;
     3394      while ((*cptr != 0) && (ISSPACE (*cptr)))
     3395        cptr++;
    31353396      if (*cptr == 0)
    3136         break;
     3397        break;
    31373398      DB (DB_JOBS, ("argv[%d] = [%s]\n", argc, cptr));
    31383399      argv[argc++] = cptr;
    3139       while ((*cptr != 0)
    3140              && (!isspace((unsigned char)*cptr)))
    3141         cptr++;
     3400      while ((*cptr != 0) && (!ISSPACE (*cptr)))
     3401        cptr++;
    31423402      if (*cptr != 0)
    3143         *cptr++ = 0;
     3403        *cptr++ = 0;
    31443404    }
    31453405#else
     
    31553415     * is not confused.
    31563416     */
    3157     if (shell) {
    3158       char *p = w32ify (shell, 0);
    3159       strcpy (shell, p);
    3160     }
     3417    if (shell)
     3418      {
     3419        char *p = w32ify (shell, 0);
     3420        strcpy (shell, p);
     3421      }
    31613422#endif
    31623423#ifdef __EMX__
     
    31663427      static int init = 0;
    31673428      if (init == 0)
    3168         {
    3169           unixroot = getenv ("UNIXROOT");
    3170           /* unixroot must be NULL or not empty */
    3171           if (unixroot && unixroot[0] == '\0') unixroot = NULL;
    3172           init = 1;
    3173         }
     3429        {
     3430          unixroot = getenv ("UNIXROOT");
     3431          /* unixroot must be NULL or not empty */
     3432          if (unixroot && unixroot[0] == '\0') unixroot = NULL;
     3433          init = 1;
     3434        }
    31743435
    31753436      /* if we have an unixroot drive and if shell is not default_shell
     
    31793440         "$UNIXROOT/bin/sh" instead.  */
    31803441      if (unixroot && shell && strcmp (shell, last_shell) != 0
    3181           && (shell[0] == '/' || shell[0] == '\\'))
    3182         {
    3183           /* trying a new shell, check whether it exists */
    3184           size_t size = strlen (shell);
    3185           char *buf = xmalloc (size + 7);
    3186           memcpy (buf, shell, size);
    3187           memcpy (buf + size, ".exe", 5); /* including the trailing '\0' */
     3442          && (shell[0] == '/' || shell[0] == '\\'))
     3443        {
     3444          /* trying a new shell, check whether it exists */
     3445          size_t size = strlen (shell);
     3446          char *buf = xmalloc (size + 7);
     3447          memcpy (buf, shell, size);
     3448          memcpy (buf + size, ".exe", 5); /* including the trailing '\0' */
    31883449          if (access (shell, F_OK) != 0 && access (buf, F_OK) != 0)
    3189             {
    3190               /* try the same for the unixroot drive */
    3191               memmove (buf + 2, buf, size + 5);
    3192               buf[0] = unixroot[0];
    3193               buf[1] = unixroot[1];
    3194               if (access (buf, F_OK) == 0)
    3195                 /* we have found a shell! */
    3196                 /* free(shell); */
    3197                 shell = buf;
    3198               else
    3199                 free (buf);
    3200             }
    3201           else
     3450            {
     3451              /* try the same for the unixroot drive */
     3452              memmove (buf + 2, buf, size + 5);
     3453              buf[0] = unixroot[0];
     3454              buf[1] = unixroot[1];
     3455              if (access (buf, F_OK) == 0)
     3456                /* we have found a shell! */
     3457                /* free(shell); */
     3458                shell = buf;
     3459              else
     3460                free (buf);
     3461            }
     3462          else
    32023463            free (buf);
    3203         }
     3464        }
    32043465    }
    32053466#endif /* __EMX__ */
     
    32123473
    32133474  argv = construct_command_argv_internal (line, restp, shell, shellflags, ifs,
    3214                                           cmd_flags, batch_filename_ptr);
     3475                                          cmd_flags, batch_filename);
    32153476
    32163477  free (shell);
     
    32293490
    32303491  (void) close (new);
    3231   fd = dup (old);
     3492  EINTRLOOP (fd, dup (old));
    32323493  if (fd != new)
    32333494    {
  • vendor/gnumake/current/job.h

    r2596 r3138  
    11/* Definitions for managing subprocesses in GNU Make.
    2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    3 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    4 Foundation, Inc.
     2Copyright (C) 1992-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #ifndef SEEN_JOB_H
    20 #define SEEN_JOB_H
     17#include "output.h"
    2118
    2219#ifdef HAVE_FCNTL_H
     
    2825/* How to set close-on-exec for a file descriptor.  */
    2926
    30 #if !defined F_SETFD
    31 # define CLOSE_ON_EXEC(_d)
     27#if !defined(F_SETFD) || !defined(F_GETFD)
     28# ifdef WINDOWS32
     29#  define CLOSE_ON_EXEC(_d)  process_noinherit(_d)
     30# else
     31#  define CLOSE_ON_EXEC(_d)
     32# endif
    3233#else
    3334# ifndef FD_CLOEXEC
     
    3738#endif
    3839
     40#ifdef NO_OUTPUT_SYNC
     41# define RECORD_SYNC_MUTEX(m) \
     42    O (error, NILF,                                                    \
     43       _("-O[TYPE] (--output-sync[=TYPE]) is not configured for this build."));
     44#else
     45# ifdef WINDOWS32
     46/* For emulations in w32/compat/posixfcn.c.  */
     47#  define F_GETFD 1
     48#  define F_SETLKW 2
     49/* Implementation note: None of the values of l_type below can be zero
     50   -- they are compared with a static instance of the struct, so zero
     51   means unknown/invalid, see w32/compat/posixfcn.c. */
     52#  define F_WRLCK 1
     53#  define F_UNLCK 2
     54
     55struct flock
     56  {
     57    short l_type;
     58    short l_whence;
     59    off_t l_start;
     60    off_t l_len;
     61    pid_t l_pid;
     62  };
     63
     64/* This type is actually a HANDLE, but we want to avoid including
     65   windows.h as much as possible.  */
     66typedef intptr_t sync_handle_t;
     67
     68/* Public functions emulated/provided in posixfcn.c.  */
     69int fcntl (intptr_t fd, int cmd, ...);
     70intptr_t create_mutex (void);
     71int same_stream (FILE *f1, FILE *f2);
     72
     73#  define RECORD_SYNC_MUTEX(m) record_sync_mutex(m)
     74void record_sync_mutex (const char *str);
     75void prepare_mutex_handle_string (intptr_t hdl);
     76# else  /* !WINDOWS32 */
     77
     78typedef int sync_handle_t;      /* file descriptor */
     79
     80#  define RECORD_SYNC_MUTEX(m) (void)(m)
     81
     82# endif
     83#endif  /* !NO_OUTPUT_SYNC */
     84
    3985/* Structure describing a running or dead child process.  */
    4086
    4187struct child
    4288  {
    43     struct child *next;         /* Link in the chain.  */
     89    struct child *next;         /* Link in the chain.  */
    4490
    45     struct file *file;          /* File being remade.  */
     91    struct file *file;          /* File being remade.  */
    4692
    47     char **environment;         /* Environment for commands.  */
     93    char **environment;         /* Environment for commands.  */
     94    char *sh_batch_file;        /* Script file for shell commands */
     95    char **command_lines;       /* Array of variable-expanded cmd lines.  */
     96    char *command_ptr;          /* Ptr into command_lines[command_line].  */
    4897
    49     char **command_lines;       /* Array of variable-expanded cmd lines.  */
    50     unsigned int command_line;  /* Index into above.  */
    51     char *command_ptr;          /* Ptr into command_lines[command_line].  */
     98#ifdef VMS
     99    char *comname;              /* Temporary command file name */
     100    int efn;                    /* Completion event flag number */
     101    int cstatus;                /* Completion status */
     102    int vms_launch_status;      /* non-zero if lib$spawn, etc failed */
     103#endif
    52104
    53     pid_t pid;                  /* Child process's ID number.  */
    54 #ifdef VMS
    55     int efn;                    /* Completion event flag number */
    56     int cstatus;                /* Completion status */
    57     char *comname;              /* Temporary command file name */
    58 #endif
    59     char *sh_batch_file;        /* Script file for shell commands */
    60     unsigned int remote:1;      /* Nonzero if executing remotely.  */
    61 
    62     unsigned int noerror:1;     /* Nonzero if commands contained a `-'.  */
    63 
    64     unsigned int good_stdin:1;  /* Nonzero if this child has a good stdin.  */
    65     unsigned int deleted:1;     /* Nonzero if targets have been deleted.  */
    66     unsigned int dontcare:1;    /* Saved dontcare flag.  */
     105    unsigned int  command_line; /* Index into command_lines.  */
     106    struct output output;       /* Output for this child.  */
     107    pid_t         pid;          /* Child process's ID number.  */
     108    unsigned int  remote:1;     /* Nonzero if executing remotely.  */
     109    unsigned int  noerror:1;    /* Nonzero if commands contained a '-'.  */
     110    unsigned int  good_stdin:1; /* Nonzero if this child has a good stdin.  */
     111    unsigned int  deleted:1;    /* Nonzero if targets have been deleted.  */
     112    unsigned int  recursive:1;  /* Nonzero for recursive command ('+' etc.)  */
     113    unsigned int  dontcare:1;   /* Saved dontcare flag.  */
    67114  };
    68115
    69116extern struct child *children;
    70117
     118/* A signal handler for SIGCHLD, if needed.  */
     119RETSIGTYPE child_handler (int sig);
    71120int is_bourne_compatible_shell(const char *path);
    72121void new_job (struct file *file);
     
    76125char **construct_command_argv (char *line, char **restp, struct file *file,
    77126                               int cmd_flags, char** batch_file);
     127
    78128#ifdef VMS
    79 int child_execute_job (char *argv, struct child *child);
    80 #elif defined(__EMX__)
    81 int child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp);
     129int child_execute_job (struct child *child, char *argv);
    82130#else
    83 void child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp);
     131# define FD_STDIN       (fileno (stdin))
     132# define FD_STDOUT      (fileno (stdout))
     133# define FD_STDERR      (fileno (stderr))
     134int child_execute_job (struct output *out, int good_stdin, char **argv, char **envp);
    84135#endif
     136
    85137#ifdef _AMIGA
    86 void exec_command (char **argv);
     138void exec_command (char **argv) __attribute__ ((noreturn));
    87139#elif defined(__EMX__)
    88140int exec_command (char **argv, char **envp);
    89141#else
    90 void exec_command (char **argv, char **envp);
     142void exec_command (char **argv, char **envp) __attribute__ ((noreturn));
    91143#endif
    92144
     
    97149void unblock_sigs (void);
    98150#else
    99 #ifdef  HAVE_SIGSETMASK
     151#ifdef  HAVE_SIGSETMASK
    100152extern int fatal_signal_mask;
    101 #define unblock_sigs()  sigsetmask (0)
     153#define unblock_sigs()  sigsetmask (0)
    102154#else
    103 #define unblock_sigs()
     155#define unblock_sigs()
    104156#endif
    105157#endif
    106158
    107159extern unsigned int jobserver_tokens;
    108 
    109 #endif /* SEEN_JOB_H */
  • vendor/gnumake/current/main.c

    r2596 r3138  
    11/* Argument parsing and main program of GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
     18#include "os.h"
     19#include "filedef.h"
    2020#include "dep.h"
    21 #include "filedef.h"
    2221#include "variable.h"
    2322#include "job.h"
     
    3332#endif
    3433#ifdef WINDOWS32
    35 #include <windows.h>
    36 #include <io.h>
    37 #include "pathstuff.h"
     34# include <windows.h>
     35# include <io.h>
     36# include "pathstuff.h"
     37# include "sub_proc.h"
     38# include "w32err.h"
    3839#endif
    3940#ifdef __EMX__
     
    4849int __stack = 20000; /* Make sure we have 20K of stack space */
    4950#endif
    50 
    51 void init_dir (void);
    52 void remote_setup (void);
    53 void remote_cleanup (void);
    54 RETSIGTYPE fatal_error_signal (int sig);
    55 
    56 void print_variable_data_base (void);
    57 void print_dir_data_base (void);
    58 void print_rule_data_base (void);
    59 void print_vpath_data_base (void);
    60 
    61 void verify_file_data_base (void);
     51#ifdef VMS
     52int vms_use_mcr_command = 0;
     53int vms_always_use_cmd_file = 0;
     54int vms_gnv_shell = 0;
     55int vms_legacy_behavior = 0;
     56int vms_comma_separator = 0;
     57int vms_unix_simulation = 0;
     58int vms_report_unix_paths = 0;
     59
     60/* Evaluates if a VMS environment option is set, only look at first character */
     61static int
     62get_vms_env_flag (const char *name, int default_value)
     63{
     64char * value;
     65char x;
     66
     67  value = getenv (name);
     68  if (value == NULL)
     69    return default_value;
     70
     71  x = toupper (value[0]);
     72  switch (x)
     73    {
     74    case '1':
     75    case 'T':
     76    case 'E':
     77      return 1;
     78      break;
     79    case '0':
     80    case 'F':
     81    case 'D':
     82      return 0;
     83    }
     84}
     85#endif
    6286
    6387#if defined HAVE_WAITPID || defined HAVE_WAIT3
     
    6589#endif
    6690
    67 #ifndef HAVE_UNISTD_H
     91#ifndef HAVE_UNISTD_H
    6892int chdir ();
    6993#endif
    70 #ifndef STDC_HEADERS
    71 # ifndef sun                    /* Sun has an incorrect decl in a header.  */
     94#ifndef STDC_HEADERS
     95# ifndef sun                    /* Sun has an incorrect decl in a header.  */
    7296void exit (int) __attribute__ ((noreturn));
    7397# endif
     
    78102static void print_data_base (void);
    79103static void print_version (void);
    80 static void decode_switches (int argc, char **argv, int env);
    81 static void decode_env_switches (char *envar, unsigned int len);
    82 static const char *define_makeflags (int all, int makefile);
     104static void decode_switches (int argc, const char **argv, int env);
     105static void decode_env_switches (const char *envar, unsigned int len);
     106static struct variable *define_makeflags (int all, int makefile);
    83107static char *quote_for_env (char *out, const char *in);
    84108static void initialize_global_hash_tables (void);
     
    90114struct command_switch
    91115  {
    92     int c;                      /* The switch character.  */
    93 
    94     enum                        /* Type of the value.  */
     116    int c;                      /* The switch character.  */
     117
     118    enum                        /* Type of the value.  */
    95119      {
    96         flag,                   /* Turn int flag on.  */
    97         flag_off,               /* Turn int flag off.  */
    98         string,                 /* One string per switch.  */
    99         filename,               /* A string containing a file name.  */
    100         positive_int,           /* A positive integer.  */
    101         floating,               /* A floating-point number (double).  */
    102         ignore                  /* Ignored.  */
     120        flag,                   /* Turn int flag on.  */
     121        flag_off,               /* Turn int flag off.  */
     122        string,                 /* One string per invocation.  */
     123        strlist,                /* One string per switch.  */
     124        filename,               /* A string containing a file name.  */
     125        positive_int,           /* A positive integer.  */
     126        floating,               /* A floating-point number (double).  */
     127        ignore                  /* Ignored.  */
    103128      } type;
    104129
    105     void *value_ptr;    /* Pointer to the value-holding variable.  */
    106 
    107     unsigned int env:1;         /* Can come from MAKEFLAGS.  */
    108     unsigned int toenv:1;       /* Should be put in MAKEFLAGS.  */
    109     unsigned int no_makefile:1; /* Don't propagate when remaking makefiles.  */
    110 
    111     const void *noarg_value;    /* Pointer to value used if no arg given.  */
    112     const void *default_value;  /* Pointer to default value.  */
    113 
    114     char *long_name;            /* Long option name.  */
     130    void *value_ptr;    /* Pointer to the value-holding variable.  */
     131
     132    unsigned int env:1;         /* Can come from MAKEFLAGS.  */
     133    unsigned int toenv:1;       /* Should be put in MAKEFLAGS.  */
     134    unsigned int no_makefile:1; /* Don't propagate when remaking makefiles.  */
     135
     136    const void *noarg_value;    /* Pointer to value used if no arg given.  */
     137    const void *default_value;  /* Pointer to default value.  */
     138
     139    const char *long_name;      /* Long option name.  */
    115140  };
    116141
     
    120145
    121146/* The structure used to hold the list of strings given
    122    in command switches of a type that takes string arguments.  */
     147   in command switches of a type that takes strlist arguments.  */
    123148
    124149struct stringlist
    125150  {
    126     const char **list;  /* Nil-terminated list of strings.  */
    127     unsigned int idx;   /* Index into above.  */
    128     unsigned int max;   /* Number of pointers allocated.  */
     151    const char **list;  /* Nil-terminated list of strings.  */
     152    unsigned int idx;   /* Index into above.  */
     153    unsigned int max;   /* Number of pointers allocated.  */
    129154  };
    130155
    131156
    132157/* The recognized command switches.  */
     158
     159/* Nonzero means do extra verification (that may slow things down).  */
     160
     161int verify_flag;
    133162
    134163/* Nonzero means do not print commands to be executed (-s).  */
     
    148177/* Print debugging info (--debug).  */
    149178
    150 static struct stringlist *db_flags;
     179static struct stringlist *db_flags = 0;
    151180static int debug_flag = 0;
    152181
    153182int db_level = 0;
    154183
    155 /* Output level (--verbosity).  */
    156 
    157 static struct stringlist *verbosity_flags;
     184/* Synchronize output (--output-sync).  */
     185
     186char *output_sync_option = 0;
    158187
    159188#ifdef WINDOWS32
     
    220249
    221250
    222 /* Number of job slots (commands that can be run at once).  */
    223 
    224 unsigned int job_slots = 1;
    225 unsigned int default_job_slots = 1;
     251/* Number of job slots for parallelism.  */
     252
     253unsigned int job_slots;
     254
     255#define INVALID_JOB_SLOTS (-1)
    226256static unsigned int master_job_slots = 0;
     257static int arg_job_slots = INVALID_JOB_SLOTS;
     258
     259static const int default_job_slots = INVALID_JOB_SLOTS;
    227260
    228261/* Value of job_slots that means no limit.  */
    229262
    230 static unsigned int inf_jobs = 0;
    231 
    232 /* File descriptors for the jobs pipe.  */
    233 
    234 static struct stringlist *jobserver_fds = 0;
    235 
    236 int job_fds[2] = { -1, -1 };
    237 int job_rfd = -1;
     263static const int inf_jobs = 0;
     264
     265/* Authorization for the jobserver.  */
     266
     267static char *jobserver_auth = NULL;
     268
     269/* Handle for the mutex used on Windows to synchronize output of our
     270   children under -O.  */
     271
     272char *sync_mutex = NULL;
    238273
    239274/* Maximum load average at which multiple jobs will be run.
     
    346381                              Consider FILE to be very old and don't remake it.\n"),
    347382    N_("\
     383  -O[TYPE], --output-sync[=TYPE]\n\
     384                              Synchronize output of parallel jobs by TYPE.\n"),
     385    N_("\
    348386  -p, --print-data-base       Print make's internal database.\n"),
    349387    N_("\
     
    361399  -t, --touch                 Touch targets instead of remaking them.\n"),
    362400    N_("\
     401  --trace                     Print tracing information.\n"),
     402    N_("\
    363403  -v, --version               Print the version number of make and exit.\n"),
    364404    N_("\
     
    374414  };
    375415
    376 /* The table of command switches.  */
     416/* The table of command switches.
     417   Order matters here: this is the order MAKEFLAGS will be constructed.
     418   So be sure all simple flags (single char, no argument) come first.  */
    377419
    378420static const struct command_switch switches[] =
     
    380422    { 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },
    381423    { 'B', flag, &always_make_set, 1, 1, 0, 0, 0, "always-make" },
    382     { 'C', filename, &directories, 0, 0, 0, 0, 0, "directory" },
    383424    { 'd', flag, &debug_flag, 1, 1, 0, 0, 0, 0 },
    384     { CHAR_MAX+1, string, &db_flags, 1, 1, 0, "basic", 0, "debug" },
    385425#ifdef WINDOWS32
    386426    { 'D', flag, &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" },
    387427#endif
    388428    { 'e', flag, &env_overrides, 1, 1, 0, 0, 0, "environment-overrides", },
    389     { 'f', filename, &makefiles, 0, 0, 0, 0, 0, "file" },
    390429    { 'h', flag, &print_usage_flag, 0, 0, 0, 0, 0, "help" },
    391430    { 'i', flag, &ignore_errors_flag, 1, 1, 0, 0, 0, "ignore-errors" },
    392     { 'I', filename, &include_directories, 1, 1, 0, 0, 0,
    393       "include-dir" },
    394     { 'j', positive_int, &job_slots, 1, 1, 0, &inf_jobs, &default_job_slots,
    395       "jobs" },
    396     { CHAR_MAX+2, string, &jobserver_fds, 1, 1, 0, 0, 0, "jobserver-fds" },
    397431    { 'k', flag, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag,
    398432      "keep-going" },
    399 #ifndef NO_FLOAT
    400     { 'l', floating, &max_load_average, 1, 1, 0, &default_load_average,
    401       &default_load_average, "load-average" },
    402 #else
    403     { 'l', positive_int, &max_load_average, 1, 1, 0, &default_load_average,
    404       &default_load_average, "load-average" },
    405 #endif
    406433    { 'L', flag, &check_symlink_flag, 1, 1, 0, 0, 0, "check-symlink-times" },
    407434    { 'm', ignore, 0, 0, 0, 0, 0, 0, 0 },
    408435    { 'n', flag, &just_print_flag, 1, 1, 1, 0, 0, "just-print" },
    409     { 'o', filename, &old_files, 0, 0, 0, 0, 0, "old-file" },
    410436    { 'p', flag, &print_data_base_flag, 1, 1, 0, 0, 0, "print-data-base" },
    411437    { 'q', flag, &question_flag, 1, 1, 1, 0, 0, "question" },
     
    418444    { 't', flag, &touch_flag, 1, 1, 1, 0, 0, "touch" },
    419445    { 'v', flag, &print_version_flag, 1, 1, 0, 0, 0, "version" },
    420     { CHAR_MAX+3, string, &verbosity_flags, 1, 1, 0, 0, 0,
    421       "verbosity" },
    422446    { 'w', flag, &print_directory_flag, 1, 1, 0, 0, 0, "print-directory" },
     447
     448    /* These options take arguments.  */
     449    { 'C', filename, &directories, 0, 0, 0, 0, 0, "directory" },
     450    { 'f', filename, &makefiles, 0, 0, 0, 0, 0, "file" },
     451    { 'I', filename, &include_directories, 1, 1, 0, 0, 0,
     452      "include-dir" },
     453    { 'j', positive_int, &arg_job_slots, 1, 1, 0, &inf_jobs, &default_job_slots,
     454      "jobs" },
     455#ifndef NO_FLOAT
     456    { 'l', floating, &max_load_average, 1, 1, 0, &default_load_average,
     457      &default_load_average, "load-average" },
     458#else
     459    { 'l', positive_int, &max_load_average, 1, 1, 0, &default_load_average,
     460      &default_load_average, "load-average" },
     461#endif
     462    { 'o', filename, &old_files, 0, 0, 0, 0, 0, "old-file" },
     463    { 'O', string, &output_sync_option, 1, 1, 0, "target", 0, "output-sync" },
     464    { 'W', filename, &new_files, 0, 0, 0, 0, 0, "what-if" },
     465
     466    /* These are long-style options.  */
     467    { CHAR_MAX+1, strlist, &db_flags, 1, 1, 0, "basic", 0, "debug" },
     468    { CHAR_MAX+2, string, &jobserver_auth, 1, 1, 0, 0, 0, "jobserver-auth" },
     469    { CHAR_MAX+3, flag, &trace_flag, 1, 1, 0, 0, 0, "trace" },
    423470    { CHAR_MAX+4, flag, &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
    424471      "no-print-directory" },
    425     { 'W', filename, &new_files, 0, 0, 0, 0, 0, "what-if" },
    426472    { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
    427473      "warn-undefined-variables" },
    428     { CHAR_MAX+6, string, &eval_strings, 1, 0, 0, 0, 0, "eval" },
     474    { CHAR_MAX+6, strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
     475    { CHAR_MAX+7, string, &sync_mutex, 1, 1, 0, 0, 0, "sync-mutex" },
    429476    { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
    430477  };
     
    434481static struct option long_option_aliases[] =
    435482  {
    436     { "quiet",          no_argument,            0, 's' },
    437     { "stop",           no_argument,            0, 'S' },
    438     { "new-file",       required_argument,      0, 'W' },
    439     { "assume-new",     required_argument,      0, 'W' },
    440     { "assume-old",     required_argument,      0, 'o' },
    441     { "max-load",       optional_argument,      0, 'l' },
    442     { "dry-run",        no_argument,            0, 'n' },
    443     { "recon",          no_argument,            0, 'n' },
    444     { "makefile",       required_argument,      0, 'f' },
     483    { "quiet",          no_argument,            0, 's' },
     484    { "stop",           no_argument,            0, 'S' },
     485    { "new-file",       required_argument,      0, 'W' },
     486    { "assume-new",     required_argument,      0, 'W' },
     487    { "assume-old",     required_argument,      0, 'o' },
     488    { "max-load",       optional_argument,      0, 'l' },
     489    { "dry-run",        no_argument,            0, 'n' },
     490    { "recon",          no_argument,            0, 'n' },
     491    { "makefile",       required_argument,      0, 'f' },
    445492  };
    446493
    447494/* List of goal targets.  */
    448495
    449 static struct dep *goals, *lastgoal;
     496static struct goaldep *goals, *lastgoal;
    450497
    451498/* List of variables which were defined on the command line
     
    462509/* The name we were invoked with.  */
    463510
     511#ifdef WINDOWS32
     512/* On MS-Windows, we chop off the .exe suffix in 'main', so this
     513   cannot be 'const'.  */
    464514char *program;
     515#else
     516const char *program;
     517#endif
    465518
    466519/* Our current directory before processing any -C options.  */
     
    490543struct file *default_file;
    491544
    492 /* Nonzero if we have seen the magic `.POSIX' target.
     545/* Nonzero if we have seen the magic '.POSIX' target.
    493546   This turns on pedantic compliance with POSIX.2.  */
    494547
     
    506559int one_shell;
    507560
    508 /* Nonzero if we have seen the `.NOTPARALLEL' target.
     561/* One of OUTPUT_SYNC_* if the "--output-sync" option was given.  This
     562   attempts to synchronize the output of parallel jobs such that the results
     563   of each job stay together.  */
     564
     565int output_sync = OUTPUT_SYNC_NONE;
     566
     567/* Nonzero if the "--trace" option was given.  */
     568
     569int trace_flag = 0;
     570
     571/* Nonzero if we have seen the '.NOTPARALLEL' target.
    509572   This turns off parallel builds for this invocation of make.  */
    510573
     
    517580int clock_skew_detected;
    518581
     582/* Map of possible stop characters for searching strings.  */
     583#ifndef UCHAR_MAX
     584# define UCHAR_MAX 255
     585#endif
     586unsigned short stopchar_map[UCHAR_MAX + 1] = {0};
     587
     588/* If output-sync is enabled we'll collect all the output generated due to
     589   options, while reading makefiles, etc.  */
     590
     591struct output make_sync;
     592
     593
    519594
    520595/* Mask of signals that are being caught with fatal_error_signal.  */
    521596
    522 #ifdef  POSIX
     597#ifdef POSIX
    523598sigset_t fatal_signal_set;
    524599#else
    525 # ifdef HAVE_SIGSETMASK
     600# ifdef HAVE_SIGSETMASK
    526601int fatal_signal_mask;
    527602# endif
     
    559634}
    560635
     636/* This character map locate stop chars when parsing GNU makefiles.
     637   Each element is true if we should stop parsing on that character.  */
     638
     639static void
     640initialize_stopchar_map (void)
     641{
     642  int i;
     643
     644  stopchar_map[(int)'\0'] = MAP_NUL;
     645  stopchar_map[(int)'#'] = MAP_COMMENT;
     646  stopchar_map[(int)';'] = MAP_SEMI;
     647  stopchar_map[(int)'='] = MAP_EQUALS;
     648  stopchar_map[(int)':'] = MAP_COLON;
     649  stopchar_map[(int)'%'] = MAP_PERCENT;
     650  stopchar_map[(int)'|'] = MAP_PIPE;
     651  stopchar_map[(int)'.'] = MAP_DOT | MAP_USERFUNC;
     652  stopchar_map[(int)','] = MAP_COMMA;
     653  stopchar_map[(int)'$'] = MAP_VARIABLE;
     654
     655  stopchar_map[(int)'-'] = MAP_USERFUNC;
     656  stopchar_map[(int)'_'] = MAP_USERFUNC;
     657
     658  stopchar_map[(int)' '] = MAP_BLANK;
     659  stopchar_map[(int)'\t'] = MAP_BLANK;
     660
     661  stopchar_map[(int)'/'] = MAP_DIRSEP;
     662#if defined(VMS)
     663  stopchar_map[(int)':'] |= MAP_DIRSEP;
     664  stopchar_map[(int)']'] |= MAP_DIRSEP;
     665  stopchar_map[(int)'>'] |= MAP_DIRSEP;
     666#elif defined(HAVE_DOS_PATHS)
     667  stopchar_map[(int)'\\'] |= MAP_DIRSEP;
     668#endif
     669
     670  for (i = 1; i <= UCHAR_MAX; ++i)
     671    {
     672      if (isspace (i) && NONE_SET (stopchar_map[i], MAP_BLANK))
     673        /* Don't mark blank characters as newline characters.  */
     674        stopchar_map[i] |= MAP_NEWLINE;
     675      else if (isalnum (i))
     676        stopchar_map[i] |= MAP_USERFUNC;
     677    }
     678}
     679
    561680static const char *
    562 expand_command_line_file (char *name)
     681expand_command_line_file (const char *name)
    563682{
    564683  const char *cp;
     
    566685
    567686  if (name[0] == '\0')
    568     fatal (NILF, _("empty string invalid as file name"));
     687    O (fatal, NILF, _("empty string invalid as file name"));
    569688
    570689  if (name[0] == '~')
    571690    {
    572691      expanded = tilde_expand (name);
    573       if (expanded != 0)
    574         name = expanded;
     692      if (expanded && expanded[0] != '\0')
     693        name = expanded;
    575694    }
    576695
     
    578697     for names read from makefiles.  It is here for names passed
    579698     on the command line.  */
    580   while (name[0] == '.' && name[1] == '/' && name[2] != '\0')
     699  while (name[0] == '.' && name[1] == '/')
    581700    {
    582701      name += 2;
    583       while (*name == '/')
    584         /* Skip following slashes: ".//foo" is "foo", not "/foo".  */
    585         ++name;
    586     }
    587 
    588   if (*name == '\0')
    589     {
    590       /* It was all slashes!  Move back to the dot and truncate
    591          it after the first slash, so it becomes just "./".  */
    592       do
    593         --name;
    594       while (name[0] != '.');
    595       name[2] = '\0';
     702      while (name[0] == '/')
     703        /* Skip following slashes: ".//foo" is "foo", not "/foo".  */
     704        ++name;
     705    }
     706
     707  if (name[0] == '\0')
     708    {
     709      /* Nothing else but one or more "./", maybe plus slashes!  */
     710      name = "./";
    596711    }
    597712
    598713  cp = strcache_add (name);
    599714
    600   if (expanded)
    601     free (expanded);
     715  free (expanded);
    602716
    603717  return cp;
     
    622736    db_level = DB_ALL;
    623737
    624   if (!db_flags)
    625     return;
    626 
    627   for (pp=db_flags->list; *pp; ++pp)
    628     {
    629       const char *p = *pp;
    630 
    631       while (1)
    632         {
    633           switch (tolower (p[0]))
    634             {
    635             case 'a':
    636               db_level |= DB_ALL;
     738  if (db_flags)
     739    for (pp=db_flags->list; *pp; ++pp)
     740      {
     741        const char *p = *pp;
     742
     743        while (1)
     744          {
     745            switch (tolower (p[0]))
     746              {
     747              case 'a':
     748                db_level |= DB_ALL;
     749                break;
     750              case 'b':
     751                db_level |= DB_BASIC;
     752                break;
     753              case 'i':
     754                db_level |= DB_BASIC | DB_IMPLICIT;
     755                break;
     756              case 'j':
     757                db_level |= DB_JOBS;
     758                break;
     759              case 'm':
     760                db_level |= DB_BASIC | DB_MAKEFILES;
     761                break;
     762              case 'n':
     763                db_level = 0;
     764                break;
     765              case 'v':
     766                db_level |= DB_BASIC | DB_VERBOSE;
     767                break;
     768              default:
     769                OS (fatal, NILF,
     770                    _("unknown debug level specification '%s'"), p);
     771              }
     772
     773            while (*(++p) != '\0')
     774              if (*p == ',' || *p == ' ')
     775                {
     776                  ++p;
     777                  break;
     778                }
     779
     780            if (*p == '\0')
    637781              break;
    638             case 'b':
    639               db_level |= DB_BASIC;
    640               break;
    641             case 'i':
    642               db_level |= DB_BASIC | DB_IMPLICIT;
    643               break;
    644             case 'j':
    645               db_level |= DB_JOBS;
    646               break;
    647             case 'm':
    648               db_level |= DB_BASIC | DB_MAKEFILES;
    649               break;
    650             case 'v':
    651               db_level |= DB_BASIC | DB_VERBOSE;
    652               break;
    653             default:
    654               fatal (NILF, _("unknown debug level specification `%s'"), p);
    655             }
    656 
    657           while (*(++p) != '\0')
    658             if (*p == ',' || *p == ' ')
    659               break;
    660 
    661           if (*p == '\0')
    662             break;
    663 
    664           ++p;
    665         }
    666     }
     782          }
     783      }
     784
     785  if (db_level)
     786    verify_flag = 1;
     787
     788  if (! db_level)
     789    debug_flag = 0;
    667790}
    668791
     792static void
     793decode_output_sync_flags (void)
     794{
     795#ifdef NO_OUTPUT_SYNC
     796  output_sync = OUTPUT_SYNC_NONE;
     797#else
     798  if (output_sync_option)
     799    {
     800      if (streq (output_sync_option, "none"))
     801        output_sync = OUTPUT_SYNC_NONE;
     802      else if (streq (output_sync_option, "line"))
     803        output_sync = OUTPUT_SYNC_LINE;
     804      else if (streq (output_sync_option, "target"))
     805        output_sync = OUTPUT_SYNC_TARGET;
     806      else if (streq (output_sync_option, "recurse"))
     807        output_sync = OUTPUT_SYNC_RECURSE;
     808      else
     809        OS (fatal, NILF,
     810            _("unknown output-sync type '%s'"), output_sync_option);
     811    }
     812
     813  if (sync_mutex)
     814    RECORD_SYNC_MUTEX (sync_mutex);
     815#endif
     816}
     817
    669818#ifdef WINDOWS32
     819
     820#ifndef NO_OUTPUT_SYNC
     821
     822/* This is called from start_job_command when it detects that
     823   output_sync option is in effect.  The handle to the synchronization
     824   mutex is passed, as a string, to sub-makes via the --sync-mutex
     825   command-line argument.  */
     826void
     827prepare_mutex_handle_string (sync_handle_t handle)
     828{
     829  if (!sync_mutex)
     830    {
     831      /* Prepare the mutex handle string for our children.  */
     832      /* 2 hex digits per byte + 2 characters for "0x" + null.  */
     833      sync_mutex = xmalloc ((2 * sizeof (sync_handle_t)) + 2 + 1);
     834      sprintf (sync_mutex, "0x%Ix", handle);
     835      define_makeflags (1, 0);
     836    }
     837}
     838
     839#endif  /* NO_OUTPUT_SYNC */
     840
    670841/*
    671842 * HANDLE runtime exceptions by avoiding a requestor on the GUI. Capture
     
    678849 */
    679850LONG WINAPI
    680 handle_runtime_exceptions( struct _EXCEPTION_POINTERS *exinfo )
     851handle_runtime_exceptions (struct _EXCEPTION_POINTERS *exinfo)
    681852{
    682853  PEXCEPTION_RECORD exrec = exinfo->ExceptionRecord;
    683   LPSTR cmdline = GetCommandLine();
    684   LPSTR prg = strtok(cmdline, " ");
     854  LPSTR cmdline = GetCommandLine ();
     855  LPSTR prg = strtok (cmdline, " ");
    685856  CHAR errmsg[1024];
    686857#ifdef USE_EVENT_LOG
     
    691862  if (! ISDB (DB_VERBOSE))
    692863    {
    693       sprintf(errmsg,
    694               _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x%p)\n"),
    695               prg, exrec->ExceptionCode, exrec->ExceptionAddress);
    696       fprintf(stderr, errmsg);
    697       exit(255);
    698     }
    699 
    700   sprintf(errmsg,
    701           _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = 0x%p\n"),
    702           prg, exrec->ExceptionCode, exrec->ExceptionFlags,
    703           exrec->ExceptionAddress);
     864      sprintf (errmsg,
     865               _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x%p)\n"),
     866               prg, exrec->ExceptionCode, exrec->ExceptionAddress);
     867      fprintf (stderr, errmsg);
     868      exit (255);
     869    }
     870
     871  sprintf (errmsg,
     872           _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = 0x%p\n"),
     873           prg, exrec->ExceptionCode, exrec->ExceptionFlags,
     874           exrec->ExceptionAddress);
    704875
    705876  if (exrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION
    706877      && exrec->NumberParameters >= 2)
    707     sprintf(&errmsg[strlen(errmsg)],
    708             (exrec->ExceptionInformation[0]
    709              ? _("Access violation: write operation at address 0x%p\n")
    710              : _("Access violation: read operation at address 0x%p\n")),
    711             (PVOID)exrec->ExceptionInformation[1]);
     878    sprintf (&errmsg[strlen(errmsg)],
     879             (exrec->ExceptionInformation[0]
     880              ? _("Access violation: write operation at address 0x%p\n")
     881              : _("Access violation: read operation at address 0x%p\n")),
     882             (PVOID)exrec->ExceptionInformation[1]);
    712883
    713884  /* turn this on if we want to put stuff in the event log too */
    714885#ifdef USE_EVENT_LOG
    715   hEventSource = RegisterEventSource(NULL, "GNU Make");
     886  hEventSource = RegisterEventSource (NULL, "GNU Make");
    716887  lpszStrings[0] = errmsg;
    717888
    718889  if (hEventSource != NULL)
    719890    {
    720       ReportEvent(hEventSource,         /* handle of event source */
    721                   EVENTLOG_ERROR_TYPE,  /* event type */
    722                   0,                    /* event category */
    723                   0,                    /* event ID */
    724                   NULL,                 /* current user's SID */
    725                   1,                    /* strings in lpszStrings */
    726                   0,                    /* no bytes of raw data */
    727                   lpszStrings,          /* array of error strings */
    728                   NULL);                /* no raw data */
    729 
    730       (VOID) DeregisterEventSource(hEventSource);
     891      ReportEvent (hEventSource,         /* handle of event source */
     892                   EVENTLOG_ERROR_TYPE,  /* event type */
     893                   0,                    /* event category */
     894                   0,                    /* event ID */
     895                   NULL,                 /* current user's SID */
     896                   1,                    /* strings in lpszStrings */
     897                   0,                    /* no bytes of raw data */
     898                   lpszStrings,          /* array of error strings */
     899                   NULL);                /* no raw data */
     900
     901      (VOID) DeregisterEventSource (hEventSource);
    731902    }
    732903#endif
    733904
    734905  /* Write the error to stderr too */
    735   fprintf(stderr, errmsg);
     906  fprintf (stderr, errmsg);
    736907
    737908#ifdef DEBUG
    738909  return EXCEPTION_CONTINUE_SEARCH;
    739910#else
    740   exit(255);
     911  exit (255);
    741912  return (255); /* not reached */
    742913#endif
     
    746917 * On WIN32 systems we don't have the luxury of a /bin directory that
    747918 * is mapped globally to every drive mounted to the system. Since make could
    748  * be invoked from any drive, and we don't want to propogate /bin/sh
     919 * be invoked from any drive, and we don't want to propagate /bin/sh
    749920 * to every single drive. Allow ourselves a chance to search for
    750921 * a value for default shell here (if the default path does not exist).
     
    756927  int sh_found = 0;
    757928  char *atoken = 0;
    758   char *search_token;
    759   char *tokend;
     929  const char *search_token;
     930  const char *tokend;
    760931  PATH_VAR(sh_path);
    761   extern char *default_shell;
     932  extern const char *default_shell;
    762933
    763934  if (!token)
    764935    search_token = default_shell;
    765936  else
    766     atoken = search_token = xstrdup (token);
     937    search_token = atoken = xstrdup (token);
    767938
    768939  /* If the user explicitly requests the DOS cmd shell, obey that request.
     
    778949           || (tokend - 4 > search_token
    779950               && (tokend[-5] == '/' || tokend[-5] == '\\')))
    780           && !strcasecmp (tokend - 4, "cmd.exe"))) {
    781     batch_mode_shell = 1;
    782     unixy_shell = 0;
    783     sprintf (sh_path, "%s", search_token);
    784     default_shell = xstrdup (w32ify (sh_path, 0));
    785     DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
    786                      default_shell));
    787     sh_found = 1;
    788   } else if (!no_default_sh_exe &&
    789              (token == NULL || !strcmp (search_token, default_shell))) {
    790     /* no new information, path already set or known */
    791     sh_found = 1;
    792   } else if (file_exists_p (search_token)) {
    793     /* search token path was found */
    794     sprintf (sh_path, "%s", search_token);
    795     default_shell = xstrdup (w32ify (sh_path, 0));
    796     DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
    797                      default_shell));
    798     sh_found = 1;
    799   } else {
    800     char *p;
    801     struct variable *v = lookup_variable (STRING_SIZE_TUPLE ("PATH"));
    802 
    803     /* Search Path for shell */
    804     if (v && v->value) {
    805       char *ep;
    806 
    807       p  = v->value;
    808       ep = strchr (p, PATH_SEPARATOR_CHAR);
    809 
    810       while (ep && *ep) {
    811         *ep = '\0';
    812 
    813         if (dir_file_exists_p (p, search_token)) {
    814           sprintf (sh_path, "%s/%s", p, search_token);
    815           default_shell = xstrdup (w32ify (sh_path, 0));
    816           sh_found = 1;
    817           *ep = PATH_SEPARATOR_CHAR;
    818 
    819           /* terminate loop */
    820           p += strlen (p);
    821         } else {
    822           *ep = PATH_SEPARATOR_CHAR;
    823            p = ++ep;
     951          && !strcasecmp (tokend - 4, "cmd.exe")))
     952    {
     953      batch_mode_shell = 1;
     954      unixy_shell = 0;
     955      sprintf (sh_path, "%s", search_token);
     956      default_shell = xstrdup (w32ify (sh_path, 0));
     957      DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
     958                       default_shell));
     959      sh_found = 1;
     960    }
     961  else if (!no_default_sh_exe
     962           && (token == NULL || !strcmp (search_token, default_shell)))
     963    {
     964      /* no new information, path already set or known */
     965      sh_found = 1;
     966    }
     967  else if (_access (search_token, 0) == 0)
     968    {
     969      /* search token path was found */
     970      sprintf (sh_path, "%s", search_token);
     971      default_shell = xstrdup (w32ify (sh_path, 0));
     972      DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
     973                       default_shell));
     974      sh_found = 1;
     975    }
     976  else
     977    {
     978      char *p;
     979      struct variable *v = lookup_variable (STRING_SIZE_TUPLE ("PATH"));
     980
     981      /* Search Path for shell */
     982      if (v && v->value)
     983        {
     984          char *ep;
     985
     986          p  = v->value;
     987          ep = strchr (p, PATH_SEPARATOR_CHAR);
     988
     989          while (ep && *ep)
     990            {
     991              *ep = '\0';
     992
     993              sprintf (sh_path, "%s/%s", p, search_token);
     994              if (_access (sh_path, 0) == 0)
     995                {
     996                  default_shell = xstrdup (w32ify (sh_path, 0));
     997                  sh_found = 1;
     998                  *ep = PATH_SEPARATOR_CHAR;
     999
     1000                  /* terminate loop */
     1001                  p += strlen (p);
     1002                }
     1003              else
     1004                {
     1005                  *ep = PATH_SEPARATOR_CHAR;
     1006                  p = ++ep;
     1007                }
     1008
     1009              ep = strchr (p, PATH_SEPARATOR_CHAR);
     1010            }
     1011
     1012          /* be sure to check last element of Path */
     1013          if (p && *p)
     1014            {
     1015              sprintf (sh_path, "%s/%s", p, search_token);
     1016              if (_access (sh_path, 0) == 0)
     1017                {
     1018                  default_shell = xstrdup (w32ify (sh_path, 0));
     1019                  sh_found = 1;
     1020                }
     1021            }
     1022
     1023          if (sh_found)
     1024            DB (DB_VERBOSE,
     1025                (_("find_and_set_shell() path search set default_shell = %s\n"),
     1026                 default_shell));
    8241027        }
    825 
    826         ep = strchr (p, PATH_SEPARATOR_CHAR);
    827       }
    828 
    829       /* be sure to check last element of Path */
    830       if (p && *p && dir_file_exists_p (p, search_token)) {
    831           sprintf (sh_path, "%s/%s", p, search_token);
    832           default_shell = xstrdup (w32ify (sh_path, 0));
    833           sh_found = 1;
    834       }
    835 
    836       if (sh_found)
    837         DB (DB_VERBOSE,
    838             (_("find_and_set_shell() path search set default_shell = %s\n"),
    839              default_shell));
    840     }
    841   }
     1028    }
    8421029
    8431030  /* naive test */
    844   if (!unixy_shell && sh_found &&
    845       (strstr (default_shell, "sh") || strstr (default_shell, "SH"))) {
    846     unixy_shell = 1;
    847     batch_mode_shell = 0;
    848   }
     1031  if (!unixy_shell && sh_found
     1032      && (strstr (default_shell, "sh") || strstr (default_shell, "SH")))
     1033    {
     1034      unixy_shell = 1;
     1035      batch_mode_shell = 0;
     1036    }
    8491037
    8501038#ifdef BATCH_MODE_ONLY_SHELL
     
    8521040#endif
    8531041
    854   if (atoken)
    855     free (atoken);
     1042  free (atoken);
    8561043
    8571044  return (sh_found);
     
    8681055#endif  /* __MSDOS__ */
    8691056
    870 char *mktemp (char *template);
    871 int mkstemp (char *template);
    872 
    873 FILE *
    874 open_tmpfile(char **name, const char *template)
     1057static void
     1058reset_jobserver (void)
    8751059{
    876 #ifdef HAVE_FDOPEN
    877   int fd;
    878 #endif
    879 
    880 #if defined HAVE_MKSTEMP || defined HAVE_MKTEMP
    881 # define TEMPLATE_LEN   strlen (template)
    882 #else
    883 # define TEMPLATE_LEN   L_tmpnam
    884 #endif
    885   *name = xmalloc (TEMPLATE_LEN + 1);
    886   strcpy (*name, template);
    887 
    888 #if defined HAVE_MKSTEMP && defined HAVE_FDOPEN
    889   /* It's safest to use mkstemp(), if we can.  */
    890   fd = mkstemp (*name);
    891   if (fd == -1)
    892     return 0;
    893   return fdopen (fd, "w");
    894 #else
    895 # ifdef HAVE_MKTEMP
    896   (void) mktemp (*name);
    897 # else
    898   (void) tmpnam (*name);
    899 # endif
    900 
    901 # ifdef HAVE_FDOPEN
    902   /* Can't use mkstemp(), but guard against a race condition.  */
    903   fd = open (*name, O_CREAT|O_EXCL|O_WRONLY, 0600);
    904   if (fd == -1)
    905     return 0;
    906   return fdopen (fd, "w");
    907 # else
    908   /* Not secure, but what can we do?  */
    909   return fopen (*name, "w");
    910 # endif
    911 #endif
     1060  jobserver_clear ();
     1061  free (jobserver_auth);
     1062  jobserver_auth = NULL;
    9121063}
    913 
    9141064
    9151065#ifdef _AMIGA
     
    9231073  static char *stdin_nm = 0;
    9241074  int makefile_status = MAKE_SUCCESS;
    925   struct dep *read_makefiles;
     1075  struct goaldep *read_files;
    9261076  PATH_VAR (current_directory);
    9271077  unsigned int restarts = 0;
     1078  unsigned int syncing = 0;
     1079  int argv_slots;
    9281080#ifdef WINDOWS32
    929   char *unix_path = NULL;
    930   char *windows32_path = NULL;
    931 
    932   SetUnhandledExceptionFilter(handle_runtime_exceptions);
     1081  const char *unix_path = NULL;
     1082  const char *windows32_path = NULL;
     1083
     1084  SetUnhandledExceptionFilter (handle_runtime_exceptions);
    9331085
    9341086  /* start off assuming we have no shell */
     
    9361088  no_default_sh_exe = 1;
    9371089#endif
     1090
     1091  output_init (&make_sync);
     1092
     1093  initialize_stopchar_map();
    9381094
    9391095#ifdef SET_STACK_SIZE
     
    9551111#endif
    9561112
    957 #ifdef HAVE_ATEXIT
    958   atexit (close_stdout);
    959 #endif
    960 
    9611113  /* Needed for OS/2 */
    962   initialize_main(&argc, &argv);
    963 
    964   reading_file = 0;
     1114  initialize_main (&argc, &argv);
     1115
     1116#ifdef MAKE_MAINTAINER_MODE
     1117  /* In maintainer mode we always enable verification.  */
     1118  verify_flag = 1;
     1119#endif
    9651120
    9661121#if defined (__MSDOS__) && !defined (_POSIX_SOURCE)
    967   /* Request the most powerful version of `system', to
     1122  /* Request the most powerful version of 'system', to
    9681123     make up for the dumb default shell.  */
    9691124  __system_flags = (__system_redirect
    970                     | __system_use_shell
    971                     | __system_allow_multiple_cmds
    972                     | __system_allow_long_cmds
    973                     | __system_handle_null_commands
    974                     | __system_emulate_chdir);
     1125                    | __system_use_shell
     1126                    | __system_allow_multiple_cmds
     1127                    | __system_allow_long_cmds
     1128                    | __system_handle_null_commands
     1129                    | __system_emulate_chdir);
    9751130
    9761131#endif
     
    9831138  (void)textdomain (PACKAGE);
    9841139
    985 #ifdef  POSIX
     1140#ifdef  POSIX
    9861141  sigemptyset (&fatal_signal_set);
    987 #define ADD_SIG(sig)    sigaddset (&fatal_signal_set, sig)
     1142#define ADD_SIG(sig)    sigaddset (&fatal_signal_set, sig)
    9881143#else
    989 #ifdef  HAVE_SIGSETMASK
     1144#ifdef  HAVE_SIGSETMASK
    9901145  fatal_signal_mask = 0;
    991 #define ADD_SIG(sig)    fatal_signal_mask |= sigmask (sig)
     1146#define ADD_SIG(sig)    fatal_signal_mask |= sigmask (sig)
    9921147#else
    993 #define ADD_SIG(sig)    (void)sig      /* Needed to avoid warnings in MSVC.  */
    994 #endif
    995 #endif
    996 
    997 #define FATAL_SIG(sig)                                                        \
    998   if (bsd_signal (sig, fatal_error_signal) == SIG_IGN)                        \
    999     bsd_signal (sig, SIG_IGN);                                                \
    1000   else                                                                        \
     1148#define ADD_SIG(sig)    (void)sig
     1149#endif
     1150#endif
     1151
     1152#define FATAL_SIG(sig)                                                        \
     1153  if (bsd_signal (sig, fatal_error_signal) == SIG_IGN)                        \
     1154    bsd_signal (sig, SIG_IGN);                                                \
     1155  else                                                                        \
    10011156    ADD_SIG (sig);
    10021157
     
    10171172#endif
    10181173
    1019 #ifdef  SIGDANGER
     1174#ifdef  SIGDANGER
    10201175  FATAL_SIG (SIGDANGER);
    10211176#endif
     
    10271182#endif
    10281183
    1029 #undef  FATAL_SIG
     1184#undef  FATAL_SIG
    10301185
    10311186  /* Do not ignore the child-death signal.  This must be done before
     
    10431198#endif
    10441199
    1045   /* Make sure stdout is line-buffered.  */
    1046 
    1047 #ifdef HAVE_SETVBUF
    1048 # ifdef SETVBUF_REVERSED
    1049   setvbuf (stdout, _IOLBF, xmalloc (BUFSIZ), BUFSIZ);
    1050 # else  /* setvbuf not reversed.  */
    1051   /* Some buggy systems lose if we pass 0 instead of allocating ourselves.  */
    1052   setvbuf (stdout, 0, _IOLBF, BUFSIZ);
    1053 # endif /* setvbuf reversed.  */
    1054 #elif HAVE_SETLINEBUF
    1055   setlinebuf (stdout);
    1056 #endif  /* setlinebuf missing.  */
     1200  output_init (NULL);
    10571201
    10581202  /* Figure out where this program lives.  */
    10591203
    10601204  if (argv[0] == 0)
    1061     argv[0] = "";
     1205    argv[0] = (char *)"";
    10621206  if (argv[0][0] == '\0')
    10631207    program = "make";
    10641208  else
    10651209    {
    1066 #ifdef VMS
    1067       program = strrchr (argv[0], ']');
    1068 #else
    10691210      program = strrchr (argv[0], '/');
    1070 #endif
    10711211#if defined(__MSDOS__) || defined(__EMX__)
    10721212      if (program == 0)
    1073         program = strrchr (argv[0], '\\');
     1213        program = strrchr (argv[0], '\\');
    10741214      else
    1075         {
    1076           /* Some weird environments might pass us argv[0] with
    1077              both kinds of slashes; we must find the rightmost.  */
    1078           char *p = strrchr (argv[0], '\\');
    1079           if (p && p > program)
    1080             program = p;
    1081         }
     1215        {
     1216          /* Some weird environments might pass us argv[0] with
     1217             both kinds of slashes; we must find the rightmost.  */
     1218          char *p = strrchr (argv[0], '\\');
     1219          if (p && p > program)
     1220            program = p;
     1221        }
    10821222      if (program == 0 && argv[0][1] == ':')
    1083         program = argv[0] + 1;
     1223        program = argv[0] + 1;
    10841224#endif
    10851225#ifdef WINDOWS32
     
    10871227        {
    10881228          /* Extract program from full path */
    1089           int argv0_len;
    10901229          program = strrchr (argv[0], '\\');
    10911230          if (program)
    10921231            {
    1093               argv0_len = strlen(program);
     1232              int argv0_len = strlen (program);
    10941233              if (argv0_len > 4 && streq (&program[argv0_len - 4], ".exe"))
    10951234                /* Remove .exe extension */
     
    10981237        }
    10991238#endif
     1239#ifdef VMS
     1240      set_program_name (argv[0]);
     1241      program = program_name;
     1242      {
     1243        const char *shell;
     1244        char pwdbuf[256];
     1245        char *pwd;
     1246        shell = getenv ("SHELL");
     1247        if (shell != NULL)
     1248          vms_gnv_shell = 1;
     1249
     1250        /* Need to know if CRTL set to report UNIX paths.  Use getcwd as
     1251           it works on all versions of VMS. */
     1252        pwd = getcwd(pwdbuf, 256);
     1253        if (pwd[0] == '/')
     1254          vms_report_unix_paths = 1;
     1255
     1256        vms_use_mcr_command = get_vms_env_flag ("GNV$MAKE_USE_MCR", 0);
     1257
     1258        vms_always_use_cmd_file = get_vms_env_flag ("GNV$MAKE_USE_CMD_FILE", 0);
     1259
     1260        /* Legacy behavior is on VMS is older behavior that needed to be
     1261           changed to be compatible with standard make behavior.
     1262           For now only completely disable when running under a Bash shell.
     1263           TODO: Update VMS built in recipes and macros to not need this
     1264           behavior, at which time the default may change. */
     1265        vms_legacy_behavior = get_vms_env_flag ("GNV$MAKE_OLD_VMS",
     1266                                                !vms_gnv_shell);
     1267
     1268        /* VMS was changed to use a comma separator in the past, but that is
     1269           incompatible with built in functions that expect space separated
     1270           lists.  Allow this to be selectively turned off. */
     1271        vms_comma_separator = get_vms_env_flag ("GNV$MAKE_COMMA",
     1272                                                vms_legacy_behavior);
     1273
     1274        /* Some Posix shell syntax options are incompatible with VMS syntax.
     1275           VMS requires double quotes for strings and escapes quotes
     1276           differently.  When this option is active, VMS will try
     1277           to simulate Posix shell simulations instead of using
     1278           VMS DCL behavior. */
     1279        vms_unix_simulation = get_vms_env_flag ("GNV$MAKE_SHELL_SIM",
     1280                                                !vms_legacy_behavior);
     1281
     1282      }
     1283      if (need_vms_symbol () && !vms_use_mcr_command)
     1284        create_foreign_command (program_name, argv[0]);
     1285#else
    11001286      if (program == 0)
    1101         program = argv[0];
     1287        program = argv[0];
    11021288      else
    1103         ++program;
     1289        ++program;
     1290#endif
    11041291    }
    11051292
     
    11171304#endif
    11181305    {
    1119 #ifdef  HAVE_GETCWD
     1306#ifdef  HAVE_GETCWD
    11201307      perror_with_name ("getcwd", "");
    11211308#else
    1122       error (NILF, "getwd: %s", current_directory);
     1309      OS (error, NILF, "getwd: %s", current_directory);
    11231310#endif
    11241311      current_directory[0] = '\0';
     
    11271314  else
    11281315    directory_before_chdir = xstrdup (current_directory);
     1316
    11291317#ifdef  __MSDOS__
    11301318  /* Make sure we will return to the initial directory, come what may.  */
     
    11371325  define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1;
    11381326  define_variable_cname (".SHELLFLAGS", "-c", o_default, 0);
     1327  define_variable_cname (".LOADED", "", o_default, 0);
    11391328
    11401329  /* Set up .FEATURES
    1141      We must do this in multiple calls because define_variable_cname() is
    1142      a macro and some compilers (MSVC) don't like conditionals in macros.  */
     1330     Use a separate variable because define_variable_cname() is a macro and
     1331     some compilers (MSVC) don't like conditionals in macros.  */
    11431332  {
    11441333    const char *features = "target-specific order-only second-expansion"
    1145                            " else-if shortest-stem undefine"
     1334                           " else-if shortest-stem undefine oneshell"
    11461335#ifndef NO_ARCHIVES
    11471336                           " archives"
     
    11501339                           " jobserver"
    11511340#endif
     1341#ifndef NO_OUTPUT_SYNC
     1342                           " output-sync"
     1343#endif
    11521344#ifdef MAKE_SYMLINKS
    11531345                           " check-symlink"
    11541346#endif
     1347#ifdef HAVE_GUILE
     1348                           " guile"
     1349#endif
     1350#ifdef MAKE_LOAD
     1351                           " load"
     1352#endif
    11551353                           ;
    11561354
    11571355    define_variable_cname (".FEATURES", features, o_default, 0);
    11581356  }
     1357
     1358  /* Configure GNU Guile support */
     1359  guile_gmake_setup (NILF);
    11591360
    11601361  /* Read in variables from the environment.  It is important that this be
     
    11681369    for (i = 0; envp[i] != 0; ++i)
    11691370      {
    1170         int do_not_define = 0;
    1171         char *ep = envp[i];
    1172 
    1173         while (*ep != '\0' && *ep != '=')
     1371        struct variable *v;
     1372        const char *ep = envp[i];
     1373        /* By default, export all variables culled from the environment.  */
     1374        enum variable_export export = v_export;
     1375        unsigned int len;
     1376
     1377        while (! STOP_SET (*ep, MAP_EQUALS))
    11741378          ++ep;
     1379
     1380        /* If there's no equals sign it's a malformed environment.  Ignore.  */
     1381        if (*ep == '\0')
     1382          continue;
     1383
    11751384#ifdef WINDOWS32
    1176         if (!unix_path && strneq(envp[i], "PATH=", 5))
     1385        if (!unix_path && strneq (envp[i], "PATH=", 5))
    11771386          unix_path = ep+1;
    1178         else if (!strnicmp(envp[i], "Path=", 5)) {
    1179           do_not_define = 1; /* it gets defined after loop exits */
    1180           if (!windows32_path)
    1181             windows32_path = ep+1;
    1182         }
    1183 #endif
    1184         /* The result of pointer arithmetic is cast to unsigned int for
    1185            machines where ptrdiff_t is a different size that doesn't widen
    1186            the same.  */
    1187         if (!do_not_define)
     1387        else if (!strnicmp (envp[i], "Path=", 5))
    11881388          {
    1189             struct variable *v;
    1190 
    1191             v = define_variable (envp[i], (unsigned int) (ep - envp[i]),
    1192                                  ep + 1, o_env, 1);
    1193             /* Force exportation of every variable culled from the
    1194                environment.  We used to rely on target_environment's
    1195                v_default code to do this.  But that does not work for the
    1196                case where an environment variable is redefined in a makefile
    1197                with `override'; it should then still be exported, because it
    1198                was originally in the environment.  */
    1199             v->export = v_export;
    1200 
    1201             /* Another wrinkle is that POSIX says the value of SHELL set in
    1202                the makefile won't change the value of SHELL given to
    1203                subprocesses.  */
    1204             if (streq (v->name, "SHELL"))
     1389            if (!windows32_path)
     1390              windows32_path = ep+1;
     1391            /* PATH gets defined after the loop exits.  */
     1392            continue;
     1393          }
     1394#endif
     1395
     1396        /* Length of the variable name, and skip the '='.  */
     1397        len = ep++ - envp[i];
     1398
     1399        /* If this is MAKE_RESTARTS, check to see if the "already printed
     1400           the enter statement" flag is set.  */
     1401        if (len == 13 && strneq (envp[i], "MAKE_RESTARTS", 13))
     1402          {
     1403            if (*ep == '-')
    12051404              {
     1405                OUTPUT_TRACED ();
     1406                ++ep;
     1407              }
     1408            restarts = (unsigned int) atoi (ep);
     1409            export = v_noexport;
     1410          }
     1411
     1412        v = define_variable (envp[i], len, ep, o_env, 1);
     1413
     1414        /* POSIX says the value of SHELL set in the makefile won't change the
     1415           value of SHELL given to subprocesses.  */
     1416        if (streq (v->name, "SHELL"))
     1417          {
    12061418#ifndef __MSDOS__
    1207                 v->export = v_noexport;
    1208 #endif
    1209                 shell_var.name = "SHELL";
    1210                 shell_var.length = 5;
    1211                 shell_var.value = xstrdup (ep + 1);
    1212               }
    1213 
    1214             /* If MAKE_RESTARTS is set, remember it but don't export it.  */
    1215             if (streq (v->name, "MAKE_RESTARTS"))
    1216               {
    1217                 v->export = v_noexport;
    1218                 restarts = (unsigned int) atoi (ep + 1);
    1219               }
     1419            export = v_noexport;
     1420#endif
     1421            shell_var.name = xstrdup ("SHELL");
     1422            shell_var.length = 5;
     1423            shell_var.value = xstrdup (ep);
    12201424          }
     1425
     1426        v->export = export;
    12211427      }
    12221428  }
    12231429#ifdef WINDOWS32
    12241430    /* If we didn't find a correctly spelled PATH we define PATH as
    1225      * either the first mispelled value or an empty string
     1431     * either the first misspelled value or an empty string
    12261432     */
    12271433    if (!unix_path)
     
    12311437#else /* For Amiga, read the ENV: device, ignoring all dirs */
    12321438    {
    1233         BPTR env, file, old;
    1234         char buffer[1024];
    1235         int len;
    1236         __aligned struct FileInfoBlock fib;
    1237 
    1238         env = Lock ("ENV:", ACCESS_READ);
    1239         if (env)
    1240         {
    1241             old = CurrentDir (DupLock(env));
    1242             Examine (env, &fib);
    1243 
    1244             while (ExNext (env, &fib))
    1245             {
    1246                 if (fib.fib_DirEntryType < 0) /* File */
    1247                 {
    1248                     /* Define an empty variable. It will be filled in
    1249                         variable_lookup(). Makes startup quite a bit
    1250                         faster. */
    1251                         define_variable (fib.fib_FileName,
    1252                             strlen (fib.fib_FileName),
    1253                         "", o_env, 1)->export = v_export;
    1254                 }
    1255             }
    1256             UnLock (env);
    1257             UnLock(CurrentDir(old));
    1258         }
     1439        BPTR env, file, old;
     1440        char buffer[1024];
     1441        int len;
     1442        __aligned struct FileInfoBlock fib;
     1443
     1444        env = Lock ("ENV:", ACCESS_READ);
     1445        if (env)
     1446          {
     1447            old = CurrentDir (DupLock (env));
     1448            Examine (env, &fib);
     1449
     1450            while (ExNext (env, &fib))
     1451              {
     1452                if (fib.fib_DirEntryType < 0) /* File */
     1453                  {
     1454                    /* Define an empty variable. It will be filled in
     1455                       variable_lookup(). Makes startup quite a bit faster. */
     1456                    define_variable (fib.fib_FileName,
     1457                                     strlen (fib.fib_FileName),
     1458                                     "", o_env, 1)->export = v_export;
     1459                  }
     1460              }
     1461            UnLock (env);
     1462            UnLock (CurrentDir (old));
     1463          }
    12591464    }
    12601465#endif
    12611466
    12621467  /* Decode the switches.  */
     1468  decode_env_switches (STRING_SIZE_TUPLE ("GNUMAKEFLAGS"));
     1469
     1470  /* Clear GNUMAKEFLAGS to avoid duplication.  */
     1471  define_variable_cname ("GNUMAKEFLAGS", "", o_env, 0);
    12631472
    12641473  decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
     1474
    12651475#if 0
    12661476  /* People write things like:
     
    12701480#endif
    12711481
    1272   decode_switches (argc, argv, 0);
     1482  /* In output sync mode we need to sync any output generated by reading the
     1483     makefiles, such as in $(info ...) or stderr from $(shell ...) etc.  */
     1484
     1485  syncing = make_sync.syncout = (output_sync == OUTPUT_SYNC_LINE
     1486                                 || output_sync == OUTPUT_SYNC_TARGET);
     1487  OUTPUT_SET (&make_sync);
     1488
     1489  /* Remember the job slots set through the environment vs. command line.  */
     1490  {
     1491    int env_slots = arg_job_slots;
     1492    arg_job_slots = INVALID_JOB_SLOTS;
     1493
     1494    decode_switches (argc, (const char **)argv, 0);
     1495    argv_slots = arg_job_slots;
     1496
     1497    if (arg_job_slots == INVALID_JOB_SLOTS)
     1498      arg_job_slots = env_slots;
     1499  }
     1500
     1501  /* Set a variable specifying whether stdout/stdin is hooked to a TTY.  */
     1502#ifdef HAVE_ISATTY
     1503  if (isatty (fileno (stdout)))
     1504    if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMOUT")))
     1505      {
     1506        const char *tty = TTYNAME (fileno (stdout));
     1507        define_variable_cname ("MAKE_TERMOUT", tty ? tty : DEFAULT_TTYNAME,
     1508                               o_default, 0)->export = v_export;
     1509      }
     1510  if (isatty (fileno (stderr)))
     1511    if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMERR")))
     1512      {
     1513        const char *tty = TTYNAME (fileno (stderr));
     1514        define_variable_cname ("MAKE_TERMERR", tty ? tty : DEFAULT_TTYNAME,
     1515                               o_default, 0)->export = v_export;
     1516      }
     1517#endif
     1518
     1519  /* Reset in case the switches changed our minds.  */
     1520  syncing = (output_sync == OUTPUT_SYNC_LINE
     1521             || output_sync == OUTPUT_SYNC_TARGET);
     1522
     1523  if (make_sync.syncout && ! syncing)
     1524    output_close (&make_sync);
     1525
     1526  make_sync.syncout = syncing;
     1527  OUTPUT_SET (&make_sync);
     1528
     1529  /* Figure out the level of recursion.  */
     1530  {
     1531    struct variable *v = lookup_variable (STRING_SIZE_TUPLE (MAKELEVEL_NAME));
     1532    if (v && v->value[0] != '\0' && v->value[0] != '-')
     1533      makelevel = (unsigned int) atoi (v->value);
     1534    else
     1535      makelevel = 0;
     1536  }
    12731537
    12741538#ifdef WINDOWS32
    1275   if (suspend_flag) {
    1276         fprintf(stderr, "%s (pid = %ld)\n", argv[0], GetCurrentProcessId());
    1277         fprintf(stderr, _("%s is suspending for 30 seconds..."), argv[0]);
    1278         Sleep(30 * 1000);
    1279         fprintf(stderr, _("done sleep(30). Continuing.\n"));
    1280   }
    1281 #endif
    1282 
    1283   decode_debug_flags ();
     1539  if (suspend_flag)
     1540    {
     1541      fprintf (stderr, "%s (pid = %ld)\n", argv[0], GetCurrentProcessId ());
     1542      fprintf (stderr, _("%s is suspending for 30 seconds..."), argv[0]);
     1543      Sleep (30 * 1000);
     1544      fprintf (stderr, _("done sleep(30). Continuing.\n"));
     1545    }
     1546#endif
    12841547
    12851548  /* Set always_make_flag if -B was given and we've not restarted already.  */
    12861549  always_make_flag = always_make_set && (restarts == 0);
    12871550
    1288   /* Print version information.  */
    1289   if (print_version_flag || print_data_base_flag || db_level)
     1551  /* Print version information, and exit.  */
     1552  if (print_version_flag)
    12901553    {
    12911554      print_version ();
    1292 
    1293       /* `make --version' is supposed to just print the version and exit.  */
    1294       if (print_version_flag)
    1295         die (0);
    1296     }
     1555      die (MAKE_SUCCESS);
     1556    }
     1557
     1558  if (ISDB (DB_BASIC))
     1559    print_version ();
    12971560
    12981561#ifndef VMS
     
    13091572   * CreateProcess().
    13101573   */
    1311   if (strpbrk(argv[0], "/:\\") ||
    1312       strstr(argv[0], "..") ||
    1313       strneq(argv[0], "//", 2))
    1314     argv[0] = xstrdup(w32ify(argv[0],1));
     1574  if (strpbrk (argv[0], "/:\\") || strstr (argv[0], "..")
     1575      || strneq (argv[0], "//", 2))
     1576    argv[0] = xstrdup (w32ify (argv[0], 1));
    13151577#else /* WINDOWS32 */
    13161578#if defined (__MSDOS__) || defined (__EMX__)
     
    13211583      argv[0] = xstrdup (argv[0]);
    13221584      for (p = argv[0]; *p; p++)
    1323         if (*p == '\\')
    1324           *p = '/';
     1585        if (*p == '\\')
     1586          *p = '/';
    13251587    }
    13261588  /* If argv[0] is not in absolute form, prepend the current
     
    13491611#endif
    13501612
     1613  /* We may move, but until we do, here we are.  */
     1614  starting_directory = current_directory;
     1615
     1616  /* Set up the job_slots value and the jobserver.  This can't be usefully set
     1617     in the makefile, and we want to verify the authorization is valid before
     1618     make has a chance to start using it for something else.  */
     1619
     1620  if (jobserver_auth)
     1621    {
     1622      if (argv_slots == INVALID_JOB_SLOTS)
     1623        {
     1624          if (jobserver_parse_auth (jobserver_auth))
     1625            {
     1626              /* Success!  Use the jobserver.  */
     1627              job_slots = 0;
     1628              goto job_setup_complete;
     1629            }
     1630
     1631          O (error, NILF, _("warning: jobserver unavailable: using -j1.  Add '+' to parent make rule."));
     1632          arg_job_slots = 1;
     1633        }
     1634
     1635      /* The user provided a -j setting on the command line: use it.  */
     1636      else if (!restarts)
     1637        /* If restarts is >0 we already printed this message.  */
     1638        O (error, NILF,
     1639           _("warning: -jN forced in submake: disabling jobserver mode."));
     1640
     1641      /* We failed to use our parent's jobserver.  */
     1642      reset_jobserver ();
     1643      job_slots = (unsigned int)arg_job_slots;
     1644    }
     1645  else if (arg_job_slots == INVALID_JOB_SLOTS)
     1646    /* The default is one job at a time.  */
     1647    job_slots = 1;
     1648  else
     1649    /* Use whatever was provided.  */
     1650    job_slots = (unsigned int)arg_job_slots;
     1651
     1652 job_setup_complete:
     1653
    13511654  /* The extra indirection through $(MAKE_COMMAND) is done
    13521655     for hysterical raisins.  */
     1656
     1657#ifdef VMS
     1658  if (vms_use_mcr_command)
     1659    define_variable_cname ("MAKE_COMMAND", vms_command (argv[0]), o_default, 0);
     1660  else
     1661    define_variable_cname ("MAKE_COMMAND", program, o_default, 0);
     1662#else
    13531663  define_variable_cname ("MAKE_COMMAND", argv[0], o_default, 0);
     1664#endif
    13541665  define_variable_cname ("MAKE", "$(MAKE_COMMAND)", o_default, 1);
    13551666
     
    13621673
    13631674      /* Figure out how much space will be taken up by the command-line
    1364         variable definitions.  */
     1675        variable definitions.  */
    13651676      for (cv = command_variables; cv != 0; cv = cv->next)
    1366         {
    1367           v = cv->variable;
    1368           len += 2 * strlen (v->name);
    1369           if (! v->recursive)
    1370             ++len;
    1371           ++len;
    1372           len += 2 * strlen (v->value);
    1373           ++len;
    1374         }
     1677        {
     1678          v = cv->variable;
     1679          len += 2 * strlen (v->name);
     1680          if (! v->recursive)
     1681            ++len;
     1682          ++len;
     1683          len += 2 * strlen (v->value);
     1684          ++len;
     1685        }
    13751686
    13761687      /* Now allocate a buffer big enough and fill it.  */
    13771688      p = value = alloca (len);
    13781689      for (cv = command_variables; cv != 0; cv = cv->next)
    1379         {
    1380           v = cv->variable;
    1381           p = quote_for_env (p, v->name);
    1382           if (! v->recursive)
    1383             *p++ = ':';
    1384           *p++ = '=';
    1385           p = quote_for_env (p, v->value);
    1386           *p++ = ' ';
    1387         }
    1388       p[-1] = '\0';             /* Kill the final space and terminate.  */
     1690        {
     1691          v = cv->variable;
     1692          p = quote_for_env (p, v->name);
     1693          if (! v->recursive)
     1694            *p++ = ':';
     1695          *p++ = '=';
     1696          p = quote_for_env (p, v->value);
     1697          *p++ = ' ';
     1698        }
     1699      p[-1] = '\0';             /* Kill the final space and terminate.  */
    13891700
    13901701      /* Define an unchangeable variable with a name that no POSIX.2
    1391         makefile could validly use for its own variable.  */
     1702        makefile could validly use for its own variable.  */
    13921703      define_variable_cname ("-*-command-variables-*-", value, o_automatic, 0);
    13931704
     
    14001711      define_variable_cname ("MAKEOVERRIDES", "${-*-command-variables-*-}",
    14011712                             o_env, 1);
     1713#ifdef VMS
     1714      vms_export_dcl_symbol ("MAKEOVERRIDES", "${-*-command-variables-*-}");
     1715#endif
    14021716    }
    14031717
     
    14341748   * at the wrong place when it was first evaluated.
    14351749   */
    1436    no_default_sh_exe = !find_and_set_default_shell(NULL);
    1437 
     1750   no_default_sh_exe = !find_and_set_default_shell (NULL);
    14381751#endif /* WINDOWS32 */
    1439   /* Figure out the level of recursion.  */
    1440   {
    1441     struct variable *v = lookup_variable (STRING_SIZE_TUPLE (MAKELEVEL_NAME));
    1442     if (v != 0 && v->value[0] != '\0' && v->value[0] != '-')
    1443       makelevel = (unsigned int) atoi (v->value);
    1444     else
    1445       makelevel = 0;
    1446   }
    14471752
    14481753  /* Except under -s, always do -w in sub-makes and under -C.  */
     
    14631768                          ? 0 : include_directories->list);
    14641769
    1465   /* Figure out where we are now, after chdir'ing.  */
    1466   if (directories == 0)
    1467     /* We didn't move, so we're still in the same place.  */
    1468     starting_directory = current_directory;
    1469   else
     1770  /* If we chdir'ed, figure out where we are now.  */
     1771  if (directories)
    14701772    {
    14711773#ifdef WINDOWS32
     
    14741776      if (getcwd (current_directory, GET_PATH_MAX) == 0)
    14751777#endif
    1476         {
    1477 #ifdef  HAVE_GETCWD
    1478           perror_with_name ("getcwd", "");
     1778        {
     1779#ifdef  HAVE_GETCWD
     1780          perror_with_name ("getcwd", "");
    14791781#else
    1480           error (NILF, "getwd: %s", current_directory);
    1481 #endif
    1482           starting_directory = 0;
    1483         }
     1782          OS (error, NILF, "getwd: %s", current_directory);
     1783#endif
     1784          starting_directory = 0;
     1785        }
    14841786      else
    1485         starting_directory = current_directory;
     1787        starting_directory = current_directory;
    14861788    }
    14871789
     
    14941796      unsigned int i;
    14951797      for (i = 0; i < makefiles->idx; ++i)
    1496         if (makefiles->list[i][0] == '-' && makefiles->list[i][1] == '\0')
    1497           {
    1498             /* This makefile is standard input.  Since we may re-exec
    1499                and thus re-read the makefiles, we read standard input
    1500                into a temporary file and read from that.  */
    1501             FILE *outfile;
    1502             char *template, *tmpdir;
     1798        if (makefiles->list[i][0] == '-' && makefiles->list[i][1] == '\0')
     1799          {
     1800            /* This makefile is standard input.  Since we may re-exec
     1801               and thus re-read the makefiles, we read standard input
     1802               into a temporary file and read from that.  */
     1803            FILE *outfile;
     1804            char *template;
     1805            const char *tmpdir;
    15031806
    15041807            if (stdin_nm)
    1505               fatal (NILF, _("Makefile from standard input specified twice."));
     1808              O (fatal, NILF,
     1809                 _("Makefile from standard input specified twice."));
    15061810
    15071811#ifdef VMS
    1508 # define DEFAULT_TMPDIR     "sys$scratch:"
     1812# define DEFAULT_TMPDIR     "/sys$scratch/"
    15091813#else
    15101814# ifdef P_tmpdir
     
    15161820#define DEFAULT_TMPFILE     "GmXXXXXX"
    15171821
    1518             if (((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0')
     1822            if (((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0')
    15191823#if defined (__MSDOS__) || defined (WINDOWS32) || defined (__EMX__)
    15201824                /* These are also used commonly on these platforms.  */
     
    15231827#endif
    15241828               )
    1525               tmpdir = DEFAULT_TMPDIR;
    1526 
    1527             template = alloca (strlen (tmpdir) + sizeof (DEFAULT_TMPFILE) + 1);
    1528             strcpy (template, tmpdir);
     1829              tmpdir = DEFAULT_TMPDIR;
     1830
     1831            template = alloca (strlen (tmpdir) + CSTRLEN (DEFAULT_TMPFILE) + 2);
     1832            strcpy (template, tmpdir);
    15291833
    15301834#ifdef HAVE_DOS_PATHS
    1531             if (strchr ("/\\", template[strlen (template) - 1]) == NULL)
    1532               strcat (template, "/");
     1835            if (strchr ("/\\", template[strlen (template) - 1]) == NULL)
     1836              strcat (template, "/");
    15331837#else
    15341838# ifndef VMS
    1535             if (template[strlen (template) - 1] != '/')
    1536               strcat (template, "/");
     1839            if (template[strlen (template) - 1] != '/')
     1840              strcat (template, "/");
    15371841# endif /* !VMS */
    15381842#endif /* !HAVE_DOS_PATHS */
    15391843
    1540             strcat (template, DEFAULT_TMPFILE);
    1541             outfile = open_tmpfile (&stdin_nm, template);
    1542             if (outfile == 0)
    1543               pfatal_with_name (_("fopen (temporary file)"));
    1544             while (!feof (stdin) && ! ferror (stdin))
    1545               {
    1546                 char buf[2048];
    1547                 unsigned int n = fread (buf, 1, sizeof (buf), stdin);
    1548                 if (n > 0 && fwrite (buf, 1, n, outfile) != n)
    1549                   pfatal_with_name (_("fwrite (temporary file)"));
    1550               }
    1551             fclose (outfile);
    1552 
    1553             /* Replace the name that read_all_makefiles will
    1554                see with the name of the temporary file.  */
     1844            strcat (template, DEFAULT_TMPFILE);
     1845            outfile = output_tmpfile (&stdin_nm, template);
     1846            if (outfile == 0)
     1847              pfatal_with_name (_("fopen (temporary file)"));
     1848            while (!feof (stdin) && ! ferror (stdin))
     1849              {
     1850                char buf[2048];
     1851                unsigned int n = fread (buf, 1, sizeof (buf), stdin);
     1852                if (n > 0 && fwrite (buf, 1, n, outfile) != n)
     1853                  pfatal_with_name (_("fwrite (temporary file)"));
     1854              }
     1855            fclose (outfile);
     1856
     1857            /* Replace the name that read_all_makefiles will
     1858               see with the name of the temporary file.  */
    15551859            makefiles->list[i] = strcache_add (stdin_nm);
    15561860
    1557             /* Make sure the temporary file will not be remade.  */
     1861            /* Make sure the temporary file will not be remade.  */
    15581862            {
    15591863              struct file *f = enter_file (strcache_add (stdin_nm));
    15601864              f->updated = 1;
    1561               f->update_status = 0;
     1865              f->update_status = us_success;
    15621866              f->command_state = cs_finished;
    15631867              /* Can't be intermediate, or it'll be removed too early for
     
    15661870              f->dontcare = 0;
    15671871            }
    1568           }
     1872          }
    15691873    }
    15701874
    15711875#ifndef __EMX__ /* Don't use a SIGCHLD handler for OS/2 */
    1572 #if defined(MAKE_JOBSERVER) || !defined(HAVE_WAIT_NOHANG)
     1876#if !defined(HAVE_WAIT_NOHANG) || defined(MAKE_JOBSERVER)
    15731877  /* Set up to handle children dying.  This must be done before
    1574      reading in the makefiles so that `shell' function calls will work.
     1878     reading in the makefiles so that 'shell' function calls will work.
    15751879
    15761880     If we don't have a hanging wait we have to fall back to old, broken
     
    15781882     children.
    15791883
    1580      If we're using the jobs pipe we need a signal handler so that
    1581      SIGCHLD is not ignored; we need it to interrupt the read(2) of the
    1582      jobserver pipe in job.c if we're waiting for a token.
     1884     If we're using the jobs pipe we need a signal handler so that SIGCHLD is
     1885     not ignored; we need it to interrupt the read(2) of the jobserver pipe if
     1886     we're waiting for a token.
    15831887
    15841888     If none of these are true, we don't need a signal handler at all.  */
    15851889  {
    1586     RETSIGTYPE child_handler (int sig);
    15871890# if defined SIGCHLD
    15881891    bsd_signal (SIGCHLD, child_handler);
     
    15921895# endif
    15931896  }
     1897
     1898#ifdef HAVE_PSELECT
     1899  /* If we have pselect() then we need to block SIGCHLD so it's deferred.  */
     1900  {
     1901    sigset_t block;
     1902    sigemptyset (&block);
     1903    sigaddset (&block, SIGCHLD);
     1904    if (sigprocmask (SIG_SETMASK, &block, NULL) < 0)
     1905      pfatal_with_name ("sigprocmask(SIG_SETMASK, SIGCHLD)");
     1906  }
     1907#endif
     1908
    15941909#endif
    15951910#endif
     
    16011916
    16021917  /* Define the initial list of suffixes for old-style rules.  */
    1603 
    16041918  set_default_suffixes ();
    16051919
     
    16091923     makefiles, it results in the built-in pattern rules taking precedence
    16101924     over makefile-specified suffix rules, which is wrong.  */
    1611 
    16121925  install_default_suffix_rules ();
    16131926
    16141927  /* Define some internal and special variables.  */
    1615 
    16161928  define_automatic_variables ();
    16171929
    1618   /* Set up the MAKEFLAGS and MFLAGS variables
    1619      so makefiles can look at them.  */
    1620 
    1621   define_makeflags (0, 0);
     1930  /* Set up the MAKEFLAGS and MFLAGS variables for makefiles to see.
     1931     Initialize it to be exported but allow the makefile to reset it.  */
     1932  define_makeflags (0, 0)->export = v_export;
    16221933
    16231934  /* Define the default variables.  */
     
    16351946      char *p, *value;
    16361947      unsigned int i;
    1637       unsigned int len = sizeof ("--eval=") * eval_strings->idx;
     1948      unsigned int len = (CSTRLEN ("--eval=") + 1) * eval_strings->idx;
    16381949
    16391950      for (i = 0; i < eval_strings->idx; ++i)
     
    16411952          p = xstrdup (eval_strings->list[i]);
    16421953          len += 2 * strlen (p);
    1643           eval_buffer (p);
     1954          eval_buffer (p, NULL);
    16441955          free (p);
    16451956        }
     
    16491960        {
    16501961          strcpy (p, "--eval=");
    1651           p += strlen (p);
     1962          p += CSTRLEN ("--eval=");
    16521963          p = quote_for_env (p, eval_strings->list[i]);
    16531964          *(p++) = ' ';
     
    16601971  /* Read all the makefiles.  */
    16611972
    1662   read_makefiles
    1663     = read_all_makefiles (makefiles == 0 ? 0 : makefiles->list);
     1973  read_files = read_all_makefiles (makefiles == 0 ? 0 : makefiles->list);
    16641974
    16651975#ifdef WINDOWS32
    16661976  /* look one last time after reading all Makefiles */
    16671977  if (no_default_sh_exe)
    1668     no_default_sh_exe = !find_and_set_default_shell(NULL);
     1978    no_default_sh_exe = !find_and_set_default_shell (NULL);
    16691979#endif /* WINDOWS32 */
    16701980
    1671 #if defined (__MSDOS__) || defined (__EMX__)
     1981#if defined (__MSDOS__) || defined (__EMX__) || defined (VMS)
    16721982  /* We need to know what kind of shell we will be using.  */
    16731983  {
     
    16751985    struct variable *shv = lookup_variable (STRING_SIZE_TUPLE ("SHELL"));
    16761986    extern int unixy_shell;
    1677     extern char *default_shell;
     1987    extern const char *default_shell;
    16781988
    16791989    if (shv && *shv->value)
    16801990      {
    1681         char *shell_path = recursively_expand(shv);
    1682 
    1683         if (shell_path && _is_unixy_shell (shell_path))
    1684           unixy_shell = 1;
    1685         else
    1686           unixy_shell = 0;
    1687         if (shell_path)
    1688           default_shell = shell_path;
     1991        char *shell_path = recursively_expand (shv);
     1992
     1993        if (shell_path && _is_unixy_shell (shell_path))
     1994          unixy_shell = 1;
     1995        else
     1996          unixy_shell = 0;
     1997        if (shell_path)
     1998          default_shell = shell_path;
    16891999      }
    16902000  }
    16912001#endif /* __MSDOS__ || __EMX__ */
    16922002
    1693   /* Decode switches again, in case the variables were set by the makefile.  */
    1694   decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
     2003  {
     2004    int old_builtin_rules_flag = no_builtin_rules_flag;
     2005    int old_builtin_variables_flag = no_builtin_variables_flag;
     2006
     2007    /* Decode switches again, for variables set by the makefile.  */
     2008    decode_env_switches (STRING_SIZE_TUPLE ("GNUMAKEFLAGS"));
     2009
     2010    /* Clear GNUMAKEFLAGS to avoid duplication.  */
     2011    define_variable_cname ("GNUMAKEFLAGS", "", o_override, 0);
     2012
     2013    decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
    16952014#if 0
    1696   decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
    1697 #endif
    1698 
    1699 #if defined (__MSDOS__) || defined (__EMX__)
    1700   if (job_slots != 1
     2015    decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
     2016#endif
     2017
     2018    /* Reset in case the switches changed our mind.  */
     2019    syncing = (output_sync == OUTPUT_SYNC_LINE
     2020               || output_sync == OUTPUT_SYNC_TARGET);
     2021
     2022    if (make_sync.syncout && ! syncing)
     2023      output_close (&make_sync);
     2024
     2025    make_sync.syncout = syncing;
     2026    OUTPUT_SET (&make_sync);
     2027
     2028    /* If we've disabled builtin rules, get rid of them.  */
     2029    if (no_builtin_rules_flag && ! old_builtin_rules_flag)
     2030      {
     2031        if (suffix_file->builtin)
     2032          {
     2033            free_dep_chain (suffix_file->deps);
     2034            suffix_file->deps = 0;
     2035          }
     2036        define_variable_cname ("SUFFIXES", "", o_default, 0);
     2037      }
     2038
     2039    /* If we've disabled builtin variables, get rid of them.  */
     2040    if (no_builtin_variables_flag && ! old_builtin_variables_flag)
     2041      undefine_default_variables ();
     2042  }
     2043
     2044#if defined (__MSDOS__) || defined (__EMX__) || defined (VMS)
     2045  if (arg_job_slots != 1
    17012046# ifdef __EMX__
    17022047      && _osmode != OS2_MODE /* turn off -j if we are in DOS mode */
     
    17042049      )
    17052050    {
    1706       error (NILF,
    1707              _("Parallel jobs (-j) are not supported on this platform."));
    1708       error (NILF, _("Resetting to single job (-j1) mode."));
    1709       job_slots = 1;
    1710     }
    1711 #endif
    1712 
    1713 #ifdef MAKE_JOBSERVER
    1714   /* If the jobserver-fds option is seen, make sure that -j is reasonable.  */
    1715 
    1716   if (jobserver_fds)
    1717     {
    1718       const char *cp;
    1719       unsigned int ui;
    1720 
    1721       for (ui=1; ui < jobserver_fds->idx; ++ui)
    1722         if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui]))
    1723           fatal (NILF, _("internal error: multiple --jobserver-fds options"));
    1724 
    1725       /* Now parse the fds string and make sure it has the proper format.  */
    1726 
    1727       cp = jobserver_fds->list[0];
    1728 
    1729       if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2)
    1730         fatal (NILF,
    1731                _("internal error: invalid --jobserver-fds string `%s'"), cp);
    1732 
    1733       DB (DB_JOBS,
    1734           (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1]));
    1735 
    1736       /* The combination of a pipe + !job_slots means we're using the
    1737          jobserver.  If !job_slots and we don't have a pipe, we can start
    1738          infinite jobs.  If we see both a pipe and job_slots >0 that means the
    1739          user set -j explicitly.  This is broken; in this case obey the user
    1740          (ignore the jobserver pipe for this make) but print a message.  */
    1741 
    1742       if (job_slots > 0)
    1743         error (NILF,
    1744                _("warning: -jN forced in submake: disabling jobserver mode."));
    1745 
    1746       /* Create a duplicate pipe, that will be closed in the SIGCHLD
    1747          handler.  If this fails with EBADF, the parent has closed the pipe
    1748          on us because it didn't think we were a submake.  If so, print a
    1749          warning then default to -j1.  */
    1750 
    1751       else if ((job_rfd = dup (job_fds[0])) < 0)
     2051      O (error, NILF,
     2052         _("Parallel jobs (-j) are not supported on this platform."));
     2053      O (error, NILF, _("Resetting to single job (-j1) mode."));
     2054      arg_job_slots = job_slots = 1;
     2055    }
     2056#endif
     2057
     2058  /* If we have >1 slot at this point, then we're a top-level make.
     2059     Set up the jobserver.
     2060
     2061     Every make assumes that it always has one job it can run.  For the
     2062     submakes it's the token they were given by their parent.  For the top
     2063     make, we just subtract one from the number the user wants.  */
     2064
     2065  if (job_slots > 1 && jobserver_setup (job_slots - 1))
     2066    {
     2067      /* Fill in the jobserver_auth for our children.  */
     2068      jobserver_auth = jobserver_get_auth ();
     2069
     2070      if (jobserver_auth)
    17522071        {
    1753           if (errno != EBADF)
    1754             pfatal_with_name (_("dup jobserver"));
    1755 
    1756           error (NILF,
    1757                  _("warning: jobserver unavailable: using -j1.  Add `+' to parent make rule."));
    1758           job_slots = 1;
     2072          /* We're using the jobserver so set job_slots to 0.  */
     2073          master_job_slots = job_slots;
     2074          job_slots = 0;
    17592075        }
    1760 
    1761       if (job_slots > 0)
    1762         {
    1763           close (job_fds[0]);
    1764           close (job_fds[1]);
    1765           job_fds[0] = job_fds[1] = -1;
    1766           free (jobserver_fds->list);
    1767           free (jobserver_fds);
    1768           jobserver_fds = 0;
    1769         }
    1770     }
    1771 
    1772   /* If we have >1 slot but no jobserver-fds, then we're a top-level make.
    1773      Set up the pipe and install the fds option for our children.  */
    1774 
    1775   if (job_slots > 1)
    1776     {
    1777       char *cp;
    1778       char c = '+';
    1779 
    1780       if (pipe (job_fds) < 0 || (job_rfd = dup (job_fds[0])) < 0)
    1781         pfatal_with_name (_("creating jobs pipe"));
    1782 
    1783       /* Every make assumes that it always has one job it can run.  For the
    1784          submakes it's the token they were given by their parent.  For the
    1785          top make, we just subtract one from the number the user wants.  We
    1786          want job_slots to be 0 to indicate we're using the jobserver.  */
    1787 
    1788       master_job_slots = job_slots;
    1789 
    1790       while (--job_slots)
    1791         {
    1792           int r;
    1793 
    1794           EINTRLOOP (r, write (job_fds[1], &c, 1));
    1795           if (r != 1)
    1796             pfatal_with_name (_("init jobserver pipe"));
    1797         }
    1798 
    1799       /* Fill in the jobserver_fds struct for our children.  */
    1800 
    1801       cp = xmalloc ((sizeof ("1024")*2)+1);
    1802       sprintf (cp, "%d,%d", job_fds[0], job_fds[1]);
    1803 
    1804       jobserver_fds = (struct stringlist *)
    1805                         xmalloc (sizeof (struct stringlist));
    1806       jobserver_fds->list = xmalloc (sizeof (char *));
    1807       jobserver_fds->list[0] = cp;
    1808       jobserver_fds->idx = 1;
    1809       jobserver_fds->max = 1;
    1810     }
    1811 #endif
     2076    }
     2077
     2078  /* If we're not using parallel jobs, then we don't need output sync.
     2079     This is so people can enable output sync in GNUMAKEFLAGS or similar, but
     2080     not have it take effect unless parallel builds are enabled.  */
     2081  if (syncing && job_slots == 1)
     2082    {
     2083      OUTPUT_UNSET ();
     2084      output_close (&make_sync);
     2085      syncing = 0;
     2086      output_sync = OUTPUT_SYNC_NONE;
     2087    }
    18122088
    18132089#ifndef MAKE_SYMLINKS
    18142090  if (check_symlink_flag)
    18152091    {
    1816       error (NILF, _("Symbolic links not supported: disabling -L."));
     2092      O (error, NILF, _("Symbolic links not supported: disabling -L."));
    18172093      check_symlink_flag = 0;
    18182094    }
     
    18232099  define_makeflags (1, 0);
    18242100
    1825   /* Make each `struct dep' point at the `struct file' for the file
     2101  /* Make each 'struct goaldep' point at the 'struct file' for the file
    18262102     depended on.  Also do magic for special targets.  */
    18272103
     
    18622138          f->last_mtime = f->mtime_before_update = OLD_MTIME;
    18632139          f->updated = 1;
    1864           f->update_status = 0;
     2140          f->update_status = us_success;
    18652141          f->command_state = cs_finished;
    18662142        }
     
    18712147      const char **p;
    18722148      for (p = new_files->list; *p != 0; ++p)
    1873         {
    1874           struct file *f = enter_file (*p);
    1875           f->last_mtime = f->mtime_before_update = NEW_MTIME;
    1876         }
     2149        {
     2150          struct file *f = enter_file (*p);
     2151          f->last_mtime = f->mtime_before_update = NEW_MTIME;
     2152        }
    18772153    }
    18782154
     
    18802156  remote_setup ();
    18812157
    1882   if (read_makefiles != 0)
     2158  /* Dump any output we've collected.  */
     2159
     2160  OUTPUT_UNSET ();
     2161  output_close (&make_sync);
     2162
     2163  if (read_files != 0)
    18832164    {
    18842165      /* Update any makefiles if necessary.  */
     
    18862167      FILE_TIMESTAMP *makefile_mtimes = 0;
    18872168      unsigned int mm_idx = 0;
    1888       char **nargv;
     2169      char **aargv = NULL;
     2170      const char **nargv;
    18892171      int nargc;
    1890       int orig_db_level = db_level;
    1891       int status;
    1892 
    1893       if (! ISDB (DB_MAKEFILES))
    1894         db_level = DB_NONE;
     2172      enum update_status status;
    18952173
    18962174      DB (DB_BASIC, (_("Updating makefiles....\n")));
    18972175
    18982176      /* Remove any makefiles we don't want to try to update.
    1899         Also record the current modtimes so we can compare them later.  */
     2177        Also record the current modtimes so we can compare them later.  */
    19002178      {
    1901         register struct dep *d, *last;
    1902         last = 0;
    1903         d = read_makefiles;
    1904         while (d != 0)
    1905           {
    1906             struct file *f = d->file;
    1907             if (f->double_colon)
    1908               for (f = f->double_colon; f != NULL; f = f->prev)
    1909                 {
    1910                   if (f->deps == 0 && f->cmds != 0)
    1911                     {
    1912                       /* This makefile is a :: target with commands, but
    1913                         no dependencies.  So, it will always be remade.
    1914                         This might well cause an infinite loop, so don't
    1915                         try to remake it.  (This will only happen if
    1916                         your makefiles are written exceptionally
    1917                         stupidly; but if you work for Athena, that's how
    1918                         you write your makefiles.)  */
    1919 
    1920                       DB (DB_VERBOSE,
    1921                           (_("Makefile `%s' might loop; not remaking it.\n"),
     2179        register struct goaldep *d, *last;
     2180        last = 0;
     2181        d = read_files;
     2182        while (d != 0)
     2183          {
     2184            struct file *f = d->file;
     2185            if (f->double_colon)
     2186              for (f = f->double_colon; f != NULL; f = f->prev)
     2187                {
     2188                  if (f->deps == 0 && f->cmds != 0)
     2189                    {
     2190                      /* This makefile is a :: target with commands, but
     2191                        no dependencies.  So, it will always be remade.
     2192                        This might well cause an infinite loop, so don't
     2193                        try to remake it.  (This will only happen if
     2194                        your makefiles are written exceptionally
     2195                        stupidly; but if you work for Athena, that's how
     2196                        you write your makefiles.)  */
     2197
     2198                      DB (DB_VERBOSE,
     2199                          (_("Makefile '%s' might loop; not remaking it.\n"),
    19222200                           f->name));
    19232201
    1924                       if (last == 0)
    1925                         read_makefiles = d->next;
    1926                       else
    1927                         last->next = d->next;
    1928 
    1929                       /* Free the storage.  */
    1930                       free_dep (d);
    1931 
    1932                       d = last == 0 ? read_makefiles : last->next;
    1933 
    1934                       break;
    1935                     }
    1936                 }
    1937             if (f == NULL || !f->double_colon)
    1938               {
     2202                      if (last == 0)
     2203                        read_files = d->next;
     2204                      else
     2205                        last->next = d->next;
     2206
     2207                      /* Free the storage.  */
     2208                      free_goaldep (d);
     2209
     2210                      d = last == 0 ? read_files : last->next;
     2211
     2212                      break;
     2213                    }
     2214                }
     2215
     2216            if (f == NULL || !f->double_colon)
     2217              {
    19392218                makefile_mtimes = xrealloc (makefile_mtimes,
    19402219                                            (mm_idx+1)
    19412220                                            * sizeof (FILE_TIMESTAMP));
    1942                 makefile_mtimes[mm_idx++] = file_mtime_no_search (d->file);
    1943                 last = d;
    1944                 d = d->next;
    1945               }
    1946           }
     2221                makefile_mtimes[mm_idx++] = file_mtime_no_search (d->file);
     2222                last = d;
     2223                d = d->next;
     2224              }
     2225          }
    19472226      }
    19482227
    1949       /* Set up `MAKEFLAGS' specially while remaking makefiles.  */
     2228      /* Set up 'MAKEFLAGS' specially while remaking makefiles.  */
    19502229      define_makeflags (1, 1);
    19512230
    1952       rebuilding_makefiles = 1;
    1953       status = update_goal_chain (read_makefiles);
    1954       rebuilding_makefiles = 0;
     2231      {
     2232        int orig_db_level = db_level;
     2233
     2234        if (! ISDB (DB_MAKEFILES))
     2235          db_level = DB_NONE;
     2236
     2237        rebuilding_makefiles = 1;
     2238        status = update_goal_chain (read_files);
     2239        rebuilding_makefiles = 0;
     2240
     2241        db_level = orig_db_level;
     2242      }
    19552243
    19562244      switch (status)
    1957         {
    1958         case 1:
     2245        {
     2246        case us_question:
    19592247          /* The only way this can happen is if the user specified -q and asked
    1960            * for one of the makefiles to be remade as a target on the command
    1961            * line.  Since we're not actually updating anything with -q we can
    1962            * treat this as "did nothing".
    1963            */
    1964 
    1965         case -1:
    1966           /* Did nothing.  */
    1967           break;
    1968 
    1969         case 2:
    1970           /* Failed to update.  Figure out if we care.  */
    1971           {
    1972             /* Nonzero if any makefile was successfully remade.  */
    1973             int any_remade = 0;
    1974             /* Nonzero if any makefile we care about failed
    1975                in updating or could not be found at all.  */
    1976             int any_failed = 0;
    1977             unsigned int i;
    1978             struct dep *d;
    1979 
    1980             for (i = 0, d = read_makefiles; d != 0; ++i, d = d->next)
     2248             for one of the makefiles to be remade as a target on the command
     2249             line.  Since we're not actually updating anything with -q we can
     2250             treat this as "did nothing".  */
     2251
     2252        case us_none:
     2253          /* Did nothing.  */
     2254          break;
     2255
     2256        case us_failed:
     2257          /* Failed to update.  Figure out if we care.  */
     2258          {
     2259            /* Nonzero if any makefile was successfully remade.  */
     2260            int any_remade = 0;
     2261            /* Nonzero if any makefile we care about failed
     2262               in updating or could not be found at all.  */
     2263            int any_failed = 0;
     2264            unsigned int i;
     2265            struct goaldep *d;
     2266
     2267            for (i = 0, d = read_files; d != 0; ++i, d = d->next)
    19812268              {
    1982                 /* Reset the considered flag; we may need to look at the file
    1983                    again to print an error.  */
    1984                 d->file->considered = 0;
    1985 
    19862269                if (d->file->updated)
    19872270                  {
    19882271                    /* This makefile was updated.  */
    1989                     if (d->file->update_status == 0)
     2272                    if (d->file->update_status == us_success)
    19902273                      {
    19912274                        /* It was successfully updated.  */
     
    19932276                                       != makefile_mtimes[i]);
    19942277                      }
    1995                     else if (! (d->changed & RM_DONTCARE))
     2278                    else if (! (d->flags & RM_DONTCARE))
    19962279                      {
    19972280                        FILE_TIMESTAMP mtime;
    19982281                        /* The update failed and this makefile was not
    19992282                           from the MAKEFILES variable, so we care.  */
    2000                         error (NILF, _("Failed to remake makefile `%s'."),
    2001                                d->file->name);
     2283                        OS (error, NILF, _("Failed to remake makefile '%s'."),
     2284                            d->file->name);
    20022285                        mtime = file_mtime_no_search (d->file);
    20032286                        any_remade |= (mtime != NONEXISTENT_MTIME
     
    20082291                else
    20092292                  /* This makefile was not found at all.  */
    2010                   if (! (d->changed & RM_DONTCARE))
     2293                  if (! (d->flags & RM_DONTCARE))
    20112294                    {
     2295                      const char *dnm = dep_name (d);
     2296                      size_t l = strlen (dnm);
     2297
    20122298                      /* This is a makefile we care about.  See how much.  */
    2013                       if (d->changed & RM_INCLUDED)
    2014                         /* An included makefile.  We don't need
    2015                            to die, but we do want to complain.  */
    2016                         error (NILF,
    2017                                _("Included makefile `%s' was not found."),
    2018                                dep_name (d));
     2299                      if (d->flags & RM_INCLUDED)
     2300                        /* An included makefile.  We don't need to die, but we
     2301                           do want to complain.  */
     2302                        error (NILF, l,
     2303                               _("Included makefile '%s' was not found."), dnm);
    20192304                      else
    20202305                        {
    20212306                          /* A normal makefile.  We must die later.  */
    2022                           error (NILF, _("Makefile `%s' was not found"),
    2023                                  dep_name (d));
     2307                          error (NILF, l,
     2308                                 _("Makefile '%s' was not found"), dnm);
    20242309                          any_failed = 1;
    20252310                        }
     
    20272312              }
    20282313            /* Reset this to empty so we get the right error message below.  */
    2029             read_makefiles = 0;
    2030 
    2031             if (any_remade)
    2032               goto re_exec;
    2033             if (any_failed)
    2034               die (2);
     2314            read_files = 0;
     2315
     2316            if (any_remade)
     2317              goto re_exec;
     2318            if (any_failed)
     2319              die (MAKE_FAILURE);
    20352320            break;
    2036           }
    2037 
    2038         case 0:
    2039         re_exec:
    2040           /* Updated successfully.  Re-exec ourselves.  */
    2041 
    2042           remove_intermediates (0);
    2043 
    2044           if (print_data_base_flag)
    2045             print_data_base ();
    2046 
    2047           log_working_directory (0);
     2321          }
     2322
     2323        case us_success:
     2324        re_exec:
     2325          /* Updated successfully.  Re-exec ourselves.  */
     2326
     2327          remove_intermediates (0);
     2328
     2329          if (print_data_base_flag)
     2330            print_data_base ();
    20482331
    20492332          clean_jobserver (0);
    20502333
    2051           if (makefiles != 0)
    2052             {
    2053               /* These names might have changed.  */
    2054               int i, j = 0;
    2055               for (i = 1; i < argc; ++i)
    2056                 if (strneq (argv[i], "-f", 2)) /* XXX */
    2057                   {
    2058                     if (argv[i][2] == '\0')
     2334          if (makefiles != 0)
     2335            {
     2336              /* These names might have changed.  */
     2337              int i, j = 0;
     2338              for (i = 1; i < argc; ++i)
     2339                if (strneq (argv[i], "-f", 2)) /* XXX */
     2340                  {
     2341                    if (argv[i][2] == '\0')
    20592342                      /* This cast is OK since we never modify argv.  */
    2060                       argv[++i] = (char *) makefiles->list[j];
    2061                     else
    2062                       argv[i] = xstrdup (concat (2, "-f", makefiles->list[j]));
    2063                     ++j;
    2064                   }
    2065             }
     2343                      argv[++i] = (char *) makefiles->list[j];
     2344                    else
     2345                      argv[i] = xstrdup (concat (2, "-f", makefiles->list[j]));
     2346                    ++j;
     2347                  }
     2348            }
    20662349
    20672350          /* Add -o option for the stdin temporary file, if necessary.  */
     
    20692352          if (stdin_nm)
    20702353            {
    2071               nargv = xmalloc ((nargc + 2) * sizeof (char *));
    2072               memcpy (nargv, argv, argc * sizeof (char *));
    2073               nargv[nargc++] = xstrdup (concat (2, "-o", stdin_nm));
    2074               nargv[nargc] = 0;
     2354              void *m = xmalloc ((nargc + 2) * sizeof (char *));
     2355              aargv = m;
     2356              memcpy (aargv, argv, argc * sizeof (char *));
     2357              aargv[nargc++] = xstrdup (concat (2, "-o", stdin_nm));
     2358              aargv[nargc] = 0;
     2359              nargv = m;
    20752360            }
    20762361          else
    2077             nargv = argv;
    2078 
    2079           if (directories != 0 && directories->idx > 0)
    2080             {
    2081               int bad = 1;
    2082               if (directory_before_chdir != 0)
    2083                 {
    2084                   if (chdir (directory_before_chdir) < 0)
    2085                       perror_with_name ("chdir", "");
    2086                   else
    2087                     bad = 0;
    2088                 }
    2089               if (bad)
    2090                 fatal (NILF, _("Couldn't change back to original directory."));
    2091             }
     2362            nargv = (const char**)argv;
     2363
     2364          if (directories != 0 && directories->idx > 0)
     2365            {
     2366              int bad = 1;
     2367              if (directory_before_chdir != 0)
     2368                {
     2369                  if (chdir (directory_before_chdir) < 0)
     2370                      perror_with_name ("chdir", "");
     2371                  else
     2372                    bad = 0;
     2373                }
     2374              if (bad)
     2375                O (fatal, NILF,
     2376                   _("Couldn't change back to original directory."));
     2377            }
    20922378
    20932379          ++restarts;
    20942380
    2095           /* Reset makeflags in case they were changed.  */
    2096           {
    2097             const char *pv = define_makeflags (1, 1);
    2098             char *p = alloca (sizeof ("MAKEFLAGS=") + strlen (pv) + 1);
    2099             sprintf (p, "MAKEFLAGS=%s", pv);
    2100             putenv (p);
    2101           }
    2102 
    2103           if (ISDB (DB_BASIC))
    2104             {
    2105               char **p;
    2106               printf (_("Re-executing[%u]:"), restarts);
    2107               for (p = nargv; *p != 0; ++p)
    2108                 printf (" %s", *p);
    2109               putchar ('\n');
    2110             }
     2381          if (ISDB (DB_BASIC))
     2382            {
     2383              const char **p;
     2384              printf (_("Re-executing[%u]:"), restarts);
     2385              for (p = nargv; *p != 0; ++p)
     2386                printf (" %s", *p);
     2387              putchar ('\n');
     2388              fflush (stdout);
     2389            }
    21112390
    21122391#ifndef _AMIGA
     
    21152394            for (p = environ; *p != 0; ++p)
    21162395              {
    2117                 if (strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH)
    2118                     && (*p)[MAKELEVEL_LENGTH] == '=')
     2396                if (strneq (*p, MAKELEVEL_NAME "=", MAKELEVEL_LENGTH+1))
    21192397                  {
    21202398                    *p = alloca (40);
    21212399                    sprintf (*p, "%s=%u", MAKELEVEL_NAME, makelevel);
     2400#ifdef VMS
     2401                    vms_putenv_symbol (*p);
     2402#endif
    21222403                  }
    2123                 if (strneq (*p, "MAKE_RESTARTS=", 14))
     2404                else if (strneq (*p, "MAKE_RESTARTS=", CSTRLEN ("MAKE_RESTARTS=")))
    21242405                  {
    21252406                    *p = alloca (40);
    2126                     sprintf (*p, "MAKE_RESTARTS=%u", restarts);
     2407                    sprintf (*p, "MAKE_RESTARTS=%s%u",
     2408                             OUTPUT_IS_TRACED () ? "-" : "", restarts);
    21272409                    restarts = 0;
    21282410                  }
     
    21302412          }
    21312413#else /* AMIGA */
    2132           {
    2133             char buffer[256];
     2414          {
     2415            char buffer[256];
    21342416
    21352417            sprintf (buffer, "%u", makelevel);
    21362418            SetVar (MAKELEVEL_NAME, buffer, -1, GVF_GLOBAL_ONLY);
    21372419
    2138             sprintf (buffer, "%u", restarts);
     2420            sprintf (buffer, "%s%u", OUTPUT_IS_TRACED () ? "-" : "", restarts);
    21392421            SetVar ("MAKE_RESTARTS", buffer, -1, GVF_GLOBAL_ONLY);
    21402422            restarts = 0;
    2141           }
     2423          }
    21422424#endif
    21432425
     
    21462428            {
    21472429              char *b = alloca (40);
    2148               sprintf (b, "MAKE_RESTARTS=%u", restarts);
     2430              sprintf (b, "MAKE_RESTARTS=%s%u",
     2431                       OUTPUT_IS_TRACED () ? "-" : "", restarts);
    21492432              putenv (b);
    21502433            }
    21512434
    2152           fflush (stdout);
    2153           fflush (stderr);
    2154 
    2155           /* Close the dup'd jobserver pipe if we opened one.  */
    2156           if (job_rfd >= 0)
    2157             close (job_rfd);
     2435          fflush (stdout);
     2436          fflush (stderr);
    21582437
    21592438#ifdef _AMIGA
    2160           exec_command (nargv);
    2161           exit (0);
     2439          exec_command (nargv);
     2440          exit (0);
    21622441#elif defined (__EMX__)
    2163           {
    2164             /* It is not possible to use execve() here because this
    2165                would cause the parent process to be terminated with
    2166                exit code 0 before the child process has been terminated.
    2167                Therefore it may be the best solution simply to spawn the
    2168                child process including all file handles and to wait for its
    2169                termination. */
    2170             int pid;
    2171             int status;
    2172             pid = child_execute_job (0, 1, nargv, environ);
    2173 
    2174             /* is this loop really necessary? */
    2175             do {
    2176               pid = wait (&status);
    2177             } while (pid <= 0);
    2178             /* use the exit code of the child process */
    2179             exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);
    2180           }
     2442          {
     2443            /* It is not possible to use execve() here because this
     2444               would cause the parent process to be terminated with
     2445               exit code 0 before the child process has been terminated.
     2446               Therefore it may be the best solution simply to spawn the
     2447               child process including all file handles and to wait for its
     2448               termination. */
     2449            int pid;
     2450            int r;
     2451            pid = child_execute_job (NULL, 1, nargv, environ);
     2452
     2453            /* is this loop really necessary? */
     2454            do {
     2455              pid = wait (&r);
     2456            } while (pid <= 0);
     2457            /* use the exit code of the child process */
     2458            exit (WIFEXITED(r) ? WEXITSTATUS(r) : EXIT_FAILURE);
     2459          }
    21812460#else
    2182           exec_command (nargv, environ);
    2183 #endif
    2184           /* NOTREACHED */
    2185 
    2186         default:
    2187 #define BOGUS_UPDATE_STATUS 0
    2188           assert (BOGUS_UPDATE_STATUS);
    2189           break;
    2190         }
    2191 
    2192       db_level = orig_db_level;
    2193 
    2194       /* Free the makefile mtimes (if we allocated any).  */
    2195       if (makefile_mtimes)
    2196         free (makefile_mtimes);
    2197     }
    2198 
    2199   /* Set up `MAKEFLAGS' again for the normal targets.  */
     2461#ifdef SET_STACK_SIZE
     2462          /* Reset limits, if necessary.  */
     2463          if (stack_limit.rlim_cur)
     2464            setrlimit (RLIMIT_STACK, &stack_limit);
     2465#endif
     2466          exec_command ((char **)nargv, environ);
     2467#endif
     2468          free (aargv);
     2469          break;
     2470        }
     2471
     2472      /* Free the makefile mtimes.  */
     2473      free (makefile_mtimes);
     2474    }
     2475
     2476  /* Set up 'MAKEFLAGS' again for the normal targets.  */
    22002477  define_makeflags (1, 0);
    22012478
     
    22082485      const char **p;
    22092486      for (p = new_files->list; *p != 0; ++p)
    2210         {
    2211           struct file *f = enter_file (*p);
    2212           f->last_mtime = f->mtime_before_update = NEW_MTIME;
    2213         }
     2487        {
     2488          struct file *f = enter_file (*p);
     2489          f->last_mtime = f->mtime_before_update = NEW_MTIME;
     2490        }
    22142491    }
    22152492
     
    22442521              struct nameseq *ns;
    22452522
    2246               ns = PARSE_FILE_SEQ (&p, struct nameseq, '\0', NULL, 0);
     2523              ns = PARSE_SIMPLE_SEQ (&p, struct nameseq);
    22472524              if (ns)
    22482525                {
    22492526                  /* .DEFAULT_GOAL should contain one target. */
    22502527                  if (ns->next != 0)
    2251                     fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));
     2528                    O (fatal, NILF,
     2529                       _(".DEFAULT_GOAL contains more than one target"));
    22522530
    22532531                  f = enter_file (strcache_add (ns->name));
     
    22602538          if (f)
    22612539            {
    2262               goals = alloc_dep ();
     2540              goals = alloc_goaldep ();
    22632541              goals->file = f;
    22642542            }
     
    22712549  if (!goals)
    22722550    {
    2273       if (read_makefiles == 0)
    2274         fatal (NILF, _("No targets specified and no makefile found"));
    2275 
    2276       fatal (NILF, _("No targets"));
     2551      if (read_files == 0)
     2552        O (fatal, NILF, _("No targets specified and no makefile found"));
     2553
     2554      O (fatal, NILF, _("No targets"));
    22772555    }
    22782556
     
    22822560
    22832561  {
    2284     int status;
    2285 
    22862562    switch (update_goal_chain (goals))
    22872563    {
    2288       case -1:
     2564      case us_none:
    22892565        /* Nothing happened.  */
    2290       case 0:
    2291         /* Updated successfully.  */
    2292         status = makefile_status;
     2566        /* FALLTHROUGH */
     2567      case us_success:
     2568        /* Keep the previous result.  */
    22932569        break;
    2294       case 1:
     2570      case us_question:
    22952571        /* We are under -q and would run some commands.  */
    2296         status = MAKE_TROUBLE;
     2572        makefile_status = MAKE_TROUBLE;
    22972573        break;
    2298       case 2:
    2299         /* Updating failed.  POSIX.2 specifies exit status >1 for this;
    2300            but in VMS, there is only success and failure.  */
    2301         status = MAKE_FAILURE;
     2574      case us_failed:
     2575        /* Updating failed.  POSIX.2 specifies exit status >1 for this; */
     2576        makefile_status = MAKE_FAILURE;
    23022577        break;
    2303       default:
    2304         abort ();
    23052578    }
    23062579
    23072580    /* If we detected some clock skew, generate one last warning */
    23082581    if (clock_skew_detected)
    2309       error (NILF,
    2310              _("warning:  Clock skew detected.  Your build may be incomplete."));
     2582      O (error, NILF,
     2583         _("warning:  Clock skew detected.  Your build may be incomplete."));
    23112584
    23122585    /* Exit.  */
    2313     die (status);
     2586    die (makefile_status);
    23142587  }
    23152588
    23162589  /* NOTREACHED */
    2317   return 0;
     2590  exit (MAKE_SUCCESS);
    23182591}
    23192592
     
    23232596static char options[1 + sizeof (switches) / sizeof (switches[0]) * 3];
    23242597static struct option long_options[(sizeof (switches) / sizeof (switches[0])) +
    2325                                   (sizeof (long_option_aliases) /
    2326                                    sizeof (long_option_aliases[0]))];
     2598                                  (sizeof (long_option_aliases) /
     2599                                   sizeof (long_option_aliases[0]))];
    23272600
    23282601/* Fill in the string and vector for getopt.  */
     
    23472620    {
    23482621      long_options[i].name = (switches[i].long_name == 0 ? "" :
    2349                               switches[i].long_name);
     2622                              switches[i].long_name);
    23502623      long_options[i].flag = 0;
    23512624      long_options[i].val = switches[i].c;
    23522625      if (short_option (switches[i].c))
    2353         *p++ = switches[i].c;
     2626        *p++ = switches[i].c;
    23542627      switch (switches[i].type)
    2355         {
    2356         case flag:
    2357         case flag_off:
    2358         case ignore:
    2359           long_options[i].has_arg = no_argument;
    2360           break;
    2361 
    2362         case string:
     2628        {
     2629        case flag:
     2630        case flag_off:
     2631        case ignore:
     2632          long_options[i].has_arg = no_argument;
     2633          break;
     2634
     2635        case string:
     2636        case strlist:
    23632637        case filename:
    2364         case positive_int:
    2365         case floating:
    2366           if (short_option (switches[i].c))
    2367             *p++ = ':';
    2368           if (switches[i].noarg_value != 0)
    2369             {
    2370               if (short_option (switches[i].c))
    2371                 *p++ = ':';
    2372               long_options[i].has_arg = optional_argument;
    2373             }
    2374           else
    2375             long_options[i].has_arg = required_argument;
    2376           break;
    2377         }
     2638        case positive_int:
     2639        case floating:
     2640          if (short_option (switches[i].c))
     2641            *p++ = ':';
     2642          if (switches[i].noarg_value != 0)
     2643            {
     2644              if (short_option (switches[i].c))
     2645                *p++ = ':';
     2646              long_options[i].has_arg = optional_argument;
     2647            }
     2648          else
     2649            long_options[i].has_arg = required_argument;
     2650          break;
     2651        }
    23782652    }
    23792653  *p = '\0';
    23802654  for (c = 0; c < (sizeof (long_option_aliases) /
    2381                    sizeof (long_option_aliases[0]));
     2655                   sizeof (long_option_aliases[0]));
    23822656       ++c)
    23832657    long_options[i++] = long_option_aliases[c];
     
    23852659}
    23862660
     2661
     2662/* Non-option argument.  It might be a variable definition.  */
    23872663static void
    2388 handle_non_switch_argument (char *arg, int env)
     2664handle_non_switch_argument (const char *arg, int env)
    23892665{
    2390   /* Non-option argument.  It might be a variable definition.  */
    23912666  struct variable *v;
     2667
    23922668  if (arg[0] == '-' && arg[1] == '\0')
    2393     /* Ignore plain `-' for compatibility.  */
     2669    /* Ignore plain '-' for compatibility.  */
    23942670    return;
     2671
     2672#ifdef VMS
     2673  {
     2674    /* VMS DCL quoting can result in foo="bar baz" showing up here.
     2675       Need to remove the double quotes from the value. */
     2676    char * eq_ptr;
     2677    char * new_arg;
     2678    eq_ptr = strchr (arg, '=');
     2679    if ((eq_ptr != NULL) && (eq_ptr[1] == '"'))
     2680      {
     2681         int len;
     2682         int seg1;
     2683         int seg2;
     2684         len = strlen(arg);
     2685         new_arg = alloca(len);
     2686         seg1 = eq_ptr - arg + 1;
     2687         strncpy(new_arg, arg, (seg1));
     2688         seg2 = len - seg1 - 1;
     2689         strncpy(&new_arg[seg1], &eq_ptr[2], seg2);
     2690         new_arg[seg1 + seg2] = 0;
     2691         if (new_arg[seg1 + seg2 - 1] == '"')
     2692           new_arg[seg1 + seg2 - 1] = 0;
     2693         arg = new_arg;
     2694      }
     2695  }
     2696#endif
    23952697  v = try_variable_definition (0, arg, o_command, 0);
    23962698  if (v != 0)
    23972699    {
    23982700      /* It is indeed a variable definition.  If we don't already have this
    2399         one, record a pointer to the variable for later use in
    2400         define_makeflags.  */
     2701        one, record a pointer to the variable for later use in
     2702        define_makeflags.  */
    24012703      struct command_variable *cv;
    24022704
     
    24052707          break;
    24062708
    2407       if (! cv) {
    2408         cv = xmalloc (sizeof (*cv));
    2409         cv->variable = v;
    2410         cv->next = command_variables;
    2411         command_variables = cv;
    2412       }
     2709      if (! cv)
     2710        {
     2711          cv = xmalloc (sizeof (*cv));
     2712          cv->variable = v;
     2713          cv->next = command_variables;
     2714          command_variables = cv;
     2715        }
    24132716    }
    24142717  else if (! env)
    24152718    {
    24162719      /* Not an option or variable definition; it must be a goal
    2417         target!  Enter it as a file and add it to the dep chain of
    2418         goals.  */
     2720        target!  Enter it as a file and add it to the dep chain of
     2721        goals.  */
    24192722      struct file *f = enter_file (strcache_add (expand_command_line_file (arg)));
    24202723      f->cmd_target = 1;
    24212724
    24222725      if (goals == 0)
    2423         {
    2424           goals = alloc_dep ();
    2425           lastgoal = goals;
    2426         }
     2726        {
     2727          goals = alloc_goaldep ();
     2728          lastgoal = goals;
     2729        }
    24272730      else
    2428         {
    2429           lastgoal->next = alloc_dep ();
    2430           lastgoal = lastgoal->next;
    2431         }
     2731        {
     2732          lastgoal->next = alloc_goaldep ();
     2733          lastgoal = lastgoal->next;
     2734        }
    24322735
    24332736      lastgoal->file = f;
     
    24912794
    24922795static void
    2493 decode_switches (int argc, char **argv, int env)
     2796decode_switches (int argc, const char **argv, int env)
    24942797{
    24952798  int bad = 0;
     
    25112814  while (optind < argc)
    25122815    {
     2816      const char *coptarg;
     2817
    25132818      /* Parse the next argument.  */
    2514       c = getopt_long (argc, argv, options, long_options, (int *) 0);
     2819      c = getopt_long (argc, (char*const*)argv, options, long_options, NULL);
     2820      coptarg = optarg;
    25152821      if (c == EOF)
    2516         /* End of arguments, or "--" marker seen.  */
    2517         break;
     2822        /* End of arguments, or "--" marker seen.  */
     2823        break;
    25182824      else if (c == 1)
    2519         /* An argument not starting with a dash.  */
    2520         handle_non_switch_argument (optarg, env);
     2825        /* An argument not starting with a dash.  */
     2826        handle_non_switch_argument (coptarg, env);
    25212827      else if (c == '?')
    2522         /* Bad option.  We will print a usage message and die later.
    2523            But continue to parse the other options so the user can
    2524            see all he did wrong.  */
    2525         bad = 1;
     2828        /* Bad option.  We will print a usage message and die later.
     2829           But continue to parse the other options so the user can
     2830           see all he did wrong.  */
     2831        bad = 1;
    25262832      else
    2527         for (cs = switches; cs->c != '\0'; ++cs)
    2528           if (cs->c == c)
    2529             {
    2530               /* Whether or not we will actually do anything with
    2531                  this switch.  We test this individually inside the
    2532                  switch below rather than just once outside it, so that
    2533                  options which are to be ignored still consume args.  */
    2534               int doit = !env || cs->env;
    2535 
    2536               switch (cs->type)
    2537                 {
    2538                 default:
    2539                   abort ();
    2540 
    2541                 case ignore:
    2542                   break;
    2543 
    2544                 case flag:
    2545                 case flag_off:
    2546                   if (doit)
    2547                     *(int *) cs->value_ptr = cs->type == flag;
    2548                   break;
    2549 
    2550                 case string:
    2551                 case filename:
    2552                   if (!doit)
    2553                     break;
    2554 
    2555                   if (optarg == 0)
    2556                     optarg = xstrdup (cs->noarg_value);
    2557                   else if (*optarg == '\0')
     2833        for (cs = switches; cs->c != '\0'; ++cs)
     2834          if (cs->c == c)
     2835            {
     2836              /* Whether or not we will actually do anything with
     2837                 this switch.  We test this individually inside the
     2838                 switch below rather than just once outside it, so that
     2839                 options which are to be ignored still consume args.  */
     2840              int doit = !env || cs->env;
     2841
     2842              switch (cs->type)
     2843                {
     2844                default:
     2845                  abort ();
     2846
     2847                case ignore:
     2848                  break;
     2849
     2850                case flag:
     2851                case flag_off:
     2852                  if (doit)
     2853                    *(int *) cs->value_ptr = cs->type == flag;
     2854                  break;
     2855
     2856                case string:
     2857                case strlist:
     2858                case filename:
     2859                  if (!doit)
     2860                    break;
     2861
     2862                  if (! coptarg)
     2863                    coptarg = xstrdup (cs->noarg_value);
     2864                  else if (*coptarg == '\0')
    25582865                    {
    25592866                      char opt[2] = "c";
     
    25652872                        op = cs->long_name;
    25662873
    2567                       error (NILF, _("the `%s%s' option requires a non-empty string argument"),
     2874                      error (NILF, strlen (op),
     2875                             _("the '%s%s' option requires a non-empty string argument"),
    25682876                             short_option (cs->c) ? "-" : "--", op);
    25692877                      bad = 1;
     2878                      break;
    25702879                    }
    25712880
    2572                   sl = *(struct stringlist **) cs->value_ptr;
    2573                   if (sl == 0)
    2574                     {
    2575                       sl = (struct stringlist *)
    2576                         xmalloc (sizeof (struct stringlist));
    2577                       sl->max = 5;
    2578                       sl->idx = 0;
    2579                       sl->list = xmalloc (5 * sizeof (char *));
    2580                       *(struct stringlist **) cs->value_ptr = sl;
    2581                     }
    2582                   else if (sl->idx == sl->max - 1)
    2583                     {
    2584                       sl->max += 5;
     2881                  if (cs->type == string)
     2882                    {
     2883                      char **val = (char **)cs->value_ptr;
     2884                      free (*val);
     2885                      *val = xstrdup (coptarg);
     2886                      break;
     2887                    }
     2888
     2889                  sl = *(struct stringlist **) cs->value_ptr;
     2890                  if (sl == 0)
     2891                    {
     2892                      sl = xmalloc (sizeof (struct stringlist));
     2893                      sl->max = 5;
     2894                      sl->idx = 0;
     2895                      sl->list = xmalloc (5 * sizeof (char *));
     2896                      *(struct stringlist **) cs->value_ptr = sl;
     2897                    }
     2898                  else if (sl->idx == sl->max - 1)
     2899                    {
     2900                      sl->max += 5;
    25852901                      /* MSVC erroneously warns without a cast here.  */
    2586                       sl->list = xrealloc ((void *)sl->list,
     2902                      sl->list = xrealloc ((void *)sl->list,
    25872903                                           sl->max * sizeof (char *));
    2588                     }
     2904                    }
    25892905                  if (cs->type == filename)
    2590                     sl->list[sl->idx++] = expand_command_line_file (optarg);
     2906                    sl->list[sl->idx++] = expand_command_line_file (coptarg);
    25912907                  else
    2592                     sl->list[sl->idx++] = optarg;
    2593                   sl->list[sl->idx] = 0;
    2594                   break;
    2595 
    2596                 case positive_int:
     2908                    sl->list[sl->idx++] = xstrdup (coptarg);
     2909                  sl->list[sl->idx] = 0;
     2910                  break;
     2911
     2912                case positive_int:
    25972913                  /* See if we have an option argument; if we do require that
    25982914                     it's all digits, not something like "10foo".  */
    2599                   if (optarg == 0 && argc > optind)
     2915                  if (coptarg == 0 && argc > optind)
    26002916                    {
    26012917                      const char *cp;
     
    26032919                        ;
    26042920                      if (cp[0] == '\0')
    2605                         optarg = argv[optind++];
     2921                        coptarg = argv[optind++];
    26062922                    }
    26072923
    2608                   if (!doit)
    2609                     break;
    2610 
    2611                   if (optarg != 0)
    2612                     {
    2613                       int i = atoi (optarg);
     2924                  if (!doit)
     2925                    break;
     2926
     2927                  if (coptarg)
     2928                    {
     2929                      int i = atoi (coptarg);
    26142930                      const char *cp;
    26152931
    26162932                      /* Yes, I realize we're repeating this in some cases.  */
    2617                       for (cp = optarg; ISDIGIT (cp[0]); ++cp)
     2933                      for (cp = coptarg; ISDIGIT (cp[0]); ++cp)
    26182934                        ;
    26192935
    2620                       if (i < 1 || cp[0] != '\0')
    2621                         {
    2622                           error (NILF, _("the `-%c' option requires a positive integral argument"),
     2936                      if (i < 1 || cp[0] != '\0')
     2937                        {
     2938                          error (NILF, 0,
     2939                                 _("the '-%c' option requires a positive integer argument"),
    26232940                                 cs->c);
    2624                           bad = 1;
    2625                         }
    2626                       else
    2627                         *(unsigned int *) cs->value_ptr = i;
    2628                     }
    2629                   else
    2630                     *(unsigned int *) cs->value_ptr
    2631                       = *(unsigned int *) cs->noarg_value;
    2632                   break;
     2941                          bad = 1;
     2942                        }
     2943                      else
     2944                        *(unsigned int *) cs->value_ptr = i;
     2945                    }
     2946                  else
     2947                    *(unsigned int *) cs->value_ptr
     2948                      = *(unsigned int *) cs->noarg_value;
     2949                  break;
    26332950
    26342951#ifndef NO_FLOAT
    2635                 case floating:
    2636                   if (optarg == 0 && optind < argc
    2637                       && (ISDIGIT (argv[optind][0]) || argv[optind][0] == '.'))
    2638                     optarg = argv[optind++];
    2639 
    2640                   if (doit)
    2641                     *(double *) cs->value_ptr
    2642                       = (optarg != 0 ? atof (optarg)
    2643                         : *(double *) cs->noarg_value);
    2644 
    2645                   break;
    2646 #endif
    2647                 }
    2648 
    2649               /* We've found the switch.  Stop looking.  */
    2650               break;
    2651             }
     2952                case floating:
     2953                  if (coptarg == 0 && optind < argc
     2954                      && (ISDIGIT (argv[optind][0]) || argv[optind][0] == '.'))
     2955                    coptarg = argv[optind++];
     2956
     2957                  if (doit)
     2958                    *(double *) cs->value_ptr
     2959                      = (coptarg != 0 ? atof (coptarg)
     2960                        : *(double *) cs->noarg_value);
     2961
     2962                  break;
     2963#endif
     2964                }
     2965
     2966              /* We've found the switch.  Stop looking.  */
     2967              break;
     2968            }
    26522969    }
    26532970
     
    26592976    handle_non_switch_argument (argv[optind++], env);
    26602977
    2661 
    26622978  if (!env && (bad || print_usage_flag))
    26632979    {
    26642980      print_usage (bad);
    2665       die (bad ? 2 : 0);
    2666     }
     2981      die (bad ? MAKE_FAILURE : MAKE_SUCCESS);
     2982    }
     2983
     2984  /* If there are any options that need to be decoded do it now.  */
     2985  decode_debug_flags ();
     2986  decode_output_sync_flags ();
    26672987}
    26682988
     
    26732993
    26742994static void
    2675 decode_env_switches (char *envar, unsigned int len)
     2995decode_env_switches (const char *envar, unsigned int len)
    26762996{
    26772997  char *varref = alloca (2 + len + 2);
    2678   char *value, *p;
     2998  char *value, *p, *buf;
    26792999  int argc;
    2680   char **argv;
     3000  const char **argv;
    26813001
    26823002  /* Get the variable's value.  */
     
    26893009
    26903010  /* Skip whitespace, and check for an empty value.  */
    2691   value = next_token (value);
     3011  NEXT_TOKEN (value);
    26923012  len = strlen (value);
    26933013  if (len == 0)
     
    26963016  /* Allocate a vector that is definitely big enough.  */
    26973017  argv = alloca ((1 + len + 1) * sizeof (char *));
    2698 
    2699   /* Allocate a buffer to copy the value into while we split it into words
    2700      and unquote it.  We must use permanent storage for this because
    2701      decode_switches may store pointers into the passed argument words.  */
    2702   p = xmalloc (2 * len);
    27033018
    27043019  /* getopt will look at the arguments starting at ARGV[1].
     
    27063021  argv[0] = 0;
    27073022  argc = 1;
     3023
     3024  /* We need a buffer to copy the value into while we split it into words
     3025     and unquote it.  Set up in case we need to prepend a dash later.  */
     3026  buf = alloca (1 + len + 1);
     3027  buf[0] = '-';
     3028  p = buf+1;
    27083029  argv[argc] = p;
    27093030  while (*value != '\0')
    27103031    {
    27113032      if (*value == '\\' && value[1] != '\0')
    2712         ++value;                /* Skip the backslash.  */
    2713       else if (isblank ((unsigned char)*value))
    2714         {
    2715           /* End of the word.  */
    2716           *p++ = '\0';
    2717           argv[++argc] = p;
    2718           do
    2719             ++value;
    2720           while (isblank ((unsigned char)*value));
    2721           continue;
    2722         }
     3033        ++value;                /* Skip the backslash.  */
     3034      else if (ISBLANK (*value))
     3035        {
     3036          /* End of the word.  */
     3037          *p++ = '\0';
     3038          argv[++argc] = p;
     3039          do
     3040            ++value;
     3041          while (ISBLANK (*value));
     3042          continue;
     3043        }
    27233044      *p++ = *value++;
    27243045    }
    27253046  *p = '\0';
    27263047  argv[++argc] = 0;
     3048  assert (p < buf + len + 2);
    27273049
    27283050  if (argv[1][0] != '-' && strchr (argv[1], '=') == 0)
    27293051    /* The first word doesn't start with a dash and isn't a variable
    2730        definition.  Add a dash and pass it along to decode_switches.  We
    2731        need permanent storage for this in case decode_switches saves
    2732        pointers into the value.  */
    2733     argv[1] = xstrdup (concat (2, "-", argv[1]));
     3052       definition, so add a dash.  */
     3053    argv[1] = buf;
    27343054
    27353055  /* Parse those words.  */
     
    27503070    {
    27513071      if (*in == '$')
    2752         *out++ = '$';
    2753       else if (isblank ((unsigned char)*in) || *in == '\\')
     3072        *out++ = '$';
     3073      else if (ISBLANK (*in) || *in == '\\')
    27543074        *out++ = '\\';
    27553075      *out++ = *in++;
     
    27613081/* Define the MAKEFLAGS and MFLAGS variables to reflect the settings of the
    27623082   command switches.  Include options with args if ALL is nonzero.
    2763    Don't include options with the `no_makefile' flag set if MAKEFILE.  */
    2764 
    2765 static const char *
     3083   Don't include options with the 'no_makefile' flag set if MAKEFILE.  */
     3084
     3085static struct variable *
    27663086define_makeflags (int all, int makefile)
    27673087{
     
    27713091  const struct command_switch *cs;
    27723092  char *flagstring;
    2773   register char *p;
    2774   unsigned int words;
    2775   struct variable *v;
    2776 
    2777   /* We will construct a linked list of `struct flag's describing
     3093  char *p;
     3094
     3095  /* We will construct a linked list of 'struct flag's describing
    27783096     all the flags which need to go in MAKEFLAGS.  Then, once we
    27793097     know how many there are and their lengths, we can put them all
     
    27873105    };
    27883106  struct flag *flags = 0;
     3107  struct flag *last = 0;
    27893108  unsigned int flagslen = 0;
    2790 #define ADD_FLAG(ARG, LEN) \
    2791   do {                                                                        \
    2792     struct flag *new = alloca (sizeof (struct flag));                         \
    2793     new->cs = cs;                                                             \
    2794     new->arg = (ARG);                                                         \
    2795     new->next = flags;                                                        \
    2796     flags = new;                                                              \
    2797     if (new->arg == 0)                                                        \
    2798       ++flagslen;               /* Just a single flag letter.  */             \
    2799     else                                                                      \
    2800       /* " -x foo", plus space to expand "foo".  */                           \
    2801       flagslen += 1 + 1 + 1 + 1 + (3 * (LEN));                                \
    2802     if (!short_option (cs->c))                                                \
     3109#define ADD_FLAG(ARG, LEN) \
     3110  do {                                                                        \
     3111    struct flag *new = alloca (sizeof (struct flag));                         \
     3112    new->cs = cs;                                                             \
     3113    new->arg = (ARG);                                                         \
     3114    new->next = 0;                                                            \
     3115    if (! flags)                                                              \
     3116      flags = new;                                                            \
     3117    else                                                                      \
     3118      last->next = new;                                                       \
     3119    last = new;                                                               \
     3120    if (new->arg == 0)                                                        \
     3121      /* Just a single flag letter: " -x"  */                                 \
     3122      flagslen += 3;                                                          \
     3123    else                                                                      \
     3124      /* " -xfoo", plus space to escape "foo".  */                            \
     3125      flagslen += 1 + 1 + 1 + (3 * (LEN));                                    \
     3126    if (!short_option (cs->c))                                                \
    28033127      /* This switch has no single-letter version, so we use the long.  */    \
    2804       flagslen += 2 + strlen (cs->long_name);                                 \
     3128      flagslen += 2 + strlen (cs->long_name);                                 \
    28053129  } while (0)
    28063130
     
    28083132    if (cs->toenv && (!makefile || !cs->no_makefile))
    28093133      switch (cs->type)
    2810         {
    2811         case ignore:
    2812           break;
    2813 
    2814         case flag:
    2815         case flag_off:
    2816           if (!*(int *) cs->value_ptr == (cs->type == flag_off)
    2817               && (cs->default_value == 0
    2818                   || *(int *) cs->value_ptr != *(int *) cs->default_value))
    2819             ADD_FLAG (0, 0);
    2820           break;
    2821 
    2822         case positive_int:
    2823           if (all)
    2824             {
    2825               if ((cs->default_value != 0
    2826                    && (*(unsigned int *) cs->value_ptr
    2827                        == *(unsigned int *) cs->default_value)))
    2828                 break;
    2829               else if (cs->noarg_value != 0
    2830                        && (*(unsigned int *) cs->value_ptr ==
    2831                            *(unsigned int *) cs->noarg_value))
    2832                 ADD_FLAG ("", 0); /* Optional value omitted; see below.  */
    2833               else if (cs->c == 'j')
    2834                 /* Special case for `-j'.  */
    2835                 ADD_FLAG ("1", 1);
    2836               else
    2837                 {
    2838                   char *buf = alloca (30);
    2839                   sprintf (buf, "%u", *(unsigned int *) cs->value_ptr);
    2840                   ADD_FLAG (buf, strlen (buf));
    2841                 }
    2842             }
    2843           break;
     3134        {
     3135        case ignore:
     3136          break;
     3137
     3138        case flag:
     3139        case flag_off:
     3140          if ((!*(int *) cs->value_ptr) == (cs->type == flag_off)
     3141              && (cs->default_value == 0
     3142                  || *(int *) cs->value_ptr != *(int *) cs->default_value))
     3143            ADD_FLAG (0, 0);
     3144          break;
     3145
     3146        case positive_int:
     3147          if (all)
     3148            {
     3149              if ((cs->default_value != 0
     3150                   && (*(unsigned int *) cs->value_ptr
     3151                       == *(unsigned int *) cs->default_value)))
     3152                break;
     3153              else if (cs->noarg_value != 0
     3154                       && (*(unsigned int *) cs->value_ptr ==
     3155                           *(unsigned int *) cs->noarg_value))
     3156                ADD_FLAG ("", 0); /* Optional value omitted; see below.  */
     3157              else
     3158                {
     3159                  char *buf = alloca (30);
     3160                  sprintf (buf, "%u", *(unsigned int *) cs->value_ptr);
     3161                  ADD_FLAG (buf, strlen (buf));
     3162                }
     3163            }
     3164          break;
    28443165
    28453166#ifndef NO_FLOAT
    2846         case floating:
    2847           if (all)
    2848             {
    2849               if (cs->default_value != 0
    2850                   && (*(double *) cs->value_ptr
    2851                       == *(double *) cs->default_value))
    2852                 break;
    2853               else if (cs->noarg_value != 0
    2854                        && (*(double *) cs->value_ptr
    2855                            == *(double *) cs->noarg_value))
    2856                 ADD_FLAG ("", 0); /* Optional value omitted; see below.  */
    2857               else
    2858                 {
    2859                   char *buf = alloca (100);
    2860                   sprintf (buf, "%g", *(double *) cs->value_ptr);
    2861                   ADD_FLAG (buf, strlen (buf));
    2862                 }
    2863             }
    2864           break;
    2865 #endif
    2866 
    2867         case filename:
    2868         case string:
    2869           if (all)
    2870             {
    2871               struct stringlist *sl = *(struct stringlist **) cs->value_ptr;
    2872               if (sl != 0)
    2873                 {
    2874                   /* Add the elements in reverse order, because all the flags
    2875                      get reversed below; and the order matters for some
    2876                      switches (like -I).  */
    2877                   unsigned int i = sl->idx;
    2878                   while (i-- > 0)
    2879                     ADD_FLAG (sl->list[i], strlen (sl->list[i]));
    2880                 }
    2881             }
    2882           break;
    2883 
    2884         default:
    2885           abort ();
    2886         }
    2887 
    2888   /* Four more for the possible " -- ".  */
    2889   flagslen += 4 + sizeof (posixref) + sizeof (evalref);
    2890 
    2891 #undef  ADD_FLAG
     3167        case floating:
     3168          if (all)
     3169            {
     3170              if (cs->default_value != 0
     3171                  && (*(double *) cs->value_ptr
     3172                      == *(double *) cs->default_value))
     3173                break;
     3174              else if (cs->noarg_value != 0
     3175                       && (*(double *) cs->value_ptr
     3176                           == *(double *) cs->noarg_value))
     3177                ADD_FLAG ("", 0); /* Optional value omitted; see below.  */
     3178              else
     3179                {
     3180                  char *buf = alloca (100);
     3181                  sprintf (buf, "%g", *(double *) cs->value_ptr);
     3182                  ADD_FLAG (buf, strlen (buf));
     3183                }
     3184            }
     3185          break;
     3186#endif
     3187
     3188        case string:
     3189          if (all)
     3190            {
     3191              p = *((char **)cs->value_ptr);
     3192              if (p)
     3193                ADD_FLAG (p, strlen (p));
     3194            }
     3195          break;
     3196
     3197        case filename:
     3198        case strlist:
     3199          if (all)
     3200            {
     3201              struct stringlist *sl = *(struct stringlist **) cs->value_ptr;
     3202              if (sl != 0)
     3203                {
     3204                  unsigned int i;
     3205                  for (i = 0; i < sl->idx; ++i)
     3206                    ADD_FLAG (sl->list[i], strlen (sl->list[i]));
     3207                }
     3208            }
     3209          break;
     3210
     3211        default:
     3212          abort ();
     3213        }
     3214
     3215#undef  ADD_FLAG
     3216
     3217  /* Four more for the possible " -- ", plus variable references.  */
     3218  flagslen += 4 + CSTRLEN (posixref) + 1 + CSTRLEN (evalref) + 1;
    28923219
    28933220  /* Construct the value in FLAGSTRING.
     
    28963223  memset (flagstring, '\0', 1 + flagslen + 1);
    28973224  p = flagstring;
    2898   words = 1;
     3225
     3226  /* Start with a dash, for MFLAGS.  */
    28993227  *p++ = '-';
    2900   while (flags != 0)
    2901     {
     3228
     3229  /* Add simple options as a group.  */
     3230  while (flags != 0 && !flags->arg && short_option (flags->cs->c))
     3231    {
     3232      *p++ = flags->cs->c;
     3233      flags = flags->next;
     3234    }
     3235
     3236  /* Now add more complex flags: ones with options and/or long names.  */
     3237  while (flags)
     3238    {
     3239      *p++ = ' ';
     3240      *p++ = '-';
     3241
    29023242      /* Add the flag letter or name to the string.  */
    29033243      if (short_option (flags->cs->c))
    2904         *p++ = flags->cs->c;
     3244        *p++ = flags->cs->c;
    29053245      else
    2906         {
    2907           if (*p != '-')
    2908             {
    2909               *p++ = ' ';
    2910               *p++ = '-';
    2911             }
    2912           *p++ = '-';
    2913           strcpy (p, flags->cs->long_name);
    2914           p += strlen (p);
    2915         }
    2916       if (flags->arg != 0)
    2917         {
    2918           /* A flag that takes an optional argument which in this case is
    2919              omitted is specified by ARG being "".  We must distinguish
    2920              because a following flag appended without an intervening " -"
    2921              is considered the arg for the first.  */
    2922           if (flags->arg[0] != '\0')
    2923             {
    2924               /* Add its argument too.  */
    2925               *p++ = !short_option (flags->cs->c) ? '=' : ' ';
    2926               p = quote_for_env (p, flags->arg);
    2927             }
    2928           ++words;
    2929           /* Write a following space and dash, for the next flag.  */
    2930           *p++ = ' ';
    2931           *p++ = '-';
    2932         }
    2933       else if (!short_option (flags->cs->c))
    2934         {
    2935           ++words;
    2936           /* Long options must each go in their own word,
    2937              so we write the following space and dash.  */
    2938           *p++ = ' ';
    2939           *p++ = '-';
    2940         }
     3246        {
     3247          /* Long options require a double-dash.  */
     3248          *p++ = '-';
     3249          strcpy (p, flags->cs->long_name);
     3250          p += strlen (p);
     3251        }
     3252      /* An omitted optional argument has an ARG of "".  */
     3253      if (flags->arg && flags->arg[0] != '\0')
     3254        {
     3255          if (!short_option (flags->cs->c))
     3256            /* Long options require '='.  */
     3257            *p++ = '=';
     3258          p = quote_for_env (p, flags->arg);
     3259        }
    29413260      flags = flags->next;
    29423261    }
    29433262
    2944   /* Define MFLAGS before appending variable definitions.  */
    2945 
     3263  /* If no flags at all, get rid of the initial dash.  */
    29463264  if (p == &flagstring[1])
    2947     /* No flags.  */
    2948     flagstring[0] = '\0';
    2949   else if (p[-1] == '-')
    2950     {
    2951       /* Kill the final space and dash.  */
    2952       p -= 2;
    2953       *p = '\0';
    2954     }
    2955   else
    2956     /* Terminate the string.  */
    2957     *p = '\0';
    2958 
    2959   /* Since MFLAGS is not parsed for flags, there is no reason to
     3265    {
     3266      flagstring[0] = '\0';
     3267      p = flagstring;
     3268    }
     3269
     3270  /* Define MFLAGS before appending variable definitions.  Omit an initial
     3271     empty dash.  Since MFLAGS is not parsed for flags, there is no reason to
    29603272     override any makefile redefinition.  */
    2961   define_variable_cname ("MFLAGS", flagstring, o_env, 1);
     3273  define_variable_cname ("MFLAGS",
     3274                         flagstring + (flagstring[0] == '-' && flagstring[1] == ' ' ? 2 : 0),
     3275                         o_env, 1);
    29623276
    29633277  /* Write a reference to -*-eval-flags-*-, which contains all the --eval
     
    29653279  if (eval_strings)
    29663280    {
    2967       if (p == &flagstring[1])
    2968         /* No flags written, so elide the leading dash already written.  */
    2969         p = flagstring;
    2970       else
    2971         *p++ = ' ';
    2972       memcpy (p, evalref, sizeof (evalref) - 1);
    2973       p += sizeof (evalref) - 1;
    2974     }
    2975 
    2976   if (all && command_variables != 0)
    2977     {
    2978       /* Now write a reference to $(MAKEOVERRIDES), which contains all the
    2979          command-line variable definitions.  */
    2980 
    2981       if (p == &flagstring[1])
    2982         /* No flags written, so elide the leading dash already written.  */
    2983         p = flagstring;
    2984       else
    2985         {
    2986           /* Separate the variables from the switches with a "--" arg.  */
    2987           if (p[-1] != '-')
    2988             {
    2989               /* We did not already write a trailing " -".  */
    2990               *p++ = ' ';
    2991               *p++ = '-';
    2992             }
    2993           /* There is a trailing " -"; fill it out to " -- ".  */
    2994           *p++ = '-';
    2995           *p++ = ' ';
    2996         }
     3281      *p++ = ' ';
     3282      memcpy (p, evalref, CSTRLEN (evalref));
     3283      p += CSTRLEN (evalref);
     3284    }
     3285
     3286  if (all && command_variables)
     3287    {
     3288      /* Write a reference to $(MAKEOVERRIDES), which contains all the
     3289         command-line variable definitions.  Separate the variables from the
     3290         switches with a "--" arg.  */
     3291
     3292      strcpy (p, " -- ");
     3293      p += 4;
    29973294
    29983295      /* Copy in the string.  */
    29993296      if (posix_pedantic)
    3000         {
    3001           memcpy (p, posixref, sizeof (posixref) - 1);
    3002           p += sizeof (posixref) - 1;
    3003         }
     3297        {
     3298          memcpy (p, posixref, CSTRLEN (posixref));
     3299          p += CSTRLEN (posixref);
     3300        }
    30043301      else
    3005         {
    3006           memcpy (p, ref, sizeof (ref) - 1);
    3007           p += sizeof (ref) - 1;
    3008         }
    3009     }
    3010   else if (p == &flagstring[1])
    3011     {
    3012       words = 0;
    3013       --p;
    3014     }
    3015   else if (p[-1] == '-')
    3016     /* Kill the final space and dash.  */
    3017     p -= 2;
    3018   /* Terminate the string.  */
    3019   *p = '\0';
    3020 
    3021   /* If there are switches, omit the leading dash unless it is a single long
    3022      option with two leading dashes.  */
    3023   if (flagstring[0] == '-' && flagstring[1] != '-')
     3302        {
     3303          memcpy (p, ref, CSTRLEN (ref));
     3304          p += CSTRLEN (ref);
     3305        }
     3306    }
     3307
     3308  /* If there is a leading dash, omit it.  */
     3309  if (flagstring[0] == '-')
    30243310    ++flagstring;
    30253311
    3026   v = define_variable_cname ("MAKEFLAGS", flagstring,
    3027                              /* This used to use o_env, but that lost when a
    3028                                 makefile defined MAKEFLAGS.  Makefiles set
    3029                                 MAKEFLAGS to add switches, but we still want
    3030                                 to redefine its value with the full set of
    3031                                 switches.  Of course, an override or command
    3032                                 definition will still take precedence.  */
    3033                              o_file, 1);
    3034 
    3035   if (! all)
    3036     /* The first time we are called, set MAKEFLAGS to always be exported.
    3037        We should not do this again on the second call, because that is
    3038        after reading makefiles which might have done `unexport MAKEFLAGS'. */
    3039     v->export = v_export;
    3040 
    3041   return v->value;
     3312  /* This used to use o_env, but that lost when a makefile defined MAKEFLAGS.
     3313     Makefiles set MAKEFLAGS to add switches, but we still want to redefine
     3314     its value with the full set of switches.  Then we used o_file, but that
     3315     lost when users added -e, causing a previous MAKEFLAGS env. var. to take
     3316     precedence over the new one.  Of course, an override or command
     3317     definition will still take precedence.  */
     3318  return define_variable_cname ("MAKEFLAGS", flagstring,
     3319                                env_overrides ? o_env_override : o_file, 1);
    30423320}
    30433321
     
    30503328  static int printed_version = 0;
    30513329
    3052   char *precede = print_data_base_flag ? "# " : "";
     3330  const char *precede = print_data_base_flag ? "# " : "";
    30533331
    30543332  if (printed_version)
     
    30673345     (C) to the copyright symbol, but this string is going to change every
    30683346     year, and none of the rest of it should be translated (including the
    3069      word "Copyright", so it hardly seems worth it.  */
    3070 
    3071   printf ("%sCopyright (C) 2010  Free Software Foundation, Inc.\n", precede);
     3347     word "Copyright"), so it hardly seems worth it.  */
     3348
     3349  printf ("%sCopyright (C) 1988-2016 Free Software Foundation, Inc.\n",
     3350          precede);
    30723351
    30733352  printf (_("%sLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
     
    30793358
    30803359  /* Flush stdout so the user doesn't have to wait to see the
    3081      version information while things are thought about.  */
     3360     version information while make thinks about things.  */
    30823361  fflush (stdout);
    30833362}
     
    30863365
    30873366static void
    3088 print_data_base ()
     3367print_data_base (void)
    30893368{
    3090   time_t when;
    3091 
    3092   when = time ((time_t *) 0);
     3369  time_t when = time ((time_t *) 0);
     3370
     3371  print_version ();
     3372
    30933373  printf (_("\n# Make data base, printed on %s"), ctime (&when));
    30943374
     
    31073387clean_jobserver (int status)
    31083388{
    3109   char token = '+';
    3110 
    31113389  /* Sanity: have we written all our jobserver tokens back?  If our
    31123390     exit status is 2 that means some kind of syntax error; we might not
     
    31143392     after any other error code, that's bad.  */
    31153393
    3116   if (job_fds[0] != -1 && jobserver_tokens)
     3394  if (jobserver_enabled() && jobserver_tokens)
    31173395    {
    31183396      if (status != 2)
    3119         error (NILF,
    3120                "INTERNAL: Exiting with %u jobserver tokens (should be 0)!",
    3121                jobserver_tokens);
     3397        ON (error, NILF,
     3398            "INTERNAL: Exiting with %u jobserver tokens (should be 0)!",
     3399            jobserver_tokens);
    31223400      else
    3123         while (jobserver_tokens--)
    3124           {
    3125             int r;
    3126 
    3127             EINTRLOOP (r, write (job_fds[1], &token, 1));
    3128             if (r != 1)
    3129               perror_with_name ("write", "");
    3130           }
     3401        /* Don't write back the "free" token */
     3402        while (--jobserver_tokens)
     3403          jobserver_release (0);
    31313404    }
    31323405
     
    31373410    {
    31383411      /* We didn't write one for ourself, so start at 1.  */
    3139       unsigned int tcnt = 1;
    3140 
    3141       /* Close the write side, so the read() won't hang.  */
    3142       close (job_fds[1]);
    3143 
    3144       while (read (job_fds[0], &token, 1) == 1)
    3145         ++tcnt;
    3146 
    3147       if (tcnt != master_job_slots)
    3148         error (NILF,
    3149                "INTERNAL: Exiting with %u jobserver tokens available; should be %u!",
    3150                tcnt, master_job_slots);
    3151 
    3152       close (job_fds[0]);
    3153 
    3154       /* Clean out jobserver_fds so we don't pass this information to any
    3155          sub-makes.  Also reset job_slots since it will be put on the command
    3156          line, not in MAKEFLAGS.  */
    3157       job_slots = default_job_slots;
    3158       if (jobserver_fds)
    3159         {
    3160           /* MSVC erroneously warns without a cast here.  */
    3161           free ((void *)jobserver_fds->list);
    3162           free (jobserver_fds);
    3163           jobserver_fds = 0;
    3164         }
     3412      unsigned int tokens = 1 + jobserver_acquire_all ();
     3413
     3414      if (tokens != master_job_slots)
     3415        ONN (error, NILF,
     3416             "INTERNAL: Exiting with %u jobserver tokens available; should be %u!",
     3417             tokens, master_job_slots);
     3418
     3419      reset_jobserver ();
    31653420    }
    31663421}
     
    31813436
    31823437      if (print_version_flag)
    3183         print_version ();
     3438        print_version ();
    31843439
    31853440      /* Wait for children to die.  */
    31863441      err = (status != 0);
    31873442      while (job_slots_used > 0)
    3188         reap_children (1, err);
     3443        reap_children (1, err);
    31893444
    31903445      /* Let the remote job module clean up its state.  */
     
    31953450
    31963451      if (print_data_base_flag)
    3197         print_data_base ();
    3198 
    3199       verify_file_data_base ();
     3452        print_data_base ();
     3453
     3454      if (verify_flag)
     3455        verify_file_data_base ();
    32003456
    32013457      clean_jobserver (status);
    32023458
     3459      if (output_context)
     3460        {
     3461          /* die() might be called in a recipe output context due to an
     3462             $(error ...) function.  */
     3463          output_close (output_context);
     3464
     3465          if (output_context != &make_sync)
     3466            output_close (&make_sync);
     3467
     3468          OUTPUT_UNSET ();
     3469        }
     3470
     3471      output_close (NULL);
     3472
    32033473      /* Try to move back to the original directory.  This is essential on
    3204         MS-DOS (where there is really only one process), and on Unix it
    3205         puts core files in the original directory instead of the -C
    3206         directory.  Must wait until after remove_intermediates(), or unlinks
     3474        MS-DOS (where there is really only one process), and on Unix it
     3475        puts core files in the original directory instead of the -C
     3476        directory.  Must wait until after remove_intermediates(), or unlinks
    32073477         of relative pathnames fail.  */
    32083478      if (directory_before_chdir != 0)
    32093479        {
    32103480          /* If it fails we don't care: shut up GCC.  */
    3211           int _x;
     3481          int _x UNUSED;
    32123482          _x = chdir (directory_before_chdir);
    32133483        }
    3214 
    3215       log_working_directory (0);
    32163484    }
    32173485
    32183486  exit (status);
    32193487}
    3220 
    3221 
    3222 /* Write a message indicating that we've just entered or
    3223    left (according to ENTERING) the current directory.  */
    3224 
    3225 void
    3226 log_working_directory (int entering)
    3227 {
    3228   static int entered = 0;
    3229 
    3230   /* Print nothing without the flag.  Don't print the entering message
    3231      again if we already have.  Don't print the leaving message if we
    3232      haven't printed the entering message.  */
    3233   if (! print_directory_flag || entering == entered)
    3234     return;
    3235 
    3236   entered = entering;
    3237 
    3238   if (print_data_base_flag)
    3239     fputs ("# ", stdout);
    3240 
    3241   /* Use entire sentences to give the translators a fighting chance.  */
    3242 
    3243   if (makelevel == 0)
    3244     if (starting_directory == 0)
    3245       if (entering)
    3246         printf (_("%s: Entering an unknown directory\n"), program);
    3247       else
    3248         printf (_("%s: Leaving an unknown directory\n"), program);
    3249     else
    3250       if (entering)
    3251         printf (_("%s: Entering directory `%s'\n"),
    3252                 program, starting_directory);
    3253       else
    3254         printf (_("%s: Leaving directory `%s'\n"),
    3255                 program, starting_directory);
    3256   else
    3257     if (starting_directory == 0)
    3258       if (entering)
    3259         printf (_("%s[%u]: Entering an unknown directory\n"),
    3260                 program, makelevel);
    3261       else
    3262         printf (_("%s[%u]: Leaving an unknown directory\n"),
    3263                 program, makelevel);
    3264     else
    3265       if (entering)
    3266         printf (_("%s[%u]: Entering directory `%s'\n"),
    3267                 program, makelevel, starting_directory);
    3268       else
    3269         printf (_("%s[%u]: Leaving directory `%s'\n"),
    3270                 program, makelevel, starting_directory);
    3271 
    3272   /* Flush stdout to be sure this comes before any stderr output.  */
    3273   fflush (stdout);
    3274 }
  • vendor/gnumake/current/maintMakefile

    r2596 r3138  
    11# Maintainer-only makefile segment.  This contains things that are relevant
    2 # only if you have the full copy of the GNU make sources from the CVS
     2# only if you have the full copy of the GNU make sources from the Git
    33# tree, not a dist copy.
    44
     5BUGLIST := bug-make@gnu.org
     6
     7# These are related to my personal setup.
     8GPG_FINGERPRINT := 6338B6D4
     9
     10# SRCROOTDIR is just a handy location to keep source files in
     11SRCROOTDIR ?= $(HOME)/src
     12
     13# Where the gnulib project has been locally cloned
     14GNULIBDIR ?= $(SRCROOTDIR)/gnulib
     15
     16# Where to put the CVS checkout of the GNU web repository
     17GNUWEBDIR ?= $(SRCROOTDIR)/gnu-www
     18
     19# Where to put the CVS checkout of the GNU make web repository
     20MAKEWEBDIR ?= $(SRCROOTDIR)/make/make-web
     21
    522# We like mondo-warnings!
    6 AM_CFLAGS += -Wall -Wextra -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast
     23AM_CFLAGS += -Wall -Wwrite-strings -Wextra -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast
     24
     25MAKE_MAINTAINER_MODE := -DMAKE_MAINTAINER_MODE
     26AM_CPPFLAGS += $(MAKE_MAINTAINER_MODE)
    727
    828# I want this one but I have to wait for the const cleanup!
     
    1939# These are built as a side-effect of the dist rule
    2040#all-am: $(TEMPLATES) $(MTEMPLATES) build.sh.in
     41
     42# Create preprocessor output files--GCC specific!
     43%.i : %.c
     44        $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -E -dD -o $@ $<
    2145
    2246# General rule for turning a .template into a regular file.
     
    81105         done) > $@
    82106
    83 # Get rid of everything "else".
    84 #
    85 maintFILES = configure aclocal.m4 config.h.in Makefile.in stamp-h.in
    86 
    87 CVS-CLEAN-FILES +=      $(maintFILES) $(TEMPLATES) $(MTEMPLATES) NMakefile \
    88                         build.sh.in .deps .dep_segment ABOUT-NLS \
    89                         ansi2knr.*
    90 
    91 # This rule tries to clean the tree right down to how it looks when you do a
    92 # virgin CVS checkout.
    93 
    94 # This target is potentially dangerous since it removes _ANY FILE_ that
    95 # is not in CVS.  Including files you might mean to add to CVS but
    96 # haven't yet...  I only use this in subdirectories where it's unlikely
    97 # we have any new files.  Still... be careful!!
    98 
    99 cvsclean = $(PERL) -e '$$k{CVS} = 1; open(E,"< CVS/Entries") || die "CVS/Entries: $$!\n"; while (defined ($$_ = <E>)) { m%^/([^/]*)% or next; $$k{$$1} = 1; } close(E) || die "CVS/Entries: $$!\n"; opendir(D, ".") || die ".: $$!\n"; while (defined ($$_ = readdir(D))) { -f $$_ && ! exists $$k{$$_} && unlink($$_); } closedir(D) || die ".: $$!\n";'
    100 
    101 .PHONY: cvs-clean
    102 cvs-clean: maintainer-clean
    103         -rm -rf *~ $(CVS-CLEAN-FILES)
    104         -cd config && $(cvsclean)
    105         -cd po     && $(cvsclean)
    106         -cd doc    && $(cvsclean)
    107         -cd glob   && $(cvsclean)
    108 
    109 
    110 # ----------------------------------------------------------------------
    111 #
    112 # The sections below were stolen from the Makefile.maint used by fileutils,
    113 # sh-utils, textutils, CPPI, Bison, and Autoconf.
     107# Cleaning
     108
     109GIT :=  git
     110
     111# git-clean:      Clean all "ignored" files.  Leave untracked files.
     112# git-very-clean: Clean all files that aren't stored in source control.
     113
     114.PHONY: git-clean git-very-clean
     115git-clean:
     116        -$(GIT) clean -fdX
     117git-very-clean: git-clean
     118        -$(GIT) clean -fd
     119
     120
     121
     122## ---------------------- ##
     123## Generating ChangeLog.  ##
     124## ---------------------- ##
     125
     126gl2cl-date := 2013-10-10
     127gl2cl := $(GNULIBDIR)/build-aux/gitlog-to-changelog
     128
     129# Rebuild the changelog whenever a new commit is added
     130ChangeLog: .check-git-HEAD
     131        if test -f '$(gl2cl)'; then \
     132            '$(gl2cl)' --since='$(gl2cl-date)' > '$@'; \
     133        else \
     134            echo "WARNING: $(gl2cl) is not available.  No $@ generated."; \
     135        fi
     136
     137.PHONY: .check-git-HEAD
     138.check-git-HEAD:
     139        sha="`git rev-parse HEAD`"; \
     140        [ -f '$@' ] && [ "`cat '$@' 2>/dev/null`" = "$$sha" ] \
     141            || echo "$$sha" > '$@'
    114142
    115143
     
    117145## Updating files.  ##
    118146## ---------------- ##
    119 
    120 WGET = wget --passive-ftp -nv
     147RSYNC = rsync -Lrtvz
     148WGET = wget --passive-ftp -np -nv
    121149ftp-gnu = ftp://ftp.gnu.org/gnu
    122150
     
    124152                    echo $(target) is unchanged; rm -f $(target).t; \
    125153                  else \
    126                     mv $(target).t $(target); \
     154                    mv -f $(target).t $(target); \
    127155                  fi
    128156
     
    136164#   ftp://tiger.informatik.hu-berlin.de/pub/po/maint/
    137165
     166po_wget_flags = --recursive --level=1 --no-directories --no-check-certificate
    138167po_repo = http://translationproject.org/latest/$(PACKAGE)
     168po_sync = translationproject.org::tp/latest/$(PACKAGE)/
     169
    139170.PHONY: do-po-update po-update
    140171do-po-update:
     
    142173          && rm -rf "$$tmppo" \
    143174          && mkdir "$$tmppo" \
    144           && (cd "$$tmppo" \
    145                 && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) \
    146           && cp "$$tmppo"/*.po $(top_srcdir)/po && rm -rf "$$tmppo"
     175          && $(RSYNC) $(po_sync) "$$tmppo" \
     176          && cp "$$tmppo"/*.po $(top_srcdir)/po \
     177          && rm -rf "$$tmppo"
    147178        cd po && $(MAKE) update-po
    148179        $(MAKE) po-check
     
    193224
    194225
     226# ---------------------------------- #
     227# Alternative configuration checks.  #
     228# ---------------------------------- #
     229
     230.PHONY: check-alt-config
     231check-alt-config: \
     232        checkcfg.--disable-job-server \
     233        checkcfg.--disable-load \
     234        checkcfg.--without-guile \
     235        checkcfg.CPPFLAGS^-DNO_OUTPUT_SYNC \
     236        checkcfg.CPPFLAGS^-DNO_ARCHIVES
     237
     238# Trick GNU make so it doesn't run the submake as a recursive make.
     239NR_MAKE = $(MAKE)
     240
     241# Check builds both with build.sh and with make
     242checkcfg.%: distdir
     243        @echo "Building $@ (output in checkcfg.$*.log)"
     244        @exec >'checkcfg.$*.log' 2>&1; \
     245           rm -rf $(distdir)/_build \
     246        && mkdir $(distdir)/_build \
     247        && cd $(distdir)/_build \
     248        && echo "Testing configure with $(subst ^,=,$*)" \
     249        && ../configure --srcdir=.. $(subst ^,=,$*) \
     250                $(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS) \
     251                CFLAGS='$(AM_CFLAGS)' \
     252        && ./build.sh \
     253        && ./make $(AM_MAKEFLAGS) check \
     254        && rm -f *.o make \
     255        && $(NR_MAKE) $(AM_MAKEFLAGS) \
     256        && ./make $(AM_MAKEFLAGS) check
     257
     258
    195259## --------------- ##
    196260## Sanity checks.  ##
    197261## --------------- ##
    198262
    199 # Checks that don't require cvs.  Run `changelog-check' last as
     263# Before we build a distribution be sure we run our local checks
     264#distdir: local-check
     265
     266.PHONY: local-check po-check changelog-check
     267
     268# Checks that don't require Git.  Run 'changelog-check' last as
    200269# previous test may reveal problems requiring new ChangeLog entries.
    201270local-check: po-check changelog-check
     
    212281
    213282# Verify that all source files using _() are listed in po/POTFILES.in.
    214 # Ignore make.h; it defines _().
     283# Ignore makeint.h; it defines _().
    215284po-check:
    216285        if test -f po/POTFILES.in; then \
    217286          grep '^[^#]' po/POTFILES.in | sort > $@-1; \
    218           $(PERL) -wn -e 'if (/\b_\(/) { $$ARGV eq "make.h" || print "$$ARGV\n" and close ARGV }' *.c *.h | sort > $@-2; \
     287          $(PERL) -wn -e 'if (/\b_\(/) { $$ARGV eq "./makeint.h" || print "$$ARGV\n" and close ARGV }' `find . -name '*.[ch]'` | sed 's,^\./,,' | sort > $@-2; \
    219288          diff -u $@-1 $@-2 || exit 1; \
    220289          rm -f $@-1 $@-2; \
    221290        fi
    222291
     292
     293## --------------- ##
     294## Generate docs.  ##
     295## --------------- ##
     296
     297.PHONY: update-makeweb gendocs
     298
     299CVS = cvs
     300
     301makeweb-repo = $(USER)@cvs.sv.gnu.org:/web/make
     302gnuweb-repo = :pserver:anonymous@cvs.sv.gnu.org:/web/www
     303gnuweb-dir = www/server/standards
     304
     305# Get the GNU make web page boilerplate etc.
     306update-makeweb:
     307        [ -d '$(MAKEWEBDIR)' ] || mkdir -p '$(MAKEWEBDIR)'
     308        [ -d '$(MAKEWEBDIR)'/CVS ] \
     309            && { cd '$(MAKEWEBDIR)' && $(CVS) update; } \
     310            || { mkdir -p '$(dir $(MAKEWEBDIR))' && cd '$(dir $(MAKEWEBDIR))' \
     311                 && $(CVS) -d $(makeweb-repo) co -d '$(notdir $(MAKEWEBDIR))' make; }
     312
     313# Get the GNU web page boilerplate etc.
     314update-gnuweb:
     315        [ -d '$(GNUWEBDIR)' ] || mkdir -p '$(GNUWEBDIR)'
     316        [ -d '$(GNUWEBDIR)/$(gnuweb-dir)'/CVS ] \
     317            && { cd '$(GNUWEBDIR)/$(gnuweb-dir)' && $(CVS) update; } \
     318            || { cd '$(GNUWEBDIR)' && $(CVS) -d $(gnuweb-repo) co '$(gnuweb-dir)'; }
     319
     320gendocs: update-gnuweb update-makeweb
     321        cp $(GNULIBDIR)/doc/gendocs_template doc
     322        cd doc \
     323          && rm -rf doc/manual \
     324          && $(GNULIBDIR)/build-aux/gendocs.sh --email '$(BUGLIST)' \
     325                make 'GNU Make Manual'
     326        find '$(MAKEWEBDIR)'/manual \( -name CVS -prune \) -o \( -name '[!.]*' -type f -exec rm -f '{}' \; \)
     327        cp -r doc/manual '$(MAKEWEBDIR)'
     328        @echo 'Status of $(MAKEWEBDIR) repo:' && cd '$(MAKEWEBDIR)' \
     329            && cvs -q -n update | grep -v '^M ' \
     330            && echo '- cvs add <new files>' \
     331            && echo '- cvs remove <deleted files>' \
     332            && echo '- cvs commit' \
     333            && echo '- cvs tag make-$(subst .,-,$(VERSION))'
     334
     335## ------------------------- ##
     336## Make release targets.     ##
     337## ------------------------- ##
     338
     339.PHONY: tag-release
     340tag-release:
     341        case '$(VERSION)' in \
     342            (*.*.9*) message=" candidate" ;; \
     343            (*)      message= ;; \
     344        esac; \
     345        $(GIT) tag -m "GNU Make release$$message $(VERSION)" -u '$(GPG_FINGERPRINT)' '$(VERSION)'
     346
    223347## ------------------------- ##
    224348## GNU FTP upload artifacts. ##
     
    230354
    231355GPG = gpg
    232 GPGFLAGS = -u 6338B6D4
     356GPGFLAGS = -u $(GPG_FINGERPRINT)
    233357
    234358DIST_ARCHIVES_SIG = $(addsuffix .sig,$(DIST_ARCHIVES))
     
    267391
    268392
    269 # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    270 # 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     393# Rebuild Makefile.in if this file is modifed.
     394Makefile.in: maintMakefile
     395
     396# Copyright (C) 1997-2016 Free Software Foundation, Inc.
    271397# This file is part of GNU Make.
    272398#
  • vendor/gnumake/current/make.1

    r2596 r3138  
    1 .TH MAKE 1 "22 August 1989" "GNU" "LOCAL USER COMMANDS"
     1.TH MAKE 1 "28 February 2016" "GNU" "User Commands"
    22.SH NAME
    33make \- GNU make utility to maintain groups of programs
    44.SH SYNOPSIS
    5 .B "make "
    6 [
    7 .B \-f
    8 .I makefile
    9 ] [ options ] ... [ targets ] ...
    10 .SH WARNING
    11 This man page is an extract of the documentation of GNU
    12 .IR make .
    13 It is updated only occasionally, because the GNU project does not use nroff.
    14 For complete, current documentation, refer to the Info file
    15 .B make.info
    16 which is made from the Texinfo source file
    17 .BR make.texi .
     5.B make
     6[\fIOPTION\fR]... [\fITARGET\fR]...
    187.SH DESCRIPTION
    198.LP
    20 The purpose of the
     9The
    2110.I make
    22 utility is to determine automatically which
    23 pieces of a large program need to be recompiled, and issue the commands to
    24 recompile them.
    25 The manual describes the GNU implementation of
    26 .IR make ,
    27 which was written by Richard Stallman and Roland McGrath, and is
    28 currently maintained by Paul Smith.
    29 Our examples show C programs, since they are most common, but you can use
    30 .I make
    31 with any programming language whose compiler can be run with a
    32 shell command.
     11utility will determine automatically which pieces of a large program need to
     12be recompiled, and issue the commands to recompile them.  The manual describes
     13the GNU implementation of
     14.BR make ,
     15which was written by Richard Stallman and Roland McGrath, and is currently
     16maintained by Paul Smith.  Our examples show C programs, since they are very
     17common, but you can use
     18.B make
     19with any programming language whose compiler can be run with a shell command.
    3320In fact,
    34 .I make
    35 is not limited to programs.
    36 You can use it to describe any task where some files must be
    37 updated automatically from others whenever the others change.
     21.B make
     22is not limited to programs.  You can use it to describe any task where some
     23files must be updated automatically from others whenever the others change.
    3824.LP
    3925To prepare to use
    40 .IR make ,
     26.BR make ,
    4127you must write a file called the
    4228.I makefile
    43 that describes the relationships among files in your program, and the
    44 states the commands for updating each file.
    45 In a program, typically the executable file is updated from object
    46 files, which are in turn made by compiling source files.
     29that describes the relationships among files in your program, and the states
     30the commands for updating each file.  In a program, typically the executable
     31file is updated from object files, which are in turn made by compiling source
     32files.
    4733.LP
    4834Once a suitable makefile exists, each time you change some source files,
     
    5541suffices to perform all necessary recompilations.
    5642The
    57 .I make
    58 program uses the makefile data base and the last-modification times
    59 of the files to decide which of the files need to be updated.
    60 For each of those files, it issues the commands recorded in the data base.
    61 .LP
    62 .I make
     43.B make
     44program uses the makefile description and the last-modification times of the
     45files to decide which of the files need to be updated.  For each of those
     46files, it issues the commands recorded in the makefile.
     47.LP
     48.B make
    6349executes commands in the
    6450.I makefile
    65 to update
    66 one or more target
     51to update one or more target
    6752.IR names ,
    6853where
     
    7257.B \-f
    7358option is present,
    74 .I make
     59.B make
    7560will look for the makefiles
    7661.IR GNUmakefile ,
     
    9176The first name checked,
    9277.IR GNUmakefile ,
    93 is not recommended for most makefiles.
    94 You should use this name if you have a makefile that is specific to GNU
    95 .IR make ,
     78is not recommended for most makefiles.  You should use this name if you have a
     79makefile that is specific to GNU
     80.BR make ,
    9681and will not be understood by other versions of
    97 .IR make .
     82.BR make .
    9883If
    9984.I makefile
    100 is `\-', the standard input is read.
    101 .LP
    102 .I make
     85is '\-', the standard input is read.
     86.LP
     87.B make
    10388updates a target if it depends on prerequisite files
    10489that have been modified since the target was last modified,
     
    10792.sp 1
    10893.TP 0.5i
    109 .BR \-b , " \-m"
     94\fB\-b\fR, \fB\-m\fR
    11095These options are ignored for compatibility with other versions of
    111 .IR make .
    112 .TP 0.5i
    113 .BR \-B , " \-\-always\-make"
     96.BR make .
     97.TP 0.5i
     98\fB\-B\fR, \fB\-\-always\-make\fR
    11499Unconditionally make all targets.
    115100.TP 0.5i
     
    127112.BR "\-C " /etc.
    128113This is typically used with recursive invocations of
    129 .IR make .
     114.BR make .
    130115.TP 0.5i
    131116.B \-d
     
    135120which files actually need to be remade, which implicit rules are
    136121considered and which are applied---everything interesting about how
    137 .I make
     122.B make
    138123decides what to do.
    139124.TP 0.5i
     
    159144for details on invocation of commands, and
    160145.I m
    161 for debugging while remaking makefiles.
    162 .TP 0.5i
    163 .BR \-e , " \-\-environment\-overrides"
     146for debugging while remaking makefiles.  Use
     147.I n
     148to disable all previous debugging flags.
     149.TP 0.5i
     150\fB\-e\fR, \fB\-\-environment\-overrides\fR
    164151Give variables taken from the environment precedence
    165152over variables from makefiles.
     
    170157as a makefile.
    171158.TP 0.5i
    172 .BR \-i , " \-\-ignore\-errors"
     159\fB\-i\fR, \fB\-\-ignore\-errors\fR
    173160Ignore all errors in commands executed to remake files.
    174161.TP 0.5i
     
    182169searched in the order specified.
    183170Unlike the arguments to other flags of
    184 .IR make ,
     171.BR make ,
    185172directories given with
    186173.B \-I
     
    188175.BI \-I dir
    189176is allowed, as well as
    190 .BI "\-I " dir.
     177.B \-I
     178.IR dir .
    191179This syntax is allowed for compatibility with the C
    192180preprocessor's
     
    204192.B \-j
    205193option is given without an argument,
    206 .IR make
     194.BR make
    207195will not limit the number of jobs that can run simultaneously.
    208196.TP 0.5i
    209 .BR \-k , " \-\-keep\-going"
     197\fB\-k\fR, \fB\-\-keep\-going\fR
    210198Continue as much as possible after an error.
    211199While the target that failed, and those that depend on it, cannot
     
    220208With no argument, removes a previous load limit.
    221209.TP 0.5i
    222 .BR \-L , " \-\-check\-symlink\-times"
     210\fB\-L\fR, \fB\-\-check\-symlink\-times\fR
    223211Use the latest mtime between symlinks and target.
    224212.TP 0.5i
    225 .BR \-n , " \-\-just\-print" , " \-\-dry\-run" , " \-\-recon"
     213\fB\-n\fR, \fB\-\-just\-print\fR, \fB\-\-dry\-run\fR, \fB\-\-recon\fR
    226214Print the commands that would be executed, but do not execute them (except in
    227215certain circumstances).
     
    235223Essentially the file is treated as very old and its rules are ignored.
    236224.TP 0.5i
    237 .BR \-p , " \-\-print\-data\-base"
     225\fB\-O\fR[\fItype\fR], \fB\-\-output\-sync\fR[=\fItype\fR]
     226When running multiple jobs in parallel with \fB-j\fR, ensure the output of
     227each job is collected together rather than interspersed with output from
     228other jobs.  If
     229.I type
     230is not specified or is
     231.B target
     232the output from the entire recipe for each target is grouped together.  If
     233.I type
     234is
     235.B line
     236the output from each command line within a recipe is grouped together.
     237If
     238.I type
     239is
     240.B recurse
     241output from an entire recursive make is grouped together.  If
     242.I type
     243is
     244.B none
     245output synchronization is disabled.
     246.TP 0.5i
     247\fB\-p\fR, \fB\-\-print\-data\-base\fR
    238248Print the data base (rules and variable values) that results from
    239249reading the makefiles; then execute as usual or as otherwise
     
    243253switch (see below).
    244254To print the data base without trying to remake any files, use
    245 .B make
    246 .B \-p
    247 .BI \-f /dev/null.
    248 .TP 0.5i
    249 .BR \-q , " \-\-question"
     255.IR "make \-p \-f/dev/null" .
     256.TP 0.5i
     257\fB\-q\fR, \fB\-\-question\fR
    250258``Question mode''.
    251259Do not run any commands, or print anything; just return an exit status
     
    253261otherwise.
    254262.TP 0.5i
    255 .BR \-r , " \-\-no\-builtin\-rules"
     263\fB\-r\fR, \fB\-\-no\-builtin\-rules\fR
    256264Eliminate use of the built\-in implicit rules.
    257265Also clear out the default list of suffixes for suffix rules.
    258266.TP 0.5i
    259 .BR \-R , " \-\-no\-builtin\-variables"
     267\fB\-R\fR, \fB\-\-no\-builtin\-variables\fR
    260268Don't define any built\-in variables.
    261269.TP 0.5i
    262 .BR \-s , " \-\-silent" , " \-\-quiet"
     270\fB\-s\fR, \fB\-\-silent\fR, \fB\-\-quiet\fR
    263271Silent operation; do not print the commands as they are executed.
    264272.TP 0.5i
    265 .BR \-S , " \-\-no\-keep\-going" , " \-\-stop"
     273\fB\-S\fR, \fB\-\-no\-keep\-going\fR, \fB\-\-stop\fR
    266274Cancel the effect of the
    267275.B \-k
    268276option.
    269277This is never necessary except in a recursive
    270 .I make
     278.B make
    271279where
    272280.B \-k
    273281might be inherited from the top-level
    274 .I make
     282.B make
    275283via MAKEFLAGS or if you set
    276284.B \-k
    277285in MAKEFLAGS in your environment.
    278286.TP 0.5i
    279 .BR \-t , " \-\-touch"
     287\fB\-t\fR, \fB\-\-touch\fR
    280288Touch files (mark them up to date without really changing them)
    281289instead of running their commands.
    282290This is used to pretend that the commands were done, in order to fool
    283291future invocations of
    284 .IR make .
    285 .TP 0.5i
    286 .BR \-v , " \-\-version"
     292.BR make .
     293.TP 0.5i
     294.B \-\-trace
     295Information about the disposition of each target is printed (why the target is
     296being rebuilt and what commands are run to rebuild it).
     297.TP 0.5i
     298\fB\-v\fR, \fB\-\-version\fR
    287299Print the version of the
    288 .I make
     300.B make
    289301program plus a copyright, a list of authors and a notice that there
    290302is no warranty.
    291303.TP 0.5i
    292 .BR \-w , " \-\-print\-directory"
     304\fB\-w\fR, \fB\-\-print\-directory\fR
    293305Print a message containing the working directory
    294306before and after other processing.
    295307This may be useful for tracking down errors from complicated nests of
    296308recursive
    297 .I make
     309.B make
    298310commands.
    299311.TP 0.5i
     
    315327.I touch
    316328command on the given file before running
    317 .IR make ,
     329.BR make ,
    318330except that the modification time is changed only in the imagination of
    319 .IR make .
     331.BR make .
    320332.TP 0.5i
    321333.B \-\-warn\-undefined\-variables
     
    323335.SH "EXIT STATUS"
    324336GNU
    325 .I make
     337.B make
    326338exits with a status of zero if all makefiles were successfully parsed
    327339and no targets that were built failed.  A status of one will be returned
     
    329341.B \-q
    330342flag was used and
    331 .I make
     343.B make
    332344determines that a target needs to be rebuilt.  A status of two will be
    333345returned if any errors were encountered.
    334346.SH "SEE ALSO"
    335 .I "The GNU Make Manual"
     347The full documentation for
     348.B make
     349is maintained as a Texinfo manual.  If the
     350.B info
     351and
     352.B make
     353programs are properly installed at your site, the command
     354.IP
     355.B info make
     356.PP
     357should give you access to the complete manual.
    336358.SH BUGS
    337 See the chapter `Problems and Bugs' in
     359See the chapter ``Problems and Bugs'' in
    338360.IR "The GNU Make Manual" .
    339361.SH AUTHOR
    340362This manual page contributed by Dennis Morse of Stanford University.
    341 It has been reworked by Roland McGrath.  Further updates contributed by
    342 Mike Frysinger.
     363Further updates contributed by Mike Frysinger.  It has been reworked by Roland
     364McGrath.  Maintained by Paul Smith.
    343365.SH "COPYRIGHT"
    344 Copyright (C) 1992, 1993, 1996, 1999, 2007 Free Software Foundation, Inc.
    345 This file is part of GNU
    346 .IR make .
     366Copyright \(co 1992-1993, 1996-2016 Free Software Foundation, Inc.
     367This file is part of
     368.IR "GNU make" .
    347369.LP
    348370GNU Make is free software; you can redistribute it and/or modify it under the
  • vendor/gnumake/current/make.lnk

    r501 r3138  
    1 FROM LIB:cres.o "commands.o"+"job.o"+"dir.o"+"file.o"+"misc.o"+"main.o"+"read.o"+"remake.o"+"rule.o"+"implicit.o"+"default.o"+"variable.o"+"expand.o"+"function.o"+"vpath.o"+"version.o"+"ar.o"+"arscan.o"+"signame.o"+"remote-stub.o"+"getopt.o"+"getopt1.o"+"alloca.o"+"amiga.o"+"hash.o"+"strcache.o"
     1FROM LIB:cres.o "commands.o"+"job.o"+"dir.o"+"file.o"+"misc.o"+"main.o"+"read.o"+"remake.o"+"rule.o"+"implicit.o"+"default.o"+"variable.o"+"expand.o"+"function.o"+"vpath.o"+"version.o"+"ar.o"+"arscan.o"+"signame.o"+"remote-stub.o"+"getopt.o"+"getopt1.o"+"alloca.o"+"amiga.o"+"hash.o"+"strcache.o"+"output.o"
    22TO "make.new"
    33LIB glob/glob.lib LIB:sc.lib LIB:amiga.lib
  • vendor/gnumake/current/make_msvc_net2003.vcproj

    r501 r3138  
    155155                                RelativePath=".\getopt1.c">
    156156                        </File>
     157
     158                        <File
     159                                RelativePath=".\guile.c">
     160                        </File>
     161
    157162                        <File
    158163                                RelativePath=".\hash.c">
     
    166171                        <File
    167172                                RelativePath=".\job.c">
     173                        </File>
     174                        <File
     175                                RelativePath=".\load.c">
     176                        </File>
     177                        <File
     178                                RelativePath=".\output.c">
    168179                        </File>
    169180                        <File
     
    202213                                <File
    203214                                        RelativePath=".\w32\compat\dirent.c">
     215                                </File>
     216                                <File
     217                                        RelativePath=".\w32\compat\posixfcn.c">
    204218                                </File>
    205219                                <File
     
    222236                                </File>
    223237                                <File
     238                                        RelativePath=".\w32\w32os.c">
     239                                </File>
     240                                <File
    224241                                        RelativePath=".\w32\subproc\sub_proc.c">
    225242                                </File>
     
    265282                        </File>
    266283                        <File
     284                                RelativePath=".\gmk-default.h">
     285                        </File>
     286                        <File
    267287                                RelativePath=".\hash.h">
    268288                        </File>
     
    271291                        </File>
    272292                        <File
    273                                 RelativePath=".\make.h">
     293                                RelativePath=".\output.h">
     294                        </File>
     295                        <File
     296                                RelativePath=".\makeint.h">
    274297                        </File>
    275298                        <File
  • vendor/gnumake/current/makefile.com

    r2596 r3138  
    22$! Makefile.com - builds GNU Make for VMS
    33$!
    4 $! P1 is non-empty if you want to link with the VAXCRTL library instead
    5 $!    of the shareable executable
     4$! P1 = LIST will provide compiler listings.
    65$! P2 = DEBUG will build an image with debug information
    76$! P3 = WALL will enable all warning messages (some are suppressed since
     
    5150$ endif
    5251$!
     52$!
     53$ if (p1 .eqs. "LIST")
     54$ then
     55$   ccopt = ccopt + "/list/show=(expan,inclu)"
     56$ endif
     57$!
    5358$! Should we build a debug image
    5459$!
     
    6873$ endif
    6974$ filelist = "alloca ar arscan commands default dir expand file function " + -
    70              "hash implicit job main misc read remake remote-stub rule " + -
    71              "signame variable version vmsfunctions vmsify vpath " + -
    72              "[.glob]glob [.glob]fnmatch getopt1 getopt strcache"
     75             "guile hash implicit job load main misc read remake " + -
     76             "remote-stub rule output signame variable version " + -
     77             "vmsfunctions vmsify vpath vms_progname vms_exit " + -
     78             "vms_export_symbol [.glob]glob [.glob]fnmatch getopt1 " + -
     79             "getopt strcache"
     80$!
    7381$ copy config.h-vms config.h
    7482$ n=0
     
    7886$ if cfile .eqs. " " then goto linkit
    7987$ write sys$output "Compiling ''cfile'..."
    80 $ call compileit 'cfile' 'p1'
     88$ call compileit 'cfile'
    8189$ n = n + 1
    8290$ goto loop
    8391$ linkit:
    8492$ close optf
    85 $ if p1 .nes. "" then goto link_using_library
    8693$ link/exe=make make.opt/opt'lopt
    8794$ goto cleanup
    88 $
    89 $ link_using_library:
    90 $ link/exe=make make.opt/opt,sys$library:vaxcrtl/lib'lopt
    9195$
    9296$ cleanup:
     
    129133$ compileit : subroutine
    130134$ ploc = f$locate("]",p1)
    131 $ filnam = p1
    132 $ if ploc .lt. f$length(p1) then filnam=f$extract(ploc+1,100,p1)
    133 $ write optf "''filnam'"
    134 $ cc'ccopt'/include=([],[.glob]) -
    135   /define=("allocated_variable_expand_for_file=alloc_var_expand_for_file","unlink=remove","HAVE_CONFIG_H","VMS") -
     135$! filnam = p1
     136$ if ploc .lt. f$length(p1)
     137$ then
     138$   objdir = f$extract(0, ploc+1, p1)
     139$   write optf p1
     140$ else
     141$   objdir := []
     142$   write optf objdir+p1
     143$ endif
     144$ cc'ccopt'/nested=none/include=([],[.glob])/obj='objdir' -
     145  /define=("allocated_variable_expand_for_file=alloc_var_expand_for_file",-
     146  "unlink=remove","HAVE_CONFIG_H","VMS") -
    136147  'p1'
    137148$ exit
     
    139150$!
    140151$!-----------------------------------------------------------------------------
    141 $!Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    142 $!2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     152$!Copyright (C) 1996-2016 Free Software Foundation, Inc.
    143153$!This file is part of GNU Make.
    144154$!
  • vendor/gnumake/current/makefile.vms

    r2596 r3138  
    11# -*-Makefile-*- to build GNU make on VMS
    22#
    3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    4 # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     3# Copyright (C) 1996-2016 Free Software Foundation, Inc.
    54# This file is part of GNU Make.
    65#
     
    2221# Modified for version 3.78.1 by Hartmut.Becker@compaq.com.
    2322# Modified for version 3.80 by zinser@decus.de
    24 # Modified for version 3.81 by Hartmut Becker
     23# Modified for versions 3.81, 3.99.90 by Hartmut Becker
    2524
    2625CC = cc
     
    3433
    3534ifeq ($(CC),cc)
    36 CFLAGS = $(defines) /include=([],[.glob])/prefix=(all,except=(glob,globfree))/standard=relaxed/warn=(disable=questcompare)
     35cinclude = /nested=none/include=([],[.glob])
     36cprefix = /prefix=(all,except=(glob,globfree))
     37cwarn = /standard=relaxed/warn=(disable=questcompare)
     38CFLAGS = $(defines) $(cinclude)$(cprefix)$(cwarn)
    3739else
    38 CFLAGS = $(defines) /include=([],[.glob])
     40CFLAGS = $(defines) $(cinclude)
    3941endif
    4042#LDFLAGS = /deb
     
    8385glob = ,[.glob]glob.obj,[.glob]fnmatch.obj
    8486getopt = ,getopt.obj,getopt1.obj
    85 # Directory to install `make' in.
     87# Directory to install 'make' in.
    8688bindir = []
    8789# Directory to install the man page in.
     
    9092manext = 1
    9193
    92 objs = commands.obj,job.obj,dir.obj,file.obj,misc.obj,hash.obj,\
    93        main.obj,read.obj,remake.obj,rule.obj,implicit.obj,\
     94guile = ,guile.obj
     95
     96objs = commands.obj,job.obj,output.obj,dir.obj,file.obj,misc.obj,hash.obj,\
     97       load.obj,main.obj,read.obj,remake.obj,rule.obj,implicit.obj,\
    9498       default.obj,variable.obj,expand.obj,function.obj,strcache.obj,\
    95        vpath.obj,version.obj$(ARCHIVES)$(ALLOCA)$(extras)$(getopt)$(glob)
    96 srcs = commands.c job.c dir.c file.c misc.c  hash.c \
    97         main.c read.c remake.c rule.c implicit.c \
     99       vpath.obj,version.obj,vms_progname.obj,vms_exit.obj,\
     100       vms_export_symbol.obj$(guile)$(ARCHIVES)$(extras)$(getopt)$(glob)
     101
     102srcs = commands.c job.c output.c dir.c file.c misc.c guile.c hash.c \
     103        load.c main.c read.c remake.c rule.c implicit.c \
    98104        default.c variable.c expand.c function.c strcache.c \
    99         vpath.c version.c vmsfunctions.c vmsify.c $(ARCHIVES_SRC) $(ALLOCASRC) \
    100         commands.h dep.h filedef.h job.h make.h rule.h variable.h
     105        vpath.c version.c vmsfunctions.c vmsify.c vms_progname.c vms_exit.c \
     106        vms_export_symbol.c $(ARCHIVES_SRC) $(ALLOCASRC) \
     107        commands.h dep.h filedef.h job.h output.h makeint.h rule.h variable.h
    101108
    102109
     
    112119.PHONY: clean realclean
    113120clean:
    114         $$ purge [...]
     121        -purge [...]
    115122        -$(RM) make.exe;,*.obj;
    116123        -$(RM) [.glob]*.obj;
    117124
    118 # Automatically generated dependencies.
    119 commands.obj: commands.c make.h dep.h commands.h filedef.h variable.h job.h
    120 job.obj: job.c vmsjobs.c make.h commands.h job.h filedef.h variable.h
    121 dir.obj: dir.c make.h
    122 file.obj: file.c make.h commands.h dep.h filedef.h variable.h
    123 misc.obj: misc.c make.h dep.h
    124 hash.obj: hash.c make.h hash.h
    125 strcache.obj: strcache.c make.h hash.h
    126 main.obj: main.c make.h commands.h dep.h filedef.h variable.h job.h
    127 read.obj: read.c make.h commands.h dep.h filedef.h variable.h
    128 remake.obj: remake.c make.h commands.h job.h dep.h filedef.h
    129 rule.obj: rule.c make.h commands.h dep.h filedef.h variable.h rule.h
    130 implicit.obj: implicit.c make.h rule.h dep.h filedef.h
    131 default.obj: default.c make.h rule.h dep.h filedef.h commands.h variable.h
    132 variable.obj: variable.c make.h commands.h variable.h dep.h filedef.h
    133 expand.obj: expand.c make.h commands.h filedef.h variable.h
    134 function.obj: function.c make.h variable.h dep.h commands.h job.h
    135 vpath.obj: vpath.c make.h filedef.h variable.h
     125ar.obj: ar.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h dep.h \
     126     [.glob]fnmatch.h
     127arscan.obj: arscan.c makeint.h config.h gnumake.h gettext.h
     128commands.obj: commands.c makeint.h config.h gnumake.h gettext.h filedef.h \
     129     hash.h dep.h variable.h job.h output.h commands.h
     130default.obj: default.c makeint.h config.h gnumake.h gettext.h filedef.h \
     131     hash.h variable.h rule.h dep.h job.h output.h commands.h
     132dir.obj: dir.c makeint.h config.h gnumake.h gettext.h hash.h filedef.h \
     133     dep.h [.glob]glob.h
     134expand.obj: expand.c makeint.h config.h gnumake.h gettext.h filedef.h \
     135     hash.h job.h output.h commands.h variable.h rule.h
     136file.obj: file.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h \
     137     dep.h job.h output.h commands.h variable.h debug.h
     138[.glob]fnmatch.obj: [.glob]fnmatch.c config.h [.glob]fnmatch.h
     139function.obj: function.c makeint.h config.h gnumake.h gettext.h filedef.h \
     140     hash.h variable.h dep.h job.h output.h commands.h debug.h
     141getopt.obj: getopt.c config.h gettext.h getopt.h
     142getopt1.obj: getopt1.c config.h getopt.h
     143[.glob]glob.obj: [.glob]glob.c config.h [.glob]fnmatch.h [.glob]glob.h
     144guile.obj: guile.c makeint.h config.h gnumake.h gettext.h
     145hash.obj: hash.c makeint.h config.h gnumake.h gettext.h hash.h
     146implicit.obj: implicit.c makeint.h config.h gnumake.h gettext.h filedef.h \
     147     hash.h rule.h dep.h debug.h variable.h job.h output.h commands.h
     148job.obj: job.c makeint.h config.h gnumake.h gettext.h job.h output.h debug.h \
     149     filedef.h hash.h commands.h variable.h debug.h vmsjobs.c
     150load.obj: load.c makeint.h config.h gnumake.h gettext.h
     151main.obj: main.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h \
     152     dep.h variable.h job.h output.h commands.h rule.h debug.h getopt.h
     153misc.obj: misc.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h \
     154     dep.h debug.h
     155output.obj: output.c makeint.h config.h gnumake.h gettext.h job.h output.h
     156read.obj: read.c makeint.h config.h gnumake.h gettext.h [.glob]glob.h \
     157     filedef.h hash.h dep.h job.h output.h commands.h variable.h rule.h \
     158     debug.h
     159remake.obj: remake.c makeint.h config.h gnumake.h gettext.h filedef.h \
     160     hash.h job.h output.h commands.h dep.h variable.h debug.h
     161remote-stub.obj: remote-stub.c makeint.h config.h gnumake.h gettext.h \
     162     filedef.h hash.h job.h output.h commands.h
     163rule.obj: rule.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h \
     164     dep.h job.h output.h commands.h variable.h rule.h
     165signame.obj: signame.c makeint.h config.h gnumake.h gettext.h
     166strcache.obj: strcache.c makeint.h config.h gnumake.h gettext.h hash.h
     167variable.obj: variable.c makeint.h config.h gnumake.h gettext.h filedef.h \
     168     hash.h dep.h job.h output.h commands.h variable.h rule.h
    136169version.obj: version.c config.h
    137 arscan.obj: arscan.c
    138 ar.obj: ar.c make.h filedef.h
    139 signame.obj: signame.c
    140 remote-stub.obj: remote-stub.c
    141 [.glob]glob.obj: [.glob]glob.c
    142 [.glob]fnmatch.obj: [.glob]fnmatch.c
    143 getopt.obj: getopt.c
    144 getopt1.obj: getopt1.c
    145 vmsfunctions.obj: vmsfunctions.c make.h vmsdir.h
    146 vmsify.obj: vmsify.c make.h
     170vmsfunctions.obj: vmsfunctions.c makeint.h config.h gnumake.h gettext.h \
     171     debug.h job.h output.h vmsdir.h
     172vmsify.obj: vmsify.c
     173vpath.obj: vpath.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h \
     174     variable.h
     175vms_progname.obj: vms_progname.c
     176vms_exit.obj: vms_exit.c
     177vms_export_symbol.obj: vms_export_symbol.c
    147178
    148179config.h: config.h-vms
  • vendor/gnumake/current/makeint.h

    r3137 r3138  
    11/* Miscellaneous global declarations and portability cruft for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1917/* We use <config.h> instead of "config.h" so that a compilation
    2018   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
    21    (which it would do because make.h was found in $srcdir).  */
     19   (which it would do because makeint.h was found in $srcdir).  */
    2220#include <config.h>
    2321#undef  HAVE_CONFIG_H
     
    4442#endif
    4543
     44/* Disable assert() unless we're a maintainer.
     45   Some asserts are compute-intensive.  */
     46#ifndef MAKE_MAINTAINER_MODE
     47# define NDEBUG 1
     48#endif
     49
     50/* Include the externally-visible content.
     51   Be sure to use the local one, and not one installed on the system.
     52   Define GMK_BUILDING_MAKE for proper selection of dllexport/dllimport
     53   declarations for MS-Windows.  */
     54#ifdef WINDOWS32
     55# define GMK_BUILDING_MAKE
     56#endif
     57#include "gnumake.h"
    4658
    4759#ifdef  CRAY
     
    6173#include <stdio.h>
    6274#include <ctype.h>
     75
    6376#ifdef HAVE_SYS_TIMEB_H
    64 /* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
    65    unless <sys/timeb.h> has been included first.  Does every system have a
    66    <sys/timeb.h>?  If any does not, configure should check for it.  */
     77/* SCO 3.2 "devsys 4.2" has a prototype for 'ftime' in <time.h> that bombs
     78   unless <sys/timeb.h> has been included first.  */
    6779# include <sys/timeb.h>
    6880#endif
    69 
    7081#if TIME_WITH_SYS_TIME
    7182# include <sys/time.h>
     
    8596#endif
    8697
    87 #ifndef isblank
    88 # define isblank(c)     ((c) == ' ' || (c) == '\t')
     98#ifdef __VMS
     99/* In strict ANSI mode, VMS compilers should not be defining the
     100   VMS macro.  Define it here instead of a bulk edit for the correct code.
     101 */
     102# ifndef VMS
     103#  define VMS
     104# endif
    89105#endif
    90106
     
    92108# include <unistd.h>
    93109/* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
    94    POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself!  */
     110   POSIX.1 behavior with 'cc -YPOSIX', which predefines POSIX itself!  */
    95111# if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
    96112#  define POSIX 1
     
    117133#ifndef HAVE_SA_RESTART
    118134# define SA_RESTART 0
     135#endif
     136
     137#ifdef HAVE_VFORK_H
     138# include <vfork.h>
    119139#endif
    120140
     
    149169#endif
    150170
    151 /* Nonzero if the integer type T is signed.  */
    152 #define INTEGER_TYPE_SIGNED(t) ((t) -1 < 0)
     171#ifndef USHRT_MAX
     172# define USHRT_MAX 65535
     173#endif
     174
     175/* Nonzero if the integer type T is signed.
     176   Use <= to avoid GCC warnings about always-false expressions.  */
     177#define INTEGER_TYPE_SIGNED(t) ((t) -1 <= 0)
    153178
    154179/* The minimum and maximum values for the integer type T.
     
    179204
    180205#ifdef VMS
     206# include <fcntl.h>
    181207# include <types.h>
    182208# include <unixlib.h>
     
    185211/* Needed to use alloca on VMS.  */
    186212# include <builtins.h>
     213
     214extern int vms_use_mcr_command;
     215extern int vms_always_use_cmd_file;
     216extern int vms_gnv_shell;
     217extern int vms_comma_separator;
     218extern int vms_legacy_behavior;
     219extern int vms_unix_simulation;
    187220#endif
    188221
     
    192225#  define __attribute__(x)
    193226# endif
    194 /* The __-protected variants of `format' and `printf' attributes
     227/* The __-protected variants of 'format' and 'printf' attributes
    195228   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
    196229# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
     
    250283# include <inttypes.h>
    251284#endif
     285#if HAVE_STDINT_H
     286# include <stdint.h>
     287#endif
    252288#define FILE_TIMESTAMP uintmax_t
    253289
     
    263299   POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
    264300   only '0' through '9' are digits.  Prefer ISDIGIT to isdigit() unless
    265    it's important to use the locale's definition of `digit' even when the
     301   it's important to use the locale's definition of 'digit' even when the
    266302   host does not conform to POSIX.  */
    267303#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
     
    306342#define S_(msg1,msg2,num)   ngettext (msg1,msg2,num)
    307343
    308 /* Handle other OSs.  */
    309 #ifndef PATH_SEPARATOR_CHAR
    310 # if defined(HAVE_DOS_PATHS)
    311 #  define PATH_SEPARATOR_CHAR ';'
    312 # elif defined(VMS)
    313 #  define PATH_SEPARATOR_CHAR ','
    314 # else
    315 #  define PATH_SEPARATOR_CHAR ':'
    316 # endif
    317 #endif
    318 
    319344/* This is needed for getcwd() and chdir(), on some W32 systems.  */
    320345#if defined(HAVE_DIRECT_H)
     
    327352# define pipe(_p)        _pipe((_p), 512, O_BINARY)
    328353# define kill(_pid,_sig) w32_kill((_pid),(_sig))
     354/* MSVC and Watcom C don't have ftruncate.  */
     355# if defined(_MSC_VER) || defined(__WATCOMC__)
     356#  define ftruncate(_fd,_len) _chsize(_fd,_len)
     357# endif
     358/* MinGW64 doesn't have _S_ISDIR.  */
     359# ifndef _S_ISDIR
     360#  define _S_ISDIR(m)  S_ISDIR(m)
     361# endif
    329362
    330363void sync_Path_environment (void);
    331364int w32_kill (pid_t pid, int sig);
    332 char *end_of_token_w32 (const char *s, char stopchar);
    333365int find_and_set_default_shell (const char *token);
    334366
     
    338370/* is default_shell unixy? */
    339371extern int unixy_shell;
     372
     373/* We don't have a preferred fixed value for LOCALEDIR.  */
     374# ifndef LOCALEDIR
     375#  define LOCALEDIR NULL
     376# endif
     377
     378/* Include only the minimal stuff from windows.h.   */
     379# define WIN32_LEAN_AND_MEAN
    340380#endif  /* WINDOWS32 */
     381
     382#define ANY_SET(_v,_m)  (((_v)&(_m)) != 0)
     383#define NONE_SET(_v,_m) (! ANY_SET ((_v),(_m)))
     384
     385#define MAP_NUL         0x0001
     386#define MAP_BLANK       0x0002
     387#define MAP_NEWLINE     0x0004
     388#define MAP_COMMENT     0x0008
     389#define MAP_SEMI        0x0010
     390#define MAP_EQUALS      0x0020
     391#define MAP_COLON       0x0040
     392#define MAP_PERCENT     0x0080
     393#define MAP_PIPE        0x0100
     394#define MAP_DOT         0x0200
     395#define MAP_COMMA       0x0400
     396
     397/* These are the valid characters for a user-defined function.  */
     398#define MAP_USERFUNC    0x2000
     399/* This means not only a '$', but skip the variable reference.  */
     400#define MAP_VARIABLE    0x4000
     401/* The set of characters which are directory separators is OS-specific.  */
     402#define MAP_DIRSEP      0x8000
     403
     404#ifdef VMS
     405# define MAP_VMSCOMMA   MAP_COMMA
     406#else
     407# define MAP_VMSCOMMA   0x0000
     408#endif
     409
     410#define MAP_SPACE       (MAP_BLANK|MAP_NEWLINE)
     411
     412/* Handle other OSs.
     413   To overcome an issue parsing paths in a DOS/Windows environment when
     414   built in a unix based environment, override the PATH_SEPARATOR_CHAR
     415   definition unless being built for Cygwin. */
     416#if defined(HAVE_DOS_PATHS) && !defined(__CYGWIN__)
     417# undef PATH_SEPARATOR_CHAR
     418# define PATH_SEPARATOR_CHAR ';'
     419# define MAP_PATHSEP    MAP_SEMI
     420#elif !defined(PATH_SEPARATOR_CHAR)
     421# if defined (VMS)
     422#  define PATH_SEPARATOR_CHAR (vms_comma_separator ? ',' : ':')
     423#  define MAP_PATHSEP    (vms_comma_separator ? MAP_COMMA : MAP_SEMI)
     424# else
     425#  define PATH_SEPARATOR_CHAR ':'
     426#  define MAP_PATHSEP    MAP_COLON
     427# endif
     428#elif PATH_SEPARATOR_CHAR == ':'
     429# define MAP_PATHSEP     MAP_COLON
     430#elif PATH_SEPARATOR_CHAR == ';'
     431# define MAP_PATHSEP     MAP_SEMI
     432#elif PATH_SEPARATOR_CHAR == ','
     433# define MAP_PATHSEP     MAP_COMMA
     434#else
     435# error "Unknown PATH_SEPARATOR_CHAR"
     436#endif
     437
     438#define STOP_SET(_v,_m) ANY_SET(stopchar_map[(unsigned char)(_v)],(_m))
     439
     440#define ISBLANK(c)      STOP_SET((c),MAP_BLANK)
     441#define ISSPACE(c)      STOP_SET((c),MAP_SPACE)
     442#define NEXT_TOKEN(s)   while (ISSPACE (*(s))) ++(s)
     443#define END_OF_TOKEN(s) while (! STOP_SET (*(s), MAP_SPACE|MAP_NUL)) ++(s)
    341444
    342445#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
     
    345448#ifdef SET_STACK_SIZE
    346449# include <sys/resource.h>
    347 struct rlimit stack_limit;
    348 #endif
    349 
    350 struct floc
     450extern struct rlimit stack_limit;
     451#endif
     452
     453#include <glob.h>
     454
     455#define NILF ((floc *)0)
     456
     457#define CSTRLEN(_s)           (sizeof (_s)-1)
     458#define STRING_SIZE_TUPLE(_s) (_s), CSTRLEN(_s)
     459
     460/* The number of bytes needed to represent the largest integer as a string.  */
     461#define INTSTR_LENGTH         CSTRLEN ("18446744073709551616")
     462
     463#define DEFAULT_TTYNAME "true"
     464#ifdef HAVE_TTYNAME
     465# define TTYNAME(_f) ttyname (_f)
     466#else
     467# define TTYNAME(_f) DEFAULT_TTYNAME
     468#endif
     469
     470
     471
     472
     473/* Specify the location of elements read from makefiles.  */
     474typedef struct
    351475  {
    352476    const char *filenm;
    353477    unsigned long lineno;
    354   };
    355 #define NILF ((struct floc *)0)
    356 
    357 #define STRING_SIZE_TUPLE(_s) (_s), (sizeof (_s)-1)
    358 
    359 
    360 
    361 /* We have to have stdarg.h or varargs.h AND v*printf or doprnt to use
    362    variadic versions of these functions.  */
    363 
    364 #if HAVE_STDARG_H || HAVE_VARARGS_H
    365 # if HAVE_VPRINTF || HAVE_DOPRNT
    366 #  define USE_VARIADIC 1
    367 # endif
    368 #endif
    369 
    370 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
     478    unsigned long offset;
     479  } floc;
     480
    371481const char *concat (unsigned int, ...);
    372 void message (int prefix, const char *fmt, ...)
    373               __attribute__ ((__format__ (__printf__, 2, 3)));
    374 void error (const struct floc *flocp, const char *fmt, ...)
    375             __attribute__ ((__format__ (__printf__, 2, 3)));
    376 void fatal (const struct floc *flocp, const char *fmt, ...)
    377                    __attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
    378 #else
    379 const char *concat ();
    380 void message ();
    381 void error ();
    382 void fatal ();
    383 #endif
     482void message (int prefix, size_t length, const char *fmt, ...)
     483              __attribute__ ((__format__ (__printf__, 3, 4)));
     484void error (const floc *flocp, size_t length, const char *fmt, ...)
     485            __attribute__ ((__format__ (__printf__, 3, 4)));
     486void fatal (const floc *flocp, size_t length, const char *fmt, ...)
     487            __attribute__ ((noreturn, __format__ (__printf__, 3, 4)));
     488
     489#define O(_t,_a,_f)           _t((_a), 0, (_f))
     490#define OS(_t,_a,_f,_s)       _t((_a), strlen (_s), (_f), (_s))
     491#define OSS(_t,_a,_f,_s1,_s2) _t((_a), strlen (_s1) + strlen (_s2), \
     492                                 (_f), (_s1), (_s2))
     493#define OSSS(_t,_a,_f,_s1,_s2,_s3) _t((_a), strlen (_s1) + strlen (_s2) + strlen (_s3), \
     494                                      (_f), (_s1), (_s2), (_s3))
     495#define ON(_t,_a,_f,_n)       _t((_a), INTSTR_LENGTH, (_f), (_n))
     496#define ONN(_t,_a,_f,_n1,_n2) _t((_a), INTSTR_LENGTH*2, (_f), (_n1), (_n2))
     497
     498#define OSN(_t,_a,_f,_s,_n)   _t((_a), strlen (_s) + INTSTR_LENGTH, \
     499                                 (_f), (_s), (_n))
     500#define ONS(_t,_a,_f,_n,_s)   _t((_a), INTSTR_LENGTH + strlen (_s), \
     501                                 (_f), (_n), (_s))
     502
     503#define OUT_OF_MEM() O (fatal, NILF, _("virtual memory exhausted"))
    384504
    385505void die (int) __attribute__ ((noreturn));
    386 void log_working_directory (int);
    387506void pfatal_with_name (const char *) __attribute__ ((noreturn));
    388507void perror_with_name (const char *, const char *);
     508#define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
    389509void *xmalloc (unsigned int);
    390510void *xcalloc (unsigned int);
     
    401521char *find_percent (char *);
    402522const char *find_percent_cached (const char **);
    403 FILE *open_tmpfile (char **, const char *);
    404523
    405524#ifndef NO_ARCHIVES
     
    410529
    411530typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated,
    412                                       long int hdrpos, long int datapos,
    413                                       long int size, long int date, int uid,
    414                                       int gid, int mode, const void *arg);
     531                                      long int hdrpos, long int datapos,
     532                                      long int size, long int date, int uid,
     533                                      int gid, unsigned int mode,
     534                                      const void *arg);
    415535
    416536long int ar_scan (const char *archive, ar_member_func_t function, const void *arg);
     
    426546void file_impossible (const char *);
    427547const char *dir_name (const char *);
     548void print_dir_data_base (void);
     549void dir_setup_glob (glob_t *);
    428550void hash_init_directories (void);
    429551
    430552void define_default_variables (void);
     553void undefine_default_variables (void);
    431554void set_default_suffixes (void);
    432555void install_default_suffix_rules (void);
     
    445568void child_access (void);
    446569
    447 void close_stdout (void);
    448 
    449570char *strip_whitespace (const char **begpp, const char **endpp);
     571
     572void show_goal_error (void);
    450573
    451574/* String caching  */
     
    454577int strcache_iscached (const char *str);
    455578const char *strcache_add (const char *str);
    456 const char *strcache_add_len (const char *str, int len);
    457 int strcache_setbufsize (int size);
    458 
    459 #ifdef  HAVE_VFORK_H
    460 # include <vfork.h>
    461 #endif
     579const char *strcache_add_len (const char *str, unsigned int len);
     580
     581/* Guile support  */
     582int guile_gmake_setup (const floc *flocp);
     583
     584/* Loadable object support.  Sets to the strcached name of the loaded file.  */
     585typedef int (*load_func_t)(const floc *flocp);
     586int load_file (const floc *flocp, const char **filename, int noerror);
     587void unload_file (const char *name);
    462588
    463589/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
     
    471597# endif
    472598
     599# ifdef  HAVE_GETCWD
     600#  if !defined(VMS) && !defined(__DECC)
     601char *getcwd ();
     602#  endif
     603# else
     604char *getwd ();
     605#  define getcwd(buf, len)       getwd (buf)
     606# endif
     607
    473608#endif  /* Not GNU C library or POSIX.  */
    474 
    475 #ifdef  HAVE_GETCWD
    476 # if !defined(VMS) && !defined(__DECC)
    477 char *getcwd ();
    478 # endif
    479 #else
    480 char *getwd ();
    481 # define getcwd(buf, len)       getwd (buf)
    482 #endif
    483609
    484610#if !HAVE_STRCASECMP
     
    504630#endif
    505631
    506 extern const struct floc *reading_file;
    507 extern const struct floc **expanding_var;
    508 
     632#define OUTPUT_SYNC_NONE    0
     633#define OUTPUT_SYNC_LINE    1
     634#define OUTPUT_SYNC_TARGET  2
     635#define OUTPUT_SYNC_RECURSE 3
     636
     637/* Non-GNU systems may not declare this in unistd.h.  */
    509638extern char **environ;
     639
     640extern const floc *reading_file;
     641extern const floc **expanding_var;
     642
     643extern unsigned short stopchar_map[];
    510644
    511645extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
     
    513647extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
    514648extern int print_version_flag, print_directory_flag, check_symlink_flag;
    515 extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
    516 extern int second_expansion, clock_skew_detected, rebuilding_makefiles;
    517 extern int one_shell;
     649extern int warn_undefined_variables_flag, trace_flag, posix_pedantic;
     650extern int not_parallel, second_expansion, clock_skew_detected;
     651extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
     652
     653extern const char *default_shell;
    518654
    519655/* can we run commands via 'sh -c xxx' or must we use batch files? */
     
    526662
    527663extern unsigned int job_slots;
    528 extern int job_fds[2];
    529 extern int job_rfd;
    530664#ifndef NO_FLOAT
    531665extern double max_load_average;
     
    534668#endif
    535669
     670#ifdef WINDOWS32
    536671extern char *program;
     672#else
     673extern const char *program;
     674#endif
     675
     676#ifdef VMS
     677const char *vms_command (const char *argv0);
     678const char *vms_progname (const char *argv0);
     679
     680void vms_exit (int);
     681# define _exit(foo) vms_exit(foo)
     682# define exit(foo) vms_exit(foo)
     683
     684extern char *program_name;
     685
     686void
     687set_program_name (const char *arv0);
     688
     689int
     690need_vms_symbol (void);
     691
     692int
     693create_foreign_command (const char *command, const char *image);
     694
     695int
     696vms_export_dcl_symbol (const char *name, const char *value);
     697
     698int
     699vms_putenv_symbol (const char *string);
     700
     701void
     702vms_restore_symbol (const char *string);
     703
     704#endif
     705
     706void remote_setup (void);
     707void remote_cleanup (void);
     708int start_remote_job_p (int);
     709int start_remote_job (char **, char **, int, int *, int *, int *);
     710int remote_status (int *, int *, int *, int);
     711void block_remote_children (void);
     712void unblock_remote_children (void);
     713int remote_kill (int id, int sig);
     714void print_variable_data_base (void);
     715void print_vpath_data_base (void);
     716
    537717extern char *starting_directory;
    538718extern unsigned int makelevel;
     
    551731#endif
    552732
    553 #ifdef VMS
    554 #  define MAKE_SUCCESS 1
    555 #  define MAKE_TROUBLE 2
    556 #  define MAKE_FAILURE 3
    557 #else
    558 #  define MAKE_SUCCESS 0
    559 #  define MAKE_TROUBLE 1
    560 #  define MAKE_FAILURE 2
    561 #endif
     733
     734#define MAKE_SUCCESS 0
     735#define MAKE_TROUBLE 1
     736#define MAKE_FAILURE 2
    562737
    563738/* Set up heap debugging library dmalloc.  */
  • vendor/gnumake/current/misc.c

    r2596 r3138  
    11/* Miscellaneous generic support functions for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
     18#include "filedef.h"
    2019#include "dep.h"
    2120#include "debug.h"
    2221
    23 /* Variadic functions.  We go through contortions to allow proper function
    24    prototypes for both ANSI and pre-ANSI C compilers, and also for those
    25    which support stdarg.h vs. varargs.h, and finally those which have
    26    vfprintf(), etc. and those who have _doprnt... or nothing.
    27 
    28    This fancy stuff all came from GNU fileutils, except for the VA_PRINTF and
    29    VA_END macros used here since we have multiple print functions.  */
    30 
    31 #if USE_VARIADIC
    32 # if HAVE_STDARG_H
    33 #  include <stdarg.h>
    34 #  define VA_START(args, lastarg) va_start(args, lastarg)
    35 # else
    36 #  include <varargs.h>
    37 #  define VA_START(args, lastarg) va_start(args)
    38 # endif
    39 # if HAVE_VPRINTF
    40 #  define VA_PRINTF(fp, lastarg, args) vfprintf((fp), (lastarg), (args))
    41 # else
    42 #  define VA_PRINTF(fp, lastarg, args) _doprnt((lastarg), (args), (fp))
    43 # endif
    44 # define VA_END(args) va_end(args)
    45 #else
    46 /* We can't use any variadic interface! */
    47 # define va_alist a1, a2, a3, a4, a5, a6, a7, a8
    48 # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
    49 # define VA_START(args, lastarg)
    50 # define VA_PRINTF(fp, lastarg, args) fprintf((fp), (lastarg), va_alist)
    51 # define VA_END(args)
    52 #endif
    53 
     22/* GNU make no longer supports pre-ANSI89 environments.  */
     23
     24#include <stdarg.h>
     25
     26#ifdef HAVE_FCNTL_H
     27# include <fcntl.h>
     28#else
     29# include <sys/file.h>
     30#endif
    5431
    5532/* Compare strings *S1 and *S2.
     
    7653collapse_continuations (char *line)
    7754{
    78   register char *in, *out, *p;
    79   register int backslash;
    80   register unsigned int bs_write;
     55  char *in, *out, *p;
    8156
    8257  in = strchr (line, '\n');
     
    9166    {
    9267      /* BS_WRITE gets the number of quoted backslashes at
    93         the end just before IN, and BACKSLASH gets nonzero
    94         if the next character is quoted.  */
    95       backslash = 0;
    96       bs_write = 0;
     68        the end just before IN, and BACKSLASH gets nonzero
     69        if the next character is quoted.  */
     70      unsigned int backslash = 0;
     71      unsigned int bs_write = 0;
    9772      for (p = in - 1; p >= line && *p == '\\'; --p)
    98         {
    99           if (backslash)
    100             ++bs_write;
    101           backslash = !backslash;
    102 
    103           /* It should be impossible to go back this far without exiting,
    104              but if we do, we can't get the right answer.  */
    105           if (in == out - 1)
    106             abort ();
    107         }
     73        {
     74          if (backslash)
     75            ++bs_write;
     76          backslash = !backslash;
     77
     78          /* It should be impossible to go back this far without exiting,
     79             but if we do, we can't get the right answer.  */
     80          if (in == out - 1)
     81            abort ();
     82        }
    10883
    10984      /* Output the appropriate number of backslashes.  */
    11085      while (bs_write-- > 0)
    111         *out++ = '\\';
     86        *out++ = '\\';
    11287
    11388      /* Skip the newline.  */
    11489      ++in;
    11590
    116       /* If the newline is escaped, discard following whitespace leaving just
    117          one space.  POSIX requires that each backslash/newline/following
    118          whitespace sequence be reduced to a single space.  */
    11991      if (backslash)
    120         {
    121           in = next_token (in);
    122           /* Removing this loop will fix Savannah bug #16670: do we want to? */
    123           while (out > line && isblank ((unsigned char)out[-1]))
    124             --out;
    125           *out++ = ' ';
    126         }
     92        {
     93          /* Backslash/newline handling:
     94             In traditional GNU make all trailing whitespace, consecutive
     95             backslash/newlines, and any leading non-newline whitespace on the
     96             next line is reduced to a single space.
     97             In POSIX, each backslash/newline and is replaced by a space.  */
     98          while (ISBLANK (*in))
     99            ++in;
     100          if (! posix_pedantic)
     101            while (out > line && ISBLANK (out[-1]))
     102              --out;
     103          *out++ = ' ';
     104        }
    127105      else
    128         /* If the newline isn't quoted, put it in the output.  */
    129         *out++ = '\n';
     106        /* If the newline isn't quoted, put it in the output.  */
     107        *out++ = '\n';
    130108
    131109      /* Now copy the following line to the output.
    132         Stop when we find backslashes followed by a newline.  */
     110        Stop when we find backslashes followed by a newline.  */
    133111      while (*in != '\0')
    134         if (*in == '\\')
    135           {
    136             p = in + 1;
    137             while (*p == '\\')
    138               ++p;
    139             if (*p == '\n')
    140               {
    141                 in = p;
    142                 break;
    143               }
    144             while (in < p)
    145               *out++ = *in++;
    146           }
    147         else
    148           *out++ = *in++;
     112        if (*in == '\\')
     113          {
     114            p = in + 1;
     115            while (*p == '\\')
     116              ++p;
     117            if (*p == '\n')
     118              {
     119                in = p;
     120                break;
     121              }
     122            while (in < p)
     123              *out++ = *in++;
     124          }
     125        else
     126          *out++ = *in++;
    149127    }
    150128
     
    168146
    169147const char *
    170 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
    171148concat (unsigned int num, ...)
    172 #else
    173 concat (num, va_alist)
    174      unsigned int num;
    175      va_dcl
    176 #endif
    177149{
    178150  static unsigned int rlen = 0;
    179151  static char *result = NULL;
    180   int ri = 0;
    181 
    182 #if USE_VARIADIC
     152  unsigned int ri = 0;
    183153  va_list args;
    184 #endif
    185 
    186   VA_START (args, num);
     154
     155  va_start (args, num);
    187156
    188157  while (num-- > 0)
    189158    {
    190159      const char *s = va_arg (args, const char *);
    191       unsigned int l = s ? strlen (s) : 0;
     160      unsigned int l = xstrlen (s);
    192161
    193162      if (l == 0)
     
    204173    }
    205174
    206   VA_END (args);
     175  va_end (args);
    207176
    208177  /* Get some more memory if we don't have enough space for the
     
    220189
    221190
    222 /* Print a message on stdout.  */
    223 
    224 void
    225 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
    226 message (int prefix, const char *fmt, ...)
    227 #else
    228 message (prefix, fmt, va_alist)
    229      int prefix;
    230      const char *fmt;
    231      va_dcl
    232 #endif
    233 {
    234 #if USE_VARIADIC
    235   va_list args;
    236 #endif
    237 
    238   log_working_directory (1);
    239 
    240   if (fmt != 0)
    241     {
    242       if (prefix)
    243         {
    244           if (makelevel == 0)
    245             printf ("%s: ", program);
    246           else
    247             printf ("%s[%u]: ", program, makelevel);
    248         }
    249       VA_START (args, fmt);
    250       VA_PRINTF (stdout, fmt, args);
    251       VA_END (args);
    252       putchar ('\n');
    253     }
    254 
    255   fflush (stdout);
    256 }
    257 
    258 /* Print an error message.  */
    259 
    260 void
    261 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
    262 error (const struct floc *flocp, const char *fmt, ...)
    263 #else
    264 error (flocp, fmt, va_alist)
    265      const struct floc *flocp;
    266      const char *fmt;
    267      va_dcl
    268 #endif
    269 {
    270 #if USE_VARIADIC
    271   va_list args;
    272 #endif
    273 
    274   log_working_directory (1);
    275 
    276   if (flocp && flocp->filenm)
    277     fprintf (stderr, "%s:%lu: ", flocp->filenm, flocp->lineno);
    278   else if (makelevel == 0)
    279     fprintf (stderr, "%s: ", program);
    280   else
    281     fprintf (stderr, "%s[%u]: ", program, makelevel);
    282 
    283   VA_START(args, fmt);
    284   VA_PRINTF (stderr, fmt, args);
    285   VA_END (args);
    286 
    287   putc ('\n', stderr);
    288   fflush (stderr);
    289 }
    290 
    291 /* Print an error message and exit.  */
    292 
    293 void
    294 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
    295 fatal (const struct floc *flocp, const char *fmt, ...)
    296 #else
    297 fatal (flocp, fmt, va_alist)
    298      const struct floc *flocp;
    299      const char *fmt;
    300      va_dcl
    301 #endif
    302 {
    303 #if USE_VARIADIC
    304   va_list args;
    305 #endif
    306 
    307   log_working_directory (1);
    308 
    309   if (flocp && flocp->filenm)
    310     fprintf (stderr, "%s:%lu: *** ", flocp->filenm, flocp->lineno);
    311   else if (makelevel == 0)
    312     fprintf (stderr, "%s: *** ", program);
    313   else
    314     fprintf (stderr, "%s[%u]: *** ", program, makelevel);
    315 
    316   VA_START(args, fmt);
    317   VA_PRINTF (stderr, fmt, args);
    318   VA_END (args);
    319 
    320   fputs (_(".  Stop.\n"), stderr);
    321 
    322   die (2);
    323 }
    324191
    325192#ifndef HAVE_STRERROR
    326 
    327 #undef  strerror
    328 
     193#undef  strerror
    329194char *
    330195strerror (int errnum)
     
    343208}
    344209#endif
    345 
    346 /* Print an error message from errno.  */
    347 
    348 void
    349 perror_with_name (const char *str, const char *name)
    350 {
    351   error (NILF, _("%s%s: %s"), str, name, strerror (errno));
    352 }
    353 
    354 /* Print an error message from errno and exit.  */
    355 
    356 void
    357 pfatal_with_name (const char *name)
    358 {
    359   fatal (NILF, _("%s: %s"), name, strerror (errno));
    360 
    361   /* NOTREACHED */
    362 }
    363210
    364211
     
    379226  void *result = malloc (size ? size : 1);
    380227  if (result == 0)
    381     fatal (NILF, _("virtual memory exhausted"));
     228    OUT_OF_MEM();
    382229  return result;
    383230}
     
    390237  void *result = calloc (size ? size : 1, 1);
    391238  if (result == 0)
    392     fatal (NILF, _("virtual memory exhausted"));
     239    OUT_OF_MEM();
    393240  return result;
    394241}
     
    405252  result = ptr ? realloc (ptr, size) : malloc (size);
    406253  if (result == 0)
    407     fatal (NILF, _("virtual memory exhausted"));
     254    OUT_OF_MEM();
    408255  return result;
    409256}
     
    422269
    423270  if (result == 0)
    424     fatal (NILF, _("virtual memory exhausted"));
     271    OUT_OF_MEM();
    425272
    426273#ifdef HAVE_STRDUP
     
    441288  result = strndup (str, length);
    442289  if (result == 0)
    443     fatal (NILF, _("virtual memory exhausted"));
     290    OUT_OF_MEM();
    444291#else
    445292  result = xmalloc (length + 1);
     
    476323end_of_token (const char *s)
    477324{
    478   while (*s != '\0' && !isblank ((unsigned char)*s))
    479     ++s;
     325  END_OF_TOKEN (s);
    480326  return (char *)s;
    481327}
    482 
    483 #ifdef WINDOWS32
    484 /*
    485  * Same as end_of_token, but take into account a stop character
    486  */
    487 char *
    488 end_of_token_w32 (const char *s, char stopchar)
    489 {
    490   const char *p = s;
    491   int backslash = 0;
    492 
    493   while (*p != '\0' && *p != stopchar
    494          && (backslash || !isblank ((unsigned char)*p)))
    495     {
    496       if (*p++ == '\\')
    497         {
    498           backslash = !backslash;
    499           while (*p == '\\')
    500             {
    501               backslash = !backslash;
    502               ++p;
    503             }
    504         }
    505       else
    506         backslash = 0;
    507     }
    508 
    509   return (char *)p;
    510 }
    511 #endif
    512328
    513329/* Return the address of the first nonwhitespace or null in the string S.  */
     
    516332next_token (const char *s)
    517333{
    518   while (isblank ((unsigned char)*s))
    519     ++s;
     334  NEXT_TOKEN (s);
    520335  return (char *)s;
    521336}
     
    542357
    543358
    544 /* Copy a chain of `struct dep'.  For 2nd expansion deps, dup the name.  */
     359/* Copy a chain of 'struct dep'.  For 2nd expansion deps, dup the name.  */
    545360
    546361struct dep *
     
    560375      c->next = 0;
    561376      if (firstnew == 0)
    562         firstnew = lastnew = c;
     377        firstnew = lastnew = c;
    563378      else
    564         lastnew = lastnew->next = c;
     379        lastnew = lastnew->next = c;
    565380
    566381      d = d->next;
     
    568383
    569384  return firstnew;
    570 }
    571 
    572 /* Free a chain of 'struct dep'.  */
    573 
    574 void
    575 free_dep_chain (struct dep *d)
    576 {
    577   while (d != 0)
    578     {
    579       struct dep *df = d;
    580       d = d->next;
    581       free_dep (df);
    582     }
    583385}
    584386
     
    593395      struct nameseq *t = ns;
    594396      ns = ns->next;
    595       free (t);
     397      free_ns (t);
    596398    }
    597399}
     
    600402
    601403#if !HAVE_STRCASECMP && !HAVE_STRICMP && !HAVE_STRCMPI
    602 
    603404/* If we don't have strcasecmp() (from POSIX), or anything that can substitute
    604405   for it, define our own version.  */
     
    626427
    627428#if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI
    628 
    629429/* If we don't have strncasecmp() (from POSIX), or anything that can
    630430   substitute for it, define our own version.  */
     
    654454
    655455
    656 #ifdef  GETLOADAVG_PRIVILEGED
     456#ifdef  GETLOADAVG_PRIVILEGED
    657457
    658458#ifdef POSIX
     
    667467#undef HAVE_SETREGID
    668468
    669 #else   /* Not POSIX.  */
     469#else   /* Not POSIX.  */
    670470
    671471/* Some POSIX.1 systems have the seteuid and setegid functions.  In a
     
    677477#undef HAVE_SETEGID
    678478
    679 #endif  /* POSIX.  */
    680 
    681 #ifndef HAVE_UNISTD_H
     479#endif  /* POSIX.  */
     480
     481#ifndef HAVE_UNISTD_H
    682482extern int getuid (), getgid (), geteuid (), getegid ();
    683483extern int setuid (), setgid ();
     
    685485extern int seteuid ();
    686486#else
    687 #ifdef  HAVE_SETREUID
     487#ifdef  HAVE_SETREUID
    688488extern int setreuid ();
    689 #endif  /* Have setreuid.  */
    690 #endif  /* Have seteuid.  */
     489#endif  /* Have setreuid.  */
     490#endif  /* Have seteuid.  */
    691491#ifdef HAVE_SETEGID
    692492extern int setegid ();
    693493#else
    694 #ifdef  HAVE_SETREGID
     494#ifdef  HAVE_SETREGID
    695495extern int setregid ();
    696 #endif  /* Have setregid.  */
    697 #endif  /* Have setegid.  */
    698 #endif  /* No <unistd.h>.  */
     496#endif  /* Have setregid.  */
     497#endif  /* Have setegid.  */
     498#endif  /* No <unistd.h>.  */
    699499
    700500/* Keep track of the user and group IDs for user- and make- access.  */
    701501static int user_uid = -1, user_gid = -1, make_uid = -1, make_gid = -1;
    702 #define access_inited   (user_uid != -1)
     502#define access_inited   (user_uid != -1)
    703503static enum { make, user } current_access;
    704504
     
    717517
    718518  fprintf (stderr, _("%s: user %lu (real %lu), group %lu (real %lu)\n"),
    719            flavor, (unsigned long) geteuid (), (unsigned long) getuid (),
     519           flavor, (unsigned long) geteuid (), (unsigned long) getuid (),
    720520           (unsigned long) getegid (), (unsigned long) getgid ());
    721521  fflush (stderr);
     
    743543}
    744544
    745 #endif  /* GETLOADAVG_PRIVILEGED */
     545#endif  /* GETLOADAVG_PRIVILEGED */
    746546
    747547/* Give the process appropriate permissions for access to
     
    750550user_access (void)
    751551{
    752 #ifdef  GETLOADAVG_PRIVILEGED
     552#ifdef  GETLOADAVG_PRIVILEGED
    753553
    754554  if (!access_inited)
     
    763563     which are the IDs of the process that exec'd make.  */
    764564
    765 #ifdef  HAVE_SETEUID
     565#ifdef  HAVE_SETEUID
    766566
    767567  /* Modern systems have the seteuid/setegid calls which set only the
     
    771571    pfatal_with_name ("user_access: seteuid");
    772572
    773 #else   /* Not HAVE_SETEUID.  */
    774 
    775 #ifndef HAVE_SETREUID
     573#else   /* Not HAVE_SETEUID.  */
     574
     575#ifndef HAVE_SETREUID
    776576
    777577  /* System V has only the setuid/setgid calls to set user/group IDs.
     
    786586    pfatal_with_name ("user_access: setuid");
    787587
    788 #else   /* HAVE_SETREUID.  */
     588#else   /* HAVE_SETREUID.  */
    789589
    790590  /* In 4BSD, the setreuid/setregid calls set both the real and effective IDs.
     
    798598    pfatal_with_name ("user_access: setreuid");
    799599
    800 #endif  /* Not HAVE_SETREUID.  */
    801 #endif  /* HAVE_SETEUID.  */
    802 
    803 #ifdef  HAVE_SETEGID
     600#endif  /* Not HAVE_SETREUID.  */
     601#endif  /* HAVE_SETEUID.  */
     602
     603#ifdef  HAVE_SETEGID
    804604  if (setegid (user_gid) < 0)
    805605    pfatal_with_name ("user_access: setegid");
    806606#else
    807 #ifndef HAVE_SETREGID
     607#ifndef HAVE_SETREGID
    808608  if (setgid (user_gid) < 0)
    809609    pfatal_with_name ("user_access: setgid");
     
    818618  log_access (_("User access"));
    819619
    820 #endif  /* GETLOADAVG_PRIVILEGED */
     620#endif  /* GETLOADAVG_PRIVILEGED */
    821621}
    822622
     
    826626make_access (void)
    827627{
    828 #ifdef  GETLOADAVG_PRIVILEGED
     628#ifdef  GETLOADAVG_PRIVILEGED
    829629
    830630  if (!access_inited)
     
    836636  /* See comments in user_access, above.  */
    837637
    838 #ifdef  HAVE_SETEUID
     638#ifdef  HAVE_SETEUID
    839639  if (seteuid (make_uid) < 0)
    840640    pfatal_with_name ("make_access: seteuid");
    841641#else
    842 #ifndef HAVE_SETREUID
     642#ifndef HAVE_SETREUID
    843643  if (setuid (make_uid) < 0)
    844644    pfatal_with_name ("make_access: setuid");
     
    849649#endif
    850650
    851 #ifdef  HAVE_SETEGID
     651#ifdef  HAVE_SETEGID
    852652  if (setegid (make_gid) < 0)
    853653    pfatal_with_name ("make_access: setegid");
    854654#else
    855 #ifndef HAVE_SETREGID
     655#ifndef HAVE_SETREGID
    856656  if (setgid (make_gid) < 0)
    857657    pfatal_with_name ("make_access: setgid");
     
    866666  log_access (_("Make access"));
    867667
    868 #endif  /* GETLOADAVG_PRIVILEGED */
     668#endif  /* GETLOADAVG_PRIVILEGED */
    869669}
    870670
     
    874674child_access (void)
    875675{
    876 #ifdef  GETLOADAVG_PRIVILEGED
     676#ifdef  GETLOADAVG_PRIVILEGED
    877677
    878678  if (!access_inited)
     
    882682     They cannot be changed back to make's.  */
    883683
    884 #ifndef HAVE_SETREUID
     684#ifndef HAVE_SETREUID
    885685  if (setuid (user_uid) < 0)
    886686    pfatal_with_name ("child_access: setuid");
     
    890690#endif
    891691
    892 #ifndef HAVE_SETREGID
     692#ifndef HAVE_SETREGID
    893693  if (setgid (user_gid) < 0)
    894694    pfatal_with_name ("child_access: setgid");
     
    900700  log_access (_("Child access"));
    901701
    902 #endif  /* GETLOADAVG_PRIVILEGED */
    903 }
    904 
     702#endif  /* GETLOADAVG_PRIVILEGED */
     703}
    905704
    906705#ifdef NEED_GET_PATH_MAX
     
    914713      long int x = pathconf ("/", _PC_PATH_MAX);
    915714      if (x > 0)
    916         value = x;
     715        value = x;
    917716      else
    918         return MAXPATHLEN;
     717        return MAXPATHLEN;
    919718    }
    920719
     
    922721}
    923722#endif
    924 
    925 
    926 
    927 /* This code is stolen from gnulib.
    928    If/when we abandon the requirement to work with K&R compilers, we can
    929    remove this (and perhaps other parts of GNU make!) and migrate to using
    930    gnulib directly.
    931 
    932    This is called only through atexit(), which means die() has already been
    933    invoked.  So, call exit() here directly.  Apparently that works...?
    934 */
    935 
    936 /* Close standard output, exiting with status 'exit_failure' on failure.
    937    If a program writes *anything* to stdout, that program should close
    938    stdout and make sure that it succeeds before exiting.  Otherwise,
    939    suppose that you go to the extreme of checking the return status
    940    of every function that does an explicit write to stdout.  The last
    941    printf can succeed in writing to the internal stream buffer, and yet
    942    the fclose(stdout) could still fail (due e.g., to a disk full error)
    943    when it tries to write out that buffered data.  Thus, you would be
    944    left with an incomplete output file and the offending program would
    945    exit successfully.  Even calling fflush is not always sufficient,
    946    since some file systems (NFS and CODA) buffer written/flushed data
    947    until an actual close call.
    948 
    949    Besides, it's wasteful to check the return value from every call
    950    that writes to stdout -- just let the internal stream state record
    951    the failure.  That's what the ferror test is checking below.
    952 
    953    It's important to detect such failures and exit nonzero because many
    954    tools (most notably `make' and other build-management systems) depend
    955    on being able to detect failure in other tools via their exit status.  */
    956 
    957 void
    958 close_stdout (void)
    959 {
    960   int prev_fail = ferror (stdout);
    961   int fclose_fail = fclose (stdout);
    962 
    963   if (prev_fail || fclose_fail)
    964     {
    965       if (fclose_fail)
    966         error (NILF, _("write error: %s"), strerror (errno));
    967       else
    968         error (NILF, _("write error"));
    969       exit (EXIT_FAILURE);
    970     }
    971 }
  • vendor/gnumake/current/po/LINGUAS

    r2596 r3138  
    1 # Set of available languages: 24 languages
     1# Set of available languages: 25 languages
    22
    3 be da de es fi fr ga gl he hr id it ja ko lt nl pl pt_BR ru sv tr uk vi zh_CN
     3be cs da de es fi fr ga gl he hr id it ja ko lt nl pl pt_BR ru sv tr uk vi zh_CN
    44
    55# Can't seem to get en@quot and en@boldquot to build properly?
  • vendor/gnumake/current/po/Makevars

    r2596 r3138  
    11# This is a -*-Makefile-*-
    2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
    3 # Software Foundation, Inc.
     2# Copyright (C) 2002-2016 Free Software Foundation, Inc.
    43# This file is part of GNU Make.
    54#
  • vendor/gnumake/current/po/POTFILES.in

    r2596 r3138  
    11# List of source files containing translatable strings.
    2 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    3 # 2010 Free Software Foundation, Inc.
     2# Copyright (C) 2000-2016 Free Software Foundation, Inc.
    43# This file is part of GNU Make.
    54#
     
    2524function.c
    2625getopt.c
     26guile.c
    2727hash.c
    2828implicit.c
    2929job.c
     30job.h
     31load.c
    3032main.c
    3133misc.c
     34output.c
     35posixos.c
    3236read.c
    3337remake.c
     
    4145vmsjobs.c
    4246vpath.c
     47w32/w32os.c
  • vendor/gnumake/current/prepare_w32.bat

    r1991 r3138  
    11@echo off
    2 @echo Windows32 CVS build preparation of config.h.W32 and NMakefile.
     2@echo Windows32 SCM build preparation of config.h.W32 and NMakefile.
    33if not exist config.h.W32 copy config.h.W32.template config.h.W32
    44if not exist config.h copy config.h.W32 config.h
  • vendor/gnumake/current/read.c

    r2596 r3138  
    11/* Reading and parsing of makefiles for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018
    2119#include <assert.h>
    2220
    23 #include <glob.h>
    24 
     21#include "filedef.h"
    2522#include "dep.h"
    26 #include "filedef.h"
    2723#include "job.h"
    2824#include "commands.h"
     
    3329
    3430
    35 #ifndef WINDOWS32
     31#ifdef WINDOWS32
     32#include <windows.h>
     33#include "sub_proc.h"
     34#else  /* !WINDOWS32 */
    3635#ifndef _AMIGA
    3736#ifndef VMS
     
    5453    unsigned int size;  /* Malloc'd size of buffer. */
    5554    FILE *fp;           /* File, or NULL if this is an internal buffer.  */
    56     struct floc floc;   /* Info on the file in fp (if any).  */
     55    floc floc;          /* Info on the file in fp (if any).  */
    5756  };
    5857
     
    7776
    7877
    79 /* A `struct conditionals' contains the information describing
     78/* A 'struct conditionals' contains the information describing
    8079   all the active conditionals in a makefile.
    8180
    82    The global variable `conditionals' contains the conditionals
     81   The global variable 'conditionals' contains the conditionals
    8382   information for the current makefile.  It is initialized from
    84    the static structure `toplevel_conditionals' and is later changed
     83   the static structure 'toplevel_conditionals' and is later changed
    8584   to new structures for included makefiles.  */
    8685
    8786struct conditionals
    8887  {
    89     unsigned int if_cmds;       /* Depth of conditional nesting.  */
    90     unsigned int allocated;     /* Elts allocated in following arrays.  */
    91     char *ignoring;             /* Are we ignoring or interpreting?
     88    unsigned int if_cmds;       /* Depth of conditional nesting.  */
     89    unsigned int allocated;     /* Elts allocated in following arrays.  */
     90    char *ignoring;             /* Are we ignoring or interpreting?
    9291                                   0=interpreting, 1=not yet interpreted,
    9392                                   2=already interpreted */
    94     char *seen_else;            /* Have we already seen an `else'?  */
     93    char *seen_else;            /* Have we already seen an 'else'?  */
    9594  };
    9695
     
    128127   makefile currently being read in.  */
    129128
    130 const struct floc *reading_file = 0;
    131 
    132 /* The chain of makefiles read by read_makefile.  */
    133 
    134 static struct dep *read_makefiles = 0;
    135 
    136 static int eval_makefile (const char *filename, int flags);
     129const floc *reading_file = 0;
     130
     131/* The chain of files read by read_all_makefiles.  */
     132
     133static struct goaldep *read_files = 0;
     134
     135static struct goaldep *eval_makefile (const char *filename, int flags);
    137136static void eval (struct ebuffer *buffer, int flags);
    138137
     
    142141static struct variable *do_define (char *name, enum variable_origin origin,
    143142                                   struct ebuffer *ebuf);
    144 static int conditional_line (char *line, int len, const struct floc *flocp);
     143static int conditional_line (char *line, int len, const floc *flocp);
    145144static void record_files (struct nameseq *filenames, const char *pattern,
    146145                          const char *pattern_percent, char *depstr,
    147146                          unsigned int cmds_started, char *commands,
    148147                          unsigned int commands_idx, int two_colon,
    149                           const struct floc *flocp);
     148                          char prefix, const floc *flocp);
    150149static void record_target_var (struct nameseq *filenames, char *defn,
    151150                               enum variable_origin origin,
    152151                               struct vmodifiers *vmod,
    153                                const struct floc *flocp);
     152                               const floc *flocp);
    154153static enum make_word_type get_next_mword (char *buffer, char *delim,
    155154                                           char **startp, unsigned int *length);
    156155static void remove_comments (char *line);
    157 static char *find_char_unquote (char *string, int stop1, int stop2,
    158                                 int blank, int ignorevars);
     156static char *find_char_unquote (char *string, int map);
     157static char *unescape_char (char *string, int c);
    159158
    160159
     
    162161   P must point to the word to be tested, and WLEN must be the length.
    163162*/
    164 #define word1eq(s)      (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
    165 
    166 
    167 
    168 /* Read in all the makefiles and return the chain of their names.  */
    169 
    170 struct dep *
     163#define word1eq(s)      (wlen == CSTRLEN (s) && strneq (s, p, CSTRLEN (s)))
     164
     165
     166
     167/* Read in all the makefiles and return a chain of targets to rebuild.  */
     168
     169struct goaldep *
    171170read_all_makefiles (const char **makefiles)
    172171{
     
    205204    while ((name = find_next_token ((const char **)&p, &length)) != 0)
    206205      {
    207         if (*p != '\0')
    208           *p++ = '\0';
    209         eval_makefile (name, RM_NO_DEFAULT_GOAL|RM_INCLUDED|RM_DONTCARE);
     206        if (*p != '\0')
     207          *p++ = '\0';
     208        eval_makefile (name, RM_NO_DEFAULT_GOAL|RM_INCLUDED|RM_DONTCARE);
    210209      }
    211210
     
    218217    while (*makefiles != 0)
    219218      {
    220         struct dep *tail = read_makefiles;
    221         register struct dep *d;
    222 
    223         if (! eval_makefile (*makefiles, 0))
    224           perror_with_name ("", *makefiles);
    225 
    226         /* Find the right element of read_makefiles.  */
    227         d = read_makefiles;
    228         while (d->next != tail)
    229           d = d->next;
    230 
    231         /* Use the storage read_makefile allocates.  */
    232         *makefiles = dep_name (d);
    233         ++num_makefiles;
    234         ++makefiles;
     219        struct goaldep *d = eval_makefile (*makefiles, 0);
     220
     221        if (errno)
     222          perror_with_name ("", *makefiles);
     223
     224        /* Reuse the storage allocated for the read_file.  */
     225        *makefiles = dep_name (d);
     226        ++num_makefiles;
     227        ++makefiles;
    235228      }
    236229
     
    239232  if (num_makefiles == 0)
    240233    {
    241       static char *default_makefiles[] =
     234      static const char *default_makefiles[] =
    242235#ifdef VMS
    243         /* all lower case since readdir() (the vms version) 'lowercasifies' */
    244         { "makefile.vms", "gnumakefile.", "makefile.", 0 };
     236        /* all lower case since readdir() (the vms version) 'lowercasifies' */
     237        /* TODO: Above is not always true, this needs more work */
     238        { "makefile.vms", "gnumakefile", "makefile", 0 };
    245239#else
    246240#ifdef _AMIGA
    247         { "GNUmakefile", "Makefile", "SMakefile", 0 };
     241        { "GNUmakefile", "Makefile", "SMakefile", 0 };
    248242#else /* !Amiga && !VMS */
    249         { "GNUmakefile", "makefile", "Makefile", 0 };
     243#ifdef WINDOWS32
     244        { "GNUmakefile", "makefile", "Makefile", "makefile.mak", 0 };
     245#else /* !Amiga && !VMS && !WINDOWS32 */
     246        { "GNUmakefile", "makefile", "Makefile", 0 };
     247#endif /* !Amiga && !VMS && !WINDOWS32 */
    250248#endif /* AMIGA */
    251249#endif /* VMS */
    252       register char **p = default_makefiles;
     250      const char **p = default_makefiles;
    253251      while (*p != 0 && !file_exists_p (*p))
    254         ++p;
     252        ++p;
    255253
    256254      if (*p != 0)
    257         {
    258           if (! eval_makefile (*p, 0))
    259             perror_with_name ("", *p);
    260         }
     255        {
     256          eval_makefile (*p, 0);
     257          if (errno)
     258            perror_with_name ("", *p);
     259        }
    261260      else
    262         {
    263           /* No default makefile was found.  Add the default makefiles to the
    264              `read_makefiles' chain so they will be updated if possible.  */
    265           struct dep *tail = read_makefiles;
    266           /* Add them to the tail, after any MAKEFILES variable makefiles.  */
    267           while (tail != 0 && tail->next != 0)
    268             tail = tail->next;
    269           for (p = default_makefiles; *p != 0; ++p)
    270             {
    271               struct dep *d = alloc_dep ();
    272               d->file = enter_file (strcache_add (*p));
    273               d->dontcare = 1;
    274               /* Tell update_goal_chain to bail out as soon as this file is
    275                  made, and main not to die if we can't make this file.  */
    276               d->changed = RM_DONTCARE;
    277               if (tail == 0)
    278                 read_makefiles = d;
    279               else
    280                 tail->next = d;
    281               tail = d;
    282             }
    283           if (tail != 0)
    284             tail->next = 0;
    285         }
    286     }
    287 
    288   return read_makefiles;
     261        {
     262          /* No default makefile was found.  Add the default makefiles to the
     263             'read_files' chain so they will be updated if possible.  */
     264          struct goaldep *tail = read_files;
     265          /* Add them to the tail, after any MAKEFILES variable makefiles.  */
     266          while (tail != 0 && tail->next != 0)
     267            tail = tail->next;
     268          for (p = default_makefiles; *p != 0; ++p)
     269            {
     270              struct goaldep *d = alloc_goaldep ();
     271              d->file = enter_file (strcache_add (*p));
     272              /* Tell update_goal_chain to bail out as soon as this file is
     273                 made, and main not to die if we can't make this file.  */
     274              d->flags = RM_DONTCARE;
     275              if (tail == 0)
     276                read_files = d;
     277              else
     278                tail->next = d;
     279              tail = d;
     280            }
     281          if (tail != 0)
     282            tail->next = 0;
     283        }
     284    }
     285
     286  return read_files;
    289287}
    290288
     
    309307{
    310308  /* Free any space allocated by conditional_line.  */
    311   if (conditionals->ignoring)
    312     free (conditionals->ignoring);
    313   if (conditionals->seen_else)
    314     free (conditionals->seen_else);
     309  free (conditionals->ignoring);
     310  free (conditionals->seen_else);
    315311
    316312  /* Restore state.  */
     
    319315
    320316
    321 static int
     317static struct goaldep *
    322318eval_makefile (const char *filename, int flags)
    323319{
    324   struct dep *deps;
     320  struct goaldep *deps;
    325321  struct ebuffer ebuf;
    326   const struct floc *curfile;
     322  const floc *curfile;
    327323  char *expanded = 0;
    328324  int makefile_errno;
    329325
    330   filename = strcache_add (filename);
    331   ebuf.floc.filenm = filename;
     326  ebuf.floc.filenm = filename; /* Use the original file name.  */
    332327  ebuf.floc.lineno = 1;
     328  ebuf.floc.offset = 0;
    333329
    334330  if (ISDB (DB_VERBOSE))
    335331    {
    336       printf (_("Reading makefile `%s'"), filename);
     332      printf (_("Reading makefile '%s'"), filename);
    337333      if (flags & RM_NO_DEFAULT_GOAL)
    338         printf (_(" (no default goal)"));
     334        printf (_(" (no default goal)"));
    339335      if (flags & RM_INCLUDED)
    340         printf (_(" (search path)"));
     336        printf (_(" (search path)"));
    341337      if (flags & RM_DONTCARE)
    342         printf (_(" (don't care)"));
     338        printf (_(" (don't care)"));
    343339      if (flags & RM_NO_TILDE)
    344         printf (_(" (no ~ expansion)"));
     340        printf (_(" (no ~ expansion)"));
    345341      puts ("...");
    346342    }
     
    348344  /* First, get a stream to read.  */
    349345
    350   /* Expand ~ in FILENAME unless it came from `include',
     346  /* Expand ~ in FILENAME unless it came from 'include',
    351347     in which case it was already done.  */
    352348  if (!(flags & RM_NO_TILDE) && filename[0] == '~')
     
    354350      expanded = tilde_expand (filename);
    355351      if (expanded != 0)
    356         filename = expanded;
    357     }
    358 
    359   ebuf.fp = fopen (filename, "r");
     352        filename = expanded;
     353    }
     354
     355  ENULLLOOP (ebuf.fp, fopen (filename, "r"));
     356
    360357  /* Save the error code so we print the right message later.  */
    361358  makefile_errno = errno;
    362359
     360  /* Check for unrecoverable errors: out of mem or FILE slots.  */
     361  switch (makefile_errno)
     362    {
     363#ifdef EMFILE
     364    case EMFILE:
     365#endif
     366#ifdef ENFILE
     367    case ENFILE:
     368#endif
     369    case ENOMEM:
     370      {
     371        const char *err = strerror (makefile_errno);
     372        OS (fatal, reading_file, "%s", err);
     373      }
     374    }
     375
    363376  /* If the makefile wasn't found and it's either a makefile from
    364      the `MAKEFILES' variable or an included makefile,
     377     the 'MAKEFILES' variable or an included makefile,
    365378     search the included makefile search path for this makefile.  */
    366379  if (ebuf.fp == 0 && (flags & RM_INCLUDED) && *filename != '/')
     
    368381      unsigned int i;
    369382      for (i = 0; include_directories[i] != 0; ++i)
    370         {
    371           const char *included = concat (3, include_directories[i],
     383        {
     384          const char *included = concat (3, include_directories[i],
    372385                                         "/", filename);
    373           ebuf.fp = fopen (included, "r");
    374           if (ebuf.fp)
    375             {
    376               filename = strcache_add (included);
    377               break;
    378             }
    379         }
    380     }
     386          ebuf.fp = fopen (included, "r");
     387          if (ebuf.fp)
     388            {
     389              filename = included;
     390              break;
     391            }
     392        }
     393    }
     394
     395  /* Now we have the final name for this makefile. Enter it into
     396     the cache.  */
     397  filename = strcache_add (filename);
    381398
    382399  /* Add FILENAME to the chain of read makefiles.  */
    383   deps = alloc_dep ();
    384   deps->next = read_makefiles;
    385   read_makefiles = deps;
     400  deps = alloc_goaldep ();
     401  deps->next = read_files;
     402  read_files = deps;
    386403  deps->file = lookup_file (filename);
    387404  if (deps->file == 0)
    388405    deps->file = enter_file (filename);
    389406  filename = deps->file->name;
    390   deps->changed = flags;
    391   if (flags & RM_DONTCARE)
    392     deps->dontcare = 1;
    393 
    394   if (expanded)
    395     free (expanded);
     407  deps->flags = flags;
     408
     409  free (expanded);
    396410
    397411  /* If the makefile can't be found at all, give up entirely.  */
     
    400414    {
    401415      /* If we did some searching, errno has the error from the last
    402          attempt, rather from FILENAME itself.  Restore it in case the
    403         caller wants to use it in a message.  */
     416         attempt, rather from FILENAME itself.  Store it in case the
     417        caller wants to use it in a message.  */
    404418      errno = makefile_errno;
    405       return 0;
     419      return deps;
    406420    }
    407421
     
    433447  alloca (0);
    434448
    435   return 1;
     449  errno = 0;
     450  return deps;
    436451}
    437452
    438453void
    439 eval_buffer (char *buffer)
     454eval_buffer (char *buffer, const floc *flocp)
    440455{
    441456  struct ebuffer ebuf;
    442457  struct conditionals *saved;
    443458  struct conditionals new;
    444   const struct floc *curfile;
     459  const floc *curfile;
    445460
    446461  /* Evaluate the buffer */
     
    450465  ebuf.fp = NULL;
    451466
    452   if (reading_file)
     467  if (flocp)
     468    ebuf.floc = *flocp;
     469  else if (reading_file)
    453470    ebuf.floc = *reading_file;
    454471  else
    455     ebuf.floc.filenm = NULL;
     472    {
     473      ebuf.floc.filenm = NULL;
     474      ebuf.floc.lineno = 1;
     475      ebuf.floc.offset = 0;
     476    }
    456477
    457478  curfile = reading_file;
     
    488509
    489510  /* Find the start of the next token.  If there isn't one we're done.  */
    490   line = next_token (line);
     511  NEXT_TOKEN (line);
    491512  if (*line == '\0')
    492513    return (char *)line;
     
    497518      int wlen;
    498519      const char *p2;
    499       enum variable_flavor flavor;
    500 
    501       p2 = parse_variable_definition (p, &flavor);
     520      struct variable v;
     521
     522      p2 = parse_variable_definition (p, &v);
    502523
    503524      /* If this is a variable assignment, we're done.  */
     
    560581  unsigned int cmds_started, tgts_started;
    561582  int ignoring = 0, in_ignored_define = 0;
    562   int no_targets = 0;           /* Set when reading a rule without targets.  */
     583  int no_targets = 0;           /* Set when reading a rule without targets.  */
    563584  struct nameseq *filenames = 0;
    564585  char *depstr = 0;
    565586  long nlines = 0;
    566587  int two_colon = 0;
     588  char prefix = cmd_prefix;
    567589  const char *pattern = 0;
    568590  const char *pattern_percent;
    569   struct floc *fstart;
    570   struct floc fi;
    571 
    572 #define record_waiting_files()                                                \
    573   do                                                                          \
    574     {                                                                         \
    575       if (filenames != 0)                                                     \
     591  floc *fstart;
     592  floc fi;
     593
     594#define record_waiting_files()                                                \
     595  do                                                                          \
     596    {                                                                         \
     597      if (filenames != 0)                                                     \
    576598        {                                                                     \
    577           fi.lineno = tgts_started;                                           \
    578           record_files (filenames, pattern, pattern_percent, depstr,          \
     599          fi.lineno = tgts_started;                                           \
     600          fi.offset = 0;                                                      \
     601          record_files (filenames, pattern, pattern_percent, depstr,          \
    579602                        cmds_started, commands, commands_idx, two_colon,      \
    580                         &fi);                                                 \
    581           filenames = 0;                                                      \
     603                        prefix, &fi);                                         \
     604          filenames = 0;                                                      \
    582605        }                                                                     \
    583       commands_idx = 0;                                                       \
     606      commands_idx = 0;                                                       \
    584607      no_targets = 0;                                                         \
    585608      pattern = 0;                                                            \
     
    598621
    599622     When you see a "continue" in the loop below, that means we are moving on
    600      to the next line _without_ ending any rule that we happen to be working
    601      with at the moment.  If you see a "goto rule_complete", then the
    602      statement we just parsed also finishes the previous rule.  */
     623     to the next line.  If you see record_waiting_files(), then the statement
     624     we are parsing also finishes the previous rule.  */
    603625
    604626  commands = xmalloc (200);
     
    622644        break;
    623645
     646      line = ebuf->buffer;
     647
     648      /* If this is the first line, check for a UTF-8 BOM and skip it.  */
     649      if (ebuf->floc.lineno == 1 && line[0] == (char)0xEF
     650          && line[1] == (char)0xBB && line[2] == (char)0xBF)
     651        {
     652          line += 3;
     653          if (ISDB(DB_BASIC))
     654            {
     655              if (ebuf->floc.filenm)
     656                printf (_("Skipping UTF-8 BOM in makefile '%s'\n"),
     657                        ebuf->floc.filenm);
     658              else
     659                printf (_("Skipping UTF-8 BOM in makefile buffer\n"));
     660            }
     661        }
     662
    624663      /* If this line is empty, skip it.  */
    625       line = ebuf->buffer;
    626664      if (line[0] == '\0')
    627665        continue;
     
    630668
    631669      /* Check for a shell command line first.
    632          If it is not one, we can stop treating tab specially.  */
     670         If it is not one, we can stop treating cmd_prefix specially.  */
    633671      if (line[0] == cmd_prefix)
    634         {
    635           if (no_targets)
    636             /* Ignore the commands in a rule with no targets.  */
    637             continue;
    638 
    639           /* If there is no preceding rule line, don't treat this line
    640              as a command, even though it begins with a recipe prefix.
    641              SunOS 4 make appears to behave this way.  */
    642 
    643           if (filenames != 0)
    644             {
    645               if (ignoring)
    646                 /* Yep, this is a shell command, and we don't care.  */
    647                 continue;
    648 
    649               /* Append this command line to the line being accumulated.
    650                  Strip command prefix chars that appear after newlines.  */
    651               if (commands_idx == 0)
    652                 cmds_started = ebuf->floc.lineno;
    653 
    654               if (linelen + commands_idx > commands_len)
    655                 {
    656                   commands_len = (linelen + commands_idx) * 2;
    657                   commands = xrealloc (commands, commands_len);
    658                 }
    659               p = &commands[commands_idx];
    660               p2 = line + 1;
    661               while (--linelen)
     672        {
     673          if (no_targets)
     674            /* Ignore the commands in a rule with no targets.  */
     675            continue;
     676
     677          /* If there is no preceding rule line, don't treat this line
     678             as a command, even though it begins with a recipe prefix.
     679             SunOS 4 make appears to behave this way.  */
     680
     681          if (filenames != 0)
     682            {
     683              if (ignoring)
     684                /* Yep, this is a shell command, and we don't care.  */
     685                continue;
     686
     687              if (commands_idx == 0)
     688                cmds_started = ebuf->floc.lineno;
     689
     690              /* Append this command line to the line being accumulated.
     691                 Skip the initial command prefix character.  */
     692              if (linelen + commands_idx > commands_len)
    662693                {
    663                   ++commands_idx;
    664                   *(p++) = *p2;
    665                   if (p2[0] == '\n' && p2[1] == cmd_prefix)
    666                     {
    667                       ++p2;
    668                       --linelen;
    669                     }
    670                   ++p2;
     694                  commands_len = (linelen + commands_idx) * 2;
     695                  commands = xrealloc (commands, commands_len);
    671696                }
    672               *p = '\n';
    673               ++commands_idx;
    674 
    675               continue;
    676             }
    677         }
     697              memcpy (&commands[commands_idx], line + 1, linelen - 1);
     698              commands_idx += linelen - 1;
     699              commands[commands_idx++] = '\n';
     700              continue;
     701            }
     702        }
    678703
    679704      /* This line is not a shell command line.  Don't worry about whitespace.
     
    682707
    683708      if (collapsed_length < linelen+1)
    684         {
    685           collapsed_length = linelen+1;
    686           if (collapsed)
    687             free (collapsed);
     709        {
     710          collapsed_length = linelen+1;
     711          free (collapsed);
    688712          /* Don't need xrealloc: we don't need to preserve the content.  */
    689           collapsed = xmalloc (collapsed_length);
    690         }
     713          collapsed = xmalloc (collapsed_length);
     714        }
    691715      strcpy (collapsed, line);
    692716      /* Collapse continuation lines.  */
     
    696720      /* Get rid if starting space (including formfeed, vtab, etc.)  */
    697721      p = collapsed;
    698       while (isspace ((unsigned char)*p))
    699         ++p;
     722      NEXT_TOKEN (p);
    700723
    701724      /* See if this is a variable assignment.  We need to do this early, to
    702725         allow variables with names like 'ifdef', 'export', 'private', etc.  */
    703       p = parse_var_assignment(p, &vmod);
     726      p = parse_var_assignment (p, &vmod);
    704727      if (vmod.assign_v)
    705728        {
     
    708731
    709732          /* If we're ignoring then we're done now.  */
    710           if (ignoring)
     733          if (ignoring)
    711734            {
    712735              if (vmod.define_v)
     
    715738            }
    716739
     740          /* Variable assignment ends the previous rule.  */
     741          record_waiting_files ();
     742
    717743          if (vmod.undefine_v)
    718744          {
    719745            do_undefine (p, origin, ebuf);
    720 
    721             /* This line has been dealt with.  */
    722             goto rule_complete;
     746            continue;
    723747          }
    724748          else if (vmod.define_v)
     
    735759
    736760          /* This line has been dealt with.  */
    737           goto rule_complete;
     761          continue;
    738762        }
    739763
    740764      /* If this line is completely empty, ignore it.  */
    741765      if (*p == '\0')
    742         continue;
     766        continue;
    743767
    744768      p2 = end_of_token (p);
    745769      wlen = p2 - p;
    746       p2 = next_token (p2);
     770      NEXT_TOKEN (p2);
    747771
    748772      /* If we're in an ignored define, skip this line (but maybe get out).  */
    749773      if (in_ignored_define)
    750         {
     774        {
    751775          /* See if this is an endef line (plus optional comment).  */
    752           if (word1eq ("endef") && (*p2 == '\0' || *p2 == '#'))
     776          if (word1eq ("endef") && STOP_SET (*p2, MAP_COMMENT|MAP_NUL))
    753777            in_ignored_define = 0;
    754778
    755           continue;
    756         }
     779          continue;
     780        }
    757781
    758782      /* Check for conditional state changes.  */
     
    762786          {
    763787            if (i == -1)
    764               fatal (fstart, _("invalid syntax in conditional"));
     788              O (fatal, fstart, _("invalid syntax in conditional"));
    765789
    766790            ignoring = i;
     
    771795      /* Nothing to see here... move along.  */
    772796      if (ignoring)
    773         continue;
     797        continue;
    774798
    775799      /* Manage the "export" keyword used outside of variable assignment
    776800         as well as "unexport".  */
    777801      if (word1eq ("export") || word1eq ("unexport"))
    778         {
     802        {
    779803          int exporting = *p == 'u' ? 0 : 1;
    780804
     805          /* Export/unexport ends the previous rule.  */
     806          record_waiting_files ();
     807
    781808          /* (un)export by itself causes everything to be (un)exported. */
    782           if (*p2 == '\0')
     809          if (*p2 == '\0')
    783810            export_all_variables = exporting;
    784811          else
     
    797824                  struct variable *v = lookup_variable (p, l);
    798825                  if (v == 0)
    799                     v = define_variable_loc (p, l, "", o_file, 0, fstart);
     826                    v = define_variable_global (p, l, "", o_file, 0, fstart);
    800827                  v->export = exporting ? v_export : v_noexport;
    801828                }
     
    803830              free (ap);
    804831            }
    805           goto rule_complete;
    806         }
     832          continue;
     833        }
    807834
    808835      /* Handle the special syntax for vpath.  */
    809836      if (word1eq ("vpath"))
    810         {
     837        {
    811838          const char *cp;
    812           char *vpat;
    813           unsigned int l;
    814           cp = variable_expand (p2);
    815           p = find_next_token (&cp, &l);
    816           if (p != 0)
    817             {
    818               vpat = xstrndup (p, l);
    819               p = find_next_token (&cp, &l);
    820               /* No searchpath means remove all previous
    821                  selective VPATH's with the same pattern.  */
    822             }
    823           else
    824             /* No pattern means remove all previous selective VPATH's.  */
    825             vpat = 0;
    826           construct_vpath_list (vpat, p);
    827           if (vpat != 0)
    828             free (vpat);
    829 
    830           goto rule_complete;
    831         }
     839          char *vpat;
     840          unsigned int l;
     841
     842          /* vpath ends the previous rule.  */
     843          record_waiting_files ();
     844
     845          cp = variable_expand (p2);
     846          p = find_next_token (&cp, &l);
     847          if (p != 0)
     848            {
     849              vpat = xstrndup (p, l);
     850              p = find_next_token (&cp, &l);
     851              /* No searchpath means remove all previous
     852                 selective VPATH's with the same pattern.  */
     853            }
     854          else
     855            /* No pattern means remove all previous selective VPATH's.  */
     856            vpat = 0;
     857          construct_vpath_list (vpat, p);
     858          free (vpat);
     859
     860          continue;
     861        }
    832862
    833863      /* Handle include and variants.  */
    834864      if (word1eq ("include") || word1eq ("-include") || word1eq ("sinclude"))
    835         {
    836           /* We have found an `include' line specifying a nested
    837              makefile to be read at this point.  */
    838           struct conditionals *save;
     865        {
     866          /* We have found an 'include' line specifying a nested
     867             makefile to be read at this point.  */
     868          struct conditionals *save;
    839869          struct conditionals new_conditionals;
    840           struct nameseq *files;
    841           /* "-include" (vs "include") says no error if the file does not
    842              exist.  "sinclude" is an alias for this from SGI.  */
    843           int noerror = (p[0] != 'i');
    844 
    845           p = allocated_variable_expand (p2);
     870          struct nameseq *files;
     871          /* "-include" (vs "include") says no error if the file does not
     872             exist.  "sinclude" is an alias for this from SGI.  */
     873          int noerror = (p[0] != 'i');
     874
     875          /* Include ends the previous rule.  */
     876          record_waiting_files ();
     877
     878          p = allocated_variable_expand (p2);
    846879
    847880          /* If no filenames, it's a no-op.  */
    848           if (*p == '\0')
     881          if (*p == '\0')
    849882            {
    850883              free (p);
     
    852885            }
    853886
    854           /* Parse the list of file names.  Don't expand archive references!  */
    855           p2 = p;
    856           files = PARSE_FILE_SEQ (&p2, struct nameseq, '\0', NULL,
     887          /* Parse the list of file names.  Don't expand archive references!  */
     888          p2 = p;
     889          files = PARSE_FILE_SEQ (&p2, struct nameseq, MAP_NUL, NULL,
    857890                                  PARSEFS_NOAR);
    858           free (p);
    859 
    860           /* Save the state of conditionals and start
    861              the included makefile with a clean slate.  */
    862           save = install_conditionals (&new_conditionals);
    863 
    864           /* Record the rules that are waiting so they will determine
    865              the default goal before those in the included makefile.  */
    866           record_waiting_files ();
    867 
    868           /* Read each included makefile.  */
    869           while (files != 0)
    870             {
    871               struct nameseq *next = files->next;
    872               const char *name = files->name;
     891          free (p);
     892
     893          /* Save the state of conditionals and start
     894             the included makefile with a clean slate.  */
     895          save = install_conditionals (&new_conditionals);
     896
     897          /* Record the rules that are waiting so they will determine
     898             the default goal before those in the included makefile.  */
     899          record_waiting_files ();
     900
     901          /* Read each included makefile.  */
     902          while (files != 0)
     903            {
     904              struct nameseq *next = files->next;
     905              int flags = (RM_INCLUDED | RM_NO_TILDE
     906                           | (noerror ? RM_DONTCARE : 0)
     907                           | (set_default ? 0 : RM_NO_DEFAULT_GOAL));
     908
     909              struct goaldep *d = eval_makefile (files->name, flags);
     910
     911              if (errno)
     912                {
     913                  d->error = (unsigned short)errno;
     914                  d->floc = *fstart;
     915                }
     916
     917              free_ns (files);
     918              files = next;
     919            }
     920
     921          /* Restore conditional state.  */
     922          restore_conditionals (save);
     923
     924          continue;
     925        }
     926
     927      /* Handle the load operations.  */
     928      if (word1eq ("load") || word1eq ("-load"))
     929        {
     930          /* A 'load' line specifies a dynamic object to load.  */
     931          struct nameseq *files;
     932          int noerror = (p[0] == '-');
     933
     934          /* Load ends the previous rule.  */
     935          record_waiting_files ();
     936
     937          p = allocated_variable_expand (p2);
     938
     939          /* If no filenames, it's a no-op.  */
     940          if (*p == '\0')
     941            {
     942              free (p);
     943              continue;
     944            }
     945
     946          /* Parse the list of file names.
     947             Don't expand archive references or strip "./"  */
     948          p2 = p;
     949          files = PARSE_FILE_SEQ (&p2, struct nameseq, MAP_NUL, NULL,
     950                                  PARSEFS_NOAR);
     951          free (p);
     952
     953          /* Load each file.  */
     954          while (files != 0)
     955            {
     956              struct nameseq *next = files->next;
     957              const char *name = files->name;
     958              struct goaldep *deps;
    873959              int r;
    874960
    875               free_ns (files);
    876               files = next;
    877 
    878               r = eval_makefile (name,
    879                                  (RM_INCLUDED | RM_NO_TILDE
    880                                   | (noerror ? RM_DONTCARE : 0)
    881                                   | (set_default ? 0 : RM_NO_DEFAULT_GOAL)));
    882               if (!r && !noerror)
    883                 error (fstart, "%s: %s", name, strerror (errno));
    884             }
    885 
    886           /* Restore conditional state.  */
    887           restore_conditionals (save);
    888 
    889           goto rule_complete;
    890         }
     961              /* Load the file.  0 means failure.  */
     962              r = load_file (&ebuf->floc, &name, noerror);
     963              if (! r && ! noerror)
     964                OS (fatal, &ebuf->floc, _("%s: failed to load"), name);
     965
     966              free_ns (files);
     967              files = next;
     968
     969              /* Return of -1 means a special load: don't rebuild it.  */
     970              if (r == -1)
     971                continue;
     972
     973              /* It succeeded, so add it to the list "to be rebuilt".  */
     974              deps = alloc_goaldep ();
     975              deps->next = read_files;
     976              read_files = deps;
     977              deps->file = lookup_file (name);
     978              if (deps->file == 0)
     979                deps->file = enter_file (name);
     980              deps->file->loaded = 1;
     981            }
     982
     983          continue;
     984        }
    891985
    892986      /* This line starts with a tab but was not caught above because there
     
    894988         variable definition.  But now we know it is definitely lossage.  */
    895989      if (line[0] == cmd_prefix)
    896         fatal(fstart, _("recipe commences before first target"));
     990        O (fatal, fstart, _("recipe commences before first target"));
    897991
    898992      /* This line describes some target files.  This is complicated by
    899993         the existence of target-specific variables, because we can't
    900994         expand the entire line until we know if we have one or not.  So
    901          we expand the line word by word until we find the first `:',
     995         we expand the line word by word until we find the first ':',
    902996         then check to see if it's a target-specific variable.
    903997
    904          In this algorithm, `lb_next' will point to the beginning of the
    905          unexpanded parts of the input buffer, while `p2' points to the
     998         In this algorithm, 'lb_next' will point to the beginning of the
     999         unexpanded parts of the input buffer, while 'p2' points to the
    9061000         parts of the expanded buffer we haven't searched yet. */
    9071001
     
    9201014        /* Search the line for an unquoted ; that is not after an
    9211015           unquoted #.  */
    922         cmdleft = find_char_unquote (line, ';', '#', 0, 1);
     1016        cmdleft = find_char_unquote (line, MAP_SEMI|MAP_COMMENT|MAP_VARIABLE);
    9231017        if (cmdleft != 0 && *cmdleft == '#')
    9241018          {
     
    9381032           beginning, expanding as we go, and looking for "interesting"
    9391033           chars.  The first word is always expandable.  */
    940         wtype = get_next_mword(line, NULL, &lb_next, &wlen);
     1034        wtype = get_next_mword (line, NULL, &lb_next, &wlen);
    9411035        switch (wtype)
    9421036          {
    9431037          case w_eol:
    9441038            if (cmdleft != 0)
    945               fatal(fstart, _("missing rule before recipe"));
     1039              O (fatal, fstart, _("missing rule before recipe"));
    9461040            /* This line contained something but turned out to be nothing
    9471041               but whitespace (a comment?).  */
     
    9591053          }
    9601054
    961         p2 = variable_expand_string(NULL, lb_next, wlen);
     1055        p2 = variable_expand_string (NULL, lb_next, wlen);
    9621056
    9631057        while (1)
     
    9671061              {
    9681062                /* Look for a semicolon in the expanded line.  */
    969                 cmdleft = find_char_unquote (p2, ';', 0, 0, 0);
     1063                cmdleft = find_char_unquote (p2, MAP_SEMI);
    9701064
    9711065                if (cmdleft != 0)
     
    9731067                    unsigned long p2_off = p2 - variable_buffer;
    9741068                    unsigned long cmd_off = cmdleft - variable_buffer;
    975                     char *pend = p2 + strlen(p2);
     1069                    char *pend = p2 + strlen (p2);
    9761070
    9771071                    /* Append any remnants of lb, then cut the line short
     
    9831077                       and into a command script.  However, the old parser
    9841078                       expanded the whole line, so we continue that for
    985                        backwards-compatiblity.  Also, it wouldn't be
     1079                       backwards-compatibility.  Also, it wouldn't be
    9861080                       entirely consistent, since we do an unconditional
    9871081                       expand below once we know we don't have a
    9881082                       target-specific variable. */
    989                     (void)variable_expand_string(pend, lb_next, (long)-1);
    990                     lb_next += strlen(lb_next);
     1083                    (void)variable_expand_string (pend, lb_next, (long)-1);
     1084                    lb_next += strlen (lb_next);
    9911085                    p2 = variable_buffer + p2_off;
    9921086                    cmdleft = variable_buffer + cmd_off + 1;
     
    9941088              }
    9951089
    996             colonp = find_char_unquote(p2, ':', 0, 0, 0);
     1090            colonp = find_char_unquote (p2, MAP_COLON);
    9971091#ifdef HAVE_DOS_PATHS
    9981092            /* The drive spec brain-damage strikes again...  */
     
    10031097                   colonp > p2 && isalpha ((unsigned char)colonp[-1]) &&
    10041098                   (colonp == p2 + 1 || strchr (" \t(", colonp[-2]) != 0))
    1005               colonp = find_char_unquote(colonp + 1, ':', 0, 0, 0);
     1099              colonp = find_char_unquote (colonp + 1, MAP_COLON);
    10061100#endif
    10071101            if (colonp != 0)
    10081102              break;
    10091103
    1010             wtype = get_next_mword(lb_next, NULL, &lb_next, &wlen);
     1104            wtype = get_next_mword (lb_next, NULL, &lb_next, &wlen);
    10111105            if (wtype == w_eol)
    10121106              break;
    10131107
    1014             p2 += strlen(p2);
     1108            p2 += strlen (p2);
    10151109            *(p2++) = ' ';
    1016             p2 = variable_expand_string(p2, lb_next, wlen);
     1110            p2 = variable_expand_string (p2, lb_next, wlen);
    10171111            /* We don't need to worry about cmdleft here, because if it was
    10181112               found in the variable_buffer the entire buffer has already
     
    10271121        if (wtype == w_eol)
    10281122          {
    1029             if (*p2 != '\0')
    1030               /* There's no need to be ivory-tower about this: check for
    1031                  one of the most common bugs found in makefiles...  */
    1032               fatal (fstart, _("missing separator%s"),
    1033                      (cmd_prefix == '\t' && !strneq(line, "        ", 8))
    1034                      ? "" : _(" (did you mean TAB instead of 8 spaces?)"));
    1035             continue;
     1123            if (*p2 == '\0')
     1124              continue;
     1125
     1126            /* There's no need to be ivory-tower about this: check for
     1127               one of the most common bugs found in makefiles...  */
     1128            if (cmd_prefix == '\t' && strneq (line, "        ", 8))
     1129              O (fatal, fstart, _("missing separator (did you mean TAB instead of 8 spaces?)"));
     1130            else
     1131              O (fatal, fstart, _("missing separator"));
    10361132          }
    10371133
    10381134        /* Make the colon the end-of-string so we know where to stop
    1039            looking for targets.  */
     1135           looking for targets.  Start there again once we're done.  */
    10401136        *colonp = '\0';
    1041         filenames = PARSE_FILE_SEQ (&p2, struct nameseq, '\0', NULL, 0);
    1042         *p2 = ':';
     1137        filenames = PARSE_SIMPLE_SEQ (&p2, struct nameseq);
     1138        *colonp = ':';
     1139        p2 = colonp;
    10431140
    10441141        if (!filenames)
     
    10771174            if (semip)
    10781175              {
    1079                 unsigned int l = p - variable_buffer;
     1176                unsigned int l = p2 - variable_buffer;
    10801177                *(--semip) = ';';
    10811178                collapse_continuations (semip);
    10821179                variable_buffer_output (p2 + strlen (p2),
    10831180                                        semip, strlen (semip)+1);
    1084                 p = variable_buffer + l;
     1181                p2 = variable_buffer + l;
    10851182              }
    10861183            record_target_var (filenames, p2,
     
    10931190        /* This is a normal target, _not_ a target-specific variable.
    10941191           Unquote any = in the dependency list.  */
    1095         find_char_unquote (lb_next, '=', 0, 0, 0);
     1192        find_char_unquote (lb_next, MAP_EQUALS);
     1193
     1194        /* Remember the command prefix for this target.  */
     1195        prefix = cmd_prefix;
    10961196
    10971197        /* We have some targets, so don't ignore the following commands.  */
     
    11081208            if (cmdleft == 0)
    11091209              {
    1110                 cmdleft = find_char_unquote (p2, ';', 0, 0, 0);
     1210                cmdleft = find_char_unquote (p2, MAP_SEMI);
    11111211                if (cmdleft != 0)
    11121212                  *(cmdleft++) = '\0';
     
    11141214          }
    11151215
    1116         /* Is this a static pattern rule: `target: %targ: %dep; ...'?  */
     1216        /* Is this a static pattern rule: 'target: %targ: %dep; ...'?  */
    11171217        p = strchr (p2, ':');
    11181218        while (p != 0 && p[-1] == '\\')
     
    11401240           OR a space around the :.
    11411241        */
    1142         if (p && !(isspace ((unsigned char)p[1]) || !p[1]
    1143                    || isspace ((unsigned char)p[-1])))
     1242        if (p && !(ISSPACE (p[1]) || !p[1] || ISSPACE (p[-1])))
    11441243          p = 0;
    11451244#endif
     
    11621261          {
    11631262            struct nameseq *target;
    1164             target = PARSE_FILE_SEQ (&p2, struct nameseq, ':', NULL,
     1263            target = PARSE_FILE_SEQ (&p2, struct nameseq, MAP_COLON, NULL,
    11651264                                     PARSEFS_NOGLOB);
    11661265            ++p2;
    11671266            if (target == 0)
    1168               fatal (fstart, _("missing target pattern"));
     1267              O (fatal, fstart, _("missing target pattern"));
    11691268            else if (target->next != 0)
    1170               fatal (fstart, _("multiple target patterns"));
     1269              O (fatal, fstart, _("multiple target patterns"));
    11711270            pattern_percent = find_percent_cached (&target->name);
    11721271            pattern = target->name;
    11731272            if (pattern_percent == 0)
    1174               fatal (fstart, _("target pattern contains no `%%'"));
     1273              O (fatal, fstart, _("target pattern contains no '%%'"));
    11751274            free_ns (target);
    11761275          }
     
    12251324        if (set_default && default_goal_var->value[0] == '\0')
    12261325          {
    1227             const char *name;
    12281326            struct dep *d;
    12291327            struct nameseq *t = filenames;
     
    12321330              {
    12331331                int reject = 0;
    1234                 name = t->name;
     1332                const char *name = t->name;
    12351333
    12361334                /* We have nothing to do if this is an implicit rule. */
     
    12381336                  break;
    12391337
    1240                 /* See if this target's name does not start with a `.',
     1338                /* See if this target's name does not start with a '.',
    12411339                   unless it contains a slash.  */
    12421340                if (*name == '.' && strchr (name, '/') == 0
     
    12871385
    12881386      /* We get here except in the case that we just read a rule line.
    1289          Record now the last rule we read, so following spurious
    1290          commands are properly diagnosed.  */
    1291  rule_complete:
     1387         Record now the last rule we read, so following spurious
     1388         commands are properly diagnosed.  */
    12921389      record_waiting_files ();
    12931390    }
    12941391
    1295 #undef  word1eq
     1392#undef word1eq
    12961393
    12971394  if (conditionals->if_cmds)
    1298     fatal (fstart, _("missing `endif'"));
     1395    O (fatal, fstart, _("missing 'endif'"));
    12991396
    13001397  /* At eof, record the last rule.  */
    13011398  record_waiting_files ();
    13021399
    1303   if (collapsed)
    1304     free (collapsed);
     1400  free (collapsed);
    13051401  free (commands);
    13061402}
     
    13161412  char *comment;
    13171413
    1318   comment = find_char_unquote (line, '#', 0, 0, 0);
     1414  comment = find_char_unquote (line, MAP_COMMENT);
    13191415
    13201416  if (comment != 0)
     
    13231419}
    13241420
    1325 /* Execute a `undefine' directive.
     1421/* Execute a 'undefine' directive.
    13261422   The undefine line has already been read, and NAME is the name of
    13271423   the variable to be undefined. */
     
    13361432  name = next_token (var);
    13371433  if (*name == '\0')
    1338     fatal (&ebuf->floc, _("empty variable name"));
     1434    O (fatal, &ebuf->floc, _("empty variable name"));
    13391435  p = name + strlen (name) - 1;
    1340   while (p > name && isblank ((unsigned char)*p))
     1436  while (p > name && ISBLANK (*p))
    13411437    --p;
    13421438  p[1] = '\0';
     
    13461442}
    13471443
    1348 /* Execute a `define' directive.
     1444/* Execute a 'define' directive.
    13491445   The first line has already been read, and NAME is the name of
    13501446   the variable to be defined.  The following lines remain to be read.  */
     
    13541450{
    13551451  struct variable *v;
    1356   enum variable_flavor flavor;
    1357   struct floc defstart;
     1452  struct variable var;
     1453  floc defstart;
    13581454  int nlevels = 1;
    13591455  unsigned int length = 100;
    13601456  char *definition = xmalloc (length);
    13611457  unsigned int idx = 0;
    1362   char *p, *var;
     1458  char *p, *n;
    13631459
    13641460  defstart = ebuf->floc;
    13651461
    1366   p = parse_variable_definition (name, &flavor);
     1462  p = parse_variable_definition (name, &var);
    13671463  if (p == NULL)
    13681464    /* No assignment token, so assume recursive.  */
    1369     flavor = f_recursive;
     1465    var.flavor = f_recursive;
    13701466  else
    13711467    {
    1372       if (*(next_token (p)) != '\0')
    1373         error (&defstart, _("extraneous text after `define' directive"));
     1468      if (var.value[0] != '\0')
     1469        O (error, &defstart, _("extraneous text after 'define' directive"));
    13741470
    13751471      /* Chop the string before the assignment token to get the name.  */
    1376       p[flavor == f_recursive ? -1 : -2] = '\0';
     1472      var.name[var.length] = '\0';
    13771473    }
    13781474
    13791475  /* Expand the variable name and find the beginning (NAME) and end.  */
    1380   var = allocated_variable_expand (name);
    1381   name = next_token (var);
    1382   if (*name == '\0')
    1383     fatal (&defstart, _("empty variable name"));
     1476  n = allocated_variable_expand (name);
     1477  name = next_token (n);
     1478  if (name[0] == '\0')
     1479    O (fatal, &defstart, _("empty variable name"));
    13841480  p = name + strlen (name) - 1;
    1385   while (p > name && isblank ((unsigned char)*p))
     1481  while (p > name && ISBLANK (*p))
    13861482    --p;
    13871483  p[1] = '\0';
     
    13961492      /* If there is nothing left to be eval'd, there's no 'endef'!!  */
    13971493      if (nlines < 0)
    1398         fatal (&defstart, _("missing `endef', unterminated `define'"));
     1494        O (fatal, &defstart, _("missing 'endef', unterminated 'define'"));
    13991495
    14001496      ebuf->floc.lineno += nlines;
     
    14111507
    14121508          /* If this is another 'define', increment the level count.  */
    1413           if ((len == 6 || (len > 6 && isblank ((unsigned char)p[6])))
     1509          if ((len == 6 || (len > 6 && ISBLANK (p[6])))
    14141510              && strneq (p, "define", 6))
    14151511            ++nlevels;
     
    14171513          /* If this is an 'endef', decrement the count.  If it's now 0,
    14181514             we've found the last one.  */
    1419           else if ((len == 5 || (len > 5 && isblank ((unsigned char)p[5])))
     1515          else if ((len == 5 || (len > 5 && ISBLANK (p[5])))
    14201516                   && strneq (p, "endef", 5))
    14211517            {
     
    14231519              remove_comments (p);
    14241520              if (*(next_token (p)) != '\0')
    1425                 error (&ebuf->floc,
    1426                        _("extraneous text after `endef' directive"));
     1521                O (error, &ebuf->floc,
     1522                   _("extraneous text after 'endef' directive"));
    14271523
    14281524              if (--nlevels == 0)
     
    14511547    definition[idx - 1] = '\0';
    14521548
    1453   v = do_variable_definition (&defstart, name, definition, origin, flavor, 0);
     1549  v = do_variable_definition (&defstart, name,
     1550                              definition, origin, var.flavor, 0);
    14541551  free (definition);
    1455   free (var);
     1552  free (n);
    14561553  return (v);
    14571554}
     
    14711568
    14721569static int
    1473 conditional_line (char *line, int len, const struct floc *flocp)
     1570conditional_line (char *line, int len, const floc *flocp)
    14741571{
    1475   char *cmdname;
     1572  const char *cmdname;
    14761573  enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype;
    14771574  unsigned int i;
     
    14791576
    14801577  /* Compare a word, both length and contents. */
    1481 #define word1eq(s)      (len == sizeof(s)-1 && strneq (s, line, sizeof(s)-1))
    1482 #define chkword(s, t)   if (word1eq (s)) { cmdtype = (t); cmdname = (s); }
     1578#define word1eq(s)      (len == CSTRLEN (s) && strneq (s, line, CSTRLEN (s)))
     1579#define chkword(s, t)   if (word1eq (s)) { cmdtype = (t); cmdname = (s); }
    14831580
    14841581  /* Make sure this line is a conditional.  */
     
    14931590
    14941591  /* Found one: skip past it and any whitespace after it.  */
    1495   line = next_token (line + len);
    1496 
    1497 #define EXTRANEOUS() error (flocp, _("Extraneous text after `%s' directive"), cmdname)
     1592  line += len;
     1593  NEXT_TOKEN (line);
     1594
     1595#define EXTRATEXT() OS (error, flocp, _("extraneous text after '%s' directive"), cmdname)
     1596#define EXTRACMD()  OS (fatal, flocp, _("extraneous '%s'"), cmdname)
    14981597
    14991598  /* An 'endif' cannot contain extra text, and reduces the if-depth by 1  */
     
    15011600    {
    15021601      if (*line != '\0')
    1503         EXTRANEOUS ();
     1602        EXTRATEXT ();
    15041603
    15051604      if (!conditionals->if_cmds)
    1506         fatal (flocp, _("extraneous `%s'"), cmdname);
     1605        EXTRACMD ();
    15071606
    15081607      --conditionals->if_cmds;
     
    15181617
    15191618      if (!conditionals->if_cmds)
    1520         fatal (flocp, _("extraneous `%s'"), cmdname);
     1619        EXTRACMD ();
    15211620
    15221621      o = conditionals->if_cmds - 1;
    15231622
    15241623      if (conditionals->seen_else[o])
    1525         fatal (flocp, _("only one `else' per conditional"));
     1624        O (fatal, flocp, _("only one 'else' per conditional"));
    15261625
    15271626      /* Change the state of ignorance.  */
     
    15491648
    15501649      /* Find the length of the next word.  */
    1551       for (p = line+1; *p != '\0' && !isspace ((unsigned char)*p); ++p)
     1650      for (p = line+1; ! STOP_SET (*p, MAP_SPACE|MAP_NUL); ++p)
    15521651        ;
    15531652      len = p - line;
    15541653
    15551654      /* If it's 'else' or 'endif' or an illegal conditional, fail.  */
    1556       if (word1eq("else") || word1eq("endif")
     1655      if (word1eq ("else") || word1eq ("endif")
    15571656          || conditional_line (line, len, flocp) < 0)
    1558         EXTRANEOUS ();
     1657        EXTRATEXT ();
    15591658      else
    15601659        {
     
    15861685    }
    15871686
    1588   /* Record that we have seen an `if...' but no `else' so far.  */
     1687  /* Record that we have seen an 'if...' but no 'else' so far.  */
    15891688  conditionals->seen_else[o] = 0;
    15901689
     
    15931692    if (conditionals->ignoring[i])
    15941693      {
    1595         /* We are already ignoring, so just push a level to match the next
    1596            "else" or "endif", and keep ignoring.  We don't want to expand
    1597            variables in the condition.  */
    1598         conditionals->ignoring[o] = 1;
    1599         return 1;
     1694        /* We are already ignoring, so just push a level to match the next
     1695           "else" or "endif", and keep ignoring.  We don't want to expand
     1696           variables in the condition.  */
     1697        conditionals->ignoring[o] = 1;
     1698        return 1;
    16001699      }
    16011700
     
    16131712      p = end_of_token (var);
    16141713      i = p - var;
    1615       p = next_token (p);
     1714      NEXT_TOKEN (p);
    16161715      if (*p != '\0')
    1617         return -1;
     1716        return -1;
    16181717
    16191718      var[i] = '\0';
     
    16331732
    16341733      if (termin != ',' && termin != '"' && termin != '\'')
    1635         return -1;
     1734        return -1;
    16361735
    16371736      s1 = ++line;
    16381737      /* Find the end of the first string.  */
    16391738      if (termin == ',')
    1640         {
    1641           int count = 0;
    1642           for (; *line != '\0'; ++line)
    1643             if (*line == '(')
    1644               ++count;
    1645             else if (*line == ')')
    1646               --count;
    1647             else if (*line == ',' && count <= 0)
    1648               break;
    1649         }
     1739        {
     1740          int count = 0;
     1741          for (; *line != '\0'; ++line)
     1742            if (*line == '(')
     1743              ++count;
     1744            else if (*line == ')')
     1745              --count;
     1746            else if (*line == ',' && count <= 0)
     1747              break;
     1748        }
    16501749      else
    1651         while (*line != '\0' && *line != termin)
    1652           ++line;
     1750        while (*line != '\0' && *line != termin)
     1751          ++line;
    16531752
    16541753      if (*line == '\0')
    1655         return -1;
     1754        return -1;
    16561755
    16571756      if (termin == ',')
    1658         {
    1659           /* Strip blanks after the first string.  */
    1660           char *p = line++;
    1661           while (isblank ((unsigned char)p[-1]))
    1662             --p;
    1663           *p = '\0';
    1664         }
     1757        {
     1758          /* Strip blanks after the first string.  */
     1759          char *p = line++;
     1760          while (ISBLANK (p[-1]))
     1761            --p;
     1762          *p = '\0';
     1763        }
    16651764      else
    1666         *line++ = '\0';
     1765        *line++ = '\0';
    16671766
    16681767      s2 = variable_expand (s1);
    16691768      /* We must allocate a new copy of the expanded string because
    1670         variable_expand re-uses the same buffer.  */
     1769        variable_expand re-uses the same buffer.  */
    16711770      l = strlen (s2);
    16721771      s1 = alloca (l + 1);
     
    16741773
    16751774      if (termin != ',')
    1676         /* Find the start of the second string.  */
    1677         line = next_token (line);
     1775        /* Find the start of the second string.  */
     1776        NEXT_TOKEN (line);
    16781777
    16791778      termin = termin == ',' ? ')' : *line;
    16801779      if (termin != ')' && termin != '"' && termin != '\'')
    1681         return -1;
     1780        return -1;
    16821781
    16831782      /* Find the end of the second string.  */
    16841783      if (termin == ')')
    1685         {
    1686           int count = 0;
    1687           s2 = next_token (line);
    1688           for (line = s2; *line != '\0'; ++line)
    1689             {
    1690               if (*line == '(')
    1691                 ++count;
    1692               else if (*line == ')')
    1693                 {
    1694                   if (count <= 0)
    1695                     break;
    1696                   else
    1697                     --count;
    1698                 }
    1699             }
    1700         }
     1784        {
     1785          int count = 0;
     1786          s2 = next_token (line);
     1787          for (line = s2; *line != '\0'; ++line)
     1788            {
     1789              if (*line == '(')
     1790                ++count;
     1791              else if (*line == ')')
     1792                {
     1793                  if (count <= 0)
     1794                    break;
     1795                  else
     1796                    --count;
     1797                }
     1798            }
     1799        }
    17011800      else
    1702         {
    1703           ++line;
    1704           s2 = line;
    1705           while (*line != '\0' && *line != termin)
    1706             ++line;
    1707         }
     1801        {
     1802          ++line;
     1803          s2 = line;
     1804          while (*line != '\0' && *line != termin)
     1805            ++line;
     1806        }
    17081807
    17091808      if (*line == '\0')
    1710         return -1;
    1711 
    1712       *line = '\0';
    1713       line = next_token (++line);
     1809        return -1;
     1810
     1811      *(line++) = '\0';
     1812      NEXT_TOKEN (line);
    17141813      if (*line != '\0')
    1715         EXTRANEOUS ();
     1814        EXTRATEXT ();
    17161815
    17171816      s2 = variable_expand (s2);
     
    17411840record_target_var (struct nameseq *filenames, char *defn,
    17421841                   enum variable_origin origin, struct vmodifiers *vmod,
    1743                    const struct floc *flocp)
     1842                   const floc *flocp)
    17441843{
    17451844  struct nameseq *nextf;
     
    17551854      struct variable *v;
    17561855      const char *name = filenames->name;
    1757       const char *fname;
    17581856      const char *percent;
    17591857      struct pattern_var *p;
     
    17801878          else
    17811879            v->value = xstrdup (v->value);
    1782 
    1783           fname = p->target;
    17841880        }
    17851881      else
     
    17981894
    17991895          initialize_file_variables (f, 1);
    1800           fname = f->name;
    18011896
    18021897          current_variable_set_list = f->variables;
    18031898          v = try_variable_definition (flocp, defn, origin, 1);
    18041899          if (!v)
    1805             fatal (flocp, _("Malformed target-specific variable definition"));
     1900            O (fatal, flocp, _("Malformed target-specific variable definition"));
    18061901          current_variable_set_list = global;
    18071902        }
     
    18171912        {
    18181913          struct variable *gv;
    1819           int len = strlen(v->name);
     1914          int len = strlen (v->name);
    18201915
    18211916          gv = lookup_variable (v->name, len);
    1822           if (gv && (gv->origin == o_env_override || gv->origin == o_command))
     1917          if (gv && v != gv
     1918              && (gv->origin == o_env_override || gv->origin == o_command))
    18231919            {
    1824               if (v->value != 0)
    1825                 free (v->value);
     1920              free (v->value);
    18261921              v->value = xstrdup (gv->value);
    18271922              v->origin = gv->origin;
     
    18381933   by COMMANDS and COMMANDS_IDX, coming from FILENAME:COMMANDS_STARTED.
    18391934   TWO_COLON is nonzero if a double colon was used.
    1840    If not nil, PATTERN is the `%' pattern to make this
     1935   If not nil, PATTERN is the '%' pattern to make this
    18411936   a static pattern rule, and PATTERN_PERCENT is a pointer
    1842    to the `%' within it.
     1937   to the '%' within it.
    18431938
    18441939   The links of FILENAMES are freed, and so are any names in it
     
    18501945              unsigned int cmds_started, char *commands,
    18511946              unsigned int commands_idx, int two_colon,
    1852               const struct floc *flocp)
     1947              char prefix, const floc *flocp)
    18531948{
    18541949  struct commands *cmds;
     
    18621957     See Savannah bug # 12124.  */
    18631958  if (snapped_deps)
    1864     fatal (flocp, _("prerequisites cannot be defined in recipes"));
     1959    O (fatal, flocp, _("prerequisites cannot be defined in recipes"));
    18651960
    18661961  /* Determine if this is a pattern rule or not.  */
     
    18741969      cmds->fileinfo.filenm = flocp->filenm;
    18751970      cmds->fileinfo.lineno = cmds_started;
     1971      cmds->fileinfo.offset = 0;
    18761972      cmds->commands = xstrndup (commands, commands_idx);
    18771973      cmds->command_lines = 0;
     1974      cmds->recipe_prefix = prefix;
    18781975    }
    18791976  else
     
    18841981  if (depstr == 0)
    18851982    deps = 0;
    1886   else if (second_expansion && strchr (depstr, '$'))
    1887     {
    1888       deps = alloc_dep ();
    1889       deps->name = depstr;
    1890       deps->need_2nd_expansion = 1;
    1891       deps->staticpattern = pattern != 0;
    1892     }
    18931983  else
    18941984    {
    1895       deps = split_prereqs (depstr);
    1896       free (depstr);
    1897 
    1898       /* We'll enter static pattern prereqs later when we have the stem.  We
    1899          don't want to enter pattern rules at all so that we don't think that
    1900          they ought to exist (make manual "Implicit Rule Search Algorithm",
    1901          item 5c).  */
    1902       if (! pattern && ! implicit_percent)
    1903         deps = enter_prereqs (deps, NULL);
     1985      depstr = unescape_char (depstr, ':');
     1986      if (second_expansion && strchr (depstr, '$'))
     1987        {
     1988          deps = alloc_dep ();
     1989          deps->name = depstr;
     1990          deps->need_2nd_expansion = 1;
     1991          deps->staticpattern = pattern != 0;
     1992        }
     1993      else
     1994        {
     1995          deps = split_prereqs (depstr);
     1996          free (depstr);
     1997
     1998          /* We'll enter static pattern prereqs later when we have the stem.
     1999             We don't want to enter pattern rules at all so that we don't
     2000             think that they ought to exist (make manual "Implicit Rule Search
     2001             Algorithm", item 5c).  */
     2002          if (! pattern && ! implicit_percent)
     2003            deps = enter_prereqs (deps, NULL);
     2004        }
    19042005    }
    19052006
     
    19152016
    19162017      if (pattern != 0)
    1917         fatal (flocp, _("mixed implicit and static pattern rules"));
     2018        O (fatal, flocp, _("mixed implicit and static pattern rules"));
    19182019
    19192020      /* Count the targets to create an array of target names.
     
    19382039
    19392040          if (implicit_percent == 0)
    1940             fatal (flocp, _("mixed implicit and normal rules"));
    1941 
    1942           targets[c] = name;
    1943           target_pats[c] = implicit_percent;
     2041            O (fatal, flocp, _("mixed implicit and normal rules"));
     2042
     2043          targets[c] = name;
     2044          target_pats[c] = implicit_percent;
    19442045          ++c;
    19452046
     
    19712072          posix_pedantic = 1;
    19722073          define_variable_cname (".SHELLFLAGS", "-ec", o_default, 0);
     2074          /* These default values are based on IEEE Std 1003.1-2008.  */
     2075          define_variable_cname ("ARFLAGS", "-rv", o_default, 0);
     2076          define_variable_cname ("CC", "c99", o_default, 0);
     2077          define_variable_cname ("CFLAGS", "-O", o_default, 0);
     2078          define_variable_cname ("FC", "fort77", o_default, 0);
     2079          define_variable_cname ("FFLAGS", "-O 1", o_default, 0);
     2080          define_variable_cname ("SCCSGETFLAGS", "-s", o_default, 0);
    19732081        }
    19742082      else if (streq (name, ".SECONDEXPANSION"))
    19752083        second_expansion = 1;
    1976 #if !defined(WINDOWS32) && !defined (__MSDOS__) && !defined (__EMX__)
     2084#if !defined (__MSDOS__) && !defined (__EMX__)
    19772085      else if (streq (name, ".ONESHELL"))
    19782086        one_shell = 1;
     
    19802088
    19812089      /* If this is a static pattern rule:
    1982          `targets: target%pattern: prereq%pattern; recipe',
     2090         'targets: target%pattern: prereq%pattern; recipe',
    19832091         make sure the pattern matches this target name.  */
    19842092      if (pattern && !pattern_matches (pattern, pattern_percent, name))
    1985         error (flocp, _("target `%s' doesn't match the target pattern"), name);
     2093        OS (error, flocp,
     2094            _("target '%s' doesn't match the target pattern"), name);
    19862095      else if (deps)
    19872096        /* If there are multiple targets, copy the chain DEPS for all but the
     
    19922101      /* Find or create an entry in the file database for this target.  */
    19932102      if (!two_colon)
    1994         {
    1995           /* Single-colon.  Combine this rule with the file's existing record,
    1996              if any.  */
    1997           f = enter_file (strcache_add (name));
    1998           if (f->double_colon)
    1999             fatal (flocp,
    2000                    _("target file `%s' has both : and :: entries"), f->name);
    2001 
    2002           /* If CMDS == F->CMDS, this target was listed in this rule
    2003              more than once.  Just give a warning since this is harmless.  */
    2004           if (cmds != 0 && cmds == f->cmds)
    2005             error (flocp,
    2006                    _("target `%s' given more than once in the same rule."),
    2007                    f->name);
    2008 
    2009           /* Check for two single-colon entries both with commands.
    2010              Check is_target so that we don't lose on files such as .c.o
    2011              whose commands were preinitialized.  */
    2012           else if (cmds != 0 && f->cmds != 0 && f->is_target)
    2013             {
    2014               error (&cmds->fileinfo,
    2015                      _("warning: overriding recipe for target `%s'"),
     2103        {
     2104          /* Single-colon.  Combine this rule with the file's existing record,
     2105             if any.  */
     2106          f = enter_file (strcache_add (name));
     2107          if (f->double_colon)
     2108            OS (fatal, flocp,
     2109                _("target file '%s' has both : and :: entries"), f->name);
     2110
     2111          /* If CMDS == F->CMDS, this target was listed in this rule
     2112             more than once.  Just give a warning since this is harmless.  */
     2113          if (cmds != 0 && cmds == f->cmds)
     2114            OS (error, flocp,
     2115                _("target '%s' given more than once in the same rule"),
     2116                f->name);
     2117
     2118          /* Check for two single-colon entries both with commands.
     2119             Check is_target so that we don't lose on files such as .c.o
     2120             whose commands were preinitialized.  */
     2121          else if (cmds != 0 && f->cmds != 0 && f->is_target)
     2122            {
     2123              size_t l = strlen (f->name);
     2124              error (&cmds->fileinfo, l,
     2125                     _("warning: overriding recipe for target '%s'"),
    20162126                     f->name);
    2017               error (&f->cmds->fileinfo,
    2018                      _("warning: ignoring old recipe for target `%s'"),
     2127              error (&f->cmds->fileinfo, l,
     2128                     _("warning: ignoring old recipe for target '%s'"),
    20192129                     f->name);
    2020             }
    2021 
    2022           /* Defining .DEFAULT with no deps or cmds clears it.  */
    2023           if (f == default_file && this == 0 && cmds == 0)
    2024             f->cmds = 0;
    2025           if (cmds != 0)
    2026             f->cmds = cmds;
    2027 
    2028           /* Defining .SUFFIXES with no dependencies clears out the list of
    2029              suffixes.  */
    2030           if (f == suffix_file && this == 0)
    2031             {
     2130            }
     2131
     2132          /* Defining .DEFAULT with no deps or cmds clears it.  */
     2133          if (f == default_file && this == 0 && cmds == 0)
     2134            f->cmds = 0;
     2135          if (cmds != 0)
     2136            f->cmds = cmds;
     2137
     2138          /* Defining .SUFFIXES with no dependencies clears out the list of
     2139             suffixes.  */
     2140          if (f == suffix_file && this == 0)
     2141            {
    20322142              free_dep_chain (f->deps);
    2033               f->deps = 0;
    2034             }
    2035         }
     2143              f->deps = 0;
     2144            }
     2145        }
    20362146      else
    2037         {
    2038           /* Double-colon.  Make a new record even if there already is one.  */
    2039           f = lookup_file (name);
    2040 
    2041           /* Check for both : and :: rules.  Check is_target so we don't lose
    2042              on default suffix rules or makefiles.  */
    2043           if (f != 0 && f->is_target && !f->double_colon)
    2044             fatal (flocp,
    2045                    _("target file `%s' has both : and :: entries"), f->name);
    2046 
    2047           f = enter_file (strcache_add (name));
    2048           /* If there was an existing entry and it was a double-colon entry,
    2049              enter_file will have returned a new one, making it the prev
    2050              pointer of the old one, and setting its double_colon pointer to
    2051              the first one.  */
    2052           if (f->double_colon == 0)
    2053             /* This is the first entry for this name, so we must set its
    2054                double_colon pointer to itself.  */
    2055             f->double_colon = f;
    2056 
    2057           f->cmds = cmds;
    2058         }
     2147        {
     2148          /* Double-colon.  Make a new record even if there already is one.  */
     2149          f = lookup_file (name);
     2150
     2151          /* Check for both : and :: rules.  Check is_target so we don't lose
     2152             on default suffix rules or makefiles.  */
     2153          if (f != 0 && f->is_target && !f->double_colon)
     2154            OS (fatal, flocp,
     2155                _("target file '%s' has both : and :: entries"), f->name);
     2156
     2157          f = enter_file (strcache_add (name));
     2158          /* If there was an existing entry and it was a double-colon entry,
     2159             enter_file will have returned a new one, making it the prev
     2160             pointer of the old one, and setting its double_colon pointer to
     2161             the first one.  */
     2162          if (f->double_colon == 0)
     2163            /* This is the first entry for this name, so we must set its
     2164               double_colon pointer to itself.  */
     2165            f->double_colon = f;
     2166
     2167          f->cmds = cmds;
     2168        }
    20592169
    20602170      f->is_target = 1;
    20612171
    20622172      /* If this is a static pattern rule, set the stem to the part of its
    2063          name that matched the `%' in the pattern, so you can use $* in the
     2173         name that matched the '%' in the pattern, so you can use $* in the
    20642174         commands.  If we didn't do it before, enter the prereqs now.  */
    20652175      if (pattern)
     
    21192229      name = filenames->name;
    21202230      if (find_percent_cached (&name))
    2121         fatal (flocp, _("mixed implicit and normal rules"));
     2231        O (error, flocp,
     2232           _("*** mixed implicit and normal rules: deprecated syntax"));
    21222233    }
    21232234}
     
    21342245
    21352246static char *
    2136 find_char_unquote (char *string, int stop1, int stop2, int blank,
    2137                    int ignorevars)
     2247find_char_unquote (char *string, int map)
    21382248{
    21392249  unsigned int string_len = 0;
    21402250  char *p = string;
    21412251
    2142   if (ignorevars)
    2143     ignorevars = '$';
     2252  /* Always stop on NUL.  */
     2253  map |= MAP_NUL;
    21442254
    21452255  while (1)
    21462256    {
    2147       if (stop2 && blank)
    2148         while (*p != '\0' && *p != ignorevars && *p != stop1 && *p != stop2
    2149                && ! isblank ((unsigned char) *p))
    2150           ++p;
    2151       else if (stop2)
    2152         while (*p != '\0' && *p != ignorevars && *p != stop1 && *p != stop2)
    2153           ++p;
    2154       else if (blank)
    2155         while (*p != '\0' && *p != ignorevars && *p != stop1
    2156                && ! isblank ((unsigned char) *p))
    2157           ++p;
    2158       else
    2159         while (*p != '\0' && *p != ignorevars && *p != stop1)
    2160           ++p;
     2257      while (! STOP_SET (*p, map))
     2258        ++p;
    21612259
    21622260      if (*p == '\0')
    2163         break;
     2261        break;
    21642262
    21652263      /* If we stopped due to a variable reference, skip over its contents.  */
    2166       if (*p == ignorevars)
     2264      if (STOP_SET (*p, MAP_VARIABLE))
    21672265        {
    21682266          char openparen = p[1];
     2267
     2268          /* Check if '$' is the last character in the string.  */
     2269          if (openparen == '\0')
     2270            break;
    21692271
    21702272          p += 2;
     
    21952297
    21962298      if (p > string && p[-1] == '\\')
    2197         {
    2198           /* Search for more backslashes.  */
    2199           int i = -2;
    2200           while (&p[i] >= string && p[i] == '\\')
    2201             --i;
    2202           ++i;
    2203           /* Only compute the length if really needed.  */
    2204           if (string_len == 0)
    2205             string_len = strlen (string);
    2206           /* The number of backslashes is now -I.
    2207              Copy P over itself to swallow half of them.  */
    2208           memmove (&p[i], &p[i/2], (string_len - (p - string)) - (i/2) + 1);
    2209           p += i/2;
    2210           if (i % 2 == 0)
    2211             /* All the backslashes quoted each other; the STOPCHAR was
    2212                unquoted.  */
    2213             return p;
    2214 
    2215           /* The STOPCHAR was quoted by a backslash.  Look for another.  */
    2216         }
     2299        {
     2300          /* Search for more backslashes.  */
     2301          int i = -2;
     2302          while (&p[i] >= string && p[i] == '\\')
     2303            --i;
     2304          ++i;
     2305          /* Only compute the length if really needed.  */
     2306          if (string_len == 0)
     2307            string_len = strlen (string);
     2308          /* The number of backslashes is now -I.
     2309             Copy P over itself to swallow half of them.  */
     2310          memmove (&p[i], &p[i/2], (string_len - (p - string)) - (i/2) + 1);
     2311          p += i/2;
     2312          if (i % 2 == 0)
     2313            /* All the backslashes quoted each other; the STOPCHAR was
     2314               unquoted.  */
     2315            return p;
     2316
     2317          /* The STOPCHAR was quoted by a backslash.  Look for another.  */
     2318        }
    22172319      else
    2218         /* No backslash in sight.  */
    2219         return p;
     2320        /* No backslash in sight.  */
     2321        return p;
    22202322    }
    22212323
     
    22242326}
    22252327
     2328/* Unescape a character in a string.  The string is compressed onto itself.  */
     2329
     2330static char *
     2331unescape_char (char *string, int c)
     2332{
     2333  char *p = string;
     2334  char *s = string;
     2335
     2336  while (*s != '\0')
     2337    {
     2338      if (*s == '\\')
     2339        {
     2340          char *e = s;
     2341          int l;
     2342
     2343          /* We found a backslash.  See if it's escaping our character.  */
     2344          while (*e == '\\')
     2345            ++e;
     2346          l = e - s;
     2347
     2348          if (*e != c || l%2 == 0)
     2349            {
     2350              /* It's not; just take it all without unescaping.  */
     2351              memmove (p, s, l);
     2352              p += l;
     2353
     2354              // If we hit the end of the string, we're done
     2355              if (*e == '\0')
     2356                break;
     2357            }
     2358          else if (l > 1)
     2359            {
     2360              /* It is, and there's >1 backslash.  Take half of them.  */
     2361              l /= 2;
     2362              memmove (p, s, l);
     2363              p += l;
     2364            }
     2365
     2366          s = e;
     2367        }
     2368
     2369      *(p++) = *(s++);
     2370    }
     2371
     2372  *p = '\0';
     2373  return string;
     2374}
     2375
    22262376/* Search PATTERN for an unquoted % and handle quoting.  */
    22272377
     
    22292379find_percent (char *pattern)
    22302380{
    2231   return find_char_unquote (pattern, '%', 0, 0, 0);
     2381  return find_char_unquote (pattern, MAP_PERCENT);
    22322382}
    22332383
     
    22522402  while (1)
    22532403    {
    2254       while (*p != '\0' && *p != '%')
     2404      while (! STOP_SET (*p, MAP_PERCENT|MAP_NUL))
    22552405        ++p;
    22562406
     
    23222472 */
    23232473
    2324 static unsigned long
     2474static long
    23252475readstring (struct ebuffer *ebuf)
    23262476{
     
    23942544      len = strlen (p);
    23952545      if (len == 0)
    2396         {
    2397           /* This only happens when the first thing on the line is a '\0'.
    2398              It is a pretty hopeless case, but (wonder of wonders) Athena
    2399              lossage strikes again!  (xmkmf puts NULs in its makefiles.)
    2400              There is nothing really to be done; we synthesize a newline so
    2401              the following line doesn't appear to be part of this line.  */
    2402           error (&ebuf->floc,
    2403                  _("warning: NUL character seen; rest of line ignored"));
    2404           p[0] = '\n';
    2405           len = 1;
    2406         }
     2546        {
     2547          /* This only happens when the first thing on the line is a '\0'.
     2548             It is a pretty hopeless case, but (wonder of wonders) Athena
     2549             lossage strikes again!  (xmkmf puts NULs in its makefiles.)
     2550             There is nothing really to be done; we synthesize a newline so
     2551             the following line doesn't appear to be part of this line.  */
     2552          O (error, &ebuf->floc,
     2553             _("warning: NUL character seen; rest of line ignored"));
     2554          p[0] = '\n';
     2555          len = 1;
     2556        }
    24072557
    24082558      /* Jump past the text we just read.  */
     
    24232573        {
    24242574          --p;
    2425           p[-1] = '\n';
     2575          memmove (p-1, p, strlen (p) + 1);
    24262576        }
    24272577#endif
     
    24292579      backslash = 0;
    24302580      for (p2 = p - 2; p2 >= start; --p2)
    2431         {
    2432           if (*p2 != '\\')
    2433             break;
     2581        {
     2582          if (*p2 != '\\')
     2583            break;
    24342584          backslash = !backslash;
    2435         }
     2585        }
    24362586
    24372587      if (!backslash)
    2438         {
    2439           p[-1] = '\0';
    2440           break;
    2441         }
     2588        {
     2589          p[-1] = '\0';
     2590          break;
     2591        }
    24422592
    24432593      /* It was a backslash/newline combo.  If we have more space, read
     
    24832633     w_dcolon       A double-colon
    24842634     w_semicolon    A semicolon
    2485      w_varassign    A variable assignment operator (=, :=, +=, or ?=)
     2635     w_varassign    A variable assignment operator (=, :=, ::=, +=, ?=, or !=)
    24862636
    24872637   Note that this function is only used when reading certain parts of the
     
    24972647
    24982648  /* Skip any leading whitespace.  */
    2499   while (isblank ((unsigned char)*p))
     2649  while (ISBLANK (*p))
    25002650    ++p;
    25012651
     
    25222672        case ':':
    25232673          ++p;
    2524           wtype = w_dcolon;
     2674          if (p[1] != '=')
     2675            wtype = w_dcolon;
     2676          else
     2677            {
     2678              wtype = w_varassign;
     2679              ++p;
     2680            }
    25252681          break;
    25262682
     
    25342690    case '+':
    25352691    case '?':
     2692    case '!':
    25362693      if (*p == '=')
    25372694        {
     
    25532710  /* This is some non-operator word.  A word consists of the longest
    25542711     string of characters that doesn't contain whitespace, one of [:=#],
    2555      or [?+]=, or one of the chars in the DELIM string.  */
     2712     or [?+!]=, or one of the chars in the DELIM string.  */
    25562713
    25572714  /* We start out assuming a static word; if we see a variable we'll
     
    25752732        case ':':
    25762733#ifdef HAVE_DOS_PATHS
    2577           /* A word CAN include a colon in its drive spec.  The drive
    2578              spec is allowed either at the beginning of a word, or as part
    2579              of the archive member name, like in "libfoo.a(d:/foo/bar.o)".  */
    2580           if (!(p - beg >= 2
    2581                 && (*p == '/' || *p == '\\') && isalpha ((unsigned char)p[-2])
    2582                 && (p - beg == 2 || p[-3] == '(')))
     2734          /* A word CAN include a colon in its drive spec.  The drive
     2735             spec is allowed either at the beginning of a word, or as part
     2736             of the archive member name, like in "libfoo.a(d:/foo/bar.o)".  */
     2737          if (!(p - beg >= 2
     2738                && (*p == '/' || *p == '\\') && isalpha ((unsigned char)p[-2])
     2739                && (p - beg == 2 || p[-3] == '(')))
    25832740#endif
    2584           goto done_word;
     2741          goto done_word;
    25852742
    25862743        case '$':
     
    25882745          if (c == '$')
    25892746            break;
     2747          if (c == '\0')
     2748            goto done_word;
    25902749
    25912750          /* This is a variable reference, so note that it's expandable.
     
    26572816construct_include_path (const char **arg_dirs)
    26582817{
    2659 #ifdef VAXC             /* just don't ask ... */
     2818#ifdef VAXC             /* just don't ask ... */
    26602819  stat_t stbuf;
    26612820#else
     
    26882847    while (*arg_dirs != 0)
    26892848      {
    2690         const char *dir = *(arg_dirs++);
     2849        const char *dir = *(arg_dirs++);
    26912850        char *expanded = 0;
    26922851        int e;
    26932852
    2694         if (dir[0] == '~')
    2695           {
    2696             expanded = tilde_expand (dir);
    2697             if (expanded != 0)
    2698               dir = expanded;
    2699           }
     2853        if (dir[0] == '~')
     2854          {
     2855            expanded = tilde_expand (dir);
     2856            if (expanded != 0)
     2857              dir = expanded;
     2858          }
    27002859
    27012860        EINTRLOOP (e, stat (dir, &stbuf));
    2702         if (e == 0 && S_ISDIR (stbuf.st_mode))
     2861        if (e == 0 && S_ISDIR (stbuf.st_mode))
    27032862          {
    27042863            unsigned int len = strlen (dir);
     
    27112870          }
    27122871
    2713         if (expanded)
    2714           free (expanded);
     2872        free (expanded);
    27152873      }
    27162874
     
    27262884      {
    27272885        unsigned int len = strlen (djdir->value) + 8;
    2728         char *defdir = alloca (len + 1);
    2729 
    2730         strcat (strcpy (defdir, djdir->value), "/include");
    2731         dirs[idx++] = strcache_add (defdir);
     2886        char *defdir = alloca (len + 1);
     2887
     2888        strcat (strcpy (defdir, djdir->value), "/include");
     2889        dirs[idx++] = strcache_add (defdir);
    27322890
    27332891        if (len > max_incl_len)
     
    27752933  if (name[1] == '/' || name[1] == '\0')
    27762934    {
    2777       extern char *getenv ();
    27782935      char *home_dir;
    27792936      int is_variable;
    27802937
    27812938      {
    2782         /* Turn off --warn-undefined-variables while we expand HOME.  */
    2783         int save = warn_undefined_variables_flag;
    2784         warn_undefined_variables_flag = 0;
    2785 
    2786         home_dir = allocated_variable_expand ("$(HOME)");
    2787 
    2788         warn_undefined_variables_flag = save;
     2939        /* Turn off --warn-undefined-variables while we expand HOME.  */
     2940        int save = warn_undefined_variables_flag;
     2941        warn_undefined_variables_flag = 0;
     2942
     2943        home_dir = allocated_variable_expand ("$(HOME)");
     2944
     2945        warn_undefined_variables_flag = save;
    27892946      }
    27902947
    27912948      is_variable = home_dir[0] != '\0';
    27922949      if (!is_variable)
    2793         {
    2794           free (home_dir);
    2795           home_dir = getenv ("HOME");
    2796         }
     2950        {
     2951          free (home_dir);
     2952          home_dir = getenv ("HOME");
     2953        }
    27972954# if !defined(_AMIGA) && !defined(WINDOWS32)
    27982955      if (home_dir == 0 || home_dir[0] == '\0')
    2799         {
    2800           extern char *getlogin ();
    2801           char *logname = getlogin ();
    2802           home_dir = 0;
    2803           if (logname != 0)
    2804             {
    2805               struct passwd *p = getpwnam (logname);
    2806               if (p != 0)
    2807                 home_dir = p->pw_dir;
    2808             }
    2809         }
     2956        {
     2957          char *logname = getlogin ();
     2958          home_dir = 0;
     2959          if (logname != 0)
     2960            {
     2961              struct passwd *p = getpwnam (logname);
     2962              if (p != 0)
     2963                home_dir = p->pw_dir;
     2964            }
     2965        }
    28102966# endif /* !AMIGA && !WINDOWS32 */
    28112967      if (home_dir != 0)
    2812         {
    2813           char *new = xstrdup (concat (2, home_dir, name + 1));
    2814           if (is_variable)
    2815             free (home_dir);
    2816           return new;
    2817         }
     2968        {
     2969          char *new = xstrdup (concat (2, home_dir, name + 1));
     2970          if (is_variable)
     2971            free (home_dir);
     2972          return new;
     2973        }
    28182974    }
    28192975# if !defined(_AMIGA) && !defined(WINDOWS32)
     
    28232979      char *userend = strchr (name + 1, '/');
    28242980      if (userend != 0)
    2825         *userend = '\0';
     2981        *userend = '\0';
    28262982      pwent = getpwnam (name + 1);
    28272983      if (pwent != 0)
    2828         {
    2829           if (userend == 0)
    2830             return xstrdup (pwent->pw_dir);
    2831           else
    2832             return xstrdup (concat (3, pwent->pw_dir, "/", userend + 1));
    2833         }
     2984        {
     2985          if (userend == 0)
     2986            return xstrdup (pwent->pw_dir);
     2987          else
     2988            return xstrdup (concat (3, pwent->pw_dir, "/", userend + 1));
     2989        }
    28342990      else if (userend != 0)
    2835         *userend = '/';
     2991        *userend = '/';
    28362992    }
    28372993# endif /* !AMIGA && !WINDOWS32 */
     
    28653021
    28663022void *
    2867 parse_file_seq (char **stringp, unsigned int size, int stopchar,
     3023parse_file_seq (char **stringp, unsigned int size, int stopmap,
    28683024                const char *prefix, int flags)
    28693025{
    2870   extern void dir_setup_glob (glob_t *glob);
    2871 
    28723026  /* tmp points to tmpbuf after the prefix, if any.
    28733027     tp is the end of the buffer. */
    28743028  static char *tmpbuf = NULL;
    2875   static int tmpbuf_len = 0;
    2876 
    2877   int cachep = (! (flags & PARSEFS_NOCACHE));
     3029
     3030  int cachep = NONE_SET (flags, PARSEFS_NOCACHE);
    28783031
    28793032  struct nameseq *new = 0;
     
    28903043  char *tp;
    28913044
    2892 #ifdef VMS
    2893 # define VMS_COMMA ','
    2894 #else
    2895 # define VMS_COMMA 0
    2896 #endif
     3045  /* Always stop on NUL.  */
     3046  stopmap |= MAP_NUL;
    28973047
    28983048  if (size < sizeof (struct nameseq))
    28993049    size = sizeof (struct nameseq);
    29003050
    2901   if (! (flags & PARSEFS_NOGLOB))
     3051  if (NONE_SET (flags, PARSEFS_NOGLOB))
    29023052    dir_setup_glob (&gl);
    29033053
    29043054  /* Get enough temporary space to construct the largest possible target.  */
    29053055  {
     3056    static int tmpbuf_len = 0;
    29063057    int l = strlen (*stringp) + 1;
    29073058    if (l > tmpbuf_len)
     
    29203071      const char **nlist = 0;
    29213072      char *tildep = 0;
     3073      int globme = 1;
    29223074#ifndef NO_ARCHIVES
    29233075      char *arname = 0;
     
    29293081
    29303082      /* Skip whitespace; at the end of the string or STOPCHAR we're done.  */
    2931       p = next_token (p);
    2932       if (*p == '\0' || *p == stopchar)
    2933         break;
     3083      NEXT_TOKEN (p);
     3084      if (STOP_SET (*p, stopmap))
     3085        break;
    29343086
    29353087      /* There are names left, so find the end of the next name.
    29363088         Throughout this iteration S points to the start.  */
    29373089      s = p;
    2938       p = find_char_unquote (p, stopchar, VMS_COMMA, 1, 0);
     3090      p = find_char_unquote (p, stopmap|MAP_VMSCOMMA|MAP_BLANK);
    29393091#ifdef VMS
    2940         /* convert comma separated list to space separated */
     3092        /* convert comma separated list to space separated */
    29413093      if (p && *p == ',')
    2942         *p =' ';
     3094        *p =' ';
    29433095#endif
    29443096#ifdef _AMIGA
    2945       if (stopchar == ':' && p && *p == ':'
    2946           && !(isspace ((unsigned char)p[1]) || !p[1]
    2947                || isspace ((unsigned char)p[-1])))
    2948         p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0);
     3097      if (p && STOP_SET (*p, stopmap & MAP_COLON)
     3098          && !(ISSPACE (p[1]) || !p[1] || ISSPACE (p[-1])))
     3099        p = find_char_unquote (p+1, stopmap|MAP_VMSCOMMA|MAP_BLANK);
    29493100#endif
    29503101#ifdef HAVE_DOS_PATHS
     
    29533104       Note that tokens separated by spaces should be treated as separate
    29543105       tokens since make doesn't allow path names with spaces */
    2955     if (stopchar == ':')
    2956       while (p != 0 && !isspace ((unsigned char)*p) &&
     3106    if (stopmap | MAP_COLON)
     3107      while (p != 0 && !ISSPACE (*p) &&
    29573108             (p[1] == '\\' || p[1] == '/') && isalpha ((unsigned char)p[-1]))
    2958         p = find_char_unquote (p + 1, stopchar, VMS_COMMA, 1, 0);
     3109        p = find_char_unquote (p + 1, stopmap|MAP_VMSCOMMA|MAP_BLANK);
    29593110#endif
    29603111      if (p == 0)
    2961         p = s + strlen (s);
     3112        p = s + strlen (s);
    29623113
    29633114      /* Strip leading "this directory" references.  */
    2964       if (! (flags & PARSEFS_NOSTRIP))
     3115      if (NONE_SET (flags, PARSEFS_NOSTRIP))
    29653116#ifdef VMS
    2966         /* Skip leading `[]'s.  */
    2967         while (p - s > 2 && s[0] == '[' && s[1] == ']')
    2968 #else
    2969         /* Skip leading `./'s.  */
    2970         while (p - s > 2 && s[0] == '.' && s[1] == '/')
     3117        /* Skip leading '[]'s. should only be one set or bug somwhere else */
     3118        if (p - s > 2 && s[0] == '[' && s[1] == ']')
     3119            s += 2;
     3120        /* Skip leading '<>'s. should only be one set or bug somwhere else */
     3121        if (p - s > 2 && s[0] == '<' && s[1] == '>')
     3122            s += 2;
    29713123#endif
    2972           {
     3124        /* Skip leading './'s.  */
     3125        while (p - s > 2 && s[0] == '.' && s[1] == '/')
     3126          {
    29733127            /* Skip "./" and all following slashes.  */
    2974             s += 2;
    2975             while (*s == '/')
    2976               ++s;
    2977           }
     3128            s += 2;
     3129            while (*s == '/')
     3130              ++s;
     3131          }
    29783132
    29793133      /* Extract the filename just found, and skip it.
     
    29823136      if (s == p)
    29833137        {
    2984         /* The name was stripped to empty ("./"). */
    2985 #if defined(VMS)
    2986           continue;
    2987 #elif defined(_AMIGA)
     3138        /* The name was stripped to empty ("./"). */
     3139#if defined(_AMIGA)
    29883140          /* PDS-- This cannot be right!! */
    29893141          tp[0] = '\0';
     
    29973149        }
    29983150      else
    2999         {
     3151        {
    30003152#ifdef VMS
    30013153/* VMS filenames can have a ':' in them but they have to be '\'ed but we need
     
    30033155 * xstrdup called because S may be read-only string constant.
    30043156 */
    3005           char *n = tp;
    3006           while (s < p)
    3007             {
    3008               if (s[0] == '\\' && s[1] == ':')
     3157          char *n = tp;
     3158          while (s < p)
     3159            {
     3160              if (s[0] == '\\' && s[1] == ':')
    30093161                ++s;
    3010               *(n++) = *(s++);
    3011             }
     3162              *(n++) = *(s++);
     3163            }
    30123164          n[0] = '\0';
    30133165          nlen = strlen (tp);
     
    30283180
    30293181         TP == TMP means we're not already in an archive group.  Ignore
    3030          something starting with `(', as that cannot actually be an
     3182         something starting with '(', as that cannot actually be an
    30313183         archive-member reference (and treating it as such results in an empty
    30323184         file name, which causes much lossage).  Also if it ends in ")" then
     
    30363188         character, so ensure there's some word ending like that before
    30373189         considering this an archive group.  */
    3038       if (! (flags & PARSEFS_NOAR)
     3190      if (NONE_SET (flags, PARSEFS_NOAR)
    30393191          && tp == tmpbuf && tp[0] != '(' && tp[nlen-1] != ')')
    30403192        {
     
    30443196              /* This looks like the first element in an open archive group.
    30453197                 A valid group MUST have ')' as the last character.  */
    3046               const char *e = p + nlen;
     3198              const char *e = p;
    30473199              do
    30483200                {
    3049                   e = next_token (e);
     3201                  const char *o = e;
     3202                  NEXT_TOKEN (e);
    30503203                  /* Find the end of this word.  We don't want to unquote and
    30513204                     we don't care about quoting since we're looking for the
    30523205                     last char in the word. */
    3053                   while (*e != '\0' && *e != stopchar && *e != VMS_COMMA
    3054                          && ! isblank ((unsigned char) *e))
     3206                  while (! STOP_SET (*e, stopmap|MAP_BLANK|MAP_VMSCOMMA))
    30553207                    ++e;
     3208                  /* If we didn't move, we're done now.  */
     3209                  if (e == o)
     3210                    break;
    30563211                  if (e[-1] == ')')
    30573212                    {
     
    30623217                      tp = n + 1;
    30633218
    3064                       /* If we have just "lib(", part of something like
    3065                          "lib( a b)", go to the next item.  */
    3066                       if (! nlen)
    3067                         continue;
    3068 
    30693219                      /* We can stop looking now.  */
    30703220                      break;
     
    30723222                }
    30733223              while (*e != '\0');
     3224
     3225              /* If we have just "lib(", part of something like "lib( a b)",
     3226                 go to the next item.  */
     3227              if (! nlen)
     3228                continue;
    30743229            }
    30753230        }
     
    30983253      /* If we're not globbing we're done: add it to the end of the chain.
    30993254         Go to the next item in the string.  */
    3100       if (flags & PARSEFS_NOGLOB)
    3101         {
    3102           NEWELT (concat (2, prefix, tp));
     3255      if (ANY_SET (flags, PARSEFS_NOGLOB))
     3256        {
     3257          NEWELT (concat (2, prefix, tmpbuf));
    31033258          continue;
    31043259        }
     
    31073262         TP is a string in tmpbuf.  NLEN is no longer used.
    31083263         We may need to do more work: after this NAME will be set.  */
    3109       name = tp;
     3264      name = tmpbuf;
    31103265
    31113266      /* Expand tilde if applicable.  */
    3112       if (tp[0] == '~')
    3113         {
    3114           tildep = tilde_expand (tp);
    3115           if (tildep != 0)
     3267      if (tmpbuf[0] == '~')
     3268        {
     3269          tildep = tilde_expand (tmpbuf);
     3270          if (tildep != 0)
    31163271            name = tildep;
    3117         }
     3272        }
    31183273
    31193274#ifndef NO_ARCHIVES
     
    31213276         file name, and save the member name in MEMNAME.  We will glob on the
    31223277         archive name and then reattach MEMNAME later.  */
    3123       if (! (flags & PARSEFS_NOAR) && ar_name (name))
    3124         {
    3125           ar_parse_name (name, &arname, &memname);
    3126           name = arname;
    3127         }
     3278      if (NONE_SET (flags, PARSEFS_NOAR) && ar_name (name))
     3279        {
     3280          ar_parse_name (name, &arname, &memname);
     3281          name = arname;
     3282        }
    31283283#endif /* !NO_ARCHIVES */
    31293284
    3130       switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
    3131         {
    3132         case GLOB_NOSPACE:
    3133           fatal (NILF, _("virtual memory exhausted"));
    3134 
    3135         case 0:
    3136           /* Success.  */
    3137           i = gl.gl_pathc;
    3138           nlist = (const char **)gl.gl_pathv;
    3139           break;
    3140 
    3141         case GLOB_NOMATCH:
    3142           /* If we want only existing items, skip this one.  */
    3143           if (flags & PARSEFS_EXISTS)
    3144             {
    3145               i = 0;
    3146               break;
    3147             }
    3148           /* FALLTHROUGH */
    3149 
    3150         default:
    3151           /* By default keep this name.  */
     3285      /* glob() is expensive: don't call it unless we need to.  */
     3286      if (NONE_SET (flags, PARSEFS_EXISTS) && strpbrk (name, "?*[") == NULL)
     3287        {
     3288          globme = 0;
    31523289          i = 1;
    31533290          nlist = &name;
    3154           break;
    3155         }
     3291        }
     3292      else
     3293        switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
     3294          {
     3295          case GLOB_NOSPACE:
     3296            OUT_OF_MEM();
     3297
     3298          case 0:
     3299            /* Success.  */
     3300            i = gl.gl_pathc;
     3301            nlist = (const char **)gl.gl_pathv;
     3302            break;
     3303
     3304          case GLOB_NOMATCH:
     3305            /* If we want only existing items, skip this one.  */
     3306            if (ANY_SET (flags, PARSEFS_EXISTS))
     3307              {
     3308                i = 0;
     3309                break;
     3310              }
     3311            /* FALLTHROUGH */
     3312
     3313          default:
     3314            /* By default keep this name.  */
     3315            i = 1;
     3316            nlist = &name;
     3317            break;
     3318          }
    31563319
    31573320      /* For each matched element, add it to the list.  */
     
    31683331              {
    31693332                /* We got a chain of items.  Attach them.  */
    3170                 (*newp)->next = found;
     3333                if (*newp)
     3334                  (*newp)->next = found;
     3335                else
     3336                  *newp = found;
    31713337
    31723338                /* Find and set the new end.  Massage names if necessary.  */
     
    31903356          NEWELT (concat (2, prefix, nlist[i]));
    31913357
    3192       globfree (&gl);
     3358      if (globme)
     3359        globfree (&gl);
    31933360
    31943361#ifndef NO_ARCHIVES
    3195       if (arname)
    3196         free (arname);
     3362      free (arname);
    31973363#endif
    31983364
    3199       if (tildep)
    3200         free (tildep);
     3365      free (tildep);
    32013366    }
    32023367
  • vendor/gnumake/current/remake.c

    r2596 r3138  
    11/* Basic dependency engine for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018#include "filedef.h"
    2119#include "job.h"
     
    4038#endif
    4139
    42 extern int try_implicit_rule (struct file *file, unsigned int depth);
    43 
    4440
    4541/* The test for circular dependencies is based on the 'updating' bit in
    46    `struct file'.  However, double colon targets have seperate `struct
     42   'struct file'.  However, double colon targets have separate 'struct
    4743   file's; make sure we always use the base of the double colon chain. */
    4844
     
    5854unsigned int commands_started = 0;
    5955
    60 /* Current value for pruning the scan of the goal chain (toggle 0/1).  */
    61 static unsigned int considered;
    62 
    63 static int update_file (struct file *file, unsigned int depth);
    64 static int update_file_1 (struct file *file, unsigned int depth);
    65 static int check_dep (struct file *file, unsigned int depth,
    66                       FILE_TIMESTAMP this_mtime, int *must_make_ptr);
    67 static int touch_file (struct file *file);
     56/* Set to the goal dependency.  Mostly needed for remaking makefiles.  */
     57static struct goaldep *goal_list;
     58static struct dep *goal_dep;
     59
     60/* Current value for pruning the scan of the goal chain.
     61   All files start with considered == 0.  */
     62static unsigned int considered = 0;
     63
     64static enum update_status update_file (struct file *file, unsigned int depth);
     65static enum update_status update_file_1 (struct file *file, unsigned int depth);
     66static enum update_status check_dep (struct file *file, unsigned int depth,
     67                                     FILE_TIMESTAMP this_mtime, int *must_make);
     68static enum update_status touch_file (struct file *file);
    6869static void remake_file (struct file *file);
    6970static FILE_TIMESTAMP name_mtime (const char *name);
     
    7273
    7374
    74 /* Remake all the goals in the `struct dep' chain GOALS.  Return -1 if nothing
     75/* Remake all the goals in the 'struct dep' chain GOALS.  Return -1 if nothing
    7576   was done, 0 if all goals were updated successfully, or 1 if a goal failed.
    7677
     
    7879   and -n should be disabled for them unless they were also command-line
    7980   targets, and we should only make one goal at a time and return as soon as
    80    one goal whose `changed' member is nonzero is successfully made.  */
    81 
    82 int
    83 update_goal_chain (struct dep *goals)
     81   one goal whose 'changed' member is nonzero is successfully made.  */
     82
     83enum update_status
     84update_goal_chain (struct goaldep *goaldeps)
    8485{
    8586  int t = touch_flag, q = question_flag, n = just_print_flag;
    86   int status = -1;
    87 
    88 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \
    89                      : file_mtime (file))
     87  enum update_status status = us_none;
    9088
    9189  /* Duplicate the chain so we can remove things from it.  */
    9290
    93   goals = copy_dep_chain (goals);
    94 
    95   {
    96     /* Clear the `changed' flag of each goal in the chain.
    97        We will use the flag below to notice when any commands
    98        have actually been run for a target.  When no commands
    99        have been run, we give an "up to date" diagnostic.  */
    100 
    101     struct dep *g;
    102     for (g = goals; g != 0; g = g->next)
    103       g->changed = 0;
    104   }
    105 
    106   /* All files start with the considered bit 0, so the global value is 1.  */
    107   considered = 1;
     91  struct dep *goals = copy_dep_chain ((struct dep *)goaldeps);
     92
     93  goal_list = rebuilding_makefiles ? goaldeps : NULL;
     94
     95#define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \
     96                     : file_mtime (file))
     97
     98  /* Start a fresh batch of consideration.  */
     99  ++considered;
    108100
    109101  /* Update all the goals until they are all finished.  */
     
    124116      g = goals;
    125117      while (g != 0)
    126         {
    127           /* Iterate over all double-colon entries for this file.  */
    128           struct file *file;
    129           int stop = 0, any_not_updated = 0;
    130 
    131           for (file = g->file->double_colon ? g->file->double_colon : g->file;
    132                file != NULL;
    133                file = file->prev)
    134             {
    135               unsigned int ocommands_started;
    136               int x;
    137 
    138               file->dontcare = g->dontcare;
    139 
    140               check_renamed (file);
    141               if (rebuilding_makefiles)
    142                 {
    143                   if (file->cmd_target)
    144                     {
    145                       touch_flag = t;
    146                       question_flag = q;
    147                       just_print_flag = n;
    148                     }
    149                   else
    150                     touch_flag = question_flag = just_print_flag = 0;
    151                 }
    152 
    153               /* Save the old value of `commands_started' so we can compare
    154                  later.  It will be incremented when any commands are
    155                  actually run.  */
    156               ocommands_started = commands_started;
    157 
    158               x = update_file (file, rebuilding_makefiles ? 1 : 0);
    159               check_renamed (file);
    160 
    161               /* Set the goal's `changed' flag if any commands were started
    162                  by calling update_file above.  We check this flag below to
    163                  decide when to give an "up to date" diagnostic.  */
     118        {
     119          /* Iterate over all double-colon entries for this file.  */
     120          struct file *file;
     121          int stop = 0, any_not_updated = 0;
     122
     123          goal_dep = g;
     124
     125          for (file = g->file->double_colon ? g->file->double_colon : g->file;
     126               file != NULL;
     127               file = file->prev)
     128            {
     129              unsigned int ocommands_started;
     130              enum update_status fail;
     131
     132              file->dontcare = ANY_SET (g->flags, RM_DONTCARE);
     133
     134              check_renamed (file);
     135              if (rebuilding_makefiles)
     136                {
     137                  if (file->cmd_target)
     138                    {
     139                      touch_flag = t;
     140                      question_flag = q;
     141                      just_print_flag = n;
     142                    }
     143                  else
     144                    touch_flag = question_flag = just_print_flag = 0;
     145                }
     146
     147              /* Save the old value of 'commands_started' so we can compare
     148                 later.  It will be incremented when any commands are
     149                 actually run.  */
     150              ocommands_started = commands_started;
     151
     152              fail = update_file (file, rebuilding_makefiles ? 1 : 0);
     153              check_renamed (file);
     154
     155              /* Set the goal's 'changed' flag if any commands were started
     156                 by calling update_file above.  We check this flag below to
     157                 decide when to give an "up to date" diagnostic.  */
    164158              if (commands_started > ocommands_started)
    165159                g->changed = 1;
    166160
    167               /* If we updated a file and STATUS was not already 1, set it to
    168                  1 if updating failed, or to 0 if updating succeeded.  Leave
    169                  STATUS as it is if no updating was done.  */
    170 
    171               stop = 0;
    172               if ((x != 0 || file->updated) && status < 1)
     161              stop = 0;
     162              if ((fail || file->updated) && status < us_question)
    173163                {
    174                   if (file->update_status != 0)
     164                  /* We updated this goal.  Update STATUS and decide whether
     165                     to stop.  */
     166                  if (file->update_status)
    175167                    {
    176168                      /* Updating failed, or -q triggered.  The STATUS value
     
    199191                          if (!rebuilding_makefiles
    200192                              || (!just_print_flag && !question_flag))
    201                             status = 0;
     193                            status = us_success;
    202194                          if (rebuilding_makefiles && file->dontcare)
    203195                            /* This is a default makefile; stop remaking.  */
     
    207199                }
    208200
    209               /* Keep track if any double-colon entry is not finished.
     201              /* Keep track if any double-colon entry is not finished.
    210202                 When they are all finished, the goal is finished.  */
    211               any_not_updated |= !file->updated;
     203              any_not_updated |= !file->updated;
    212204
    213205              file->dontcare = 0;
    214206
    215               if (stop)
    216                 break;
    217             }
    218 
    219           /* Reset FILE since it is null at the end of the loop.  */
    220           file = g->file;
    221 
    222           if (stop || !any_not_updated)
    223             {
    224               /* If we have found nothing whatever to do for the goal,
    225                 print a message saying nothing needs doing.  */
    226 
    227               if (!rebuilding_makefiles
    228                   /* If the update_status is zero, we updated successfully
    229                      or not at all.  G->changed will have been set above if
    230                      any commands were actually started for this goal.  */
    231                   && file->update_status == 0 && !g->changed
    232                   /* Never give a message under -s or -q.  */
    233                   && !silent_flag && !question_flag)
    234                 message (1, ((file->phony || file->cmds == 0)
    235                              ? _("Nothing to be done for `%s'.")
    236                              : _("`%s' is up to date.")),
    237                         file->name);
    238 
    239               /* This goal is finished.  Remove it from the chain.  */
    240               if (lastgoal == 0)
    241                 goals = g->next;
    242               else
    243                 lastgoal->next = g->next;
    244 
    245               /* Free the storage.  */
    246               free (g);
    247 
    248               g = lastgoal == 0 ? goals : lastgoal->next;
    249 
    250               if (stop)
    251                 break;
    252             }
    253           else
    254             {
    255               lastgoal = g;
    256               g = g->next;
    257             }
    258         }
    259 
    260       /* If we reached the end of the dependency graph toggle the considered
    261          flag for the next pass.  */
     207              if (stop)
     208                break;
     209            }
     210
     211          /* Reset FILE since it is null at the end of the loop.  */
     212          file = g->file;
     213
     214          if (stop || !any_not_updated)
     215            {
     216              /* If we have found nothing whatever to do for the goal,
     217                print a message saying nothing needs doing.  */
     218
     219              if (!rebuilding_makefiles
     220                  /* If the update_status is success, we updated successfully
     221                     or not at all.  G->changed will have been set above if
     222                     any commands were actually started for this goal.  */
     223                  && file->update_status == us_success && !g->changed
     224                  /* Never give a message under -s or -q.  */
     225                  && !silent_flag && !question_flag)
     226                OS (message, 1, ((file->phony || file->cmds == 0)
     227                                 ? _("Nothing to be done for '%s'.")
     228                                 : _("'%s' is up to date.")),
     229                    file->name);
     230
     231              /* This goal is finished.  Remove it from the chain.  */
     232              if (lastgoal == 0)
     233                goals = g->next;
     234              else
     235                lastgoal->next = g->next;
     236
     237              /* Free the storage.  */
     238              free (g);
     239
     240              g = lastgoal == 0 ? goals : lastgoal->next;
     241
     242              if (stop)
     243                break;
     244            }
     245          else
     246            {
     247              lastgoal = g;
     248              g = g->next;
     249            }
     250        }
     251
     252      /* If we reached the end of the dependency graph update CONSIDERED
     253         for the next pass.  */
    262254      if (g == 0)
    263         considered = !considered;
     255        ++considered;
    264256    }
    265257
     
    275267
    276268
     269/* If we're rebuilding an included makefile that failed, and we care
     270   about errors, show an error message the first time.  */
     271
     272void
     273show_goal_error (void)
     274{
     275  struct goaldep *goal;
     276
     277  if ((goal_dep->flags & (RM_INCLUDED|RM_DONTCARE)) != RM_INCLUDED)
     278    return;
     279
     280  for (goal = goal_list; goal; goal = goal->next)
     281    if (goal_dep->file == goal->file)
     282      {
     283        if (goal->error)
     284          {
     285            OSS (error, &goal->floc, "%s: %s",
     286                 goal->file->name, strerror ((int)goal->error));
     287            goal->error = 0;
     288          }
     289        return;
     290      }
     291}
     292
     293
    277294/* If FILE is not up to date, execute the commands for it.
    278    Return 0 if successful, 1 if unsuccessful;
    279    but with some flag settings, just call `exit' if unsuccessful.
     295   Return 0 if successful, non-0 if unsuccessful;
     296   but with some flag settings, just call 'exit' if unsuccessful.
    280297
    281298   DEPTH is the depth in recursions of this function.
     
    287304   each is considered in turn.  */
    288305
    289 static int
     306static enum update_status
    290307update_file (struct file *file, unsigned int depth)
    291308{
    292   register int status = 0;
    293   register struct file *f;
     309  enum update_status status = us_success;
     310  struct file *f;
    294311
    295312  f = file->double_colon ? file->double_colon : file;
     
    302319    {
    303320      /* Check for the case where a target has been tried and failed but
    304          the diagnostics hasn't been issued. If we need the diagnostics
     321         the diagnostics haven't been issued. If we need the diagnostics
    305322         then we will have to continue. */
    306       if (!(f->updated && f->update_status > 0 && !f->dontcare && f->no_diag))
    307         {
    308           DBF (DB_VERBOSE, _("Pruning file `%s'.\n"));
    309           return f->command_state == cs_finished ? f->update_status : 0;
     323      if (!(f->updated && f->update_status > us_none
     324            && !f->dontcare && f->no_diag))
     325        {
     326          DBF (DB_VERBOSE, _("Pruning file '%s'.\n"));
     327          return f->command_state == cs_finished ? f->update_status : us_success;
    310328        }
    311329    }
     
    315333  for (; f != 0; f = f->prev)
    316334    {
     335      enum update_status new;
     336
    317337      f->considered = considered;
    318338
    319       status |= update_file_1 (f, depth);
     339      new = update_file_1 (f, depth);
    320340      check_renamed (f);
    321341
     
    324344
    325345      /* If we got an error, don't bother with double_colon etc.  */
    326       if (status != 0 && !keep_going_flag)
    327         return status;
     346      if (new && !keep_going_flag)
     347        return new;
    328348
    329349      if (f->command_state == cs_running
    330350          || f->command_state == cs_deps_running)
    331         {
    332           /* Don't run the other :: rules for this
    333              file until this rule is finished.  */
    334           status = 0;
    335           break;
    336         }
     351        /* Don't run other :: rules for this target until
     352           this rule is finished.  */
     353        return us_success;
     354
     355      if (new > status)
     356        status = new;
    337357    }
    338358
     
    347367
    348368        for (d = f->deps; d != 0; d = d->next)
    349           status |= update_file (d->file, depth + 1);
     369          {
     370            enum update_status new = update_file (d->file, depth + 1);
     371            if (new > status)
     372              status = new;
     373          }
    350374      }
    351375
     
    359383complain (struct file *file)
    360384{
    361   const char *msg_noparent
    362     = _("%sNo rule to make target `%s'%s");
    363   const char *msg_parent
    364     = _("%sNo rule to make target `%s', needed by `%s'%s");
    365 
    366385  /* If this file has no_diag set then it means we tried to update it
    367386     before in the dontcare mode and failed. The target that actually
     
    374393  for (d = file->deps; d != 0; d = d->next)
    375394    {
    376       if (d->file->updated && d->file->update_status > 0 && file->no_diag)
     395      if (d->file->updated && d->file->update_status > us_none && file->no_diag)
    377396        {
    378397          complain (d->file);
     
    383402  if (d == 0)
    384403    {
     404      show_goal_error ();
     405
    385406      /* Didn't find any dependencies to complain about. */
    386       if (!keep_going_flag)
    387         {
    388           if (file->parent == 0)
    389             fatal (NILF, msg_noparent, "", file->name, "");
    390 
    391           fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
    392         }
    393 
    394       if (file->parent == 0)
    395         error (NILF, msg_noparent, "*** ", file->name, ".");
     407      if (file->parent)
     408        {
     409          size_t l = strlen (file->name) + strlen (file->parent->name) + 4;
     410          const char *m = _("%sNo rule to make target '%s', needed by '%s'%s");
     411
     412          if (!keep_going_flag)
     413            fatal (NILF, l, m, "", file->name, file->parent->name, "");
     414
     415          error (NILF, l, m, "*** ", file->name, file->parent->name, ".");
     416        }
    396417      else
    397         error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
     418        {
     419          size_t l = strlen (file->name) + 4;
     420          const char *m = _("%sNo rule to make target '%s'%s");
     421
     422          if (!keep_going_flag)
     423            fatal (NILF, l, m, "", file->name, "");
     424
     425          error (NILF, l, m, "*** ", file->name, ".");
     426        }
    398427
    399428      file->no_diag = 0;
     
    401430}
    402431
    403 /* Consider a single `struct file' and update it as appropriate.  */
    404 
    405 static int
     432/* Consider a single 'struct file' and update it as appropriate.
     433   Return 0 on success, or non-0 on failure.  */
     434
     435static enum update_status
    406436update_file_1 (struct file *file, unsigned int depth)
    407437{
     438  enum update_status dep_status = us_success;
    408439  FILE_TIMESTAMP this_mtime;
    409440  int noexist, must_make, deps_changed;
    410   int dep_status = 0;
    411441  struct file *ofile;
    412442  struct dep *d, *ad;
     
    414444  int running = 0;
    415445
    416   DBF (DB_VERBOSE, _("Considering target file `%s'.\n"));
     446  DBF (DB_VERBOSE, _("Considering target file '%s'.\n"));
    417447
    418448  if (file->updated)
    419449    {
    420       if (file->update_status > 0)
    421         {
    422           DBF (DB_VERBOSE,
    423                _("Recently tried and failed to update file `%s'.\n"));
     450      if (file->update_status > us_none)
     451        {
     452          DBF (DB_VERBOSE,
     453               _("Recently tried and failed to update file '%s'.\n"));
    424454
    425455          /* If the file we tried to make is marked no_diag then no message
     
    430460              complain (file);
    431461
    432           return file->update_status;
    433         }
    434 
    435       DBF (DB_VERBOSE, _("File `%s' was considered already.\n"));
     462          return file->update_status;
     463        }
     464
     465      DBF (DB_VERBOSE, _("File '%s' was considered already.\n"));
    436466      return 0;
    437467    }
     
    443473      break;
    444474    case cs_running:
    445       DBF (DB_VERBOSE, _("Still updating file `%s'.\n"));
     475      DBF (DB_VERBOSE, _("Still updating file '%s'.\n"));
    446476      return 0;
    447477    case cs_finished:
    448       DBF (DB_VERBOSE, _("Finished updating file `%s'.\n"));
     478      DBF (DB_VERBOSE, _("Finished updating file '%s'.\n"));
    449479      return file->update_status;
    450480    default:
     
    475505  noexist = this_mtime == NONEXISTENT_MTIME;
    476506  if (noexist)
    477     DBF (DB_BASIC, _("File `%s' does not exist.\n"));
     507    DBF (DB_BASIC, _("File '%s' does not exist.\n"));
    478508  else if (ORDINARY_MTIME_MIN <= this_mtime && this_mtime <= ORDINARY_MTIME_MAX
    479            && file->low_resolution_time)
     509           && file->low_resolution_time)
    480510    {
    481511      /* Avoid spurious rebuilds due to low resolution time stamps.  */
    482512      int ns = FILE_TIMESTAMP_NS (this_mtime);
    483513      if (ns != 0)
    484         error (NILF, _("*** Warning: .LOW_RESOLUTION_TIME file `%s' has a high resolution time stamp"),
    485                file->name);
     514        OS (error, NILF,
     515            _("*** Warning: .LOW_RESOLUTION_TIME file '%s' has a high resolution time stamp"),
     516            file->name);
    486517      this_mtime += FILE_TIMESTAMPS_PER_S - 1 - ns;
    487518    }
     
    495526    {
    496527      if (try_implicit_rule (file, depth))
    497         DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));
     528        DBF (DB_IMPLICIT, _("Found an implicit rule for '%s'.\n"));
    498529      else
    499         DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));
     530        DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n"));
    500531      file->tried_implicit = 1;
    501532    }
     
    503534      && default_file != 0 && default_file->cmds != 0)
    504535    {
    505       DBF (DB_IMPLICIT, _("Using default recipe for `%s'.\n"));
     536      DBF (DB_IMPLICIT, _("Using default recipe for '%s'.\n"));
    506537      file->cmds = default_file->cmds;
    507538    }
     
    525556      while (d)
    526557        {
     558          enum update_status new;
    527559          FILE_TIMESTAMP mtime;
    528560          int maybe_make;
     
    536568          if (is_updating (d->file))
    537569            {
    538               error (NILF, _("Circular %s <- %s dependency dropped."),
    539                      file->name, d->file->name);
     570              OSS (error, NILF, _("Circular %s <- %s dependency dropped."),
     571                   file->name, d->file->name);
    540572              /* We cannot free D here because our the caller will still have
    541573                 a reference to it when we were called recursively via
     
    559591            }
    560592
    561           dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
     593          new = check_dep (d->file, depth, this_mtime, &maybe_make);
     594          if (new > dep_status)
     595            dep_status = new;
    562596
    563597          /* Restore original dontcare flag. */
     
    583617          }
    584618
    585           if (dep_status != 0 && !keep_going_flag)
     619          if (dep_status && !keep_going_flag)
    586620            break;
    587621
    588622          if (!running)
    589             /* The prereq is considered changed if the timestamp has changed while
    590                it was built, OR it doesn't exist.  */
     623            /* The prereq is considered changed if the timestamp has changed
     624               while it was built, OR it doesn't exist.  */
    591625            d->changed = ((file_mtime (d->file) != mtime)
    592626                          || (mtime == NONEXISTENT_MTIME));
     
    603637    {
    604638      for (d = file->deps; d != 0; d = d->next)
    605         if (d->file->intermediate)
    606           {
     639        if (d->file->intermediate)
     640          {
     641            enum update_status new;
    607642            int dontcare = 0;
    608643
    609             FILE_TIMESTAMP mtime = file_mtime (d->file);
    610             check_renamed (d->file);
    611             d->file->parent = file;
     644            FILE_TIMESTAMP mtime = file_mtime (d->file);
     645            check_renamed (d->file);
     646            d->file->parent = file;
    612647
    613648            /* Inherit dontcare flag from our parent. */
     
    618653              }
    619654
    620 
    621             dep_status |= update_file (d->file, depth);
     655            /* We may have already considered this file, when we didn't know
     656               we'd need to update it.  Force update_file() to consider it and
     657               not prune it.  */
     658            d->file->considered = 0;
     659
     660            new = update_file (d->file, depth);
     661            if (new > dep_status)
     662              dep_status = new;
    622663
    623664            /* Restore original dontcare flag. */
     
    625666              d->file->dontcare = dontcare;
    626667
    627             check_renamed (d->file);
    628 
    629             {
    630               register struct file *f = d->file;
    631               if (f->double_colon)
    632                 f = f->double_colon;
    633               do
    634                 {
    635                   running |= (f->command_state == cs_running
    636                               || f->command_state == cs_deps_running);
    637                   f = f->prev;
    638                 }
    639               while (f != 0);
    640             }
    641 
    642             if (dep_status != 0 && !keep_going_flag)
    643               break;
    644 
    645             if (!running)
    646               d->changed = ((file->phony && file->cmds != 0)
    647                             || file_mtime (d->file) != mtime);
    648           }
     668            check_renamed (d->file);
     669
     670            {
     671              register struct file *f = d->file;
     672              if (f->double_colon)
     673                f = f->double_colon;
     674              do
     675                {
     676                  running |= (f->command_state == cs_running
     677                              || f->command_state == cs_deps_running);
     678                  f = f->prev;
     679                }
     680              while (f != 0);
     681            }
     682
     683            if (dep_status && !keep_going_flag)
     684              break;
     685
     686            if (!running)
     687              d->changed = ((file->phony && file->cmds != 0)
     688                            || file_mtime (d->file) != mtime);
     689          }
    649690    }
    650691
     
    652693  finish_updating (ofile);
    653694
    654   DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));
     695  DBF (DB_VERBOSE, _("Finished prerequisites of target file '%s'.\n"));
    655696
    656697  if (running)
     
    658699      set_command_state (file, cs_deps_running);
    659700      --depth;
    660       DBF (DB_VERBOSE, _("The prerequisites of `%s' are being made.\n"));
     701      DBF (DB_VERBOSE, _("The prerequisites of '%s' are being made.\n"));
    661702      return 0;
    662703    }
     
    664705  /* If any dependency failed, give up now.  */
    665706
    666   if (dep_status != 0)
    667     {
    668       file->update_status = dep_status;
     707  if (dep_status)
     708    {
     709      /* I'm not sure if we can't just assign dep_status...  */
     710      file->update_status = dep_status == us_none ? us_failed : dep_status;
    669711      notice_finished_file (file);
    670712
    671713      --depth;
    672714
    673       DBF (DB_VERBOSE, _("Giving up on target file `%s'.\n"));
     715      DBF (DB_VERBOSE, _("Giving up on target file '%s'.\n"));
    674716
    675717      if (depth == 0 && keep_going_flag
    676           && !just_print_flag && !question_flag)
    677         error (NILF,
    678                _("Target `%s' not remade because of errors."), file->name);
     718          && !just_print_flag && !question_flag)
     719        OS (error, NILF,
     720            _("Target '%s' not remade because of errors."), file->name);
    679721
    680722      return dep_status;
     
    705747#if 1
    706748          /* %%% In version 4, remove this code completely to
    707            implement not remaking deps if their deps are newer
    708            than their parents.  */
     749           implement not remaking deps if their deps are newer
     750           than their parents.  */
    709751          if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate)
    710752            /* We must remake if this dep does not
     
    718760
    719761      /* Set D->changed if either this dep actually changed,
    720         or its dependent, FILE, is older or does not exist.  */
     762        or its dependent, FILE, is older or does not exist.  */
    721763      d->changed |= noexist || d_mtime > this_mtime;
    722764
    723765      if (!noexist && ISDB (DB_BASIC|DB_VERBOSE))
    724         {
     766        {
    725767          const char *fmt = 0;
    726768
     
    728770            {
    729771              if (ISDB (DB_VERBOSE))
    730                 fmt = _("Prerequisite `%s' is order-only for target `%s'.\n");
     772                fmt = _("Prerequisite '%s' is order-only for target '%s'.\n");
    731773            }
    732774          else if (d_mtime == NONEXISTENT_MTIME)
    733775            {
    734776              if (ISDB (DB_BASIC))
    735                 fmt = _("Prerequisite `%s' of target `%s' does not exist.\n");
    736             }
    737           else if (d->changed)
     777                fmt = _("Prerequisite '%s' of target '%s' does not exist.\n");
     778            }
     779          else if (d->changed)
    738780            {
    739781              if (ISDB (DB_BASIC))
    740                 fmt = _("Prerequisite `%s' is newer than target `%s'.\n");
     782                fmt = _("Prerequisite '%s' is newer than target '%s'.\n");
    741783            }
    742784          else if (ISDB (DB_VERBOSE))
    743             fmt = _("Prerequisite `%s' is older than target `%s'.\n");
     785            fmt = _("Prerequisite '%s' is older than target '%s'.\n");
    744786
    745787          if (fmt)
     
    749791              fflush (stdout);
    750792            }
    751         }
     793        }
    752794    }
    753795
     
    759801      must_make = 1;
    760802      DBF (DB_BASIC,
    761            _("Target `%s' is double-colon and has no prerequisites.\n"));
     803           _("Target '%s' is double-colon and has no prerequisites.\n"));
    762804    }
    763805  else if (!noexist && file->is_target && !deps_changed && file->cmds == 0
     
    766808      must_make = 0;
    767809      DBF (DB_VERBOSE,
    768            _("No recipe for `%s' and no prerequisites actually changed.\n"));
     810           _("No recipe for '%s' and no prerequisites actually changed.\n"));
    769811    }
    770812  else if (!must_make && file->cmds != 0 && always_make_flag)
    771813    {
    772814      must_make = 1;
    773       DBF (DB_VERBOSE, _("Making `%s' due to always-make flag.\n"));
     815      DBF (DB_VERBOSE, _("Making '%s' due to always-make flag.\n"));
    774816    }
    775817
     
    779821        {
    780822          print_spaces (depth);
    781           printf (_("No need to remake target `%s'"), file->name);
     823          printf (_("No need to remake target '%s'"), file->name);
    782824          if (!streq (file->name, file->hname))
    783               printf (_("; using VPATH name `%s'"), file->hname);
     825              printf (_("; using VPATH name '%s'"), file->hname);
    784826          puts (".");
    785827          fflush (stdout);
     
    801843    }
    802844
    803   DBF (DB_BASIC, _("Must remake target `%s'.\n"));
     845  DBF (DB_BASIC, _("Must remake target '%s'.\n"));
    804846
    805847  /* It needs to be remade.  If it's VPATH and not reset via GPATH, toss the
    806848     VPATH.  */
    807   if (!streq(file->name, file->hname))
    808     {
    809       DB (DB_BASIC, (_("  Ignoring VPATH name `%s'.\n"), file->hname));
     849  if (!streq (file->name, file->hname))
     850    {
     851      DB (DB_BASIC, (_("  Ignoring VPATH name '%s'.\n"), file->hname));
    810852      file->ignore_vpath = 1;
    811853    }
     
    816858  if (file->command_state != cs_finished)
    817859    {
    818       DBF (DB_VERBOSE, _("Recipe of `%s' is being run.\n"));
     860      DBF (DB_VERBOSE, _("Recipe of '%s' is being run.\n"));
    819861      return 0;
    820862    }
     
    822864  switch (file->update_status)
    823865    {
    824     case 2:
    825       DBF (DB_BASIC, _("Failed to remake target file `%s'.\n"));
     866    case us_failed:
     867      DBF (DB_BASIC, _("Failed to remake target file '%s'.\n"));
    826868      break;
    827     case 0:
    828       DBF (DB_BASIC, _("Successfully remade target file `%s'.\n"));
     869    case us_success:
     870      DBF (DB_BASIC, _("Successfully remade target file '%s'.\n"));
    829871      break;
    830     case 1:
    831       DBF (DB_BASIC, _("Target file `%s' needs remade under -q.\n"));
     872    case us_question:
     873      DBF (DB_BASIC, _("Target file '%s' needs to be remade under -q.\n"));
    832874      break;
    833     default:
    834       assert (file->update_status >= 0 && file->update_status <= 2);
     875    case us_none:
    835876      break;
    836877    }
     
    841882
    842883
    843 /* Set FILE's `updated' flag and re-check its mtime and the mtime's of all
    844    files listed in its `also_make' member.  Under -t, this function also
     884/* Set FILE's 'updated' flag and re-check its mtime and the mtime's of all
     885   files listed in its 'also_make' member.  Under -t, this function also
    845886   touches FILE.
    846887
    847    On return, FILE->update_status will no longer be -1 if it was.  */
     888   On return, FILE->update_status will no longer be us_none if it was.  */
    848889
    849890void
     
    859900  if (touch_flag
    860901      /* The update status will be:
    861                 -1      if this target was not remade;
    862                 0       if 0 or more commands (+ or ${MAKE}) were run and won;
    863                 1       if some commands were run and lost.
    864         We touch the target if it has commands which either were not run
    865         or won when they ran (i.e. status is 0).  */
    866       && file->update_status == 0)
     902           us_success   if 0 or more commands (+ or ${MAKE}) were run and won;
     903           us_none      if this target was not remade;
     904           >us_none     if some commands were run and lost.
     905        We touch the target if it has commands which either were not run
     906        or won when they ran (i.e. status is 0).  */
     907      && file->update_status == us_success)
    867908    {
    868909      if (file->cmds != 0 && file->cmds->any_recurse)
    869         {
    870           /* If all the command lines were recursive,
    871              we don't want to do the touching.  */
    872           unsigned int i;
    873           for (i = 0; i < file->cmds->ncommand_lines; ++i)
    874             if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE))
    875               goto have_nonrecursing;
    876         }
     910        {
     911          /* If all the command lines were recursive,
     912             we don't want to do the touching.  */
     913          unsigned int i;
     914          for (i = 0; i < file->cmds->ncommand_lines; ++i)
     915            if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE))
     916              goto have_nonrecursing;
     917        }
    877918      else
    878         {
    879         have_nonrecursing:
    880           if (file->phony)
    881             file->update_status = 0;
     919        {
     920        have_nonrecursing:
     921          if (file->phony)
     922            file->update_status = us_success;
    882923          /* According to POSIX, -t doesn't affect targets with no cmds.  */
    883           else if (file->cmds != 0)
     924          else if (file->cmds != 0)
    884925            {
    885926              /* Should set file's modification date and do nothing else.  */
     
    887928
    888929              /* Pretend we ran a real touch command, to suppress the
    889                  "`foo' is up to date" message.  */
     930                 "'foo' is up to date" message.  */
    890931              commands_started++;
    891932
     
    896937              touched = 1;
    897938            }
    898         }
     939        }
    899940    }
    900941
     
    920961
    921962      else if (file->is_target && file->cmds == 0)
    922         i = 1;
     963        i = 1;
    923964
    924965      file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME;
     
    953994    }
    954995
    955   if (ran && file->update_status != -1)
     996  if (ran && file->update_status != us_none)
    956997    /* We actually tried to update FILE, which has
    957998       updated its also_make's as well (if it worked).
     
    9601001    for (d = file->also_make; d != 0; d = d->next)
    9611002      {
    962         d->file->command_state = cs_finished;
    963         d->file->updated = 1;
    964         d->file->update_status = file->update_status;
    965 
    966         if (ran && !d->file->phony)
    967           /* Fetch the new modification time.
    968              We do this instead of just invalidating the cached time
    969              so that a vpath_search can happen.  Otherwise, it would
    970              never be done because the target is already updated.  */
    971           f_mtime (d->file, 0);
     1003        d->file->command_state = cs_finished;
     1004        d->file->updated = 1;
     1005        d->file->update_status = file->update_status;
     1006
     1007        if (ran && !d->file->phony)
     1008          /* Fetch the new modification time.
     1009             We do this instead of just invalidating the cached time
     1010             so that a vpath_search can happen.  Otherwise, it would
     1011             never be done because the target is already updated.  */
     1012          f_mtime (d->file, 0);
    9721013      }
    973   else if (file->update_status == -1)
     1014  else if (file->update_status == us_none)
    9741015    /* Nothing was done for FILE, but it needed nothing done.
    9751016       So mark it now as "succeeded".  */
    976     file->update_status = 0;
     1017    file->update_status = us_success;
    9771018}
    9781019
     
    9841025   failed.  */
    9851026
    986 static int
     1027static enum update_status
    9871028check_dep (struct file *file, unsigned int depth,
    9881029           FILE_TIMESTAMP this_mtime, int *must_make_ptr)
     
    9901031  struct file *ofile;
    9911032  struct dep *d;
    992   int dep_status = 0;
     1033  enum update_status dep_status = us_success;
    9931034
    9941035  ++depth;
     
    10091050      check_renamed (file);
    10101051      if (mtime == NONEXISTENT_MTIME || mtime > this_mtime)
    1011         *must_make_ptr = 1;
     1052        *must_make_ptr = 1;
    10121053    }
    10131054  else
     
    10171058
    10181059      if (!file->phony && file->cmds == 0 && !file->tried_implicit)
    1019         {
    1020           if (try_implicit_rule (file, depth))
    1021             DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));
    1022           else
    1023             DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));
    1024           file->tried_implicit = 1;
    1025         }
     1060        {
     1061          if (try_implicit_rule (file, depth))
     1062            DBF (DB_IMPLICIT, _("Found an implicit rule for '%s'.\n"));
     1063          else
     1064            DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n"));
     1065          file->tried_implicit = 1;
     1066        }
    10261067      if (file->cmds == 0 && !file->is_target
    1027           && default_file != 0 && default_file->cmds != 0)
    1028         {
    1029           DBF (DB_IMPLICIT, _("Using default commands for `%s'.\n"));
    1030           file->cmds = default_file->cmds;
    1031         }
     1068          && default_file != 0 && default_file->cmds != 0)
     1069        {
     1070          DBF (DB_IMPLICIT, _("Using default commands for '%s'.\n"));
     1071          file->cmds = default_file->cmds;
     1072        }
    10321073
    10331074      check_renamed (file);
     
    10371078        /* If the intermediate file actually exists and is newer, then we
    10381079           should remake from it.  */
    1039         *must_make_ptr = 1;
     1080        *must_make_ptr = 1;
    10401081      else
    1041         {
     1082        {
    10421083          /* Otherwise, update all non-intermediate files we depend on, if
    10431084             necessary, and see whether any of them is more recent than the
    10441085             file on whose behalf we are checking.  */
    1045           struct dep *ld;
     1086          struct dep *ld;
    10461087          int deps_running = 0;
    10471088
     
    10501091             prerequisite and so wasn't rebuilt then, but should be now.  */
    10511092          if (file->command_state != cs_running)
    1052             set_command_state (file, cs_not_started);
    1053 
    1054           ld = 0;
    1055           d = file->deps;
    1056           while (d != 0)
    1057             {
     1093            {
     1094              /* If the target was waiting for a dependency it has to be
     1095                 reconsidered, as that dependency might have finished.  */
     1096              if (file->command_state == cs_deps_running)
     1097                file->considered = 0;
     1098
     1099              set_command_state (file, cs_not_started);
     1100            }
     1101
     1102          ld = 0;
     1103          d = file->deps;
     1104          while (d != 0)
     1105            {
     1106              enum update_status new;
    10581107              int maybe_make;
    10591108
    1060               if (is_updating (d->file))
    1061                 {
    1062                   error (NILF, _("Circular %s <- %s dependency dropped."),
    1063                         file->name, d->file->name);
    1064                   if (ld == 0)
    1065                     {
    1066                       file->deps = d->next;
     1109              if (is_updating (d->file))
     1110                {
     1111                  OSS (error, NILF, _("Circular %s <- %s dependency dropped."),
     1112                      file->name, d->file->name);
     1113                  if (ld == 0)
     1114                    {
     1115                      file->deps = d->next;
    10671116                      free_dep (d);
    1068                       d = file->deps;
    1069                     }
    1070                   else
    1071                     {
    1072                       ld->next = d->next;
     1117                      d = file->deps;
     1118                    }
     1119                  else
     1120                    {
     1121                      ld->next = d->next;
    10731122                      free_dep (d);
    1074                       d = ld->next;
    1075                     }
    1076                   continue;
    1077                 }
    1078 
    1079               d->file->parent = file;
     1123                      d = ld->next;
     1124                    }
     1125                  continue;
     1126                }
     1127
     1128              d->file->parent = file;
    10801129              maybe_make = *must_make_ptr;
    1081               dep_status |= check_dep (d->file, depth, this_mtime,
    1082                                        &maybe_make);
     1130              new = check_dep (d->file, depth, this_mtime, &maybe_make);
     1131              if (new > dep_status)
     1132                dep_status = new;
     1133
    10831134              if (! d->ignore_mtime)
    10841135                *must_make_ptr = maybe_make;
    1085               check_renamed (d->file);
    1086               if (dep_status != 0 && !keep_going_flag)
    1087                 break;
    1088 
    1089               if (d->file->command_state == cs_running
    1090                   || d->file->command_state == cs_deps_running)
    1091                 deps_running = 1;
    1092 
    1093               ld = d;
    1094               d = d->next;
    1095             }
     1136              check_renamed (d->file);
     1137              if (dep_status && !keep_going_flag)
     1138                break;
     1139
     1140              if (d->file->command_state == cs_running
     1141                  || d->file->command_state == cs_deps_running)
     1142                deps_running = 1;
     1143
     1144              ld = d;
     1145              d = d->next;
     1146            }
    10961147
    10971148          if (deps_running)
     
    11001151               commands are finished.  */
    11011152            set_command_state (file, cs_deps_running);
    1102         }
     1153        }
    11031154    }
    11041155
     
    11101161
    11111162
    1112 /* Touch FILE.  Return zero if successful, one if not.  */
    1113 
    1114 #define TOUCH_ERROR(call) return (perror_with_name (call, file->name), 1)
    1115 
    1116 static int
     1163/* Touch FILE.  Return us_success if successful, us_failed if not.  */
     1164
     1165#define TOUCH_ERROR(call) do{ perror_with_name ((call), file->name);    \
     1166                              return us_failed; }while(0)
     1167
     1168static enum update_status
    11171169touch_file (struct file *file)
    11181170{
    11191171  if (!silent_flag)
    1120     message (0, "touch %s", file->name);
    1121 
    1122 #ifndef NO_ARCHIVES
     1172    OS (message, 0, "touch %s", file->name);
     1173
     1174  /* Print-only (-n) takes precedence over touch (-t).  */
     1175  if (just_print_flag)
     1176    return us_success;
     1177
     1178#ifndef NO_ARCHIVES
    11231179  if (ar_name (file->name))
    1124     return ar_touch (file->name);
     1180    return ar_touch (file->name) ? us_failed : us_success;
    11251181  else
    11261182#endif
    11271183    {
    1128       int fd = open (file->name, O_RDWR | O_CREAT, 0666);
    1129 
     1184      int fd;
     1185
     1186      EINTRLOOP (fd, open (file->name, O_RDWR | O_CREAT, 0666));
    11301187      if (fd < 0)
    1131         TOUCH_ERROR ("touch: open: ");
     1188        TOUCH_ERROR ("touch: open: ");
    11321189      else
    1133         {
    1134           struct stat statbuf;
    1135           char buf = 'x';
     1190        {
     1191          struct stat statbuf;
     1192          char buf = 'x';
    11361193          int e;
    11371194
    11381195          EINTRLOOP (e, fstat (fd, &statbuf));
    1139           if (e < 0)
    1140             TOUCH_ERROR ("touch: fstat: ");
    1141           /* Rewrite character 0 same as it already is.  */
    1142           if (read (fd, &buf, 1) < 0)
    1143             TOUCH_ERROR ("touch: read: ");
    1144           if (lseek (fd, 0L, 0) < 0L)
    1145             TOUCH_ERROR ("touch: lseek: ");
    1146           if (write (fd, &buf, 1) < 0)
    1147             TOUCH_ERROR ("touch: write: ");
    1148           /* If file length was 0, we just
    1149              changed it, so change it back.  */
    1150           if (statbuf.st_size == 0)
    1151             {
    1152               (void) close (fd);
    1153               fd = open (file->name, O_RDWR | O_TRUNC, 0666);
    1154               if (fd < 0)
    1155                 TOUCH_ERROR ("touch: open: ");
    1156             }
    1157           (void) close (fd);
    1158         }
    1159     }
    1160 
    1161   return 0;
     1196          if (e < 0)
     1197            TOUCH_ERROR ("touch: fstat: ");
     1198          /* Rewrite character 0 same as it already is.  */
     1199          EINTRLOOP (e, read (fd, &buf, 1));
     1200          if (e < 0)
     1201            TOUCH_ERROR ("touch: read: ");
     1202          {
     1203            off_t o;
     1204            EINTRLOOP (o, lseek (fd, 0L, 0));
     1205            if (o < 0L)
     1206              TOUCH_ERROR ("touch: lseek: ");
     1207          }
     1208          EINTRLOOP (e, write (fd, &buf, 1));
     1209          if (e < 0)
     1210            TOUCH_ERROR ("touch: write: ");
     1211
     1212          /* If file length was 0, we just changed it, so change it back.  */
     1213          if (statbuf.st_size == 0)
     1214            {
     1215              (void) close (fd);
     1216              EINTRLOOP (fd, open (file->name, O_RDWR | O_TRUNC, 0666));
     1217              if (fd < 0)
     1218                TOUCH_ERROR ("touch: open: ");
     1219            }
     1220          (void) close (fd);
     1221        }
     1222    }
     1223
     1224  return us_success;
    11621225}
    11631226
     
    11731236    {
    11741237      if (file->phony)
    1175         /* Phony target.  Pretend it succeeded.  */
    1176         file->update_status = 0;
     1238        /* Phony target.  Pretend it succeeded.  */
     1239        file->update_status = us_success;
    11771240      else if (file->is_target)
    1178         /* This is a nonexistent target file we cannot make.
    1179            Pretend it was successfully remade.  */
    1180         file->update_status = 0;
     1241        /* This is a nonexistent target file we cannot make.
     1242           Pretend it was successfully remade.  */
     1243        file->update_status = us_success;
    11811244      else
    11821245        {
     
    11841247          if (!rebuilding_makefiles || !file->dontcare)
    11851248            complain (file);
    1186           file->update_status = 2;
     1249          file->update_status = us_failed;
    11871250        }
    11881251    }
     
    11931256      /* The normal case: start some commands.  */
    11941257      if (!touch_flag || file->cmds->any_recurse)
    1195         {
    1196           execute_file_commands (file);
    1197           return;
    1198         }
     1258        {
     1259          execute_file_commands (file);
     1260          return;
     1261        }
    11991262
    12001263      /* This tells notice_finished_file it is ok to touch the file.  */
    1201       file->update_status = 0;
     1264      file->update_status = us_success;
    12021265    }
    12031266
     
    12071270
    12081271
    1209 /* Return the mtime of a file, given a `struct file'.
     1272/* Return the mtime of a file, given a 'struct file'.
    12101273   Caches the time in the struct file to avoid excess stat calls.
    12111274
     
    12191282{
    12201283  FILE_TIMESTAMP mtime;
     1284  int propagate_timestamp;
    12211285
    12221286  /* File's mtime is not known; must get it from the system.  */
    12231287
    1224 #ifndef NO_ARCHIVES
     1288#ifndef NO_ARCHIVES
    12251289  if (ar_name (file->name))
    12261290    {
     
    12351299
    12361300      /* Find the modification time of the archive itself.
    1237         Also allow for its name to be changed via VPATH search.  */
     1301        Also allow for its name to be changed via VPATH search.  */
    12381302      arfile = lookup_file (arname);
    12391303      if (arfile == 0)
     
    12421306      check_renamed (arfile);
    12431307      if (search && strcmp (arfile->hname, arname))
    1244         {
    1245           /* The archive's name has changed.
    1246              Change the archive-member reference accordingly.  */
     1308        {
     1309          /* The archive's name has changed.
     1310             Change the archive-member reference accordingly.  */
    12471311
    12481312          char *name;
    1249           unsigned int arlen, memlen;
    1250 
    1251           arlen = strlen (arfile->hname);
    1252           memlen = strlen (memname);
    1253 
    1254           name = xmalloc (arlen + 1 + memlen + 2);
    1255           memcpy (name, arfile->hname, arlen);
    1256           name[arlen] = '(';
    1257           memcpy (name + arlen + 1, memname, memlen);
    1258           name[arlen + 1 + memlen] = ')';
    1259           name[arlen + 1 + memlen + 1] = '\0';
     1313          unsigned int arlen, memlen;
     1314
     1315          arlen = strlen (arfile->hname);
     1316          memlen = strlen (memname);
     1317
     1318          name = alloca (arlen + 1 + memlen + 2);
     1319          memcpy (name, arfile->hname, arlen);
     1320          name[arlen] = '(';
     1321          memcpy (name + arlen + 1, memname, memlen);
     1322          name[arlen + 1 + memlen] = ')';
     1323          name[arlen + 1 + memlen + 1] = '\0';
    12601324
    12611325          /* If the archive was found with GPATH, make the change permanent;
    12621326             otherwise defer it until later.  */
    12631327          if (arfile->name == arfile->hname)
    1264             rename_file (file, name);
     1328            rename_file (file, strcache_add (name));
    12651329          else
    1266             rehash_file (file, name);
     1330            rehash_file (file, strcache_add (name));
    12671331          check_renamed (file);
    1268         }
     1332        }
    12691333
    12701334      free (arname);
     
    12731337
    12741338      if (mtime == NONEXISTENT_MTIME)
    1275         /* The archive doesn't exist, so its members don't exist either.  */
    1276         return NONEXISTENT_MTIME;
     1339        /* The archive doesn't exist, so its members don't exist either.  */
     1340        return NONEXISTENT_MTIME;
    12771341
    12781342      member_date = ar_member_date (file->hname);
     
    12871351
    12881352      if (mtime == NONEXISTENT_MTIME && search && !file->ignore_vpath)
    1289         {
    1290           /* If name_mtime failed, search VPATH.  */
    1291           const char *name = vpath_search (file->name, &mtime, NULL, NULL);
    1292           if (name
    1293               /* Last resort, is it a library (-lxxx)?  */
    1294               || (file->name[0] == '-' && file->name[1] == 'l'
    1295                   && (name = library_search (file->name, &mtime)) != 0))
    1296             {
    1297               if (mtime != UNKNOWN_MTIME)
    1298                 /* vpath_search and library_search store UNKNOWN_MTIME
    1299                    if they didn't need to do a stat call for their work.  */
    1300                 file->last_mtime = mtime;
     1353        {
     1354          /* If name_mtime failed, search VPATH.  */
     1355          const char *name = vpath_search (file->name, &mtime, NULL, NULL);
     1356          if (name
     1357              /* Last resort, is it a library (-lxxx)?  */
     1358              || (file->name[0] == '-' && file->name[1] == 'l'
     1359                  && (name = library_search (file->name, &mtime)) != 0))
     1360            {
     1361              int name_len;
     1362
     1363              if (mtime != UNKNOWN_MTIME)
     1364                /* vpath_search and library_search store UNKNOWN_MTIME
     1365                   if they didn't need to do a stat call for their work.  */
     1366                file->last_mtime = mtime;
    13011367
    13021368              /* If we found it in VPATH, see if it's in GPATH too; if so,
    13031369                 change the name right now; if not, defer until after the
    13041370                 dependencies are updated. */
    1305               if (gpath_search (name, strlen(name) - strlen(file->name) - 1))
     1371#ifndef VMS
     1372              name_len = strlen (name) - strlen (file->name) - 1;
     1373#else
     1374              name_len = strlen (name) - strlen (file->name);
     1375              if (name[name_len - 1] == '/')
     1376                  name_len--;
     1377#endif
     1378              if (gpath_search (name, name_len))
    13061379                {
    13071380                  rename_file (file, name);
     
    13101383                }
    13111384
    1312               rehash_file (file, name);
    1313               check_renamed (file);
     1385              rehash_file (file, name);
     1386              check_renamed (file);
    13141387              /* If the result of a vpath search is -o or -W, preserve it.
    13151388                 Otherwise, find the mtime of the resulting file.  */
    13161389              if (mtime != OLD_MTIME && mtime != NEW_MTIME)
    13171390                mtime = name_mtime (name);
    1318             }
    1319         }
     1391            }
     1392        }
    13201393    }
    13211394
     
    13631436            {
    13641437#ifdef NO_FLOAT
    1365               error (NILF, _("Warning: File `%s' has modification time in the future"),
    1366                      file->name);
     1438              OS (error, NILF,
     1439                  _("Warning: File '%s' has modification time in the future"),
     1440                  file->name);
    13671441#else
    13681442              double from_now =
     
    13761450              else
    13771451                sprintf (from_now_string, "%.2g", from_now);
    1378               error (NILF, _("Warning: File `%s' has modification time %s s in the future"),
    1379                      file->name, from_now_string);
     1452              OSS (error, NILF,
     1453                   _("Warning: File '%s' has modification time %s s in the future"),
     1454                   file->name, from_now_string);
    13801455#endif
    13811456              clock_skew_detected = 1;
     
    13841459    }
    13851460
    1386   /* Store the mtime into all the entries for this file.  */
     1461  /* Store the mtime into all the entries for this file for which it is safe
     1462     to do so: avoid propagating timestamps to double-colon rules that haven't
     1463     been examined so they're run or not based on the pre-update timestamp.  */
    13871464  if (file->double_colon)
    13881465    file = file->double_colon;
    13891466
     1467  propagate_timestamp = file->updated;
    13901468  do
    13911469    {
    13921470      /* If this file is not implicit but it is intermediate then it was
    1393         made so by the .INTERMEDIATE target.  If this file has never
    1394         been built by us but was found now, it existed before make
    1395         started.  So, turn off the intermediate bit so make doesn't
    1396         delete it, since it didn't create it.  */
     1471        made so by the .INTERMEDIATE target.  If this file has never
     1472        been built by us but was found now, it existed before make
     1473        started.  So, turn off the intermediate bit so make doesn't
     1474        delete it, since it didn't create it.  */
    13971475      if (mtime != NONEXISTENT_MTIME && file->command_state == cs_not_started
    1398           && file->command_state == cs_not_started
    1399           && !file->tried_implicit && file->intermediate)
    1400         file->intermediate = 0;
    1401 
    1402       file->last_mtime = mtime;
     1476          && !file->tried_implicit && file->intermediate)
     1477        file->intermediate = 0;
     1478
     1479      if (file->updated == propagate_timestamp)
     1480        file->last_mtime = mtime;
    14031481      file = file->prev;
    14041482    }
     
    15151593library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
    15161594{
    1517   static char *dirs[] =
     1595  static const char *dirs[] =
    15181596    {
    15191597#ifndef _AMIGA
     
    15281606#define LIBDIR "."
    15291607#endif
    1530       LIBDIR,                   /* Defined by configuration.  */
     1608      LIBDIR,                   /* Defined by configuration.  */
    15311609      0
    15321610    };
     
    15431621
    15441622  /* Information about the earliest (in the vpath sequence) match.  */
    1545   unsigned int best_vpath, best_path;
    1546   unsigned int std_dirs = 0;
    1547 
    1548   char **dp;
     1623  unsigned int best_vpath = 0, best_path = 0;
     1624
     1625  const char **dp;
    15491626
    15501627  libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)"));
     
    15631640      static unsigned int buflen = 0;
    15641641      static int libdir_maxlen = -1;
     1642      static unsigned int std_dirs = 0;
    15651643      char *libbuf = variable_expand ("");
    15661644
    15671645      /* Expand the pattern using LIB as a replacement.  */
    15681646      {
    1569         char c = p[len];
    1570         char *p3, *p4;
    1571 
    1572         p[len] = '\0';
    1573         p3 = find_percent (p);
    1574         if (!p3)
    1575           {
    1576             /* Give a warning if there is no pattern.  */
    1577             error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p);
     1647        char c = p[len];
     1648        char *p3, *p4;
     1649
     1650        p[len] = '\0';
     1651        p3 = find_percent (p);
     1652        if (!p3)
     1653          {
     1654            /* Give a warning if there is no pattern.  */
     1655            OS (error, NILF,
     1656                _(".LIBPATTERNS element '%s' is not a pattern"), p);
    15781657            p[len] = c;
    1579             continue;
    1580           }
    1581         p4 = variable_buffer_output (libbuf, p, p3-p);
    1582         p4 = variable_buffer_output (p4, lib, liblen);
    1583         p4 = variable_buffer_output (p4, p3+1, len - (p3-p));
    1584         p[len] = c;
     1658            continue;
     1659          }
     1660        p4 = variable_buffer_output (libbuf, p, p3-p);
     1661        p4 = variable_buffer_output (p4, lib, liblen);
     1662        p4 = variable_buffer_output (p4, p3+1, len - (p3-p));
     1663        p[len] = c;
    15851664      }
    15861665
    1587       /* Look first for `libNAME.a' in the current directory.  */
     1666      /* Look first for 'libNAME.a' in the current directory.  */
    15881667      mtime = name_mtime (libbuf);
    15891668      if (mtime != NONEXISTENT_MTIME)
    1590         {
    1591           if (mtime_ptr != 0)
    1592             *mtime_ptr = mtime;
    1593           file = strcache_add (libbuf);
     1669        {
     1670          if (mtime_ptr != 0)
     1671            *mtime_ptr = mtime;
     1672          file = strcache_add (libbuf);
    15941673          /* This by definition will have the best index, so stop now.  */
    15951674          break;
    1596         }
     1675        }
    15971676
    15981677      /* Now try VPATH search on that.  */
     
    16311710            }
    16321711          buflen = strlen (libbuf);
    1633           buf = xmalloc(libdir_maxlen + buflen + 2);
     1712          buf = xmalloc (libdir_maxlen + buflen + 2);
    16341713        }
    16351714      else if (buflen < strlen (libbuf))
     
    16451724
    16461725        for (dp = dirs; *dp != 0; ++dp)
    1647           {
     1726          {
    16481727            sprintf (buf, "%s/%s", *dp, libbuf);
    16491728            mtime = name_mtime (buf);
    16501729            if (mtime != NONEXISTENT_MTIME)
    1651               {
     1730              {
    16521731                if (file == 0 || vpath_index < best_vpath)
    16531732                  {
  • vendor/gnumake/current/remote-cstms.c

    r2596 r3138  
    44   the Make maintainers.
    55
    6 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    7 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    8 2010 Free Software Foundation, Inc.
     6Copyright (C) 1988-2016 Free Software Foundation, Inc.
    97This file is part of GNU Make.
    108
     
    2119this program.  If not, see <http://www.gnu.org/licenses/>.  */
    2220
    23 #include "make.h"
    24 #include "job.h"
     21#include "makeint.h"
    2522#include "filedef.h"
    2623#include "commands.h"
     
    3532char *remote_description = "Customs";
    3633
    37 /* File name of the Customs `export' client command.
     34/* File name of the Customs 'export' client command.
    3835   A full path name can be used to avoid some path-searching overhead.  */
    39 #define EXPORT_COMMAND  "/usr/local/bin/export"
     36#define EXPORT_COMMAND  "/usr/local/bin/export"
    4037
    4138/* ExportPermit gotten by start_remote_job_p, and used by start_remote_job.  */
     
    8077
    8178      /* For secure Customs, make is installed setuid root and
    82         Customs requires a privileged source port be used.  */
     79        Customs requires a privileged source port be used.  */
    8380      make_access ();
    8481
    8582      if (ISDB (DB_JOBS))
    86         Rpc_Debug(1);
     83        Rpc_Debug (1);
    8784
    8885      /* Ping the daemon once to see if it is there.  */
     
    9390
    9491      if (starting_directory == 0)
    95         /* main couldn't figure it out.  */
    96         inited = -1;
     92        /* main couldn't figure it out.  */
     93        inited = -1;
    9794      else
    98         {
    99           /* Normalize the current directory path name to something
    100              that should work on all machines exported to.  */
    101 
    102           normalized_cwd = xmalloc (GET_PATH_MAX);
    103           strcpy (normalized_cwd, starting_directory);
    104           if (Customs_NormPath (normalized_cwd, GET_PATH_MAX) < 0)
    105             /* Path normalization failure means using Customs
    106                won't work, but it's not really an error.  */
    107             inited = -1;
    108         }
     95        {
     96          /* Normalize the current directory path name to something
     97             that should work on all machines exported to.  */
     98
     99          normalized_cwd = xmalloc (GET_PATH_MAX);
     100          strcpy (normalized_cwd, starting_directory);
     101          if (Customs_NormPath (normalized_cwd, GET_PATH_MAX) < 0)
     102            /* Path normalization failure means using Customs
     103               won't work, but it's not really an error.  */
     104            inited = -1;
     105        }
    109106    }
    110107
     
    114111  njobs = job_slots_used;
    115112  if (!first_p)
    116     njobs -= 1;         /* correction for being called from reap_children() */
     113    njobs -= 1;         /* correction for being called from reap_children() */
    117114
    118115  /* the first job should run locally, or, if the -l flag is given, we use
     
    157154  if (retsock < 0)
    158155    {
    159       error (NILF, "exporting: Couldn't create return socket.");
     156      O (error, NILF, "exporting: Couldn't create return socket.");
    160157      return 1;
    161158    }
     
    176173  /* Create a WayBill to give to the server.  */
    177174  len = Customs_MakeWayBill (&permit, normalized_cwd, argv[0], argv,
    178                              envp, retport, waybill);
    179 
    180   /* Modify the waybill as if the remote child had done `child_access ()'.  */
     175                             envp, retport, waybill);
     176
     177  /* Modify the waybill as if the remote child had done 'child_access ()'.  */
    181178  {
    182179    WayBill *wb = (WayBill *) waybill;
     
    192189  sin.sin_addr = permit.addr;
    193190  status = Rpc_Call (sock, &sin, (Rpc_Proc) CUSTOMS_IMPORT,
    194                      len, (Rpc_Opaque) waybill,
    195                      sizeof(msg), (Rpc_Opaque) msg,
    196                      1, &timeout);
    197 
    198   host = gethostbyaddr((char *)&permit.addr, sizeof(permit.addr), AF_INET);
    199 
    200   if (status != RPC_SUCCESS)
    201     {
    202       (void) close (retsock);
    203       (void) close (sock);
    204       error (NILF, "exporting to %s: %s",
    205              host ? host->h_name : inet_ntoa (permit.addr),
    206              Rpc_ErrorMessage (status));
    207       return 1;
    208     }
    209   else if (msg[0] != 'O' || msg[1] != 'k' || msg[2] != '\0')
    210     {
    211       (void) close (retsock);
    212       (void) close (sock);
    213       error (NILF, "exporting to %s: %s",
    214              host ? host->h_name : inet_ntoa (permit.addr),
    215              msg);
    216       return 1;
    217     }
    218   else
    219     {
    220       error (NILF, "*** exported to %s (id %u)",
    221               host ? host->h_name : inet_ntoa (permit.addr),
    222               permit.id);
    223     }
    224 
    225   fflush (stdout);
    226   fflush (stderr);
     191                     len, (Rpc_Opaque) waybill,
     192                     sizeof (msg), (Rpc_Opaque) msg,
     193                     1, &timeout);
     194
     195  host = gethostbyaddr ((char *)&permit.addr, sizeof(permit.addr), AF_INET);
     196
     197  {
     198    const char *hnm = host ? host->h_name : inet_ntoa (permit.addr);
     199    size_t hlen = strlen (hnm);
     200
     201    if (status != RPC_SUCCESS)
     202      {
     203        const char *err = Rpc_ErrorMessage (status);
     204        (void) close (retsock);
     205        (void) close (sock);
     206        error (NILF, hlen + strlen (err),
     207               "exporting to %s: %s", hnm, err);
     208        return 1;
     209      }
     210    else if (msg[0] != 'O' || msg[1] != 'k' || msg[2] != '\0')
     211      {
     212        (void) close (retsock);
     213        (void) close (sock);
     214        error (NILF, hlen + strlen (msg), "exporting to %s: %s", hnm, msg);
     215        return 1;
     216      }
     217    else
     218      {
     219        error (NILF, hlen + INTSTR_LENGTH,
     220               "*** exported to %s (id %u)", hnm, permit.id);
     221      }
     222
     223    fflush (stdout);
     224    fflush (stderr);
     225  }
    227226
    228227  pid = vfork ();
     
    230229    {
    231230      /* The fork failed!  */
    232       perror_with_name ("vfork", "");
     231      perror_with_name ("fork", "");
    233232      return 1;
    234233    }
    235234  else if (pid == 0)
    236235    {
    237       /* Child side.  Run `export' to handle the connection.  */
     236      /* Child side.  Run 'export' to handle the connection.  */
    238237      static char sock_buf[20], retsock_buf[20], id_buf[20];
    239238      static char *new_argv[6] =
    240         { EXPORT_COMMAND, "-id", sock_buf, retsock_buf, id_buf, 0 };
     239        { EXPORT_COMMAND, "-id", sock_buf, retsock_buf, id_buf, 0 };
    241240
    242241      /* Set up the arguments.  */
     
    247246      /* Get the right stdin.  */
    248247      if (stdin_fd != 0)
    249         (void) dup2 (stdin_fd, 0);
     248        (void) dup2 (stdin_fd, 0);
    250249
    251250      /* Unblock signals in the child.  */
     
    256255    }
    257256
    258   /* Parent side.  Return the `export' process's ID.  */
     257  /* Parent side.  Return the 'export' process's ID.  */
    259258  (void) close (retsock);
    260259  (void) close (sock);
  • vendor/gnumake/current/remote-stub.c

    r2596 r3138  
    11/* Template for the remote job exportation interface to GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018#include "filedef.h"
    2119#include "job.h"
  • vendor/gnumake/current/rule.c

    r2596 r3138  
    11/* Pattern and suffix rule internals for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018
    2119#include <assert.h>
    2220
     21#include "filedef.h"
    2322#include "dep.h"
    24 #include "filedef.h"
    2523#include "job.h"
    2624#include "commands.h"
     
    7573  char *name;
    7674  int namelen;
    77   struct rule *rule, *lastrule;
     75  struct rule *rule;
    7876
    7977  num_pattern_rules = max_pattern_targets = max_pattern_deps = 0;
     
    8381  namelen = 0;
    8482  rule = pattern_rules;
    85   lastrule = 0;
    8683  while (rule != 0)
    8784    {
     
    9390
    9491      if (rule->num > max_pattern_targets)
    95         max_pattern_targets = rule->num;
     92        max_pattern_targets = rule->num;
    9693
    9794      for (dep = rule->deps; dep != 0; dep = dep->next)
    98         {
     95        {
    9996          const char *dname = dep_name (dep);
    10097          unsigned int len = strlen (dname);
     
    112109          ndeps++;
    113110
    114           if (len > max_pattern_dep_length)
    115             max_pattern_dep_length = len;
    116 
    117           if (p != 0 && p2 > p)
    118             {
    119               /* There is a slash before the % in the dep name.
    120                 Extract the directory name.  */
    121               if (p == dname)
    122                 ++p;
    123               if (p - dname > namelen)
    124                 {
    125                   namelen = p - dname;
    126                   name = xrealloc (name, namelen + 1);
    127                 }
    128               memcpy (name, dname, p - dname);
    129               name[p - dname] = '\0';
    130 
    131               /* In the deps of an implicit rule the `changed' flag
    132                 actually indicates that the dependency is in a
    133                 nonexistent subdirectory.  */
    134 
    135               dep->changed = !dir_file_exists_p (name, "");
    136             }
    137           else
    138             /* This dependency does not reside in a subdirectory.  */
    139             dep->changed = 0;
    140         }
     111          if (len > max_pattern_dep_length)
     112            max_pattern_dep_length = len;
     113
     114          if (p != 0 && p2 > p)
     115            {
     116              /* There is a slash before the % in the dep name.
     117                Extract the directory name.  */
     118              if (p == dname)
     119                ++p;
     120              if (p - dname > namelen)
     121                {
     122                  namelen = p - dname;
     123                  name = xrealloc (name, namelen + 1);
     124                }
     125              memcpy (name, dname, p - dname);
     126              name[p - dname] = '\0';
     127
     128              /* In the deps of an implicit rule the 'changed' flag
     129                actually indicates that the dependency is in a
     130                nonexistent subdirectory.  */
     131
     132              dep->changed = !dir_file_exists_p (name, "");
     133            }
     134          else
     135            /* This dependency does not reside in a subdirectory.  */
     136            dep->changed = 0;
     137        }
    141138
    142139      if (ndeps > max_pattern_deps)
    143         max_pattern_deps = ndeps;
    144 
    145       lastrule = rule;
     140        max_pattern_deps = ndeps;
     141
    146142      rule = next;
    147143    }
    148144
    149   if (name != 0)
    150     free (name);
     145  free (name);
    151146}
    152147
     
    155150   TARGET is the target suffix; SOURCE is the source suffix.
    156151   CMDS are the commands.
    157    If TARGET is nil, it means the target pattern should be `(%.o)'.
     152   If TARGET is nil, it means the target pattern should be '(%.o)'.
    158153   If SOURCE is nil, it means there should be no deps.  */
    159154
     
    170165  if (target == 0)
    171166    {
    172       /* Special case: TARGET being nil means we are defining a `.X.a' suffix
    173          rule; the target pattern is always `(%.o)'.  */
     167      /* Special case: TARGET being nil means we are defining a '.X.a' suffix
     168         rule; the target pattern is always '(%.o)'.  */
    174169#ifdef VMS
    175170      *names = strcache_add_len ("(%.obj)", 7);
     
    225220      unsigned int l = strlen (dep_name (d));
    226221      if (l > maxsuffix)
    227         maxsuffix = l;
     222        maxsuffix = l;
    228223    }
    229224
     
    236231
    237232      /* Make a rule that is just the suffix, with no deps or commands.
    238         This rule exists solely to disqualify match-anything rules.  */
     233        This rule exists solely to disqualify match-anything rules.  */
    239234      convert_suffix_rule (dep_name (d), 0, 0);
    240235
    241236      if (d->file->cmds != 0)
    242         /* Record a pattern for this suffix's null-suffix rule.  */
    243         convert_suffix_rule ("", dep_name (d), d->file->cmds);
     237        /* Record a pattern for this suffix's null-suffix rule.  */
     238        convert_suffix_rule ("", dep_name (d), d->file->cmds);
    244239
    245240      /* Add every other suffix to this one and see if it exists as a
     
    249244
    250245      for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
    251         {
     246        {
    252247          struct file *f;
    253248          unsigned int s2len;
    254249
    255           s2len = strlen (dep_name (d2));
     250          s2len = strlen (dep_name (d2));
    256251
    257252          /* Can't build something from itself.  */
    258           if (slen == s2len && streq (dep_name (d), dep_name (d2)))
    259             continue;
    260 
    261           memcpy (rulename + slen, dep_name (d2), s2len + 1);
    262           f = lookup_file (rulename);
    263           if (f == 0 || f->cmds == 0)
    264             continue;
    265 
    266           if (s2len == 2 && rulename[slen] == '.' && rulename[slen + 1] == 'a')
    267             /* A suffix rule `.X.a:' generates the pattern rule `(%.o): %.X'.
    268                It also generates a normal `%.a: %.X' rule below.  */
    269             convert_suffix_rule (NULL, /* Indicates `(%.o)'.  */
    270                                 dep_name (d),
    271                                 f->cmds);
    272 
    273           /* The suffix rule `.X.Y:' is converted
    274              to the pattern rule `%.Y: %.X'.  */
    275           convert_suffix_rule (dep_name (d2), dep_name (d), f->cmds);
    276         }
     253          if (slen == s2len && streq (dep_name (d), dep_name (d2)))
     254            continue;
     255
     256          memcpy (rulename + slen, dep_name (d2), s2len + 1);
     257          f = lookup_file (rulename);
     258          if (f == 0 || f->cmds == 0)
     259            continue;
     260
     261          if (s2len == 2 && rulename[slen] == '.' && rulename[slen + 1] == 'a')
     262            /* A suffix rule '.X.a:' generates the pattern rule '(%.o): %.X'.
     263               It also generates a normal '%.a: %.X' rule below.  */
     264            convert_suffix_rule (NULL, /* Indicates '(%.o)'.  */
     265                                dep_name (d),
     266                                f->cmds);
     267
     268          /* The suffix rule '.X.Y:' is converted
     269             to the pattern rule '%.Y: %.X'.  */
     270          convert_suffix_rule (dep_name (d2), dep_name (d), f->cmds);
     271        }
    277272    }
    278273}
     
    302297    for (i = 0; i < rule->num; ++i)
    303298      {
    304         for (j = 0; j < r->num; ++j)
    305           if (!streq (rule->targets[i], r->targets[j]))
    306             break;
     299        for (j = 0; j < r->num; ++j)
     300          if (!streq (rule->targets[i], r->targets[j]))
     301            break;
    307302        /* If all the targets matched...  */
    308         if (j == r->num)
    309           {
    310             struct dep *d, *d2;
    311             for (d = rule->deps, d2 = r->deps;
    312                 d != 0 && d2 != 0; d = d->next, d2 = d2->next)
    313               if (!streq (dep_name (d), dep_name (d2)))
    314                 break;
    315             if (d == 0 && d2 == 0)
    316               {
    317                 /* All the dependencies matched.  */
    318                 if (override)
    319                   {
    320                     /* Remove the old rule.  */
    321                     freerule (r, lastrule);
    322                     /* Install the new one.  */
    323                     if (pattern_rules == 0)
    324                       pattern_rules = rule;
    325                     else
    326                       last_pattern_rule->next = rule;
    327                     last_pattern_rule = rule;
    328 
    329                     /* We got one.  Stop looking.  */
    330                     goto matched;
    331                   }
    332                 else
    333                   {
    334                     /* The old rule stays intact.  Destroy the new one.  */
    335                     freerule (rule, (struct rule *) 0);
    336                     return 0;
    337                   }
    338               }
    339           }
     303        if (j == r->num)
     304          {
     305            struct dep *d, *d2;
     306            for (d = rule->deps, d2 = r->deps;
     307                d != 0 && d2 != 0; d = d->next, d2 = d2->next)
     308              if (!streq (dep_name (d), dep_name (d2)))
     309                break;
     310            if (d == 0 && d2 == 0)
     311              {
     312                /* All the dependencies matched.  */
     313                if (override)
     314                  {
     315                    /* Remove the old rule.  */
     316                    freerule (r, lastrule);
     317                    /* Install the new one.  */
     318                    if (pattern_rules == 0)
     319                      pattern_rules = rule;
     320                    else
     321                      last_pattern_rule->next = rule;
     322                    last_pattern_rule = rule;
     323
     324                    /* We got one.  Stop looking.  */
     325                    goto matched;
     326                  }
     327                else
     328                  {
     329                    /* The old rule stays intact.  Destroy the new one.  */
     330                    freerule (rule, (struct rule *) 0);
     331                    return 0;
     332                  }
     333              }
     334          }
    340335      }
    341336
     
    346341      /* There was no rule to replace.  */
    347342      if (pattern_rules == 0)
    348         pattern_rules = rule;
     343        pattern_rules = rule;
    349344      else
    350         last_pattern_rule->next = rule;
     345        last_pattern_rule->next = rule;
    351346      last_pattern_rule = rule;
    352347    }
     
    359354   in the structure P points to.  These strings come from one of
    360355   the arrays of default implicit pattern rules.
    361    TERMINAL specifies what the `terminal' field of the rule should be.  */
     356   TERMINAL specifies what the 'terminal' field of the rule should be.  */
    362357
    363358void
     
    365360{
    366361  struct rule *r;
    367   char *ptr;
     362  const char *ptr;
    368363
    369364  r = xmalloc (sizeof (struct rule));
     
    381376
    382377  ptr = p->dep;
    383   r->deps = PARSE_FILE_SEQ (&ptr, struct dep, '\0', NULL, 0);
     378  r->deps = PARSE_SIMPLE_SEQ ((char **)&ptr, struct dep);
    384379
    385380  if (new_pattern_rule (r, 0))
     
    389384      r->cmds->fileinfo.filenm = 0;
    390385      r->cmds->fileinfo.lineno = 0;
     386      r->cmds->fileinfo.offset = 0;
    391387      /* These will all be string literals, but we malloc space for them
    392         anyway because somebody might want to free them later.  */
     388        anyway because somebody might want to free them later.  */
    393389      r->cmds->commands = xstrdup (p->commands);
    394390      r->cmds->command_lines = 0;
     391      r->cmds->recipe_prefix = RECIPEPREFIX_DEFAULT;
    395392    }
    396393}
     
    416413     are ways that they could be in more than one place:
    417414       * If the commands came from a suffix rule, they could also be in
    418        the `struct file's for other suffix rules or plain targets given
     415       the 'struct file's for other suffix rules or plain targets given
    419416       on the same makefile line.
    420417       * If two suffixes that together make a two-suffix rule were each
    421418       given twice in the .SUFFIXES list, and in the proper order, two
    422419       identical pattern rules would be created and the second one would
    423        be discarded here, but both would contain the same `struct commands'
    424        pointer from the `struct file' for the suffix rule.  */
     420       be discarded here, but both would contain the same 'struct commands'
     421       pointer from the 'struct file' for the suffix rule.  */
    425422
    426423  free (rule);
     
    477474/* Print the data base of rules.  */
    478475
    479 static void                     /* Useful to call from gdb.  */
     476static void                     /* Useful to call from gdb.  */
    480477print_rule (struct rule *r)
    481478{
     
    513510
    514511      if (r->terminal)
    515         ++terminal;
     512        ++terminal;
    516513    }
    517514
     
    521518    {
    522519      printf (_("\n# %u implicit rules, %u"), rules, terminal);
    523 #ifndef NO_FLOAT
     520#ifndef NO_FLOAT
    524521      printf (" (%.1f%%)", (double) terminal / (double) rules * 100.0);
    525522#else
    526523      {
    527         int f = (terminal * 1000 + 5) / rules;
    528         printf (" (%d.%d%%)", f/10, f%10);
     524        int f = (terminal * 1000 + 5) / rules;
     525        printf (" (%d.%d%%)", f/10, f%10);
    529526      }
    530527#endif
     
    537534         makefiles and thus count_implicit_rule_limits wasn't called yet.  */
    538535      if (num_pattern_rules != 0)
    539         fatal (NILF, _("BUG: num_pattern_rules is wrong!  %u != %u"),
    540                num_pattern_rules, rules);
    541     }
    542 }
     536        ONN (fatal, NILF, _("BUG: num_pattern_rules is wrong!  %u != %u"),
     537             num_pattern_rules, rules);
     538    }
     539}
  • vendor/gnumake/current/rule.h

    r2596 r3138  
    11/* Definitions for using pattern rules in GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    2321  {
    2422    struct rule *next;
    25     const char **targets;       /* Targets of the rule.  */
    26     unsigned int *lens;         /* Lengths of each target.  */
    27     const char **suffixes;      /* Suffixes (after `%') of each target.  */
    28     struct dep *deps;           /* Dependencies of the rule.  */
    29     struct commands *cmds;      /* Commands to execute.  */
     23    const char **targets;       /* Targets of the rule.  */
     24    unsigned int *lens;         /* Lengths of each target.  */
     25    const char **suffixes;      /* Suffixes (after '%') of each target.  */
     26    struct dep *deps;           /* Dependencies of the rule.  */
     27    struct commands *cmds;      /* Commands to execute.  */
    3028    unsigned short num;         /* Number of targets.  */
    31     char terminal;              /* If terminal (double-colon).  */
    32     char in_use;                /* If in use by a parent pattern_search.  */
     29    char terminal;              /* If terminal (double-colon).  */
     30    char in_use;                /* If in use by a parent pattern_search.  */
    3331  };
    3432
     
    3634struct pspec
    3735  {
    38     char *target, *dep, *commands;
     36    const char *target, *dep, *commands;
    3937  };
    4038
     
    5856                          unsigned int num, int terminal, struct dep *deps,
    5957                          struct commands *commands, int override);
     58void print_rule_data_base (void);
  • vendor/gnumake/current/signame.c

    r2596 r3138  
    11/* Convert between signal names and numbers.
    2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    4 Foundation, Inc.
     2Copyright (C) 1990-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018
    2119/* If the system provides strsignal, we don't need it. */
     
    3028
    3129/* Some systems do not define NSIG in <signal.h>.  */
    32 #ifndef NSIG
    33 #ifdef  _NSIG
    34 #define NSIG    _NSIG
     30#ifndef NSIG
     31#ifdef  _NSIG
     32#define NSIG    _NSIG
    3533#else
    36 #define NSIG    32
     34#define NSIG    32
    3735#endif
    3836#endif
     
    195193#endif
    196194#if defined (SIGIO)
    197   /* "I/O pending" has also been suggested.  A disadvantage is
    198      that signal only happens when the process has
    199      asked for it, not everytime I/O is pending.  Another disadvantage
    200      is the confusion from giving it a different name than under Unix.  */
     195  /* "I/O pending" has also been suggested.  A disadvantage is that signal
     196     only happens when the process has asked for it, not every time I/O is
     197     pending.  Another disadvantage is the confusion from giving it a
     198     different name than under Unix.  */
    201199  init_sig (SIGIO, "IO", _("I/O possible"));
    202200#endif
     
    247245#endif
    248246
    249   if (sig > 0 || sig < NSIG)
     247  if (sig > 0 && sig < NSIG)
    250248    return (char *) sys_siglist[sig];
    251249
  • vendor/gnumake/current/strcache.c

    r2596 r3138  
    11/* Constant string caching for GNU Make.
    2 Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 2006-2016 Free Software Foundation, Inc.
    33This file is part of GNU Make.
    44
     
    1515this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1616
    17 #include "make.h"
    18 
     17#include "makeint.h"
     18
     19#include <stddef.h>
    1920#include <assert.h>
    2021
    2122#include "hash.h"
    22 
    23 /* The size (in bytes) of each cache buffer.
    24    Try to pick something that will map well into the heap.  */
    25 #define CACHE_BUFFER_SIZE   (8192 - 16)
    26 
    2723
    2824/* A string cached here will never be freed, so we don't need to worry about
     
    3026   hash so it can be looked up again. */
    3127
     28typedef unsigned short int sc_buflen_t;
     29
    3230struct strcache {
    33   struct strcache *next;    /* The next block of strings.  */
    34   char *end;                /* Pointer to the beginning of the free space.  */
    35   int count;                /* # of strings in this buffer (for stats).  */
    36   int bytesfree;            /* The amount of the buffer that is free.  */
     31  struct strcache *next;    /* The next block of strings.  Must be first!  */
     32  sc_buflen_t end;          /* Offset to the beginning of free space.  */
     33  sc_buflen_t bytesfree;    /* Free space left in this buffer.  */
     34  sc_buflen_t count;        /* # of strings in this buffer (for stats).  */
    3735  char buffer[1];           /* The buffer comes after this.  */
    3836};
    3937
    40 static int bufsize = CACHE_BUFFER_SIZE;
     38/* The size (in bytes) of each cache buffer.
     39   Try to pick something that will map well into the heap.
     40   This must be able to be represented by a short int (<=65535).  */
     41#define CACHE_BUFFER_BASE       (8192)
     42#define CACHE_BUFFER_ALLOC(_s)  ((_s) - (2 * sizeof (size_t)))
     43#define CACHE_BUFFER_OFFSET     (offsetof (struct strcache, buffer))
     44#define CACHE_BUFFER_SIZE(_s)   (CACHE_BUFFER_ALLOC(_s) - CACHE_BUFFER_OFFSET)
     45#define BUFSIZE                 CACHE_BUFFER_SIZE (CACHE_BUFFER_BASE)
     46
    4147static struct strcache *strcache = NULL;
     48static struct strcache *fullcache = NULL;
     49
     50static unsigned long total_buffers = 0;
     51static unsigned long total_strings = 0;
     52static unsigned long total_size = 0;
    4253
    4354/* Add a new buffer to the cache.  Add it at the front to reduce search time.
     
    4758 */
    4859static struct strcache *
    49 new_cache()
    50 {
    51   struct strcache *new;
    52   new = xmalloc (sizeof (*new) + bufsize);
    53   new->end = new->buffer;
     60new_cache (struct strcache **head, sc_buflen_t buflen)
     61{
     62  struct strcache *new = xmalloc (buflen + CACHE_BUFFER_OFFSET);
     63  new->end = 0;
    5464  new->count = 0;
    55   new->bytesfree = bufsize;
    56 
    57   new->next = strcache;
    58   strcache = new;
    59 
     65  new->bytesfree = buflen;
     66
     67  new->next = *head;
     68  *head = new;
     69
     70  ++total_buffers;
    6071  return new;
    6172}
    6273
    6374static const char *
    64 add_string(const char *str, int len)
    65 {
    66   struct strcache *best = NULL;
     75copy_string (struct strcache *sp, const char *str, unsigned int len)
     76{
     77  /* Add the string to this cache.  */
     78  char *res = &sp->buffer[sp->end];
     79
     80  memmove (res, str, len);
     81  res[len++] = '\0';
     82  sp->end += len;
     83  sp->bytesfree -= len;
     84  ++sp->count;
     85
     86  return res;
     87}
     88
     89static const char *
     90add_string (const char *str, unsigned int len)
     91{
     92  const char *res;
    6793  struct strcache *sp;
    68   const char *res;
     94  struct strcache **spp = &strcache;
     95  /* We need space for the nul char.  */
     96  unsigned int sz = len + 1;
     97
     98  ++total_strings;
     99  total_size += sz;
    69100
    70101  /* If the string we want is too large to fit into a single buffer, then
    71      we're screwed; nothing will ever fit!  Change the maximum size of the
    72      cache to be big enough.  */
    73   if (len > bufsize)
    74     bufsize = len * 2;
    75 
    76   /* First, find a cache with enough free space.  We always look through all
    77      the blocks and choose the one with the best fit (the one that leaves the
    78      least amount of space free).  */
    79   for (sp = strcache; sp != NULL; sp = sp->next)
    80     if (sp->bytesfree > len && (!best || best->bytesfree > sp->bytesfree))
    81       best = sp;
    82 
    83   /* If nothing is big enough, make a new cache.  */
    84   if (!best)
    85     best = new_cache();
    86 
    87   assert (best->bytesfree > len);
    88 
    89   /* Add the string to the best cache.  */
    90   res = best->end;
    91   memcpy (best->end, str, len);
    92   best->end += len;
    93   *(best->end++) = '\0';
    94   best->bytesfree -= len + 1;
    95   ++best->count;
     102     no existing cache is large enough.  Add it directly to the fullcache.  */
     103  if (sz > BUFSIZE)
     104    {
     105      sp = new_cache (&fullcache, sz);
     106      return copy_string (sp, str, len);
     107    }
     108
     109  /* Find the first cache with enough free space.  */
     110  for (; *spp != NULL; spp = &(*spp)->next)
     111    if ((*spp)->bytesfree > sz)
     112      break;
     113  sp = *spp;
     114
     115  /* If nothing is big enough, make a new cache at the front.  */
     116  if (sp == NULL)
     117    {
     118      sp = new_cache (&strcache, BUFSIZE);
     119      spp = &strcache;
     120    }
     121
     122  /* Add the string to this cache.  */
     123  res = copy_string (sp, str, len);
     124
     125  /* If the amount free in this cache is less than the average string size,
     126     consider it full and move it to the full list.  */
     127  if (total_strings > 20 && sp->bytesfree < (total_size / total_strings) + 1)
     128    {
     129      *spp = sp->next;
     130      sp->next = fullcache;
     131      fullcache = sp;
     132    }
    96133
    97134  return res;
    98135}
    99136
     137/* For strings too large for the strcache, we just save them in a list.  */
     138struct hugestring {
     139  struct hugestring *next;  /* The next string.  */
     140  char buffer[1];           /* The string.  */
     141};
     142
     143static struct hugestring *hugestrings = NULL;
     144
     145static const char *
     146add_hugestring (const char *str, unsigned int len)
     147{
     148  struct hugestring *new = xmalloc (sizeof (struct hugestring) + len);
     149  memcpy (new->buffer, str, len);
     150  new->buffer[len] = '\0';
     151
     152  new->next = hugestrings;
     153  hugestrings = new;
     154
     155  return new->buffer;
     156}
    100157
    101158/* Hash table of strings in the cache.  */
     
    123180
    124181static const char *
    125 add_hash (const char *str, int len)
    126 {
     182add_hash (const char *str, unsigned int len)
     183{
     184  char *const *slot;
     185  const char *key;
     186
     187  /* If it's too large for the string cache, just copy it.
     188     We don't bother trying to match these.  */
     189  if (len > USHRT_MAX - 1)
     190    return add_hugestring (str, len);
     191
    127192  /* Look up the string in the hash.  If it's there, return it.  */
    128   char *const *slot = (char *const *) hash_find_slot (&strings, str);
    129   const char *key = *slot;
    130 
    131   /* Count the total number of adds we performed.  */
     193  slot = (char *const *) hash_find_slot (&strings, str);
     194  key = *slot;
     195
     196  /* Count the total number of add operations we performed.  */
    132197  ++total_adds;
    133198
     
    148213
    149214  for (sp = strcache; sp != 0; sp = sp->next)
    150     if (str >= sp->buffer && str < sp->end)
     215    if (str >= sp->buffer && str < sp->buffer + sp->end)
    151216      return 1;
     217  for (sp = fullcache; sp != 0; sp = sp->next)
     218    if (str >= sp->buffer && str < sp->buffer + sp->end)
     219      return 1;
     220
     221  {
     222    struct hugestring *hp;
     223    for (hp = hugestrings; hp != 0; hp = hp->next)
     224      if (str == hp->buffer)
     225        return 1;
     226  }
    152227
    153228  return 0;
     
    164239
    165240const char *
    166 strcache_add_len (const char *str, int len)
     241strcache_add_len (const char *str, unsigned int len)
    167242{
    168243  /* If we're not given a nul-terminated string we have to create one, because
     
    179254}
    180255
    181 int
    182 strcache_setbufsize(int size)
    183 {
    184   if (size > bufsize)
    185     bufsize = size;
    186   return bufsize;
    187 }
    188 
    189256void
    190257strcache_init (void)
     
    199266strcache_print_stats (const char *prefix)
    200267{
    201   int numbuffs = 0, numstrs = 0;
    202   int totsize = 0, avgsize, maxsize = 0, minsize = bufsize;
    203   int totfree = 0, avgfree, maxfree = 0, minfree = bufsize;
    204   int lastused = 0, lastfree = 0;
    205 
    206   if (strcache)
    207     {
    208       const struct strcache *sp;
    209 
    210       /* Count the first buffer separately since it's not full.  */
    211       lastused = strcache->end - strcache->buffer;
    212       lastfree = strcache->bytesfree;
    213 
    214       for (sp = strcache->next; sp != NULL; sp = sp->next)
    215         {
    216           int bf = sp->bytesfree;
    217           int sz = sp->end - sp->buffer;
    218 
    219           ++numbuffs;
    220           numstrs += sp->count;
    221 
    222           totsize += sz;
    223           maxsize = (sz > maxsize ? sz : maxsize);
    224           minsize = (sz < minsize ? sz : minsize);
    225 
    226           totfree += bf;
    227           maxfree = (bf > maxfree ? bf : maxfree);
    228           minfree = (bf < minfree ? bf : minfree);
    229         }
    230     }
    231 
    232   avgsize = numbuffs ? (int)(totsize / numbuffs) : 0;
    233   avgfree = numbuffs ? (int)(totfree / numbuffs) : 0;
    234 
    235   printf (_("\n%s # of strings in strcache: %d / lookups = %lu / hits = %lu\n"),
    236           prefix, numstrs, total_adds, (total_adds - numstrs));
    237   printf (_("%s # of strcache buffers: %d (* %d B/buffer = %d B)\n"),
    238           prefix, (numbuffs + 1), bufsize, ((numbuffs + 1) * bufsize));
    239   printf (_("%s strcache used: total = %d (%d) / max = %d / min = %d / avg = %d\n"),
    240           prefix, totsize, lastused, maxsize, minsize, avgsize);
    241   printf (_("%s strcache free: total = %d (%d) / max = %d / min = %d / avg = %d\n"),
    242           prefix, totfree, lastfree, maxfree, minfree, avgfree);
    243 
    244   fputs (_("\n# strcache hash-table stats:\n# "), stdout);
     268  const struct strcache *sp;
     269  unsigned long numbuffs = 0, fullbuffs = 0;
     270  unsigned long totfree = 0, maxfree = 0, minfree = BUFSIZE;
     271
     272  if (! strcache)
     273    {
     274      printf (_("\n%s No strcache buffers\n"), prefix);
     275      return;
     276    }
     277
     278  /* Count the first buffer separately since it's not full.  */
     279  for (sp = strcache->next; sp != NULL; sp = sp->next)
     280    {
     281      sc_buflen_t bf = sp->bytesfree;
     282
     283      totfree += bf;
     284      maxfree = (bf > maxfree ? bf : maxfree);
     285      minfree = (bf < minfree ? bf : minfree);
     286
     287      ++numbuffs;
     288    }
     289  for (sp = fullcache; sp != NULL; sp = sp->next)
     290    {
     291      sc_buflen_t bf = sp->bytesfree;
     292
     293      totfree += bf;
     294      maxfree = (bf > maxfree ? bf : maxfree);
     295      minfree = (bf < minfree ? bf : minfree);
     296
     297      ++numbuffs;
     298      ++fullbuffs;
     299    }
     300
     301  /* Make sure we didn't lose any buffers.  */
     302  assert (total_buffers == numbuffs + 1);
     303
     304  printf (_("\n%s strcache buffers: %lu (%lu) / strings = %lu / storage = %lu B / avg = %lu B\n"),
     305          prefix, numbuffs + 1, fullbuffs, total_strings, total_size,
     306          (total_size / total_strings));
     307
     308  printf (_("%s current buf: size = %hu B / used = %hu B / count = %hu / avg = %hu B\n"),
     309          prefix, (sc_buflen_t)BUFSIZE, strcache->end, strcache->count,
     310          (strcache->end / strcache->count));
     311
     312  if (numbuffs)
     313    {
     314      /* Show information about non-current buffers.  */
     315      unsigned long sz = total_size - strcache->end;
     316      unsigned long cnt = total_strings - strcache->count;
     317      sc_buflen_t avgfree = totfree / numbuffs;
     318
     319      printf (_("%s other used: total = %lu B / count = %lu / avg = %lu B\n"),
     320              prefix, sz, cnt, sz / cnt);
     321
     322      printf (_("%s other free: total = %lu B / max = %lu B / min = %lu B / avg = %hu B\n"),
     323              prefix, totfree, maxfree, minfree, avgfree);
     324    }
     325
     326  printf (_("\n%s strcache performance: lookups = %lu / hit rate = %lu%%\n"),
     327          prefix, total_adds, (long unsigned)(100.0 * (total_adds - total_strings) / total_adds));
     328  fputs (_("# hash-table stats:\n# "), stdout);
    245329  hash_print_stats (&strings, stdout);
    246330}
  • vendor/gnumake/current/subproc.bat

    r2596 r3138  
    11@echo off
    2 rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    3 rem 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2rem Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43rem This file is part of GNU Make.
    54rem
     
    2221if x%2 == x set MAKE=nmake
    2322%MAKE% /f %MAKEFILE%
     23if ERRORLEVEL 1 exit /B
    2424cd ..\..
  • vendor/gnumake/current/tests/ChangeLog.1

    r3137 r3138  
     12013-10-09  Paul Smith  <psmith@gnu.org>
     2
     3        * scripts/features/patspecific_vars: Typo fixes.
     4
     52013-10-05  Paul Smith  <psmith@gnu.org>
     6
     7        * test_driver.pl (run_all_tests): Rewrite to be more clear.
     8        * scripts/features/jobserver: Avoid using $ENV{HOME} as it doesn't
     9        exist everywhere.
     10        * scripts/features/default_names: End with 1;
     11
     12        * scripts/features/loadapi: Use new calling signatures.  Verify
     13        the NOEXPAND flag works.  Test with all valid function name
     14        characters.
     15
     162013-09-29  Paul Smith  <psmith@gnu.org>
     17
     18        * scripts/variables/SHELL: Solaris /bin/sh can't handle options in
     19        multiple words; skip that test.
     20        * scripts/targets/ONESHELL: Ditto.
     21
     22        * scripts/variables/GNUMAKEFLAGS: Verify that GNUMAKEFLAGS is
     23        cleared and options are not duplicated.
     24
     252013-09-23  Paul Smith  <psmith@gnu.org>
     26
     27        * scripts/options/print-directory: Rename dash-w to
     28        print-directory to avoid conflicts with dash-W on case-insensitive
     29        filesystems.
     30
     312013-09-22  Paul Smith  <psmith@gnu.org>
     32
     33        * scripts/features/se_implicit: Verify that order-only tokens
     34        inside second expansion are parsed correctly.
     35        Test for Savannah bug #31155.
     36
     37        * run_make_tests.pl (set_more_defaults): If we can't find
     38        gnumake.h based on the make program we might be running from a
     39        remote build directory.  Parse the Makefile for the right path.
     40
     41        Fix some test issues on Solaris.
     42
     43        * scripts/features/archives: Determine what output ar gives when
     44        adding and replacing objects and compare with that.
     45        * scripts/features/escape: Solaris /bin/sh doesn't properly handle
     46        backslashes inside single quotes, so don't rely on it.
     47        * scripts/features/output-sync: false(1) gives different exit
     48        codes on different systems; use "exit 1" instead.
     49        * scripts/features/parallelism: Increase the timeout for slower systems.
     50
     512013-09-21  Paul Smith  <psmith@gnu.org>
     52
     53        * scripts/features/archives: Some versions of ar (MacOSX) generate
     54        different output when creating archives.  Run it and verify the
     55        real output.
     56        * scripts/features/default_names: MacOSX is, like Windows,
     57        case-preserving / case-insensitive.  Redo the test to avoid
     58        checking for "UNIX".
     59        * test_driver.pl (attach_default_output): Don't dup stdout into
     60        stderr.  Reported by Denis Excoffier <bug-tar@Denis-Excoffier.org>
     61
     62        * scripts/features/se_explicit: Fix a test that behaves
     63        differently with/without archive capability enabled.
     64        * scripts/features/output-sync: Don't test output-sync if it's not
     65        enabled.  We also skip it if parallelism is not enabled, although
     66        strictly speaking some of the output-sync tests are valid even
     67        without parallelism.
     68        * scripts/features/jobserver: Move some tests that require the
     69        jobserver from features/parallelism to a separate suite.  Only run
     70        this if jobserver mode is enabled.
     71
     72        * scripts/features/output-sync: Test shell functions writing to
     73        stderr in recipes: ensure it's captured via output-sync.  Test
     74        output generated while reading makefiles and make sure it's
     75        captured via output-sync.  Make sure that fatal errors dump the
     76        output so it's not lost.
     77
     78        * scripts/options/dash-w: Add a test for -w flag.
     79
     802013-09-15  Paul Smith  <psmith@gnu.org>
     81
     82        * scripts/misc/fopen-fail: Check for failure on infinite recursion.
     83        * run_make_tests.pl (run_make_test): Allow the answer string to be
     84        undef, which means that we shouldn't compare it at all.  Only the
     85        exit code matters in this case.
     86        * test_driver.pl (compare_output): Ditto.
     87        Test for Savannah bug #27374.
     88
     89        * scripts/features/parallelism: Test broken jobserver on recursion.
     90        Test for Savannah bug #39934.
     91
     92        * scripts/options/eval: Verify --eval during restart.
     93        Test for Savannah bug #39203.
     94
     952013-09-14  Paul Smith  <psmith@gnu.org>
     96
     97        * scripts/features/output-sync: Verify -Orecurse properly.
     98
     992013-09-12  Paul Smith  <psmith@gnu.org>
     100
     101        * scripts/features/output-sync: Modify for output sync behavior.
     102        * scripts/variables/MAKE_RESTARTS: Ditto.
     103        * scripts/variables/MAKEFLAGS: Remove mode for --trace.
     104        * scripts/variables/GNUMAKEFLAGS: Ditto.
     105
     1062013-07-22  Paul Smith  <psmith@gnu.org>
     107
     108        * scripts/features/rule_glob: Add tests for wildcards in rules.
     109        Test for Savannah bug #39310.
     110
     1112013-07-09  Paul Smith  <psmith@gnu.org>
     112
     113        * scripts/features/se_implicit: Add a test for SE rules depending
     114        on other SE rules to be built.
     115
     1162013-05-26  Paul Smith  <psmith@gnu.org>
     117
     118        * scripts/features/archives: Test for Savannah bug #38442.
     119
     120        * scripts/misc/bs-nl: Test for Savannah bug #39035.
     121        Add a test for Savannah bug #38945.
     122
     1232013-05-22  Paul Smith  <psmith@gnu.org>
     124
     125        * scripts/options/dash-n: Fix results after MAKEFLAGS fixes.
     126        * scripts/variables/MAKEFLAGS: Ditto.
     127        * scripts/variables/GNUMAKEFLAGS: Ditto.
     128
     1292013-05-14  Paul Smith  <psmith@gnu.org>
     130
     131        * scripts/features/loadapi: Add plugin_is_GPL_compatible symbol.
     132        * scripts/features/load: Ditto.
     133
     1342013-05-13  Paul Smith  <psmith@gnu.org>
     135
     136        * scripts/features/output-sync (output_sync_set): Update for new
     137        --trace behavior.
     138
     1392013-05-05  Paul Smith  <psmith@gnu.org>
     140
     141        * scripts/features/output-sync (output_sync_set): Remove
     142        extraneous enter/leave lines, which are no longer printed.
     143        Add tests for syncing command line printing.
     144        (output_sync_set): Rename options: "job"->"line"; "make"->"recurse"
     145
     1462013-05-04  Paul Smith  <psmith@gnu.org>
     147
     148        * scripts/features/loadapi: Use the new alloc functions.
     149
     150        * scripts/features/output-sync (output_sync_set): New test for
     151        ordered recursive output for -Ojob / -Otarget.
     152
     1532013-05-03  Eli Zaretskii  <eliz@gnu.org>
     154
     155        * scripts/features/load: Fix signatures of testload_gmk_setup and
     156        explicit_setup, to bring them in line with the documentation.
     157
     1582013-04-28  Paul Smith  <psmith@gnu.org>
     159
     160        * scripts/features/output-sync (output_sync_set): Add tests for
     161        the per-job syntax mode.
     162        (output_sync_set): Test improved error message location.
     163
     1642013-04-15  Paul Smith  <psmith@gnu.org>
     165
     166        * scripts/features/output-sync (output_sync_set): New arg syntax.
     167
     1682013-04-14  Paul Smith  <psmith@gnu.org>
     169
     170        * scripts/features/output-sync: Rewrite to be more reliable.
     171
     172        * test_driver.pl (_run_command): Don't set SIGALRM until after we
     173        start the child.  Print errors to the top-level output, which will
     174        be stderr.
     175        (attach_default_output): Use a list of file handles as the stack.
     176        (detach_default_output): Ditto.
     177
     178        * scripts/features/output-sync: Add a test for output-sync.
     179
     1802013-02-25  Paul Smith  <psmith@gnu.org>
     181
     182        * run_make_tests.pl (valid_option): Support the -srcdir flag.
     183        (set_more_defaults): Set up $srcdir if it's not set yet.
     184
     185        * scripts/functions/guile: Verify gmk-eval doesn't expand twice.
     186        * scripts/features/load: Rework to test just the load capability.
     187        * scripts/features/loadapi: New set of tests for the load API.
     188
     1892013-01-19  Paul Smith  <psmith@gnu.org>
     190
     191        * scripts/features/load: Test loaded files with and without "./"
     192        prefix.  Add tests for automatically rebuilding loaded files if
     193        they are out of date or non-existent.
     194
     1952013-01-13  Paul Smith  <psmith@gnu.org>
     196
     197        * scripts/features/archives: Add a check targets that have parens,
     198        but are not archives.  See Savannah bug #37878.
     199
     200        * scripts/options/dash-n: Verify -n is preserved after recursive /
     201        re-exec.  See Savannah bug #38051.
     202
     2032013-01-12  Paul Smith  <psmith@gnu.org>
     204
     205        * scripts/features/parallelism: Change rule so it doesn't depend
     206        on invocation order, etc.
     207
     2082012-10-29  Paul Smith  <psmith@gnu.org>
     209
     210        * scripts/features/load: New test suite for the "load" directive.
     211
     2122012-09-09  Paul Smith  <psmith@gnu.org>
     213
     214        * scripts/functions/file: Get errors in the C locale, not the
     215        current locale.  Fixes Savannah bug #35764.
     216
     217        * scripts/features/escape: Check that backslashes before
     218        non-special characters are not removed.
     219
     220        * scripts/features/utf8: New test for UTF-8 support.
     221        See Savannah bug #36529.
     222
     223        * scripts/targets/POSIX: Add tests for default macro values as
     224        specified by IEEE Std 1003.1-2008.  See Savannah bug #37069.
     225
     2262012-03-04  Paul Smith  <psmith@gnu.org>
     227
     228        * scripts/features/se_explicit: Test $(x:%=%) format in secondary
     229        expansion prerequisite lists.  See Savannah bug #16545.
     230
     231        * scripts/features/escape: Test escaped ":" in prerequisite lists.
     232        See Savannah bug #12126.
     233
     234        * scripts/variables/private: Test appending private variables in
     235        pattern-specific target rules.  See Savannah bug #35468.
     236
     2372012-03-03  Paul Smith  <psmith@gnu.org>
     238
     239        * scripts/variables/SHELL: Ensure .SHELLFLAGS works with options
     240        separated by whitespace.
     241
     242        * scripts/targets/ONESHELL: Try .ONESHELL in combination with
     243        whitespace-separated options in .SHELLFLAGS.  See Savannah bug #35397.
     244
     245        * scripts/functions/filter-out: Add filter tests and test escape
     246        operations.  See Savannah bug #35410.
     247
     248        * guile.supp: Suppress valgrind errors from Guile
     249        * run_make_tests.pl: Use the Guile suppression file.
     250
     251        * scripts/misc/bs-nl: Check for POSIX and non-POSIX
     252        backslash/newline handling.  Addresses Savannah bug #16670.
     253
     2542012-01-29  Paul Smith  <psmith@gnu.org>
     255
     256        * scripts/variables/flavors: Add tests for ::=
     257        * scripts/variables/define: Ditto
     258
     259        * scripts/functions/file: Test the new $(file ...) function.
     260
     2612012-01-12  Paul Smith  <psmith@gnu.org>
     262
     263        * scripts/functions/guile: New regression tests for Guile support.
     264
     2652011-12-10  Paul Smith  <psmith@gnu.org>
     266
     267        * scripts/targets/SECONDARY: Add prereq statements to ensure rules
     268        are printed in the right order for test #9
     269
     2702011-11-14  Paul Smith  <psmith@gnu.org>
     271
     272        * scripts/features/double_colon: Check double-colon with escaped
     273        filenames.  See Savannah bug #33399.
     274
     2752011-09-18  Paul Smith  <psmith@gnu.org>
     276
     277        * scripts/features/parallelism: On re-exec make sure we preserve
     278        the value of MAKEFLAGS when necessary.  See Savannah bug #33873.
     279
     280        * scripts/features/vpath3: Verify handling of -lfoo libraries
     281        found via vpath vs. the standard directory search.
     282        See Savannah bug #32511.
     283
     2842011-09-12  Paul Smith  <psmith@gnu.org>
     285
     286        * scripts/functions/call: Verify that using export in a $(call ...)
     287        context creates a global variable.  See Savannah bug #32498.
     288
     2892011-09-02  Paul Smith  <psmith@gnu.org>
     290
     291        * scripts/options/dash-n: Verify that in "-n -t", the -n takes
     292        priority.  Patch from Michael Witten <mfwitten@gmail.com>.
     293
     2942011-08-29  Paul Smith  <psmith@gnu.org>
     295
     296        * scripts/features/varnesting: Test resetting of variables while
     297        expanding them.  See Savannah patch #7534
     298
     2992011-06-12  Paul Smith  <psmith@gnu.org>
     300
     301        * scripts/features/archives: Check archives with whitespace at the
     302        beginning, end, and extra in the middle.
     303        Another test for Savannah bug #30612.
     304
     3052011-05-07  Paul Smith  <psmith@gnu.org>
     306
     307        * scripts/variables/private: Ensure we skip private variables when
     308        appending.  Test for Savannah bug #32872.
     309
     310        * scripts/functions/wildcard: Verify wildcard used to test for
     311        file existence/non-existence.
     312
     3132011-05-02  Paul Smith  <psmith@gnu.org>
     314
     315        * scripts/functions/sort: Add a test for Savannah bug #33125.
     316
     3172011-04-17  David A. Wheeler  <dwheeler@dwheeler.com>
     318
     319        * scripts/features/shell_assignment: Regression for "!=" feature
     320
     3212010-11-06  Paul Smith  <psmith@gnu.org>
     322
     323        * scripts/features/targetvars: Fix known-good output for BS/NL changes.
     324        * scripts/functions/call: Ditto.
     325        * scripts/variables/special: Ditto.
     326
     327        * scripts/misc/bs-nl: New test suite for backslash/newline testing.
     328
     3292010-08-29  Paul Smith  <psmith@gnu.org>
     330
     331        * scripts/features/errors: Add new error message to output text.
     332        * scripts/variables/SHELL: Ditto.
     333        * scripts/targets/POSIX: Ditto.
     334        * scripts/options/dash-k: Ditto.
     335        * scripts/features/vpathplus: Ditto.
     336        * scripts/features/patternrules: Ditto.
     337        * scripts/features/parallelism: Ditto.
     338
     3392010-08-13  Paul Smith  <psmith@gnu.org>
     340
     341        * scripts/features/archives: New regression tests for archive
     342        support.  Test for fix to Savannah bug #30612.
     343
     344        * run_make_tests.pl (set_more_defaults): Set a %FEATURES hash to
     345        the features available in $(.FEATURES).
     346
     3472010-08-10  Paul Smith  <psmith@gnu.org>
     348
     349        * scripts/features/reinvoke: Ensure command line variable settings
     350        are preserved across make re-exec.  Tests Savannah bug #30723.
     351
    13522010-07-28  Paul Smith  <psmith@gnu.org>
    2353
     
    300651        beginning with ".").
    301652
    302         * scripts/functions/andor: Tests for $(and ..) and $(or ...)
     653        * scripts/functions/andor: Tests for $(and ...) and $(or ...)
    303654        functions.
    304655
     
    3877382005-08-13  Boris Kolpackov  <boris@kolpackov.net>
    388739
    389         * scripts/functions/wildcard: Wrap calls to $(wildcard ) with
     740        * scripts/functions/wildcard: Wrap calls to $(wildcard) with
    390741        $(sort) so that the resulting order is no longer filesystem-
    391         dependant.
     742        dependent.
    392743
    3937442005-08-10  Boris Kolpackov  <boris@kolpackov.net>
     
    4608112005-06-09  Paul D. Smith  <psmith@gnu.org>
    461812
    462         * scripts/functions/foreach: Add a test for Savannah bug #11913.
     813        * scripts/functions/foreach: Add a test for Savannah bug #11913.
    463814
    4648152005-05-31  Boris Kolpackov  <boris@kolpackov.net>
     
    480831
    481832        * scripts/features/parallelism: Add a test for exporting recursive
    482         variables containing $(shell ) calls.  Rewrite this script to use
     833        variables containing $(shell) calls.  Rewrite this script to use
    483834        run_make_test() everywhere.
    484835
     
    10641415
    10651416
    1066 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    1067 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
     1417Copyright (C) 1992-2016 Free Software Foundation, Inc.
    10681418This file is part of GNU Make.
    10691419
  • vendor/gnumake/current/tests/NEWS

    r2596 r3138  
    7373    Also, some tests and stuff still haven't made it in because I
    7474    haven't had time to write the test scripts for them.  But they,
    75     too, will get in eventually.  Contributions of scripts (ie, tests
     75    too, will get in eventually.  Contributions of scripts (i.e., tests
    7676    that I can just drop in) are particularly welcome and will be
    7777    incorporated immediately.
     
    164164
    165165-------------------------------------------------------------------------------
    166 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    167 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
     166Copyright (C) 1992-2016 Free Software Foundation, Inc.
    168167This file is part of GNU Make.
    169168
  • vendor/gnumake/current/tests/README

    r2596 r3138  
    88
    99 -----------------------------------------------------------------------------
    10  Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    11  2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
     10 Copyright (C) 1992-2016 Free Software Foundation, Inc.
    1211 This file is part of GNU Make.
    1312
     
    4039
    4140By default, the test engine picks up the first executable called "make"
    42 that it finds in your path.  You may use the -make_path option (ie,
     41that it finds in your path.  You may use the -make_path option (i.e.,
    4342"perl run_make_tests -make_path /usr/local/src/make-3.78/make") if
    4443you want to run a particular copy.  This now works correctly with
     
    6059make to be setgid sys or kmem for this; if you don't want to install
    6160make just to test it, make it setgid to kmem or whatever group /dev/kmem
    62 is (ie, "chgrp kmem make;chmod g+s make" as root).  In any case, the
     61is (i.e., "chgrp kmem make;chmod g+s make" as root).  In any case, the
    6362options/dash-l test should no longer *fail* because make can't read
    6463/dev/kmem.
  • vendor/gnumake/current/tests/mkshadow

    r2596 r3138  
    44# Typically you'd put the shadow in /tmp or another local disk
    55#
    6 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    7 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    8 # Foundation, Inc.
     6# Copyright (C) 1992-2016 Free Software Foundation, Inc.
    97# This file is part of GNU Make.
    108#
     
    2927
    3028if [ ! -d "$dest" ]; then
    31   echo "Destination directory \`$dest' must exist!"
     29  echo "Destination directory '$dest' must exist!"
    3230  exit 1
    3331fi
     
    5654rm -rf work
    5755
    58 echo "Shadow test suite created in \`$dest/$name'."
     56echo "Shadow test suite created in '$dest/$name'."
    5957exit 0
  • vendor/gnumake/current/tests/run_make_tests.pl

    r2596 r3138  
    1212#                        (and others)
    1313
    14 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    15 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    16 # Foundation, Inc.
     14# Copyright (C) 1992-2016 Free Software Foundation, Inc.
    1715# This file is part of GNU Make.
    1816#
     
    3028# this program.  If not, see <http://www.gnu.org/licenses/>.
    3129
     30%FEATURES = ();
    3231
    3332$valgrind = 0;              # invoke make with valgrind
    3433$valgrind_args = '';
    35 $memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full';
     34$memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full --suppressions=guile.supp';
    3635$massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup';
    3736$pure_log = undef;
    3837
     38# The location of the GNU make source directory
     39$srcdir = '';
     40
    3941$command_string = '';
    4042
    4143$all_tests = 0;
    4244
     45# rmdir broken in some Perls on VMS.
     46if ($^O eq 'VMS')
     47{
     48  require VMS::Filespec;
     49  VMS::Filespec->import();
     50
     51  sub vms_rmdir {
     52    my $vms_file = vmspath($_[0]);
     53    $vms_file = fileify($vms_file);
     54    my $ret = unlink(vmsify($vms_file));
     55    return $ret
     56  };
     57
     58  *CORE::GLOBAL::rmdir = \&vms_rmdir;
     59}
     60
    4361require "test_driver.pl";
     62require "config-flags.pm";
    4463
    4564# Some target systems might not have the POSIX module...
     
    6180   }
    6281
     82   if ($option =~ /^-srcdir$/i) {
     83       $srcdir = shift @argv;
     84       if (! -f "$srcdir/gnumake.h") {
     85           print "$option $srcdir: Not a valid GNU make source directory.\n";
     86           exit 0;
     87       }
     88       return 1;
     89   }
     90
    6391   if ($option =~ /^-all([-_]?tests)?$/i) {
    6492       $all_tests = 1;
     
    99127$old_makefile = undef;
    100128
     129sub subst_make_string
     130{
     131    local $_ = shift;
     132    $makefile and s/#MAKEFILE#/$makefile/g;
     133    s/#MAKEPATH#/$mkpath/g;
     134    s/#MAKE#/$make_name/g;
     135    s/#PERL#/$perl_name/g;
     136    s/#PWD#/$pwd/g;
     137    return $_;
     138}
     139
    101140sub run_make_test
    102141{
    103142  local ($makestring, $options, $answer, $err_code, $timeout) = @_;
     143  my @call = caller;
    104144
    105145  # If the user specified a makefile string, create a new makefile to contain
     
    116156    }
    117157
    118     # Make sure it ends in a newline.
     158    # Make sure it ends in a newline and substitute any special tokens.
    119159    $makestring && $makestring !~ /\n$/s and $makestring .= "\n";
    120 
    121     # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
    122     # make
    123     $makestring =~ s/#MAKEFILE#/$makefile/g;
    124     $makestring =~ s/#MAKEPATH#/$mkpath/g;
    125     $makestring =~ s/#MAKE#/$make_name/g;
    126     $makestring =~ s/#PERL#/$perl_name/g;
    127     $makestring =~ s/#PWD#/$pwd/g;
     160    $makestring = subst_make_string($makestring);
    128161
    129162    # Populate the makefile!
     
    134167
    135168  # Do the same processing on $answer as we did on $makestring.
    136 
    137   $answer && $answer !~ /\n$/s and $answer .= "\n";
    138   $answer =~ s/#MAKEFILE#/$makefile/g;
    139   $answer =~ s/#MAKEPATH#/$mkpath/g;
    140   $answer =~ s/#MAKE#/$make_name/g;
    141   $answer =~ s/#PERL#/$perl_name/g;
    142   $answer =~ s/#PWD#/$pwd/g;
     169  if (defined $answer) {
     170      $answer && $answer !~ /\n$/s and $answer .= "\n";
     171      $answer = subst_make_string($answer);
     172  }
    143173
    144174  run_make_with_options($makefile, $options, &get_logfile(0),
    145                         $err_code, $timeout);
     175                        $err_code, $timeout, @call);
    146176  &compare_output($answer, &get_logfile(1));
    147177
     
    152182# The old-fashioned way...
    153183sub run_make_with_options {
    154   local ($filename,$options,$logname,$expected_code,$timeout) = @_;
     184  my ($filename,$options,$logname,$expected_code,$timeout,@call) = @_;
     185  @call = caller unless @call;
    155186  local($code);
    156187  local($command) = $make_path;
     
    166197
    167198  if ($options) {
     199    if ($^O eq 'VMS') {
     200      # Try to make sure arguments are properly quoted.
     201      # This does not handle all cases.
     202
     203      # VMS uses double quotes instead of single quotes.
     204      $options =~ s/\'/\"/g;
     205
     206      # If the leading quote is inside non-whitespace, then the
     207      # quote must be doubled, because it will be enclosed in another
     208      # set of quotes.
     209      $options =~ s/(\S)(\".*\")/$1\"$2\"/g;
     210
     211      # Options must be quoted to preserve case if not already quoted.
     212      $options =~ s/(\S+)/\"$1\"/g;
     213
     214      # Special fixup for embedded quotes.
     215      $options =~ s/(\"\".+)\"(\s+)\"(.+\"\")/$1$2$3/g;
     216
     217      $options =~ s/(\A)(?:\"\")(.+)(?:\"\")/$1\"$2\"/g;
     218
     219      # Special fixup for misc/general4 test.
     220      $options =~ s/""\@echo" "cc""/\@echo cc"/;
     221      $options =~ s/"\@echo link"""/\@echo link"/;
     222
     223      # Remove shell escapes expected to be removed by bash
     224      if ($options !~ /path=pre/) {
     225        $options =~ s/\\//g;
     226      }
     227
     228      # special fixup for options/eval
     229      $options =~ s/"--eval=\$\(info" "eval/"--eval=\$\(info eval/;
     230
     231      print ("Options fixup = -$options-\n") if $debug;
     232    }
    168233    $command .= " $options";
    169234  }
    170235
    171   $command_string = "$command\n";
     236  $command_string = "";
     237  if (@call) {
     238      $command_string = "#$call[1]:$call[2]\n";
     239  }
     240  $command_string .= "$command\n";
    172241
    173242  if ($valgrind) {
     
    184253
    185254      $code = &run_command_with_output($logname,$command);
    186 
    187255      $test_timeout = $old_timeout;
    188256  }
     
    229297{
    230298   &print_standard_usage ("run_make_tests",
    231                           "[-make_path make_pathname] [-memcheck] [-massif]",);
     299                          "[-make MAKE_PATHNAME] [-srcdir SRCDIR] [-memcheck] [-massif]",);
    232300}
    233301
     
    235303{
    236304   &print_standard_help (
    237         "-make_path",
     305        "-make",
    238306        "\tYou may specify the pathname of the copy of make to run.",
     307        "-srcdir",
     308        "\tSpecify the make source directory.",
    239309        "-valgrind",
    240310        "-memcheck",
     
    296366     $port_type = 'OS/2';
    297367   }
     368
     369   # VMS has a GNV Unix mode or a DCL mode.
     370   # The SHELL environment variable should not be defined in VMS-DCL mode.
     371   elsif ($osname eq 'VMS' && !defined $ENV{"SHELL"}) {
     372     $port_type = 'VMS-DCL';
     373   }
    298374   # Everything else, right now, is UNIX.  Note that we should integrate
    299375   # the VOS support into this as well and get rid of $vos; we'll do
     
    313389   # Find the full pathname of Make.  For DOS systems this is more
    314390   # complicated, so we ask make itself.
    315    my $mk = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
    316    chop $mk;
    317    $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE):\n
     391   if ($osname eq 'VMS') {
     392     $port_type = 'VMS-DCL' unless defined $ENV{"SHELL"};
     393     # On VMS pre-setup make to be found with simply 'make'.
     394     $make_path = 'make';
     395   } else {
     396     my $mk = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
     397     chop $mk;
     398     $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE):\n
    318399'echo \"all:;\@echo \\\$(MAKE)\" | $make_path -f-' failed!\n";
    319    $make_path = $mk;
    320    print "Make\t= `$make_path'\n" if $debug;
    321 
    322    $string = `$make_path -v -f /dev/null 2> /dev/null`;
     400     $make_path = $mk;
     401   }
     402   print "Make\t= '$make_path'\n" if $debug;
     403
     404   my $redir2 = '2> /dev/null';
     405   $redir2 = '' if os_name eq 'VMS';
     406   $string = `$make_path -v -f /dev/null $redir2`;
    323407
    324408   $string =~ /^(GNU Make [^,\n]*)/;
    325409   $testee_version = "$1\n";
    326410
    327    $string = `sh -c "$make_path -f /dev/null 2>&1"`;
     411   my $redir = '2>&1';
     412   $redir = '' if os_name eq 'VMS';
     413   $string = `sh -c "$make_path -f /dev/null $redir"`;
    328414   if ($string =~ /(.*): \*\*\* No targets\.  Stop\./) {
    329415     $make_name = $1;
    330416   }
    331417   else {
    332      if ($make_path =~ /$pathsep([^\n$pathsep]*)$/) {
    333        $make_name = $1;
    334      }
    335      else {
    336        $make_name = $make_path;
    337      }
     418     $make_path =~ /^(?:.*$pathsep)?(.+)$/;
     419     $make_name = $1;
    338420   }
    339421
     
    349431   {
    350432      $mkpath = $make_path;
     433   }
     434
     435   # If srcdir wasn't provided on the command line, see if the
     436   # location of the make program gives us a clue.  Don't fail if not;
     437   # we'll assume it's been installed into /usr/include or wherever.
     438   if (! $srcdir) {
     439       $make_path =~ /^(.*$pathsep)?/;
     440       my $d = $1 || '../';
     441       -f "${d}gnumake.h" and $srcdir = $d;
     442   }
     443
     444   # Not with the make program, so see if we can get it out of the makefile
     445   if (! $srcdir && open(MF, "< ../Makefile")) {
     446       local $/ = undef;
     447       $_ = <MF>;
     448       close(MF);
     449       /^abs_srcdir\s*=\s*(.*?)\s*$/m;
     450       -f "$1/gnumake.h" and $srcdir = $1;
    351451   }
    352452
     
    360460   }
    361461
    362    $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`;
     462   $string = `sh -c "$make_path -j 2 -f /dev/null $redir"`;
    363463   if ($string =~ /not supported/) {
    364464     $parallel_jobs = 0;
     
    368468   }
    369469
     470   %FEATURES = map { $_ => 1 } split /\s+/, `sh -c "echo '\\\$(info \\\$(.FEATURES))' | $make_path -f- 2>/dev/null"`;
     471
    370472   # Set up for valgrind, if requested.
     473
     474   $make_command = $make_path;
    371475
    372476   if ($valgrind) {
  • vendor/gnumake/current/tests/scripts/features/conditionals

    r2596 r3138  
    142142              'success');
    143143
     144# SV 47960 : ensure variable assignments in non-taken legs don't cause problems
     145run_make_test('
     146ifneq ($(FOO),yes)
     147target:
     148else
     149BAR = bar
     150target:
     151endif
     152        @echo one
     153',
     154              '', "one\n");
     155
    144156
    145157# This tells the test driver that the perl test script executed properly.
    1461581;
     159
     160### Local Variables:
     161### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     162### End:
  • vendor/gnumake/current/tests/scripts/features/default_names

    r2596 r3138  
    1111close(MAKEFILE);
    1212
    13 # DOS/WIN32 platforms preserve case, but Makefile is the same file as makefile.
    14 # Just test what we can here (avoid Makefile versus makefile test).
     13# Create another makefile called "makefile"
     14open(MAKEFILE,"> makefile");
     15print MAKEFILE "SECOND: ; \@echo It chose makefile\n";
     16close(MAKEFILE);
    1517
    16 if ($port_type eq 'UNIX') {
    17   # Create another makefile called "makefile"
    18   open(MAKEFILE,"> makefile");
    19   print MAKEFILE "SECOND: ; \@echo It chose makefile\n";
    20   close(MAKEFILE);
     18# DOS/WIN32/MacOSX platforms are case-insensitive / case-preserving, so
     19# Makefile is the same file as makefile.  Just test what we can here.
     20
     21my $case_sensitive = 0;
     22if (! -f 'Makefile') {
     23    # Create another makefile called "Makefile"
     24    $case_sensitive = 1;
     25    open(MAKEFILE,"> Makefile");
     26    print MAKEFILE "THIRD: ; \@echo It chose Makefile\n";
     27    close(MAKEFILE);
    2128}
    2229
    23 # Create another makefile called "Makefile"
    24 open(MAKEFILE,"> Makefile");
    25 print MAKEFILE "THIRD: ; \@echo It chose Makefile\n";
    26 close(MAKEFILE);
     30run_make_with_options("","",&get_logfile);
     31compare_output("It chose GNUmakefile\n",&get_logfile(1));
     32unlink($makefile);
    2733
     34run_make_with_options("","",&get_logfile);
     35compare_output("It chose makefile\n",&get_logfile(1));
     36unlink("makefile");
    2837
    29 &run_make_with_options("","",&get_logfile);
    30 &compare_output("It chose GNUmakefile\n",&get_logfile(1));
    31 unlink $makefile;
    32 
    33 if ($port_type eq 'UNIX') {
    34   &run_make_with_options("","",&get_logfile);
    35   &compare_output("It chose makefile\n",&get_logfile(1));
    36   unlink "makefile";
     38if ($case_sensitive) {
     39    run_make_with_options("","",&get_logfile);
     40    compare_output("It chose Makefile\n",&get_logfile(1));
     41    unlink("Makefile");
    3742}
    3843
    39 &run_make_with_options("","",&get_logfile);
    40 &compare_output("It chose Makefile\n",&get_logfile(1));
    41 unlink "Makefile";
     441;
  • vendor/gnumake/current/tests/scripts/features/double_colon

    r2596 r3138  
    152152unlink('result','one','two');
    153153
     154# TEST 10: SV 33399 : check for proper backslash handling
     155
     156run_make_test('
     157a\ xb :: ; @echo one
     158a\ xb :: ; @echo two
     159',
     160              '', "one\ntwo\n");
     161
     162# Test 11: SV 44742 : All double-colon rules should be run in parallel build.
     163
     164run_make_test('result :: 01
     165        @echo update
     166        @touch $@
     167result :: 02
     168        @echo update
     169        @touch $@
     170result :: 03
     171        @echo update
     172        @touch $@
     173result :: 04
     174        @echo update
     175        @touch $@
     176result :: 05
     177        @echo update
     178        @touch $@
     17901 02 03 04 05:
     180        @touch 01 02 03 04 05
     181',
     182              '-j10 result', "update\nupdate\nupdate\nupdate\nupdate\n");
     183
     184unlink('result', '01', '02', '03', '04', '05');
     185
     186# Test 12: SV 44742 : Double-colon rules with parallelism
     187
     188run_make_test('
     189root: all
     190        echo root
     191all::
     192        echo all_one
     193all:: 3
     194        echo all_two
     195%:
     196        sleep $*
     197',
     198              '-rs -j2 1 2 root', "all_one\nall_two\nroot\n");
     199
     200# SV 47995 : Parallel double-colon rules with FORCE
     201
     202run_make_test('
     203all:: ; @echo one
     204
     205all:: joe ; @echo four
     206
     207joe: FORCE ; touch joe-is-forced
     208
     209FORCE:
     210',
     211              '-j5', "one\ntouch joe-is-forced\nfour\n");
     212
     213unlink('joe-is-forced');
     214
    154215# This tells the test driver that the perl test script executed properly.
    1552161;
     217
     218### Local Variables:
     219### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     220### End:
  • vendor/gnumake/current/tests/scripts/features/errors

    r2596 r3138  
    3131              ."\t-$rm_command cleanit\n"
    3232              ."\t$rm_command foo\n"
    33               ."clean2: \n"
     33              ."clean2: \n"
    3434              ."\t$rm_command cleanit\n"
    3535              ."\t$rm_command foo\n";
     
    4343unlink("cleanit");
    4444$cleanit_error = `sh -c "$rm_command cleanit 2>&1"`;
     45chomp $cleanit_error;
    4546$delete_error_code = $? >> 8;
    4647
     
    4849# -------
    4950
    50 $answer = "$rm_command cleanit\n"
    51          . $cleanit_error
    52          ."$make_name: [clean] Error $delete_error_code (ignored)\n"
    53          ."$rm_command foo\n";
     51$answer = "$rm_command cleanit
     52$cleanit_error
     53$make_name: [$makefile:2: clean] Error $delete_error_code (ignored)
     54$rm_command foo\n";
    5455
    5556&run_make_with_options($makefile,"",&get_logfile);
     
    7576# -------
    7677
    77 $answer = "$rm_command cleanit\n"
    78          . $cleanit_error
    79          ."$make_name: [clean2] Error $delete_error_code (ignored)\n"
    80          ."$rm_command foo\n";
     78$answer = "$rm_command cleanit
     79$cleanit_error
     80$make_name: [$makefile:5: clean2] Error $delete_error_code (ignored)
     81$rm_command foo\n";
    8182
    8283&run_make_with_options($makefile,"clean2 -i",&get_logfile);
     
    9091}
    9192
     93# Test that error line offset works
     94
     95run_make_test(q!
     96all:
     97        @echo hi
     98        @echo there
     99        @exit 1
     100!,
     101              '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#:5: all] Error 1", 512);
     102
    921031;
     104
     105### Local Variables:
     106### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     107### End:
  • vendor/gnumake/current/tests/scripts/features/escape

    r2596 r3138  
    33
    44$details = "\
    5 Make sure that escaping of `:' works in target names.
     5Make sure that escaping of ':' works in target names.
    66Make sure escaping of whitespace works in target names.
    7 Make sure that escaping of '#' works.";
    8 
    9 
    10 close(MAKEFILE);
     7Make sure that escaping of '#' works.
     8Make sure that backslash before non-special characters are kept.";
    119
    1210
     
    2725run_make_test(undef,
    2826              'path=pre:',
    29               "#MAKEFILE#:2: *** target pattern contains no `%'.  Stop.",
     27              "#MAKEFILE#:2: *** target pattern contains no '%'.  Stop.",
    3028              512);
    3129
     
    4038run_make_test(undef,
    4139              "'path=pre\\\\:'",
    42               "#MAKEFILE#:2: *** target pattern contains no `%'.  Stop.",
     40              "#MAKEFILE#:2: *** target pattern contains no '%'.  Stop.",
    4341              512);
    4442
     
    5553              'foo#bar.ext = (foo#bar.ext)');
    5654
     55# Test escaped colons in prerequisites
     56# Quoting of backslashes in q!! is kind of messy.
     57# Solaris sh does not properly handle backslashes even in '' so just
     58# check the output make prints, not what the shell interprets.
     59run_make_test(q!
     60foo: foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar
     61foo foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar: ; : '$@'
     62!,
     63              '', ": 'foo:bar'\n: 'foo\\:bar'\n: 'foo\\\\:bar'\n: 'foo'\n");
     64
     65# Test backslash before non-special chars: should be kept as-is
     66
     67run_make_test(q!
     68all: ..\foo
     69.DEFAULT: ; : '$@'
     70!,
     71              '', ": '..\\foo'\n");
     72
    5773# This tells the test driver that the perl test script executed properly.
    58741;
  • vendor/gnumake/current/tests/scripts/features/include

    r2596 r3138  
    11#                                     -*-mode: perl; rm-trailing-spaces: nil-*-
    22
    3 $description = "Test various forms of the GNU make `include' command.";
     3$description = "Test various forms of the GNU make 'include' command.";
    44
    55$details = "\
     
    6161',
    6262   '',
    63    "#MAKE#: *** No rule to make target `foo.mk', needed by `error'.  Stop.\n",
     63   "#MAKE#: *** No rule to make target 'foo.mk', needed by 'error'.  Stop.\n",
    6464   512
    6565  );
     
    129129',
    130130'',
    131 "#MAKE#: *** No rule to make target `baz', needed by `bar'.  Stop.\n",
     131"#MAKE#: *** No rule to make target 'baz', needed by 'bar'.  Stop.\n",
    132132512);
    133133
     
    145145',
    146146'',
    147 "#MAKE#: *** No rule to make target `end', needed by `baz'.  Stop.\n",
     147"#MAKE#: *** No rule to make target 'end', needed by 'baz'.  Stop.\n",
    148148512);
    149149
     
    163163'',
    164164"#MAKEFILE#:2: bar: No such file or directory
    165 #MAKE#: *** No rule to make target `end', needed by `baz'.  Stop.\n",
     165#MAKE#: *** No rule to make target 'end', needed by 'baz'.  Stop.\n",
    166166512);
     167
     168# Test include of make-able file doesn't show an error (Savannah #102)
     169run_make_test(q!
     170.PHONY: default
     171default:; @echo DONE
     172
     173inc1:; echo > $@
     174include inc1
     175include inc2
     176inc2:; echo > $@
     177!,
     178              '', "echo > inc2\necho > inc1\nDONE\n");
     179
     180rmfiles('inc1', 'inc2');
     181
     182# Test include of non-make-able file does show an error (Savannah #102)
     183run_make_test(q!
     184.PHONY: default
     185default:; @echo DONE
     186
     187inc1:; echo > $@
     188include inc1
     189include inc2
     190!,
     191              '', "#MAKEFILE#:7: inc2: No such file or directory\n#MAKE#: *** No rule to make target 'inc2'.  Stop.\n", 512);
     192
     193rmfiles('inc1');
     194
     195# Include same file multiple times
     196
     197run_make_test(q!
     198default:; @echo DEFAULT
     199include inc1
     200inc1:; echo > $@
     201include inc1
     202!,
     203              '', "echo > inc1\nDEFAULT\n");
     204
     205rmfiles('inc1');
     206
     207# Included file has a prerequisite that fails to build
     208
     209run_make_test(q!
     210default:; @echo DEFAULT
     211include inc1
     212inc1: foo; echo > $@
     213foo:; exit 1
     214!,
     215              '', "exit 1\n#MAKEFILE#:3: inc1: No such file or directory\n#MAKE#: *** [#MAKEFILE#:5: foo] Error 1\n", 512);
     216
     217rmfiles('inc1');
     218
     219# Included file has a prerequisite we don't know how to build
     220
     221run_make_test(q!
     222default:; @echo DEFAULT
     223include inc1
     224inc1: foo; echo > $@
     225!,
     226              '', "#MAKEFILE#:3: inc1: No such file or directory\n#MAKE#: *** No rule to make target 'foo', needed by 'inc1'.  Stop.\n", 512);
     227
     228rmfiles('inc1');
     229
     230# include a directory
    167231
    168232if ($all_tests) {
     
    173237foo: ; @echo foo = bar > $@
    174238!,
    175                   '', "#MAKE#: `foo' is up to date.\n");
     239                  '', "#MAKE#: 'foo' is up to date.\n");
    176240    rmfiles('foo');
    177241}
  • vendor/gnumake/current/tests/scripts/features/mult_rules

    r2596 r3138  
    4848
    4949# Create the answer to what should be produced by this Makefile
    50 $answer = "$make_name: *** No rule to make target `extra.h', needed by `foo.o'.  Stop.\n";
     50$answer = "$make_name: *** No rule to make target 'extra.h', needed by 'foo.o'.  Stop.\n";
    5151
    5252&compare_output($answer,&get_logfile(1));
  • vendor/gnumake/current/tests/scripts/features/parallelism

    r2596 r3138  
    42422.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
    4343              "-j4",
    44               "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
     44              "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n", 0, 7);
    4545
    4646rmfiles(qw(1.inc 2.inc));
     
    61612.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@",
    6262              "-j4",
    63               "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
     63              "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n", 0, 7);
    6464
    6565rmfiles(qw(1.inc 2.inc));
     
    9292
    9393fail.1 fail.2 fail.3:
    94         \@sleep \$(patsubst fail.%,%,\$\@)
     94        \@$sleep_command \$(patsubst fail.%,%,\$\@)
    9595        \@echo Fail
    9696        \@exit 1
    9797
    9898ok:
    99         \@sleep 4
     99        \@$sleep_command 4
    100100        \@echo Ok done",
    101               '-rR -j5', 'Fail
    102 #MAKE#: *** [fail.1] Error 1
     101              '-rR -j5', "Fail
     102#MAKE#: *** [#MAKEFILE#:8: fail.1] Error 1
    103103#MAKE#: *** Waiting for unfinished jobs....
    104104Fail
    105 #MAKE#: *** [fail.2] Error 1
     105#MAKE#: *** [#MAKEFILE#:8: fail.2] Error 1
    106106Fail
    107 #MAKE#: *** [fail.3] Error 1
    108 Ok done',
     107#MAKE#: *** [#MAKEFILE#:8: fail.3] Error 1
     108Ok done",
    109109             512);
    110110
     
    141141rmfiles('target');
    142142
    143 # TEST #10: Don't put --jobserver-fds into a re-exec'd MAKEFLAGS.
    144 # We can't test this directly because there's no way a makefile can
    145 # show the value of MAKEFLAGS we were re-exec'd with.  We can intuit it
    146 # by looking for "disabling jobserver mode" warnings; we should only
    147 # get one from the original invocation and none from the re-exec.
    148 # See Savannah bug #18124
     143# TEST #11: Make sure -jN from MAKEFLAGS is processed even when we re-exec
     144# See Savannah bug #33873
     145
     146$extraENV{MAKEFLAGS} = '-j4';
    149147
    150148run_make_test(q!
     149things = thing1 thing2
     150all: $(things)
     151thing1:; @sleep 1; echo '$@ start'; sleep 2; echo '$@ end'
     152thing2:; @echo '$@ start'; sleep 2; echo '$@ end'
    151153-include inc.mk
    152 recur:
    153 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
    154         @rm -f inc.mk
    155         @$(MAKE) -j2 -f #MAKEFILE# all
    156 all:
    157 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
    158         @echo $@
    159 inc.mk:
    160 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
    161         @echo 'FOO = bar' > $@
     154inc.mk: ; @touch $@
    162155!,
    163               '--no-print-directory -j2', "#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.\nall\n");
    164 
     156              '', "thing2 start\nthing1 start\nthing2 end\nthing1 end\n");
     157
     158delete $extraENV{MAKEFLAGS};
    165159rmfiles('inc.mk');
    166160
    167 if ($all_tests) {
    168     # Implicit files aren't properly recreated during parallel builds
    169     # Savannah bug #26864
    170 
    171     # The first run works fine
    172     run_make_test(q!
    173 %.bar: %.x foo.y ; cat $^ > $@
    174 %.x: ; touch $@
    175 foo.y: foo.y.in ; cp $< $@
    176 foo.y.in: ; touch $@
     161# Ensure intermediate/secondary files are not pruned incorrectly.
     162# See Savannah bug #30653
     163
     164utouch(-15, 'file2');
     165utouch(-10, 'file4');
     166utouch(-5,  'file1');
     167
     168run_make_test(q!
     169.INTERMEDIATE: file3
     170file4: file3 ; @mv -f $< $@
     171file3: file2 ; touch $@
     172file2: file1 ; @touch $@
    177173!,
    178                   '-j2 main.bar',
    179                   "touch foo.y.in
    180 touch main.x
    181 cp foo.y.in foo.y
    182 cat main.x foo.y > main.bar
    183 rm main.x");
    184 
    185     # Now we touch the .in file and make sure it still works
    186     touch('foo.y.in');
    187 
    188     run_make_test(undef, '-j2 main.bar', "cp foo.y.in foo.y
    189 touch main.x
    190 cat main.x foo.y > main.bar
    191 rm main.x");
    192 
    193     # Clean up
    194     rmfiles(qw(foo.y foo.y.in main.bar));
    195 }
    196 
    197 if ($all_tests) {
    198     # Jobserver FD handling is messed up in some way.
    199     # Savannah bug #28189
    200     # It doesn't look like that bug anymore but this is the code it runs
    201 
    202     run_make_test(q!
    203 ifdef EXTRA
    204 vpath %.dst /
    205 xxx.dst: ; true
    206 yyy.dst: ; true
    207 endif
    208 
    209 M := $(MAKE)
    210 xx: ; $M --no-print-directory -j2 -f $(MAKEFILE_LIST) xxx.dst yyy.dst EXTRA=1
    211 !,
    212                   '-j2',
    213                   '#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.
    214 true
    215 true
    216 ');
    217 }
     174              '--no-print-directory -j2', "touch file3");
     175
     176rmfiles('file1', 'file2', 'file3', 'file4');
    218177
    219178# Make sure that all jobserver FDs are closed if we need to re-exec the
     
    253212
    2542131;
     214
     215### Local Variables:
     216### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     217### End:
  • vendor/gnumake/current/tests/scripts/features/patspecific_vars

    r2596 r3138  
    8282b%: pattern := good $$t
    8383
    84 global := orginal $$t
     84global := original $$t
    8585
    8686
     
    104104endif
    105105
    106 %z: ; @echo \'pattrn: $a;\'
     106%z: ; @echo \'pattern: $a;\'
    107107
    108108
     
    110110',
    111111'',
    112 'normal: global: orginal $t pattern:  inherit: ;
    113 pattrn: global: orginal $t pattern:  inherit: ;');
     112'normal: global: original $t pattern:  inherit: ;
     113pattern: global: original $t pattern:  inherit: ;');
    114114
    115115
     
    119119'rec=1',
    120120'normal: global: new $t pattern: good $t inherit: good $t;
    121 pattrn: global: new $t pattern: good $t inherit: good $t;');
     121pattern: global: new $t pattern: good $t inherit: good $t;');
    122122
    123123# TEST #8: override in pattern-specific variables
  • vendor/gnumake/current/tests/scripts/features/patternrules

    r2596 r3138  
    111111',
    112112"dir=$dir",
    113 "#MAKE#: *** [$dir/foo.bar] Error 1",
     113"#MAKE#: *** [#MAKEFILE#:6: $dir/foo.bar] Error 1",
    114114512);
    115115
     
    204204!,
    205205              'foo.tex',
    206               "#MAKE#: *** No rule to make target `foo.tex'.  Stop.", 512);
     206              "#MAKE#: *** No rule to make target 'foo.tex'.  Stop.", 512);
    207207
    208208unlink(@f);
     
    223223# This tells the test driver that the perl test script executed properly.
    2242241;
     225
     226### Local Variables:
     227### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     228### End:
  • vendor/gnumake/current/tests/scripts/features/recursion

    r2596 r3138  
    1919              ('CFLAGS=-O -w' . ($parallel_jobs ? ' -j 2' : '')),
    2020              ($vos
    21                ? "#MAKE#: Entering directory `#PWD#'
     21               ? "#MAKE#: Entering directory '#PWD#'
    2222make 'CFLAGS=-O' -f #MAKEFILE# foo
    2323make CFLAGS=-O
     
    2727MAKELEVEL = 0
    2828THE END
    29 #MAKE#: Leaving directory `#PWD#'"
    30                : "#MAKE#: Entering directory `#PWD#'
     29#MAKE#: Leaving directory '#PWD#'"
     30               : "#MAKE#: Entering directory '#PWD#'
    3131#MAKEPATH# -f #MAKEFILE# foo
    32 #MAKE#[1]: Entering directory `#PWD#'
     32#MAKE#[1]: Entering directory '#PWD#'
    3333#MAKEPATH#
    3434MAKELEVEL = 1
    3535#MAKEPATH# -f #MAKEFILE# last
    36 #MAKE#[2]: Entering directory `#PWD#'
     36#MAKE#[2]: Entering directory '#PWD#'
    3737#MAKEPATH#
    3838MAKELEVEL = 2
    3939THE END
    40 #MAKE#[2]: Leaving directory `#PWD#'
    41 #MAKE#[1]: Leaving directory `#PWD#'
    42 #MAKE#: Leaving directory `#PWD#'"));
     40#MAKE#[2]: Leaving directory '#PWD#'
     41#MAKE#[1]: Leaving directory '#PWD#'
     42#MAKE#: Leaving directory '#PWD#'"));
    4343
    4444
  • vendor/gnumake/current/tests/scripts/features/reinvoke

    r2596 r3138  
    5858# including: this and the previous one test different parts of the code.
    5959
    60 run_make_test(undef, "F=b", "[ -f b ] || echo >> b\nhello\n")
     60run_make_test(undef, 'F=b', "[ -f b ] || echo >> b\nhello\n")
    6161
    6262&rmfiles('a','b','c');
    6363
     64# Ensure command line variables are preserved properly across re-exec
     65# Tests for Savannah bug #30723
     66
     67run_make_test('
     68ifdef RECURSE
     69-include foo30723
     70endif
     71recurse: ; @$(MAKE) -f $(MAKEFILE_LIST) RECURSE=1 test
     72test: ; @echo F.O=$(F.O)
     73foo30723: ; @touch $@
     74',
     75              '--no-print-directory F.O=bar', "F.O=bar\n");
     76
     77unlink('foo30723');
     78
    6479# This tells the test driver that the perl test script executed properly.
    65801;
  • vendor/gnumake/current/tests/scripts/features/se_explicit

    r2596 r3138  
    66# TEST #0: Test handing of '$' in prerequisites with and without second
    77# expansion.
     8
     9# If we don't support archives then the prerequisite is different
     10my $prereq = exists $FEATURES{'archives'} ? '$' : '$(PRE)';
    811
    912run_make_test(q!
     
    1922!,
    2023              '',
    21               "\$\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
     24              "$prereq\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
    2225
    2326run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz");
     
    116119all : $$(eval $$(info test))
    117120!,
    118             '', "test\n#MAKE#: Nothing to be done for `all'.\n");
     121            '', "test\n#MAKE#: Nothing to be done for 'all'.\n");
    119122
    120123# TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new
     
    153156
    154157
    155 # This tells the test driver that the perl test script executed properly.
     158# Allow patsubst shorthand in second expansion context.
     159# Requires the colon to be quoted.  Savannah bug #16545
     160run_make_test(q!
     161.PHONY: foo.bar
     162.SECONDEXPANSION:
     163foo: $$(@\\:%=%.bar); @echo '$^'
     164!,
     165              '', "foo.bar\n");
     166
    1561671;
  • vendor/gnumake/current/tests/scripts/features/se_implicit

    r2596 r3138  
    223223              '', "\n");
    224224
     225# Test #10: Test second expansion with second expansion prerequisites
     226# Ensures pattern_search() recurses with SE prereqs.
     227touch('a');
     228run_make_test(q!
     229.SECONDEXPANSION:
     230sim_base_rgg := just_a_name
     231sim_base_src := a
     232sim_base_f := a a a
     233sim_%.f: $${sim_$$*_f}
     234        echo $@
     235sim_%.src: $${sim_$$*_src}
     236        echo $@
     237sim_%: \
     238        $$(if $$(sim_$$*_src),sim_%.src) \
     239        $$(if $$(sim_$$*_f),sim_%.f) \
     240        $$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s)
     241        echo $@
     242!,
     243              '-s sim_base', "#MAKE#: *** No rule to make target 'sim_base'.  Stop.", 512);
     244
     245unlink('a');
     246
     247# Ensure that order-only tokens embedded in second expansions are parsed
     248run_make_test(q!
     249.SECONDEXPANSION:
     250PREREQS=p1|p2
     251P2=p2
     252all : foo bar
     253f%o: $$(PREREQS) ; @echo '$@' from '$^' and '$|'
     254b%r: p1|$$(P2)   ; @echo '$@' from '$^' and '$|'
     255p% : ; : $@
     256!,
     257              "", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n");
     258
    225259# This tells the test driver that the perl test script executed properly.
    2262601;
  • vendor/gnumake/current/tests/scripts/features/targetvars

    r2596 r3138  
    238238run_make_test(undef, 'FOO=C', "C f1\n");
    239239
     240# TEST #19: Conditional variables with command-line settings
     241
     242run_make_test('
     243a: FOO ?= f1
     244a: ; @echo "$(FOO)"
     245',
     246              '', "f1\n");
     247
     248run_make_test(undef, 'FOO=C', "C\n");
     249
    240250# TEST #20: Check for continuation after semicolons
    241251
    242252run_make_test(q!
    243 a: A = 'hello; \
     253a: A = 'hello;\
    244254world'
    245255a: ; @echo $(A)
  • vendor/gnumake/current/tests/scripts/features/varnesting

    r2596 r3138  
    1 $description = "The following test creates a makefile to ...";
     1#                                                                    -*-perl-*-
     2$description = "Test recursive variables";
    23
    34$details = "";
    45
    5 open(MAKEFILE,"> $makefile");
     6run_make_test('
     7x = variable1
     8variable2 := Hello
     9y = $(subst 1,2,$(x))
     10z = y
     11a := $($($(z)))
     12all:
     13        @echo $(a)
     14',
     15              '', "Hello\n");
    616
    7 # The Contents of the MAKEFILE ...
     17# This tests resetting the value of a variable while expanding it.
     18# You may only see problems with this if you're using valgrind or
     19# some other memory checker that poisons freed memory.
     20# See Savannah patch #7534
    821
    9 print MAKEFILE "x = variable1\n"
    10               ."variable2 := Hello\n"
    11               ."y = \$(subst 1,2,\$(x))\n"
    12               ."z = y\n"
    13               ."a := \$(\$(\$(z)))\n"
    14               ."all: \n"
    15               ."\t\@echo \$(a)\n";
    16 
    17 # END of Contents of MAKEFILE
    18 
    19 close(MAKEFILE);
    20 
    21 &run_make_with_options($makefile,"",&get_logfile);
    22 
    23 # Create the answer to what should be produced by this Makefile
    24 $answer = "Hello\n";
    25 
    26 &compare_output($answer,&get_logfile(1));
     22run_make_test('
     23VARIABLE = $(eval VARIABLE := echo hi)$(VARIABLE)
     24wololo:
     25        @$(VARIABLE)
     26',
     27              '', "hi\n");
    2728
    28291;
  • vendor/gnumake/current/tests/scripts/features/vpath

    r2596 r3138  
    7575vpath-d/fail.te:
    7676!,
    77               '', "#MAKE#: Nothing to be done for `default'.\n");
     77              '', "#MAKE#: Nothing to be done for 'default'.\n");
    7878
    7979rmdir('vpath-d');
  • vendor/gnumake/current/tests/scripts/features/vpath3

    r2596 r3138  
    1 #                                                                     -*-perl-*-
     1#                                                                    -*-perl-*-
    22
    33$description = "Test the interaction of the -lfoo feature and vpath";
    44$details = "";
    55
    6 open(MAKEFILE,"> $makefile");
     6my @dirs_to_make = qw(a1 b1 a2 b2 b3);
     7for my $d (@dirs_to_make) {
     8    mkdir($d, 0777);
     9}
    710
    8 # The Contents of the MAKEFILE ...
    9 
    10 print MAKEFILE "vpath %.a a1\n";
    11 print MAKEFILE "vpath %.so b1\n";
    12 print MAKEFILE "vpath % a2 b2\n";
    13 print MAKEFILE "vpath % b3\n";
    14 print MAKEFILE "all: -l1 -l2 -l3; \@echo \$^\n";
    15 
    16 # END of Contents of MAKEFILE
    17 
    18 close(MAKEFILE);
    19 
    20 mkdir("a1", 0777);
    21 mkdir("b1", 0777);
    22 mkdir("a2", 0777);
    23 mkdir("b2", 0777);
    24 mkdir("b3", 0777);
    25 
    26 @files_to_touch = ("a1${pathsep}lib1.a",
    27                    "b1${pathsep}lib1.so",
    28                    "a2${pathsep}lib2.a",
    29                    "b2${pathsep}lib2.so",
    30                    "lib3.a",
    31                    "b3${pathsep}lib3.so");
    32 
     11my @files_to_touch = ("a1${pathsep}lib1.a",
     12                      "a1${pathsep}libc.a",
     13                      "b1${pathsep}lib1.so",
     14                      "a2${pathsep}lib2.a",
     15                      "b2${pathsep}lib2.so",
     16                      "lib3.a",
     17                      "b3${pathsep}lib3.so");
    3318&touch(@files_to_touch);
    3419
    35 &run_make_with_options($makefile,"",&get_logfile);
     20my $answer = "a1${pathsep}lib1.a a1${pathsep}libc.a " .
     21             "a2${pathsep}lib2.a lib3.a\n";
     22if ($port_type eq 'VMS-DCL') {
     23    $answer =~ s/ /,/g;
     24}
    3625
    37 # Create the answer to what should be produced by this Makefile
    38 $answer = "a1${pathsep}lib1.a a2${pathsep}lib2.a lib3.a\n";
     26run_make_test('
     27vpath %.h b3
     28vpath %.a a1
     29vpath %.so b1
     30vpath % a2 b2
     31vpath % b3
     32all: -l1 -lc -l2 -l3; @echo $^
     33',
     34              '', $answer);
    3935
    40 if (&compare_output($answer,&get_logfile(1)))
    41 {
    42   unlink @files_to_touch;
    43   rmdir("a1");
    44   rmdir("b1");
    45   rmdir("a2");
    46   rmdir("b2");
    47   rmdir("b3");
     36unlink(@files_to_touch);
     37for my $d (@dirs_to_make) {
     38    rmdir($d);
    4839}
    4940
  • vendor/gnumake/current/tests/scripts/features/vpathgpath

    r2596 r3138  
    5858push(@touchedfiles, "bar.c");
    5959
    60 $answer = "$make_name: Nothing to be done for `general'.\n";
     60$answer = "$make_name: Nothing to be done for 'general'.\n";
    6161
    6262&compare_output($answer,&get_logfile(1));
  • vendor/gnumake/current/tests/scripts/features/vpathplus

    r2596 r3138  
    8787$answer = "not creating notarget.c from notarget.d
    8888cat notarget.c > notarget.b 2>/dev/null || exit 1
    89 $make_name: *** [notarget.b] Error 1
     89$make_name: *** [$makefile:16: notarget.b] Error 1
    9090";
    9191
     
    127127
    1281281;
     129
     130### Local Variables:
     131### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     132### End:
  • vendor/gnumake/current/tests/scripts/functions/call

    r2596 r3138  
    55results.\n";
    66
    7 open(MAKEFILE, "> $makefile");
    8 
    9 # The Contents of the MAKEFILE ...
    10 
    11 print MAKEFILE <<'EOMAKE';
     7run_make_test(q!
    128# Simple, just reverse two things
    139#
    1410reverse = $2 $1
    1511
    16 # A complex `map' function, using recursive `call'.
     12# A complex 'map' function, using recursive 'call'.
    1713#
    1814map = $(foreach a,$2,$(call $1,$a))
     
    3935DEP_baz = quux blarp
    4036rest = $(wordlist 2,$(words ${1}),${1})
    41 tclose = $(if $1,$(firstword $1) \
     37tclose = $(if $1,$(firstword $1)\
    4238                $(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1))))
    4339
     
    4945        echo '$(call my-if,a,b,c)'; \
    5046        echo '$(call two,bar,baz)'; \
    51         echo '$(call tclose,foo)'
     47        echo '$(call tclose,foo)';
     48!,
     49              "", "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n");
    5250
    53 
    54 
    55 EOMAKE
    56 
    57 # These won't work until/unless PR/1527 is resolved.
    58 #        echo '$(call my-foreach,a,x y z,$(a)$(a))'; \
    59 #        echo '$(call my-if,,$(warning don't print this),ok)'
     51# These won't work because call expands all its arguments first, before
     52# passing them on, then marks them as resolved/simple, so they're not
     53# expanded again by the function.
    6054#
    61 # $answer = "xx yy zz\nok\n";
    62 
    63 # END of Contents of MAKEFILE
    64 
    65 close(MAKEFILE);
    66 
    67 &run_make_with_options($makefile, "", &get_logfile);
    68 $answer = "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n";
    69 &compare_output($answer, &get_logfile(1));
    70 
     55#        echo '$(call my-foreach,a,x y z,$$(a)$$(a))'; \
     56#        echo '$(call my-if,,$$(info don't print this),$$(info do print this))'
     57#
     58# $answer = "xx yy zz\ndo print this\n";
    7159
    7260# TEST eclipsing of arguments when invoking sub-calls
    7361
    74 $makefile2 = &get_tmpfile;
    75 
    76 open(MAKEFILE,"> $makefile2");
    77 
    78 print MAKEFILE <<'EOF';
    79 
     62run_make_test(q!
    8063all = $1 $2 $3 $4 $5 $6 $7 $8 $9
    8164
     
    8972        @echo $(call level2,1,2,3,4,5,6,7,8)
    9073        @echo $(call level3,1,2,3,4,5,6,7,8)
    91 EOF
     74!,
     75              "", "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n");
    9276
    93 close(MAKEFILE);
     77# Ensure that variables are defined in global scope even in a $(call ...)
    9478
    95 &run_make_with_options($makefile2, "", &get_logfile);
    96 $answer = "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n";
    97 &compare_output($answer,&get_logfile(1));
     79delete $ENV{X123};
     80
     81run_make_test('
     82tst = $(eval export X123)
     83$(call tst)
     84all: ; @echo "$${X123-not set}"
     85',
     86              '', "\n");
    9887
    99881;
     89
     90### Local Variables:
     91### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     92### End:
  • vendor/gnumake/current/tests/scripts/functions/error

    r2596 r3138  
    5555
    5656&run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512);
    57 $answer = "Some stuff\n$makefile:16: *** error is definitely.  Stop.\n";
     57$answer = "Some stuff\n$makefile:17: *** error is definitely.  Stop.\n";
    5858&compare_output($answer,&get_logfile(1));
    5959
     
    67671;
    6868
    69 
    70 
    71 
    72 
    73 
     69### Local Variables:
     70### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     71### End:
  • vendor/gnumake/current/tests/scripts/functions/filter-out

    r2596 r3138  
    11#                                                                    -*-perl-*-
    22
    3 $description = "Test the filter-out function.";
     3$description = "Test the filter and filter-out functions.";
    44
    55$details = "The makefile created in this test has two variables.  The
     
    1212functions is the same single .elc name.\n";
    1313
    14 open(MAKEFILE,"> $makefile");
     14# Basic test -- filter
     15run_make_test(q!
     16files1 := $(filter %.o, foo.elc bar.o lose.o)
     17files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o)
     18all: ; @echo '$(files1) $(files2)'
     19!,
     20              '', "bar.o lose.o foo.i bar.o lose.o\n");
    1521
    16 print MAKEFILE <<'EOF';
     22# Basic test -- filter-out
     23run_make_test(q!
    1724files1 := $(filter-out %.o, foo.elc bar.o lose.o)
    1825files2 := $(filter-out foo.i bar.i lose.i %.o, foo.i bar.i lose.i foo.elc bar.o lose.o)
    19 all: ; @echo $(files1) $(files2)
    20 EOF
     26all: ; @echo '$(files1) $(files2)'
     27!,
     28              '', "foo.elc foo.elc\n");
    2129
    22 close(MAKEFILE);
     30# Escaped patterns
     31run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!,
     32              '', "foo%bar\n");
    2333
    24 &run_make_with_options($makefile, "", &get_logfile, 0);
    25 $answer = "foo.elc foo.elc\n";
    26 &compare_output($answer,&get_logfile(1));
     34run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!,
     35              '', "foo%%\\%%bar\n");
     36
     37run_make_test(q!
     38X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar)
     39all:;@echo '$(X)'!,
     40              '', "foo\\%bar\n");
    2741
    28421;
  • vendor/gnumake/current/tests/scripts/functions/foreach

    r2596 r3138  
    11#                                                                    -*-perl-*-
    2 # $Id: foreach,v 1.5 2006/03/10 02:20:46 psmith Exp $
     2# $Id$
    33
    44$description = "Test the foreach function.";
     
    5454              'FOREACH');
    5555
     56# Allow variable names with trailing space
     57run_make_test(q!
     58$(foreach \
     59  a \
     60, b c d \
     61, $(info $a))
     62all:;@:
     63!,
     64              "", "b\nc\nd\n");
    5665
    57 # TEST 2: Check some error conditions.
     66# Allow empty variable names.  We still expand the body.
     67
     68run_make_test('
     69x = $(foreach ,1 2 3,a)
     70y := $x
     71
     72all: ; @echo $y',
     73              '', "a a a\n");
     74
     75# Check some error conditions.
    5876
    5977run_make_test('
     
    6381all: ; @echo $y',
    6482              '',
    65               "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'.  Stop.",
     83              "#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'foreach'.  Stop.",
    6684              512);
    6785
    6886run_make_test('
    69 x = $(foreach )
     87x = $(foreach x,y)
    7088y := $x
    7189
    7290all: ; @echo $y',
    7391              '',
    74               "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'.  Stop.",
     92              "#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'foreach'.  Stop.",
    7593              512);
    7694
  • vendor/gnumake/current/tests/scripts/functions/shell

    r2596 r3138  
    55$details = '';
    66
     7# Test standard shell
     8run_make_test('.PHONY: all
     9OUT := $(shell echo hi)
     10all: ; @echo $(OUT)
     11              ','','hi');
    712
    813# Test shells inside rules.
    914run_make_test('.PHONY: all
    1015all: ; @echo $(shell echo hi)
    11 ','','hi');
     16              ','','hi');
     17
     18# Verify .SHELLSTATUS
     19run_make_test('.PHONY: all
     20PRE := $(.SHELLSTATUS)
     21$(shell exit 0)
     22OK := $(.SHELLSTATUS)
     23$(shell exit 1)
     24BAD := $(.SHELLSTATUS)
     25all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
     26              ','','PRE= OK=0 BAD=1');
    1227
    1328
     
    2843.PHONY: all
    2944all: ; @echo $$HI
    30 ','','hi');
     45    ','','hi');
     46
     47# Test shell errors in recipes including offset
     48run_make_test('
     49all:
     50        @echo hi
     51        $(shell ./basdfdfsed there)
     52        @echo there
     53',
     54              '', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n");
    3155
    32561;
     57
     58### Local Variables:
     59### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     60### End:
  • vendor/gnumake/current/tests/scripts/functions/sort

    r2596 r3138  
    1 $description = "The following test creates a makefile to verify\n"
    2               ."the ability of make to sort lists of object. Sort\n"
    3               ."will also remove any duplicate entries. This will also\n"
    4               ."be tested.";
     1#                                                                    -*-perl-*-
    52
    6 $details = "The make file is built with a list of object in a random order\n"
    7           ."and includes some duplicates. Make should sort all of the elements\n"
    8           ."remove all duplicates\n";
     3$description = "The following test creates a makefile to verify
     4the ability of make to sort lists of object. Sort
     5will also remove any duplicate entries. This will also
     6be tested.";
    97
    10 open(MAKEFILE,"> $makefile");
     8$details = "The make file is built with a list of object in a random order
     9and includes some duplicates. Make should sort all of the elements
     10remove all duplicates\n";
    1111
    12 # The Contents of the MAKEFILE ...
    13 
    14 print MAKEFILE "foo := moon_light days \n"
    15               ."foo1:= jazz\n"
    16               ."bar := captured \n"
    17               ."bar2 = boy end, has rise A midnight \n"
    18               ."bar3:= \$(foo)\n"
    19               ."s1  := _by\n"
    20               ."s2  := _and_a\n"
    21               ."t1  := \$(addsuffix \$(s1), \$(bar) )\n"
    22               ."t2  := \$(addsuffix \$(s2), \$(foo1) )\n"
    23               ."t3  := \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \n"
    24               ."t4  := \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \n"
    25               ."t5  := \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \n"
    26               ."t6  := \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \n"
    27               ."t7  := \$(t6) \$(t6) \$(t6) \n"
    28               ."p1  := \$(addprefix \$(foo1), \$(s2) )\n"
    29               ."blank:= \n"
    30               ."all:\n"
    31               ."\t\@echo \$(sort \$(bar2) \$(foo)  \$(addsuffix \$(s1), \$(bar) ) \$(t2) \$(bar2) \$(bar3))\n"
    32               ."\t\@echo \$(sort \$(blank) \$(foo) \$(bar2) \$(t1) \$(p1) )\n"
    33               ."\t\@echo \$(sort \$(foo) \$(bar2) \$(t1) \$(t4) \$(t5) \$(t7) \$(t6) )\n";
     12run_make_test('
     13foo := moon_light days
     14foo1:= jazz
     15bar := captured
     16bar2 = boy end, has rise A midnight
     17bar3:= $(foo)
     18s1  := _by
     19s2  := _and_a
     20t1  := $(addsuffix $(s1), $(bar) )
     21t2  := $(addsuffix $(s2), $(foo1) )
     22t3  := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2)
     23t4  := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3)
     24t5  := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4)
     25t6  := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5)
     26t7  := $(t6) $(t6) $(t6)
     27p1  := $(addprefix $(foo1), $(s2) )
     28blank:=
     29all:
     30        @echo $(sort $(bar2) $(foo)  $(addsuffix $(s1), $(bar) ) $(t2) $(bar2) $(bar3))
     31        @echo $(sort $(blank) $(foo) $(bar2) $(t1) $(p1) )
     32        @echo $(sort $(foo) $(bar2) $(t1) $(t4) $(t5) $(t7) $(t6) )
     33',
     34              '', 'A boy captured_by days end, has jazz_and_a midnight moon_light rise
     35A boy captured_by days end, has jazz_and_a midnight moon_light rise
     36A boy captured_by days end, has jazz_and_a midnight moon_light rise
     37');
    3438
    3539
    36 # END of Contents of MAKEFILE
     40# Test with non-space/tab whitespace.  Note that you can't see the
     41# original bug except using valgrind.
    3742
    38 close(MAKEFILE);
    39 
    40 &run_make_with_options($makefile,"",&get_logfile);
    41 
    42 # Create the answer to what should be produced by this Makefile
    43 $answer = "A boy captured_by days end, has jazz_and_a midnight moon_light rise\n"
    44          ."A boy captured_by days end, has jazz_and_a midnight moon_light rise\n"
    45          ."A boy captured_by days end, has jazz_and_a midnight moon_light rise\n";
    46 
    47 &compare_output($answer,&get_logfile(1));
     43run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff
     44all: ; \@echo \$(words \$(sort \$(FOO)))\n",
     45              '', "6\n");
    4846
    49471;
    5048
    51 
    52 
    53 
    54 
    55 
     49### Local Variables:
     50### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     51### End:
  • vendor/gnumake/current/tests/scripts/functions/warning

    r2596 r3138  
    5353
    5454&run_make_with_options($makefile, "WARNING4=definitely", &get_logfile, 0);
    55 $answer = "Some stuff\n$makefile:14: warning is definitely\nhi\nthere\n";
     55$answer = "Some stuff\n$makefile:15: warning is definitely\nhi\nthere\n";
    5656&compare_output($answer,&get_logfile(1));
     57
     58# Test linenumber offset
     59
     60run_make_test(q!
     61all: one two
     62        $(warning in $@ line 3)
     63        @true
     64        $(warning in $@ line 5)
     65
     66one two:
     67        $(warning in $@ line 8)
     68        @true
     69        $(warning in $@ line 10)
     70!,
     71              '', "#MAKEFILE#:8: in one line 8
     72#MAKEFILE#:10: in one line 10
     73#MAKEFILE#:8: in two line 8
     74#MAKEFILE#:10: in two line 10
     75#MAKEFILE#:3: in all line 3
     76#MAKEFILE#:5: in all line 5\n");
    5777
    5878# This tells the test driver that the perl test script executed properly.
    59791;
    6080
    61 
    62 
    63 
    64 
    65 
     81### Local Variables:
     82### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     83### End:
  • vendor/gnumake/current/tests/scripts/functions/wildcard

    r2596 r3138  
    8989              '', "\n");
    9090
     91# TEST #5: wildcard used to verify file existence
     92
     93touch('xxx.yyy');
     94
     95run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
     96              '', "file=xxx.yyy\n");
     97
     98unlink('xxx.yyy');
     99
     100run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
     101              '', "file=\n");
     102
    911031;
  • vendor/gnumake/current/tests/scripts/functions/word

    r2596 r3138  
    5757wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))',
    5858              'word-e1',
    59               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''.  Stop.",
     59              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''.  Stop.",
    6060              512);
    6161
    6262run_make_test(undef,
    6363              'word-e2',
    64               "#MAKEFILE#:4: *** non-numeric first argument to `word' function: 'abc '.  Stop.",
     64              "#MAKEFILE#:4: *** non-numeric first argument to 'word' function: 'abc '.  Stop.",
    6565              512);
    6666
    6767run_make_test(undef,
    6868              'word-e3',
    69               "#MAKEFILE#:5: *** non-numeric first argument to `word' function: '1a'.  Stop.",
     69              "#MAKEFILE#:5: *** non-numeric first argument to 'word' function: '1a'.  Stop.",
    7070              512);
    7171
    7272run_make_test(undef,
    7373              'wordlist-e1',
    74               "#MAKEFILE#:7: *** non-numeric first argument to `wordlist' function: ''.  Stop.",
     74              "#MAKEFILE#:7: *** non-numeric first argument to 'wordlist' function: ''.  Stop.",
    7575              512);
    7676
    7777run_make_test(undef,
    7878              'wordlist-e2',
    79               "#MAKEFILE#:8: *** non-numeric first argument to `wordlist' function: 'abc '.  Stop.",
     79              "#MAKEFILE#:8: *** non-numeric first argument to 'wordlist' function: 'abc '.  Stop.",
    8080              512);
    8181
    8282run_make_test(undef,
    8383              'wordlist-e3',
    84               "#MAKEFILE#:9: *** non-numeric second argument to `wordlist' function: ' 12a '.  Stop.",
     84              "#MAKEFILE#:9: *** non-numeric second argument to 'wordlist' function: ' 12a '.  Stop.",
    8585              512);
    8686
     
    9595wordlist-e: ; @echo $(WL)',
    9696              'word-e x=',
    97               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''.  Stop.",
     97              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''.  Stop.",
    9898              512);
    9999
    100100run_make_test(undef,
    101101              'word-e x=abc',
    102               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: 'abc'.  Stop.",
     102              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: 'abc'.  Stop.",
    103103              512);
    104104
    105105run_make_test(undef,
    106106              'word-e x=0',
    107               "#MAKEFILE#:3: *** first argument to `word' function must be greater than 0.  Stop.",
     107              "#MAKEFILE#:3: *** first argument to 'word' function must be greater than 0.  Stop.",
    108108              512);
    109109
    110110run_make_test(undef,
    111111              'wordlist-e s= e=',
    112               "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: ''.  Stop.",
     112              "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: ''.  Stop.",
    113113              512);
    114114
    115115run_make_test(undef,
    116116              'wordlist-e s=abc e=',
    117               "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: 'abc'.  Stop.",
     117              "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: 'abc'.  Stop.",
    118118              512);
    119119
    120120run_make_test(undef,
    121121              'wordlist-e s=4 e=12a',
    122               "#MAKEFILE#:4: *** non-numeric second argument to `wordlist' function: '12a'.  Stop.",
     122              "#MAKEFILE#:4: *** non-numeric second argument to 'wordlist' function: '12a'.  Stop.",
    123123              512);
    124124
    125125run_make_test(undef,
    126126              'wordlist-e s=0 e=12',
    127               "#MAKEFILE#:4: *** invalid first argument to `wordlist' function: `0'.  Stop.",
     127              "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: '0'.  Stop.",
    128128              512);
    129129
  • vendor/gnumake/current/tests/scripts/misc/general3

    r2596 r3138  
    2727
    2828\$(STR) \$(TAB)",
    29               '', "#MAKE#: Nothing to be done for `all'.");
     29              '', "#MAKE#: Nothing to be done for 'all'.");
    3030
    3131# TEST 2
     
    311311foo     bar');
    312312
     313run_make_test('x:;@-exit 1', '', "#MAKE#: [#MAKEFILE#:1: x] Error 1 (ignored)\n");
     314
    3133151;
  • vendor/gnumake/current/tests/scripts/options/dash-B

    r2596 r3138  
    2323              '', 'cp bar.x foo');
    2424
    25 run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
     25run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'.");
    2626run_make_test(undef, '-B', 'cp bar.x foo');
    2727
     
    2929
    3030utouch(1000, 'foo');
    31 run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
     31run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'.");
    3232run_make_test(undef, '-B', 'cp bar.x foo');
    3333
     
    4646',
    4747              '-B', 'MAKE_RESTARTS=
    48 #MAKEFILE#:4: foo.x: No such file or directory
    4948MAKE_RESTARTS=1');
    5049
     
    6463',
    6564              '-B', 'MAKE_RESTARTS=
    66 #MAKEFILE#:4: foo.x: No such file or directory
    6765MAKE_RESTARTS=1
    6866blah.x
     
    8482
    85831;
     84
     85### Local Variables:
     86### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     87### End:
  • vendor/gnumake/current/tests/scripts/options/dash-C

    r2596 r3138  
    3535
    3636# Create the answer to what should be produced by this Makefile
    37 $answer = "$make_name: Entering directory `$wpath'\n"
     37$answer = "$make_name: Entering directory '$wpath'\n"
    3838        . "$delete_command EXAMPLE\n"
    39         . "$make_name: Leaving directory `$wpath'\n";
     39        . "$make_name: Leaving directory '$wpath'\n";
    4040
    4141&compare_output($answer,&get_logfile(1));
     
    6363
    6464# Create the answer to what should be produced by this Makefile
    65 $answer = "$make_name: Entering directory `$wpath'\n"
     65$answer = "$make_name: Entering directory '$wpath'\n"
    6666        . "$delete_command EXAMPLEslash\n"
    67         . "$make_name: Leaving directory `$wpath'\n";
     67        . "$make_name: Leaving directory '$wpath'\n";
    6868
    6969&compare_output($answer,&get_logfile(1));
  • vendor/gnumake/current/tests/scripts/options/dash-I

    r2596 r3138  
    5252
    5353$answer = "$mkpath ANOTHER -f $makefile
    54 ${make_name}[1]: Entering directory `$pwd'
     54${make_name}[1]: Entering directory '$pwd'
    5555This is another included makefile
    56 ${make_name}[1]: Leaving directory `$pwd'\n";
     56${make_name}[1]: Leaving directory '$pwd'\n";
    5757
    5858&run_make_with_options($makefile,"-I $workdir recurse",&get_logfile);
  • vendor/gnumake/current/tests/scripts/options/dash-W

    r2596 r3138  
    1313# Run it again: nothing should happen
    1414
    15 run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");
     15run_make_test(undef, '', "#MAKE#: 'a.x' is up to date.");
    1616
    1717# Now run it with -W b.x: should rebuild a.x
     
    2222
    2323utouch(1000, 'a.x');
    24 run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");
     24run_make_test(undef, '', "#MAKE#: 'a.x' is up to date.");
    2525run_make_test(undef, '-W b.x', 'echo >> a.x');
    2626
     
    4343baz.x: bar.x ; @echo "touch $@"
    4444',
    45               '', '#MAKEFILE#:3: foo.x: No such file or directory
    46 echo >> bar.x
     45              '', 'echo >> bar.x
    4746touch foo.x
    4847restarts=1
     
    8786
    88871;
     88
     89### Local Variables:
     90### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     91### End:
  • vendor/gnumake/current/tests/scripts/options/dash-k

    r2596 r3138  
    4343               "$workdir${pathsep}commands.c","$workdir${pathsep}display.c",
    4444               "$workdir${pathsep}buffer.h",
    45                "$workdir${pathsep}command.c");
     45               "$workdir${pathsep}command.c");
    4646
    4747&touch(@files_to_touch);
     
    5858# Create the answer to what should be produced by this Makefile
    5959$answer = "cc -c main.c
    60 $make_name: *** No rule to make target `kbd.c', needed by `kbd.o'.
     60$make_name: *** No rule to make target 'kbd.c', needed by 'kbd.o'.
    6161cc -c commands.c
    6262cc -c display.c
    63 $make_name: Target `edit' not remade because of errors.\n";
     63$make_name: Target 'edit' not remade because of errors.\n";
    6464
    6565# COMPARE RESULTS
     
    9393
    9494$answer = "exit 1
    95 $make_name: *** [foo.o] Error 1
    96 $make_name: Target `all' not remade because of errors.\n";
     95$make_name: *** [$makefile2:9: foo.o] Error 1
     96$make_name: Target 'all' not remade because of errors.\n";
    9797
    9898&compare_output($answer, &get_logfile(1));
     
    107107              '-k',
    108108              "#MAKEFILE#:2: ifile: No such file or directory
    109 #MAKE#: *** No rule to make target `no-such-file', needed by `ifile'.
    110 #MAKE#: Failed to remake makefile `ifile'.
     109#MAKE#: *** No rule to make target 'no-such-file', needed by 'ifile'.
     110#MAKE#: Failed to remake makefile 'ifile'.
    111111hi\n",
    112112              512);
  • vendor/gnumake/current/tests/scripts/options/dash-n

    r2596 r3138  
    44$details = "Try various uses of -n and ensure they all give the correct results.\n";
    55
    6 open(MAKEFILE, "> $makefile");
     6touch('orig');
    77
    8 # The Contents of the MAKEFILE ...
    9 
    10 print MAKEFILE <<'EOMAKE';
    11 
     8run_make_test(q!
    129final: intermediate ; echo >> $@
    1310intermediate: orig ; echo >> $@
    14 
    15 EOMAKE
    16 
    17 close(MAKEFILE);
    18 
    19 &touch('orig');
    20 
    21 # TEST 0
    22 
    23 &run_make_with_options($makefile, "", &get_logfile);
    24 $answer = "echo >> intermediate\necho >> final\n";
    25 &compare_output($answer, &get_logfile(1));
     11!,
     12              '', "echo >> intermediate\necho >> final\n");
    2613
    2714# TEST 1
    2815
    29 &run_make_with_options($makefile, "-Worig -n", &get_logfile);
    30 $answer = "echo >> intermediate\necho >> final\n";
    31 &compare_output($answer, &get_logfile(1));
     16run_make_test(undef, '-Worig -n', "echo >> intermediate\necho >> final\n");
    3217
    33 unlink('orig', 'intermediate', 'final');
     18rmfiles(qw(orig intermediate final));
    3419
    3520# We consider the actual updated timestamp of targets with all
    36 # recursive commands, even with -n.
     21# recursive commands, even with -n.  Switching this to the new model
     22# is non-trivial because we use a trick below to change the log content
     23# before we compare it ...
    3724
    3825$makefile2 = &get_tmpfile;
     
    5744
    5845&run_make_with_options($makefile2, "", &get_logfile);
    59 $answer = "$make_name: `a' is up to date.\n";
     46$answer = "$make_name: 'a' is up to date.\n";
    6047&compare_output($answer, &get_logfile(1));
    6148
     
    6350
    6451&run_make_with_options($makefile2, "-n", &get_logfile);
    65 $answer = "$make_name: `a' is up to date.\n";
     52$answer = "$make_name: 'a' is up to date.\n";
    6653&compare_output($answer, &get_logfile(1));
    6754
    68 unlink('a', 'b', 'c');
     55# TEST 4
     56
     57unlink(qw(a b));
     58
     59&run_make_with_options($makefile2, "-t -n", &get_logfile);
     60
     61open(DASH_N_LOG, ">>" . &get_logfile(1));
     62print DASH_N_LOG "a exists but should not!\n" if -e 'a';
     63print DASH_N_LOG "b exists but should not!\n" if -e 'b';
     64close(DASH_N_LOG);
     65
     66&compare_output("touch b\ntouch a\n", &get_logfile(1));
     67
     68# CLEANUP
     69
     70unlink(qw(a b c));
     71
     72# Ensure -n continues to be included with recursive/re-execed make
     73# See Savannah bug #38051
     74
     75$topmake = &get_tmpfile;
     76$submake = &get_tmpfile;
     77
     78open(MAKEFILE, "> $topmake");
     79print MAKEFILE <<"EOF";
     80foo: ; \@\$(MAKE) -f "$submake" bar
     81EOF
     82close(MAKEFILE);
     83
     84
     85# The bar target should print what would happen, but not actually run
     86open(MAKEFILE, "> $submake");
     87print MAKEFILE <<'EOF';
     88inc: ; touch $@
     89-include inc
     90bar: ; @echo $(strip $(MAKEFLAGS))
     91EOF
     92close(MAKEFILE);
     93
     94&run_make_with_options($topmake, '-n --no-print-directory', &get_logfile);
     95$answer = "$make_command -f \"$submake\" bar\ntouch inc\necho n --no-print-directory\n";
     96&compare_output($answer, &get_logfile(1));
     97
     98unlink('inc');
    6999
    701001;
  • vendor/gnumake/current/tests/scripts/options/dash-q

    r2596 r3138  
    66# TEST 0
    77
    8 run_make_test('
     8run_make_test(qq!
    99one:
    1010two: ;
    1111three: ; :
    12 four: ; $(.XY)
    13 five: ; \
    14  $(.XY)
    15 six: ; \
    16  $(.XY)
    17         $(.XY)
    18 seven: ; \
    19  $(.XY)
    20         : foo
    21         $(.XY)
    22 ',
     12four: ; \$(.XY)
     13five: ; \\
     14 \$(.XY)
     15six: ; \\
     16 \$(.XY)
     17\t\$(.XY)
     18seven: ; \\
     19 \$(.XY)
     20\t: foo
     21\t\$(.XY)
     22!,
    2323              '-q one', '');
    2424
     
    5555              '-q', '', 256);
    5656
     57# TEST 7 : Savannah bug # 42249
     58# Make sure we exit with 1 even for prerequisite updates
     59run_make_test('
     60build-stamp: ; echo $@
     61build-arch: build-stamp
     62build-x: build-arch
     63build-y: build-x
     64',
     65              '-q build-y', '', 256);
     66
     67# TEST 8
     68# Make sure we exit with 2 on error even with -q
     69run_make_test('
     70build-stamp: ; echo $@
     71build-arch: build-stamp-2
     72build-x: build-arch
     73build-y: build-x
     74',
     75              '-q build-y', "#MAKE#: *** No rule to make target 'build-stamp-2', needed by 'build-arch'.  Stop.\n", 512);
     76
     77# TEST 9 : Savannah bug # 47151
     78# Make sure we exit with 1 when invoking a recursive make
     79run_make_test('
     80foo: bar ; echo foo
     81bar: ; @$(MAKE) -f #MAKEFILE# baz
     82baz: ; echo baz
     83',
     84              '-q foo', '', 256);
     85
    57861;
  • vendor/gnumake/current/tests/scripts/options/eval

    r2596 r3138  
    1717              "eval\neval\nall\nrecurse");
    1818
     19# Make sure that --eval is handled correctly during restarting
     20run_make_test(q!
     21all: ; @echo $@
     22-include gen.mk
     23gen.mk: ; @echo > $@
     24!,
     25              '--eval=\$\(info\ eval\)', "eval\neval\nall");
     26
     27unlink('gen.mk');
     28
    19291;
  • vendor/gnumake/current/tests/scripts/options/symlinks

    r2596 r3138  
    2727  # With -L, it should update targ
    2828  run_make_test('targ: sym ; @echo make $@ from $<', '',
    29                 "#MAKE#: `targ' is up to date.");
     29                "#MAKE#: 'targ' is up to date.");
    3030  run_make_test(undef, '-L', "make targ from sym");
    3131
     
    3737  # Now update targ; in all cases targ should be up to date.
    3838  &touch('targ');
    39   run_make_test(undef, '', "#MAKE#: `targ' is up to date.");
    40   run_make_test(undef, '-L', "#MAKE#: `targ' is up to date.");
     39  run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
     40  run_make_test(undef, '-L', "#MAKE#: 'targ' is up to date.");
    4141
    4242  # Add in a new link between sym and dep.  Be sure it's newer than targ.
     
    4747  # Without -L, nothing should happen
    4848  # With -L, it should update targ
    49   run_make_test(undef, '', "#MAKE#: `targ' is up to date.");
     49  run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
    5050  run_make_test(undef, '-L', "make targ from sym");
    5151
     
    5757  symlink("../$dirname/dep", 'sym');
    5858  run_make_test('targ: sym ; @echo make $@ from $<', '',
    59                 "#MAKE#: *** No rule to make target `sym', needed by `targ'.  Stop.", 512);
     59                "#MAKE#: *** No rule to make target 'sym', needed by 'targ'.  Stop.", 512);
    6060
    6161  run_make_test('targ: sym ; @echo make $@ from $<', '-L',
  • vendor/gnumake/current/tests/scripts/options/warn-undefined-variables

    r2596 r3138  
    1919# With --warn-undefined-variables, it should warn me
    2020run_make_test(undef, '--warn-undefined-variables',
    21               "#MAKEFILE#:7: warning: undefined variable `UNDEFINED'
    22 #MAKEFILE#:9: warning: undefined variable `UNDEFINED'
     21              "#MAKEFILE#:7: warning: undefined variable 'UNDEFINED'
     22#MAKEFILE#:9: warning: undefined variable 'UNDEFINED'
    2323ref");
    2424
  • vendor/gnumake/current/tests/scripts/targets/DEFAULT

    r2596 r3138  
    3636
    3737# Create the answer to what should be produced by this Makefile
    38 $answer = "${make_name}[1]: Entering directory `$pwd'\n"
     38$answer = "${make_name}[1]: Entering directory '$pwd'\n"
    3939        . "Executing rule BAR\n"
    40         . "${make_name}[1]: Leaving directory `$pwd'\n";
     40        . "${make_name}[1]: Leaving directory '$pwd'\n";
    4141
    4242# COMPARE RESULTS
  • vendor/gnumake/current/tests/scripts/targets/INTERMEDIATE

    r2596 r3138  
    4343
    4444&run_make_with_options($makefile,'foo.d',&get_logfile);
    45 $answer = "$make_name: `foo.d' is up to date.\n";
     45$answer = "$make_name: 'foo.d' is up to date.\n";
    4646&compare_output($answer, &get_logfile(1));
    4747
     
    6464
    6565&run_make_with_options($makefile,'foo.c',&get_logfile);
    66 $answer = "$make_name: `foo.c' is up to date.\n";
     66$answer = "$make_name: 'foo.c' is up to date.\n";
    6767&compare_output($answer, &get_logfile(1));
    6868
  • vendor/gnumake/current/tests/scripts/targets/ONESHELL

    r2596 r3138  
    55$details = "";
    66
     7# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
     8# separate arguments.
     9my $t = `/bin/sh -e -c true 2>/dev/null`;
     10my $multi_ok = $? == 0;
    711
    812# Simple
     
    1721[ 0"$a" -eq "$$" ] || echo fail
    1822');
     23
     24# Simple but use multi-word SHELLFLAGS
     25
     26if ($multi_ok) {
     27    run_make_test(q!
     28.ONESHELL:
     29.SHELLFLAGS = -e -c
     30all:
     31        a=$$$$
     32        [ 0"$$a" -eq "$$$$" ] || echo fail
     33!,
     34              '', 'a=$$
     35[ 0"$a" -eq "$$" ] || echo fail
     36');
     37}
    1938
    2039# Again, but this time with inner prefix chars
  • vendor/gnumake/current/tests/scripts/targets/POSIX

    r2596 r3138  
    11#                                                                    -*-perl-*-
    22
    3 $description = "Test the behaviour of the .PHONY target.";
     3$description = "Test the behaviour of the .POSIX target.";
    44
    55$details = "";
     
    1818all: ; \@$script
    1919!,
    20               '', "#MAKE#: *** [all] Error $err\n", 512);
     20              '', "#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
    2121
    2222# User settings must override .POSIX
     
    3030              '', $out);
    3131
     32# Test the default value of various POSIX-specific variables
     33my %POSIX = (AR => 'ar', ARFLAGS => '-rv',
     34             YACC => 'yacc', YFLAGS => '',
     35             LEX => 'lex', LFLAGS => '',
     36             LDFLAGS => '',
     37             CC => 'c99', CFLAGS => '-O',
     38             FC => 'fort77', FFLAGS => '-O 1',
     39             GET => 'get', GFLAGS => '',
     40             SCCSFLAGS => '', SCCSGETFLAGS => '-s');
     41my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX);
     42my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX);
     43run_make_test(qq!
     44.POSIX:
     45all:
     46$make
     47!,
     48              '', $r);
     49
     50# Make sure that local settings take precedence
     51%extraENV = map { $_ => "xx-$_" } keys %POSIX;
     52$r = join('', map { "$_=xx-$_\n"} sort keys %POSIX);
     53run_make_test(undef, '', $r);
     54
    3255# This tells the test driver that the perl test script executed properly.
    33561;
  • vendor/gnumake/current/tests/scripts/targets/SECONDARY

    r2596 r3138  
    4545
    4646&run_make_with_options($makefile,'foo.d',&get_logfile);
    47 $answer = "$make_name: `foo.d' is up to date.\n";
     47$answer = "$make_name: 'foo.d' is up to date.\n";
    4848&compare_output($answer, &get_logfile(1));
    4949
     
    6868
    6969&run_make_with_options($makefile,'foo.c',&get_logfile);
    70 $answer = "$make_name: `foo.c' is up to date.\n";
     70$answer = "$make_name: 'foo.c' is up to date.\n";
    7171&compare_output($answer, &get_logfile(1));
    7272
     
    104104
    105105&run_make_with_options($makefile2, '', &get_logfile);
    106 $answer = "$make_name: `final' is up to date.\n";
     106$answer = "$make_name: 'final' is up to date.\n";
    107107&compare_output($answer, &get_logfile(1));
    108108
     
    130130%.c : %.b ; cp $< $@
    131131%.b : %.a ; cp $< $@
    132 all : 1.c 2.c', '-rR -j',
     132all : 1.c 2.c
     1332.a: 1.c', '-rR -j',
    133134'cp 1.a 1.b
     135cp 1.b 1.c
    134136cp 2.a 2.b
    135 cp 1.b 1.c
    136137cp 2.b 2.c
    137138rm 1.b 2.b');
  • vendor/gnumake/current/tests/scripts/variables/DEFAULT_GOAL

    r2596 r3138  
    4343',
    4444'',
    45 '#MAKE#: *** No rule to make target `foo\'.  Stop.',
     45"#MAKE#: *** No rule to make target 'foo'.  Stop.",
    4646512);
    4747
  • vendor/gnumake/current/tests/scripts/variables/LIBPATTERNS

    r2596 r3138  
    2121all: -lfoo ; @echo "build $@ from $<"
    2222',
    23               '', "#MAKE#: .LIBPATTERNS element `mtest_foo.a' is not a pattern
     23              '', "#MAKE#: .LIBPATTERNS element 'mtest_foo.a' is not a pattern
    2424build all from mtest_foo.a\n");
    2525
  • vendor/gnumake/current/tests/scripts/variables/MAKE

    r2596 r3138  
    1717              '',
    1818              "#MAKEPATH#\n#MAKEPATH# -f #MAKEFILE# foo\n"
    19               . "#MAKE#[1]: Entering directory `#PWD#'\n"
    20               . "#MAKEPATH#\n#MAKE#[1]: Leaving directory `#PWD#'\n");
     19              . "#MAKE#[1]: Entering directory '#PWD#'\n"
     20              . "#MAKEPATH#\n#MAKE#[1]: Leaving directory '#PWD#'\n");
    2121
    2222rmfiles("foo");
  • vendor/gnumake/current/tests/scripts/variables/MAKEFLAGS

    r2596 r3138  
    1 #                                                                    -*-perl-*-
     1#                                                                    -*-perl-*-
    22
    33$description = "Test proper behavior of MAKEFLAGS";
     
    99all: ; @echo $(MAKEFLAGS)
    1010!,
    11               '-e -r -R', 'Rre');
     11              '-e -r -R', 'erR');
    1212
    1313# Long arguments mean everything is prefixed with "-"
     
    1515all: ; @echo $(MAKEFLAGS)
    1616!,
    17               '--no-print-directory -e -r -R', '--no-print-directory -Rre');
     17              '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: target 'all' does not exist
     18echo erR --trace --no-print-directory
     19erR --trace --no-print-directory");
    1820
    1921
    20 if ($all_tests) {
    21     # Recursive invocations of make should accumulate MAKEFLAGS values.
    22     # Savannah bug #2216
    23     run_make_test(q!
     22# Recursive invocations of make should accumulate MAKEFLAGS values.
     23# Savannah bug #2216
     24run_make_test(q!
    2425MSG = Fails
    2526all:
     
    2728        @MSG=Works $(MAKE) -e -f #MAKEFILE# jump
    2829jump:
    29         @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
     30        @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
    3031        @$(MAKE) -f #MAKEFILE# print
    3132print:
    32         @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
    33         @echo $(MSG)
     33        @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
    3434.PHONY: all jump print
    3535!,
    3636                  '--no-print-directory',
    3737                  'all: MAKEFLAGS= --no-print-directory
    38 jump: MAKEFLAGS= --no-print-directory -e
    39 print: MAKEFLAGS= --no-print-directory -e
    40 Works');
    41 }
     38jump Works: MAKEFLAGS=e --no-print-directory
     39print Works: MAKEFLAGS=e --no-print-directory');
    4240
    43411;
     42
     43### Local Variables:
     44### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     45### End:
  • vendor/gnumake/current/tests/scripts/variables/MAKE_RESTARTS

    r2596 r3138  
    1212',
    1313              '', 'MAKE_RESTARTS=
    14 #MAKEFILE#:4: foo.x: No such file or directory
    1514MAKE_RESTARTS=1');
    1615
     
    2726',
    2827              '', 'MAKE_RESTARTS=
    29 #MAKEFILE#:4: foo.x: No such file or directory
    3028MAKE_RESTARTS=1
    31 foo.x:1: bar.x: No such file or directory
    3229MAKE_RESTARTS=2');
    3330
     
    4845',
    4946              '', "MAKE_RESTARTS=
    50 #MAKEFILE#:8: foo.x: No such file or directory
    5147MAKE_RESTARTS=1
    52 foo.x:1: bar.x: No such file or directory
    5348MAKE_RESTARTS=2
    5449recurse MAKE_RESTARTS=
     50#MAKE#[1]: Entering directory '#PWD#'
    5551MAKE_RESTARTS=
    56 #MAKE#[1]: Entering directory `#PWD#'
    5752all MAKE_RESTARTS=
    58 #MAKE#[1]: Leaving directory `#PWD#'");
     53#MAKE#[1]: Leaving directory '#PWD#'");
    5954
    6055rmfiles('foo.x', 'bar.x');
    6156
    62571;
     58
     59### Local Variables:
     60### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     61### End:
  • vendor/gnumake/current/tests/scripts/variables/SHELL

    r2596 r3138  
    7171              '', $out);
    7272
     73# Do it again but add spaces to SHELLFLAGS
     74
     75# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
     76# separate arguments.
     77my $t = `/bin/sh -e -c true 2>/dev/null`;
     78my $multi_ok = $? == 0;
     79
     80if ($multi_ok) {
     81    $flags = '-x -c';
     82    run_make_test(qq!
     83.SHELLFLAGS = $flags
     84all: ; \@$script
     85!,
     86              '', $out);
     87}
     88
    7389# We can't just use "false" because on different systems it provides a
    7490# different exit code--once again Solaris: false exits with 255 not 1
     
    8298all: ; \@$script
    8399!,
    84               '', "$out#MAKE#: *** [all] Error $err\n", 512);
     100              '', "$out#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
    85101
    861021;
  • vendor/gnumake/current/tests/scripts/variables/define

    r2596 r3138  
    3131endef
    3232
     33define posix ::=
     34@echo $(FOO)
     35endef
     36
    3337append = @echo a
    3438
     
    5054all: ; $(multi)
    5155        $(simple)
     56        $(posix)
    5257        $(append)
    5358        $(cond)
    5459',
    55               '', "echo hi\nhi\nthere\nfoo\na\nb\nfirst\n");
     60              '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n");
     61
     62# TEST 1a: Various new-style define/endef, with no spaces
     63
     64run_make_test('
     65FOO = foo
     66
     67define multi=
     68echo hi
     69@echo $(FOO)
     70endef # this is the end
     71
     72define simple:=
     73@echo $(FOO)
     74endef
     75
     76define posix::=
     77@echo $(FOO)
     78endef
     79
     80append = @echo a
     81
     82define append+=
     83
     84@echo b
     85endef
     86
     87define cond?= # this is a conditional
     88@echo first
     89endef
     90
     91define cond?=
     92@echo second
     93endef
     94
     95FOO = there
     96
     97all: ; $(multi)
     98        $(simple)
     99        $(posix)
     100        $(append)
     101        $(cond)
     102',
     103              '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n");
    56104
    57105# TEST 2: define in true section of conditional (containing conditional)
     
    113161all: ; @echo ok
    114162',
    115               '', "#MAKEFILE#:3: extraneous text after `define' directive\nok\n");
     163              '', "#MAKEFILE#:3: extraneous text after 'define' directive\nok\n");
    116164
    117165# TEST 7: NEGATIVE: extra text after endef
     
    124172all: ; @echo ok
    125173',
    126               '', "#MAKEFILE#:5: extraneous text after `endef' directive\nok\n");
     174              '', "#MAKEFILE#:5: extraneous text after 'endef' directive\nok\n");
    127175
    128176# TEST 8: NEGATIVE: missing endef
     
    135183endef$(NAME)
    136184',
    137               '', "#MAKEFILE#:4: *** missing `endef', unterminated `define'.  Stop.\n", 512);
     185              '', "#MAKEFILE#:4: *** missing 'endef', unterminated 'define'.  Stop.\n", 512);
    138186
    139187# -------------------------
  • vendor/gnumake/current/tests/scripts/variables/flavors

    r2596 r3138  
    7474              '', "Hello\n");
    7575
     76# TEST 6: Simple using POSIX syntax
     77run_make_test('
     78bar = Goodbye
     79foo ::= $(bar)
     80bar = ${ugh}
     81ugh = Hello
     82all: ; @echo $(foo)
     83',
     84              '', "Goodbye\n");
     85
     86# TEST 7: POSIX syntax no spaces
     87run_make_test('
     88bar = Goodbye
     89foo::=$(bar)
     90bar = ${ugh}
     91ugh = Hello
     92all: ; @echo $(foo)
     93',
     94              '', "Goodbye\n");
     95
    76961;
  • vendor/gnumake/current/tests/scripts/variables/private

    r2596 r3138  
    7676               '', "b=a\na=a\n");
    7777
     78# 9: make sure private suppresses inheritance
     79run_make_test(q!
     80DEFS = FOO
     81all: bar1
     82bar1: private DEFS += 1
     83bar3: private DEFS += 3
     84bar1: bar2
     85bar2: bar3
     86bar1 bar2 bar3: ; @echo '$@: $(DEFS)'
     87!,
     88              '', "bar3: FOO 3\nbar2: FOO\nbar1: FOO 1\n");
     89
     90# 10: Test append with pattern-specific variables and private
     91
     92run_make_test(q!
     93IA = global
     94PA = global
     95PS = global
     96S = global
     97PS = global
     98SV = global
     99b%: IA += b%
     100b%: private PA += b%
     101b%: private PS = b%
     102bar: all
     103bar: IA += bar
     104bar: private PA += bar
     105bar: private PS = bar
     106a%: IA += a%
     107a%: private PA += a%
     108a%: private PS = a%
     109all: IA += all
     110all: private PA += all
     111all: private PS = all
     112
     113bar all: ; @echo '$@: IA=$(IA)'; echo '$@: PA=$(PA)'; echo '$@: PS=$(PS)'
     114!,
     115              '', "all: IA=global b% bar a% all
     116all: PA=global a% all
     117all: PS=all
     118bar: IA=global b% bar
     119bar: PA=global b% bar
     120bar: PS=bar\n");
     121
    781221;
  • vendor/gnumake/current/tests/scripts/variables/special

    r2596 r3138  
    1515BAR := bar
    1616
    17 all:
    18         @echo X1 = $(X1)
    19         @echo X2 = $(X2)
    20         @echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES)))
     17all: ; @echo X1 = $(X1); echo X2 = $(X2); echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES)))
    2118',
    2219               '', "X1 =\nX2 = FOO\nLAST = BAR FOO\n");
    2320
     21# SV 45728: Test that undefining a variable is reflected properly
    2422
     23&run_make_test('
     24FOO := foo
     25BAR := bar
     26$(info one: $(sort $(filter FOO BAR BAZ,$(.VARIABLES))))
     27undefine BAR
     28BAZ := baz
     29$(info two: $(sort $(filter FOO BAR BAZ,$(.VARIABLES))))
     30all:;@:
     31',
     32               '', "one: BAR FOO\ntwo: BAZ FOO\n");
    2533
    2634# $makefile2 = &get_tmpfile;
     
    3240
    3341# all: foo
    34 #       @echo X1 = $(X1)
    35 #       @echo X2 = $(X2)
    36 #       @echo LAST = $(sort $(.TARGETS))
     42#       @echo X1 = $(X1)
     43#       @echo X2 = $(X2)
     44#       @echo LAST = $(sort $(.TARGETS))
    3745
    3846# X2 := $(sort $(.TARGETS))
     
    5462&run_make_test('
    5563define foo
    56 : foo-one \
     64: foo-one\
    5765foo-two
    5866: foo-three
     
    115123: foo-four');
    116124
     125# Test that the "did you mean TAB" message is printed properly
     126
     127run_make_test(q!
     128$x.
     129!,
     130              '', '#MAKEFILE#:2: *** missing separator.  Stop.', 512);
     131
     132run_make_test(q!
     133foo:
     134        bar
     135!,
     136              '', '#MAKEFILE#:3: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.', 512);
     137
     138run_make_test(q!
     139.RECIPEPREFIX = :
     140foo:
     141        bar
     142!,
     143              '', '#MAKEFILE#:4: *** missing separator.  Stop.', 512);
     144
    1171451;
     146
     147### Local Variables:
     148### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     149### End:
  • vendor/gnumake/current/tests/test_driver.pl

    r2596 r3138  
    66# Modified 92-02-11 through 92-02-22 by Chris Arthur to further generalize.
    77#
    8 # Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
    9 # 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    10 # Foundation, Inc.
     8# Copyright (C) 1991-2016 Free Software Foundation, Inc.
    119# This file is part of GNU Make.
    1210#
     
    3129# variables and then calls &toplevel, which does all the real work.
    3230
    33 # $Id: test_driver.pl,v 1.30 2010/07/28 05:39:50 psmith Exp $
     31# $Id$
    3432
    3533
     
    5149$test_passed = 1;
    5250
    53 
    5451# Timeout in seconds.  If the test takes longer than this we'll fail it.
    5552$test_timeout = 5;
     53$test_timeout = 10 if $^O eq 'VMS';
    5654
    5755# Path to Perl
     
    6563%extraENV = ();
    6664
     65sub vms_get_process_logicals {
     66  # Sorry for the long note here, but to keep this test running on
     67  # VMS, it is needed to be understood.
     68  #
     69  # Perl on VMS by default maps the %ENV array to the system wide logical
     70  # name table.
     71  #
     72  # This is a very large dynamically changing table.
     73  # On Linux, this would be the equivalent of a table that contained
     74  # every mount point, temporary pipe, and symbolic link on every
     75  # file system.  You normally do not have permission to clear or replace it,
     76  # and if you did, the results would be catastrophic.
     77  #
     78  # On VMS, added/changed %ENV items show up in the process logical
     79  # name table.  So to track changes, a copy of it needs to be captured.
     80
     81  my $raw_output = `show log/process/access_mode=supervisor`;
     82  my @raw_output_lines = split('\n',$raw_output);
     83  my %log_hash;
     84  foreach my $line (@raw_output_lines) {
     85    if ($line =~ /^\s+"([A-Za-z\$_]+)"\s+=\s+"(.+)"$/) {
     86      $log_hash{$1} = $2;
     87    }
     88  }
     89  return \%log_hash
     90}
     91
    6792# %origENV is the caller's original environment
    68 %origENV = %ENV;
     93if ($^O ne 'VMS') {
     94  %origENV = %ENV;
     95} else {
     96  my $proc_env = vms_get_process_logicals;
     97  %origENV = %{$proc_env};
     98}
    6999
    70100sub resetENV
     
    73103  # through Perl 5.004.  It was fixed in Perl 5.004_01, but we don't
    74104  # want to require that here, so just delete each one individually.
    75   foreach $v (keys %ENV) {
    76     delete $ENV{$v};
    77   }
    78 
    79   %ENV = %makeENV;
     105
     106  if ($^O ne 'VMS') {
     107    foreach $v (keys %ENV) {
     108      delete $ENV{$v};
     109    }
     110
     111    %ENV = %makeENV;
     112  } else {
     113    my $proc_env = vms_get_process_logicals();
     114    my %delta = %{$proc_env};
     115    foreach my $v (keys %delta) {
     116      if (exists $origENV{$v}) {
     117        if ($origENV{$v} ne $delta{$v}) {
     118          $ENV{$v} = $origENV{$v};
     119        }
     120      } else {
     121        delete $ENV{$v};
     122      }
     123    }
     124  }
     125
    80126  foreach $v (keys %extraENV) {
    81127    $ENV{$v} = $extraENV{$v};
     
    90136  foreach (# UNIX-specific things
    91137           'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
     138           'LD_LIBRARY_PATH',
    92139           # Purify things
    93140           'PURIFYOPTIONS',
     
    107154  # Replace the environment with the new one
    108155  #
    109   %origENV = %ENV;
     156  %origENV = %ENV unless $^O eq 'VMS';
    110157
    111158  resetENV();
     
    132179  &parse_command_line (@ARGV);
    133180
    134   print "OS name = `$osname'\n" if $debug;
     181  print "OS name = '$osname'\n" if $debug;
    135182
    136183  $workpath = "$cwdslash$workdir";
     
    140187
    141188  &print_banner;
     189
     190  if ($osname eq 'VMS' && $cwdslash eq "")
     191  {
     192    # Porting this script to VMS revealed a small bug in opendir() not
     193    # handling search lists correctly when the directory only exists in
     194    # one of the logical_devices.  Need to find the first directory in
     195    # the search list, as that is where things will be written to.
     196    my @dirs = split("/", $pwd);
     197
     198    my $logical_device = $ENV{$dirs[1]};
     199    if ($logical_device =~ /([A-Za-z0-9_]+):(:?.+:)+/)
     200    {
     201        # A search list was found.  Grab the first logical device
     202        # and use it instead of the search list.
     203        $dirs[1]=$1;
     204        my $lcl_pwd = join('/', @dirs);
     205        $workpath = $lcl_pwd . '/' . $workdir
     206    }
     207  }
    142208
    143209  if (-d $workpath)
     
    167233        push (@rmdirs, $dir);
    168234        -d "$workpath/$dir"
    169            || mkdir ("$workpath/$dir", 0777)
     235           || mkdir ("$workpath/$dir", 0777)
    170236           || &error ("Couldn't mkdir $workpath/$dir: $!\n");
    171237      }
     
    176242    print "Finding tests...\n";
    177243    opendir (SCRIPTDIR, $scriptpath)
    178         || &error ("Couldn't opendir $scriptpath: $!\n");
     244        || &error ("Couldn't opendir $scriptpath: $!\n");
    179245    @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR) );
    180246    closedir (SCRIPTDIR);
     
    183249      next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d "$scriptpath/$dir");
    184250      push (@rmdirs, $dir);
     251      # VMS can have overlayed file systems, so directories may repeat.
     252      next if -d "$workpath/$dir";
    185253      mkdir ("$workpath/$dir", 0777)
    186            || &error ("Couldn't mkdir $workpath/$dir: $!\n");
     254          || &error ("Couldn't mkdir $workpath/$dir: $!\n");
    187255      opendir (SCRIPTDIR, "$scriptpath/$dir")
    188           || &error ("Couldn't opendir $scriptpath/$dir: $!\n");
     256          || &error ("Couldn't opendir $scriptpath/$dir: $!\n");
    189257      @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR) );
    190258      closedir (SCRIPTDIR);
     
    192260      {
    193261        -d $test and next;
    194         push (@TESTS, "$dir/$test");
     262        push (@TESTS, "$dir/$test");
    195263      }
    196264    }
     
    204272  print "\n";
    205273
    206   &run_each_test;
     274  run_all_tests();
    207275
    208276  foreach $dir (@rmdirs)
     
    222290    print " in $categories_failed Categor";
    223291    print ($categories_failed == 1 ? "y" : "ies");
    224     print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n";
     292    print " Failed (See .$diffext* files in $workdir dir for details) :-(\n\n";
    225293    return 0;
    226294  }
     
    241309  $osname = defined($^O) ? $^O : '';
    242310
     311  if ($osname eq 'VMS')
     312  {
     313    $vos = 0;
     314    $pathsep = "/";
     315    return;
     316  }
     317
    243318  # Find a path to Perl
    244319
     
    277352    if ($osname =~ /not found/i)
    278353    {
    279         $osname = "(something posixy with no uname)";
     354        $osname = "(something posixy with no uname)";
    280355    }
    281356    elsif ($@ ne "" || $?)
     
    284359        if ($@ ne "" || $?)
    285360        {
    286             $osname = "(something posixy)";
    287         }
     361            $osname = "(something posixy)";
     362        }
    288363    }
    289364    $vos = 0;
     
    417492}
    418493
    419 sub run_each_test
    420 {
    421   $categories_run = 0;
    422 
    423   foreach $testname (sort @TESTS)
    424   {
    425     ++$categories_run;
    426     $suite_passed = 1;       # reset by test on failure
    427     $num_of_logfiles = 0;
    428     $num_of_tmpfiles = 0;
    429     $description = "";
    430     $details = "";
    431     $old_makefile = undef;
    432     $testname =~ s/^$scriptpath$pathsep//;
    433     $perl_testname = "$scriptpath$pathsep$testname";
    434     $testname =~ s/(\.pl|\.perl)$//;
    435     $testpath = "$workpath$pathsep$testname";
    436     # Leave enough space in the extensions to append a number, even
    437     # though it needs to fit into 8+3 limits.
    438     if ($short_filenames) {
    439       $logext = 'l';
    440       $diffext = 'd';
    441       $baseext = 'b';
    442       $runext = 'r';
    443       $extext = '';
    444     } else {
    445       $logext = 'log';
    446       $diffext = 'diff';
    447       $baseext = 'base';
    448       $runext = 'run';
    449       $extext = '.';
    450     }
    451     $log_filename = "$testpath.$logext";
    452     $diff_filename = "$testpath.$diffext";
    453     $base_filename = "$testpath.$baseext";
    454     $run_filename = "$testpath.$runext";
    455     $tmp_filename = "$testpath.$tmpfilesuffix";
    456 
    457     &setup_for_test;          # suite-defined
    458 
    459     $output = "........................................................ ";
    460 
    461     substr($output,0,length($testname)) = "$testname ";
    462 
    463     print $output;
    464 
    465     # Run the actual test!
    466     $tests_run = 0;
    467     $tests_passed = 0;
    468 
    469     $code = do $perl_testname;
    470 
    471     $total_tests_run += $tests_run;
    472     $total_tests_passed += $tests_passed;
    473 
    474     # How did it go?
    475     if (!defined($code))
    476     {
    477       $suite_passed = 0;
    478       if (length ($@)) {
    479         warn "\n*** Test died ($testname): $@\n";
    480       } else {
    481         warn "\n*** Couldn't run $perl_testname\n";
    482       }
    483     }
    484     elsif ($code == -1) {
    485       $suite_passed = 0;
    486     }
    487     elsif ($code != 1 && $code != -1) {
    488       $suite_passed = 0;
    489       warn "\n*** Test returned $code\n";
    490     }
    491 
    492     if ($suite_passed) {
    493       ++$categories_passed;
    494       $status = "ok     ($tests_passed passed)";
    495       for ($i = $num_of_tmpfiles; $i; $i--)
    496       {
    497         &rmfiles ($tmp_filename . &num_suffix ($i) );
    498       }
    499 
    500       for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--)
    501       {
    502         &rmfiles ($log_filename . &num_suffix ($i) );
    503         &rmfiles ($base_filename . &num_suffix ($i) );
    504       }
    505     }
    506     elsif (!defined $code || $code > 0) {
    507       $status = "FAILED ($tests_passed/$tests_run passed)";
    508     }
    509     elsif ($code < 0) {
    510       $status = "N/A";
    511       --$categories_run;
    512     }
    513 
    514     # If the verbose option has been specified, then a short description
    515     # of each test is printed before displaying the results of each test
    516     # describing WHAT is being tested.
    517 
    518     if ($verbose)
    519     {
    520       if ($detail)
    521       {
    522         print "\nWHAT IS BEING TESTED\n";
    523         print "--------------------";
    524       }
    525       print "\n\n$description\n\n";
    526     }
    527 
    528     # If the detail option has been specified, then the details of HOW
    529     # the test is testing what it says it is testing in the verbose output
    530     # will be displayed here before the results of the test are displayed.
    531 
    532     if ($detail)
    533     {
    534       print "\nHOW IT IS TESTED\n";
    535       print "----------------";
    536       print "\n\n$details\n\n";
    537     }
    538 
    539     print "$status\n";
    540   }
     494sub run_all_tests
     495{
     496    $categories_run = 0;
     497
     498    $lasttest = '';
     499    foreach $testname (sort @TESTS) {
     500        # Skip duplicates on VMS caused by logical name search lists.
     501        next if $testname eq $lasttest;
     502        $lasttest = $testname;
     503        $suite_passed = 1;       # reset by test on failure
     504        $num_of_logfiles = 0;
     505        $num_of_tmpfiles = 0;
     506        $description = "";
     507        $details = "";
     508        $old_makefile = undef;
     509        $testname =~ s/^$scriptpath$pathsep//;
     510        $perl_testname = "$scriptpath$pathsep$testname";
     511        $testname =~ s/(\.pl|\.perl)$//;
     512        $testpath = "$workpath$pathsep$testname";
     513        # Leave enough space in the extensions to append a number, even
     514        # though it needs to fit into 8+3 limits.
     515        if ($short_filenames) {
     516            $logext = 'l';
     517            $diffext = 'd';
     518            $baseext = 'b';
     519            $runext = 'r';
     520            $extext = '';
     521        } else {
     522            $logext = 'log';
     523            $diffext = 'diff';
     524            $baseext = 'base';
     525            $runext = 'run';
     526            $extext = '.';
     527        }
     528        $extext = '_' if $^O eq 'VMS';
     529        $log_filename = "$testpath.$logext";
     530        $diff_filename = "$testpath.$diffext";
     531        $base_filename = "$testpath.$baseext";
     532        $run_filename = "$testpath.$runext";
     533        $tmp_filename = "$testpath.$tmpfilesuffix";
     534
     535        setup_for_test();
     536
     537        $output = "........................................................ ";
     538
     539        substr($output,0,length($testname)) = "$testname ";
     540
     541        print $output;
     542
     543        $tests_run = 0;
     544        $tests_passed = 0;
     545
     546        # Run the test!
     547        $code = do $perl_testname;
     548
     549        ++$categories_run;
     550        $total_tests_run += $tests_run;
     551        $total_tests_passed += $tests_passed;
     552
     553        # How did it go?
     554        if (!defined($code)) {
     555            # Failed to parse or called die
     556            if (length ($@)) {
     557                warn "\n*** Test died ($testname): $@\n";
     558            } else {
     559                warn "\n*** Couldn't parse $perl_testname\n";
     560            }
     561            $status = "FAILED ($tests_passed/$tests_run passed)";
     562        }
     563
     564        elsif ($code == -1) {
     565            # Skipped... not supported
     566            $status = "N/A";
     567            --$categories_run;
     568        }
     569
     570        elsif ($code != 1) {
     571            # Bad result... this shouldn't really happen.  Usually means that
     572            # the suite forgot to end with "1;".
     573            warn "\n*** Test returned $code\n";
     574            $status = "FAILED ($tests_passed/$tests_run passed)";
     575        }
     576
     577        elsif ($tests_run == 0) {
     578            # Nothing was done!!
     579            $status = "FAILED (no tests found!)";
     580        }
     581
     582        elsif ($tests_run > $tests_passed) {
     583            # Lose!
     584            $status = "FAILED ($tests_passed/$tests_run passed)";
     585        }
     586
     587        else {
     588            # Win!
     589            ++$categories_passed;
     590            $status = "ok     ($tests_passed passed)";
     591
     592            # Clean up
     593            for ($i = $num_of_tmpfiles; $i; $i--) {
     594                rmfiles($tmp_filename . num_suffix($i));
     595            }
     596            for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--) {
     597                rmfiles($log_filename . num_suffix($i));
     598                rmfiles($base_filename . num_suffix($i));
     599            }
     600        }
     601
     602        # If the verbose option has been specified, then a short description
     603        # of each test is printed before displaying the results of each test
     604        # describing WHAT is being tested.
     605
     606        if ($verbose) {
     607            if ($detail) {
     608                print "\nWHAT IS BEING TESTED\n";
     609                print "--------------------";
     610            }
     611            print "\n\n$description\n\n";
     612        }
     613
     614        # If the detail option has been specified, then the details of HOW
     615        # the test is testing what it says it is testing in the verbose output
     616        # will be displayed here before the results of the test are displayed.
     617
     618        if ($detail) {
     619            print "\nHOW IT IS TESTED\n";
     620            print "----------------";
     621            print "\n\n$details\n\n";
     622        }
     623
     624        print "$status\n";
     625    }
    541626}
    542627
     
    655740  local($slurp, $answer_matched) = ('', 0);
    656741
    657   print "Comparing Output ........ " if $debug;
    658 
    659   $slurp = &read_file_into_string ($logfile);
    660 
    661   # For make, get rid of any time skew error before comparing--too bad this
    662   # has to go into the "generic" driver code :-/
    663   $slurp =~ s/^.*modification time .*in the future.*\n//gm;
    664   $slurp =~ s/^.*Clock skew detected.*\n//gm;
    665 
    666742  ++$tests_run;
    667743
    668   if ($slurp eq $answer) {
    669     $answer_matched = 1;
     744  if (! defined $answer) {
     745      print "Ignoring output ........ " if $debug;
     746      $answer_matched = 1;
    670747  } else {
    671     # See if it is a slash or CRLF problem
    672     local ($answer_mod, $slurp_mod) = ($answer, $slurp);
    673 
    674     $answer_mod =~ tr,\\,/,;
    675     $answer_mod =~ s,\r\n,\n,gs;
    676 
    677     $slurp_mod =~ tr,\\,/,;
    678     $slurp_mod =~ s,\r\n,\n,gs;
    679 
    680     $answer_matched = ($slurp_mod eq $answer_mod);
    681 
    682     # If it still doesn't match, see if the answer might be a regex.
    683     if (!$answer_matched && $answer =~ m,^/(.+)/$,) {
    684       $answer_matched = ($slurp =~ /$1/);
    685       if (!$answer_matched && $answer_mod =~ m,^/(.+)/$,) {
    686           $answer_matched = ($slurp_mod =~ /$1/);
     748      print "Comparing Output ........ " if $debug;
     749
     750      $slurp = &read_file_into_string ($logfile);
     751
     752      # For make, get rid of any time skew error before comparing--too bad this
     753      # has to go into the "generic" driver code :-/
     754      $slurp =~ s/^.*modification time .*in the future.*\n//gm;
     755      $slurp =~ s/^.*Clock skew detected.*\n//gm;
     756
     757      if ($slurp eq $answer) {
     758          $answer_matched = 1;
     759      } else {
     760          # See if it is a slash or CRLF problem
     761          local ($answer_mod, $slurp_mod) = ($answer, $slurp);
     762
     763          $answer_mod =~ tr,\\,/,;
     764          $answer_mod =~ s,\r\n,\n,gs;
     765
     766          $slurp_mod =~ tr,\\,/,;
     767          $slurp_mod =~ s,\r\n,\n,gs;
     768
     769          $answer_matched = ($slurp_mod eq $answer_mod);
     770          if ($^O eq 'VMS') {
     771
     772            # VMS has extra blank lines in output sometimes.
     773            # Ticket #41760
     774            if (!$answer_matched) {
     775              $slurp_mod =~ s/\n\n+/\n/gm;
     776              $slurp_mod =~ s/\A\n+//g;
     777              $answer_matched = ($slurp_mod eq $answer_mod);
     778            }
     779
     780            # VMS adding a "Waiting for unfinished jobs..."
     781            # Remove it for now to see what else is going on.
     782            if (!$answer_matched) {
     783              $slurp_mod =~ s/^.+\*\*\* Waiting for unfinished jobs.+$//m;
     784              $slurp_mod =~ s/\n\n/\n/gm;
     785              $slurp_mod =~ s/^\n+//gm;
     786              $answer_matched = ($slurp_mod eq $answer_mod);
     787            }
     788
     789            # VMS wants target device to exist or generates an error,
     790            # Some test tagets look like VMS devices and trip this.
     791            if (!$answer_matched) {
     792              $slurp_mod =~ s/^.+\: no such device or address.*$//gim;
     793              $slurp_mod =~ s/\n\n/\n/gm;
     794              $slurp_mod =~ s/^\n+//gm;
     795              $answer_matched = ($slurp_mod eq $answer_mod);
     796            }
     797
     798            # VMS error message has a different case
     799            if (!$answer_matched) {
     800              $slurp_mod =~ s/no such file /No such file /gm;
     801              $answer_matched = ($slurp_mod eq $answer_mod);
     802            }
     803
     804            # VMS is putting comas instead of spaces in output
     805            if (!$answer_matched) {
     806              $slurp_mod =~ s/,/ /gm;
     807              $answer_matched = ($slurp_mod eq $answer_mod);
     808            }
     809
     810            # VMS Is sometimes adding extra leading spaces to output?
     811            if (!$answer_matched) {
     812               my $slurp_mod = $slurp_mod;
     813               $slurp_mod =~ s/^ +//gm;
     814               $answer_matched = ($slurp_mod eq $answer_mod);
     815            }
     816
     817            # VMS port not handling POSIX encoded child status
     818            # Translate error case it for now.
     819            if (!$answer_matched) {
     820              $slurp_mod =~ s/0x1035a00a/1/gim;
     821              $answer_matched = 1 if $slurp_mod =~ /\Q$answer_mod\E/i;
     822
     823            }
     824            if (!$answer_matched) {
     825              $slurp_mod =~ s/0x1035a012/2/gim;
     826              $answer_matched = ($slurp_mod eq $answer_mod);
     827            }
     828
     829            # Tests are using a UNIX null command, temp hack
     830            # until this can be handled by the VMS port.
     831            # ticket # 41761
     832            if (!$answer_matched) {
     833              $slurp_mod =~ s/^.+DCL-W-NOCOMD.*$//gim;
     834              $slurp_mod =~ s/\n\n+/\n/gm;
     835              $slurp_mod =~ s/^\n+//gm;
     836              $answer_matched = ($slurp_mod eq $answer_mod);
     837            }
     838            # Tests are using exit 0;
     839            # this generates a warning that should stop the make, but does not
     840            if (!$answer_matched) {
     841              $slurp_mod =~ s/^.+NONAME-W-NOMSG.*$//gim;
     842              $slurp_mod =~ s/\n\n+/\n/gm;
     843              $slurp_mod =~ s/^\n+//gm;
     844              $answer_matched = ($slurp_mod eq $answer_mod);
     845            }
     846
     847            # VMS is sometimes adding single quotes to output?
     848            if (!$answer_matched) {
     849              my $noq_slurp_mod = $slurp_mod;
     850              $noq_slurp_mod =~ s/\'//gm;
     851              $answer_matched = ($noq_slurp_mod eq $answer_mod);
     852
     853              # And missing an extra space in output
     854              if (!$answer_matched) {
     855                $noq_answer_mod = $answer_mod;
     856                $noq_answer_mod =~ s/\h\h+/ /gm;
     857                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     858              }
     859
     860              # VMS adding ; to end of some lines.
     861              if (!$answer_matched) {
     862                $noq_slurp_mod =~ s/;\n/\n/gm;
     863                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     864              }
     865
     866              # VMS adding trailing space to end of some quoted lines.
     867              if (!$answer_matched) {
     868                $noq_slurp_mod =~ s/\h+\n/\n/gm;
     869                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     870              }
     871
     872              # And VMS missing leading blank line
     873              if (!$answer_matched) {
     874                $noq_answer_mod =~ s/\A\n//g;
     875                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     876              }
     877
     878              # Unix double quotes showing up as single quotes on VMS.
     879              if (!$answer_matched) {
     880                $noq_answer_mod =~ s/\"//g;
     881                $answer_matched = ($noq_slurp_mod eq $noq_answer_mod);
     882              }
     883            }
     884          }
     885
     886          # If it still doesn't match, see if the answer might be a regex.
     887          if (!$answer_matched && $answer =~ m,^/(.+)/$,) {
     888              $answer_matched = ($slurp =~ /$1/);
     889              if (!$answer_matched && $answer_mod =~ m,^/(.+)/$,) {
     890                  $answer_matched = ($slurp_mod =~ /$1/);
     891              }
     892          }
    687893      }
    688     }
    689894  }
    690895
     
    708913    local($command) = "diff -c " . &get_basefile . " " . $logfile;
    709914    &run_command_with_output(&get_difffile,$command);
    710   } else {
    711       &rmfiles ();
    712   }
    713 
    714   $suite_passed = 0;
     915  }
     916
    715917  return 0;
    716918}
     
    732934}
    733935
     936my @OUTSTACK = ();
     937my @ERRSTACK = ();
     938
    734939sub attach_default_output
    735940{
     
    744949  }
    745950
    746   open ("SAVEDOS" . $default_output_stack_level . "out", ">&STDOUT")
    747         || &error ("ado: $! duping STDOUT\n", 1);
    748   open ("SAVEDOS" . $default_output_stack_level . "err", ">&STDERR")
    749         || &error ("ado: $! duping STDERR\n", 1);
    750 
    751   open (STDOUT, "> " . $filename)
    752         || &error ("ado: $filename: $!\n", 1);
    753   open (STDERR, ">&STDOUT")
    754         || &error ("ado: $filename: $!\n", 1);
    755 
    756   $default_output_stack_level++;
     951  my $dup = undef;
     952  open($dup, '>&', STDOUT) or error("ado: $! duping STDOUT\n", 1);
     953  push @OUTSTACK, $dup;
     954
     955  $dup = undef;
     956  open($dup, '>&', STDERR) or error("ado: $! duping STDERR\n", 1);
     957  push @ERRSTACK, $dup;
     958
     959  open(STDOUT, '>', $filename) or error("ado: $filename: $!\n", 1);
     960  open(STDERR, ">&STDOUT") or error("ado: $filename: $!\n", 1);
    757961}
    758962
     
    771975  }
    772976
    773   if (--$default_output_stack_level < 0)
    774   {
    775     &error ("default output stack has flown under!\n", 1);
    776   }
    777 
    778   close (STDOUT);
    779   close (STDERR);
    780 
    781   open (STDOUT, ">&SAVEDOS" . $default_output_stack_level . "out")
    782         || &error ("ddo: $! duping STDOUT\n", 1);
    783   open (STDERR, ">&SAVEDOS" . $default_output_stack_level . "err")
    784         || &error ("ddo: $! duping STDERR\n", 1);
    785 
    786   close ("SAVEDOS" . $default_output_stack_level . "out")
    787         || &error ("ddo: $! closing SCSDOSout\n", 1);
    788   close ("SAVEDOS" . $default_output_stack_level . "err")
    789          || &error ("ddo: $! closing SAVEDOSerr\n", 1);
     977  @OUTSTACK or error("default output stack has flown under!\n", 1);
     978
     979  close(STDOUT);
     980  close(STDERR) unless $^O eq 'VMS';
     981
     982
     983  open (STDOUT, '>&', pop @OUTSTACK) or error("ddo: $! duping STDOUT\n", 1);
     984  open (STDERR, '>&', pop @ERRSTACK) or error("ddo: $! duping STDERR\n", 1);
    790985}
    791986
     
    801996
    802997  eval {
    803       local $SIG{ALRM} = sub { die "timeout\n"; };
    804       alarm $test_timeout;
    805       $code = system(@_);
     998      if ($^O eq 'VMS') {
     999          local $SIG{ALRM} = sub {
     1000              my $e = $ERRSTACK[0];
     1001              print $e "\nTest timed out after $test_timeout seconds\n";
     1002              die "timeout\n"; };
     1003#          alarm $test_timeout;
     1004          system(@_);
     1005          my $severity = ${^CHILD_ERROR_NATIVE} & 7;
     1006          $code = 0;
     1007          if (($severity & 1) == 0) {
     1008              $code = 512;
     1009          }
     1010
     1011          # Get the vms status.
     1012          my $vms_code = ${^CHILD_ERROR_NATIVE};
     1013
     1014          # Remove the print status bit
     1015          $vms_code &= ~0x10000000;
     1016
     1017          # Posix code translation.
     1018          if (($vms_code & 0xFFFFF000) == 0x35a000) {
     1019              $code = (($vms_code & 0xFFF) >> 3) * 256;
     1020          }
     1021      } else {
     1022          my $pid = fork();
     1023          if (! $pid) {
     1024              exec(@_) or die "Cannot execute $_[0]\n";
     1025          }
     1026          local $SIG{ALRM} = sub { my $e = $ERRSTACK[0]; print $e "\nTest timed out after $test_timeout seconds\n"; die "timeout\n"; };
     1027          alarm $test_timeout;
     1028          waitpid($pid, 0) > 0 or die "No such pid: $pid\n";
     1029          $code = $?;
     1030      }
    8061031      alarm 0;
    8071032  };
    8081033  if ($@) {
    8091034      # The eval failed.  If it wasn't SIGALRM then die.
    810       $@ eq "timeout\n" or die;
     1035      $@ eq "timeout\n" or die "Command failed: $@";
    8111036
    8121037      # Timed out.  Resend the alarm to our process group to kill the children.
     
    8271052  my $code = _run_command(@_);
    8281053  print "run_command returned $code.\n" if $debug;
    829 
     1054  print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $^O eq 'VMS';
    8301055  return $code;
    8311056}
     
    8421067  print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
    8431068  &attach_default_output ($filename);
    844   my $code = _run_command(@_);
     1069  my $code = eval { _run_command(@_) };
     1070  my $err = $@;
    8451071  &detach_default_output;
     1072
     1073  $err and die $err;
     1074
    8461075  print "run_command_with_output returned $code.\n" if $debug;
    847 
     1076  print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $^O eq 'VMS';
    8481077  return $code;
    8491078}
     
    9051134    else
    9061135    {
    907       unlink $object || return 0;
     1136      if ($^O ne 'VMS')
     1137      {
     1138        unlink $object || return 0;
     1139      }
     1140      else
     1141      {
     1142        # VMS can have multiple versions of a file.
     1143        1 while unlink $object;
     1144      }
    9081145    }
    9091146  }
     
    9431180  foreach $file (@_) {
    9441181    (open(T, ">> $file") && print(T "\n") && close(T))
    945         || &error("Couldn't touch $file: $!\n", 1);
     1182        || &error("Couldn't touch $file: $!\n", 1);
    9461183  }
    9471184}
  • vendor/gnumake/current/variable.c

    r2596 r3138  
    11/* Internals of variables for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018
    2119#include <assert.h>
    2220
     21#include "filedef.h"
    2322#include "dep.h"
    24 #include "filedef.h"
    2523#include "job.h"
    2624#include "commands.h"
     
    3129#endif
    3230#include "hash.h"
     31
     32/* Incremented every time we add or remove a global variable.  */
     33static unsigned long variable_changenum;
    3334
    3435/* Chain of all pattern-specific variables.  */
     
    101102{
    102103  struct pattern_var *p;
    103   unsigned int targlen = strlen(target);
     104  unsigned int targlen = strlen (target);
    104105
    105106  for (p = start ? start->next : pattern_vars; p != 0; p = p->next)
     
    162163}
    163164
    164 #ifndef VARIABLE_BUCKETS
    165 #define VARIABLE_BUCKETS                523
     165#ifndef VARIABLE_BUCKETS
     166#define VARIABLE_BUCKETS                523
    166167#endif
    167 #ifndef PERFILE_VARIABLE_BUCKETS
    168 #define PERFILE_VARIABLE_BUCKETS        23
     168#ifndef PERFILE_VARIABLE_BUCKETS
     169#define PERFILE_VARIABLE_BUCKETS        23
    169170#endif
    170 #ifndef SMALL_SCOPE_VARIABLE_BUCKETS
    171 #define SMALL_SCOPE_VARIABLE_BUCKETS    13
     171#ifndef SMALL_SCOPE_VARIABLE_BUCKETS
     172#define SMALL_SCOPE_VARIABLE_BUCKETS    13
    172173#endif
    173174
     
    184185{
    185186  hash_init (&global_variable_set.table, VARIABLE_BUCKETS,
    186              variable_hash_1, variable_hash_2, variable_hash_cmp);
     187             variable_hash_1, variable_hash_2, variable_hash_cmp);
    187188}
    188189
     
    198199                        const char *value, enum variable_origin origin,
    199200                        int recursive, struct variable_set *set,
    200                         const struct floc *flocp)
     201                        const floc *flocp)
    201202{
    202203  struct variable *v;
     
    210211  var_key.length = length;
    211212  var_slot = (struct variable **) hash_find_slot (&set->table, &var_key);
     213  v = *var_slot;
     214
     215#ifdef VMS
     216  /* VMS does not populate envp[] with DCL symbols and logical names which
     217     historically are mapped to environent variables.
     218     If the variable is not yet defined, then we need to check if getenv()
     219     can find it.  Do not do this for origin == o_env to avoid infinte
     220     recursion */
     221  if (HASH_VACANT (v) && (origin != o_env))
     222    {
     223      struct variable * vms_variable;
     224      char * vname = alloca (length + 1);
     225      char * vvalue;
     226
     227      strncpy (vname, name, length);
     228      vvalue = getenv(vname);
     229
     230      /* Values starting with '$' are probably foreign commands.
     231         We want to treat them as Shell aliases and not look them up here */
     232      if ((vvalue != NULL) && (vvalue[0] != '$'))
     233        {
     234          vms_variable =  lookup_variable(name, length);
     235          /* Refresh the slot */
     236          var_slot = (struct variable **) hash_find_slot (&set->table,
     237                                                          &var_key);
     238          v = *var_slot;
     239        }
     240    }
     241#endif
    212242
    213243  if (env_overrides && origin == o_env)
    214244    origin = o_env_override;
    215245
    216   v = *var_slot;
    217246  if (! HASH_VACANT (v))
    218247    {
    219248      if (env_overrides && v->origin == o_env)
    220         /* V came from in the environment.  Since it was defined
    221            before the switches were parsed, it wasn't affected by -e.  */
    222         v->origin = o_env_override;
     249        /* V came from in the environment.  Since it was defined
     250           before the switches were parsed, it wasn't affected by -e.  */
     251        v->origin = o_env_override;
    223252
    224253      /* A variable of this name is already defined.
    225         If the old definition is from a stronger source
    226         than this one, don't redefine it.  */
     254        If the old definition is from a stronger source
     255        than this one, don't redefine it.  */
    227256      if ((int) origin >= (int) v->origin)
    228         {
    229           if (v->value != 0)
    230             free (v->value);
    231           v->value = xstrdup (value);
     257        {
     258          free (v->value);
     259          v->value = xstrdup (value);
    232260          if (flocp != 0)
    233261            v->fileinfo = *flocp;
    234262          else
    235263            v->fileinfo.filenm = 0;
    236           v->origin = origin;
    237           v->recursive = recursive;
    238         }
     264          v->origin = origin;
     265          v->recursive = recursive;
     266        }
    239267      return v;
    240268    }
     
    246274  v->length = length;
    247275  hash_insert_at (&set->table, v, var_slot);
     276  if (set == &global_variable_set)
     277    ++variable_changenum;
     278
    248279  v->value = xstrdup (value);
    249280  if (flocp != 0)
     
    286317
    287318static void
    288 free_variable_name_and_value (const void *item);
     319free_variable_name_and_value (const void *item)
     320{
     321  struct variable *v = (struct variable *) item;
     322  free (v->name);
     323  free (v->value);
     324}
     325
     326void
     327free_variable_set (struct variable_set_list *list)
     328{
     329  hash_map (&list->set->table, free_variable_name_and_value);
     330  hash_free (&list->set->table, 1);
     331  free (list->set);
     332  free (list);
     333}
    289334
    290335void
     
    311356    {
    312357      if (env_overrides && v->origin == o_env)
    313         /* V came from in the environment.  Since it was defined
    314            before the switches were parsed, it wasn't affected by -e.  */
    315         v->origin = o_env_override;
    316 
    317       /* If the definition is from a stronger source than this one, don't
    318          undefine it.  */
     358        /* V came from in the environment.  Since it was defined
     359           before the switches were parsed, it wasn't affected by -e.  */
     360        v->origin = o_env_override;
     361
     362      /* Undefine only if this undefinition is from an equal or stronger
     363         source than the variable definition.  */
    319364      if ((int) origin >= (int) v->origin)
    320         {
     365        {
    321366          hash_delete_at (&set->table, var_slot);
    322367          free_variable_name_and_value (v);
    323         }
     368          free (v);
     369          if (set == &global_variable_set)
     370            ++variable_changenum;
     371        }
    324372    }
    325373}
     
    338386lookup_special_var (struct variable *var)
    339387{
    340   static unsigned long last_var_count = 0;
     388  static unsigned long last_changenum = 0;
    341389
    342390
     
    366414  */
    367415
    368   if (streq (var->name, ".VARIABLES")
    369       && global_variable_set.table.ht_fill != last_var_count)
     416  if (variable_changenum != last_changenum && streq (var->name, ".VARIABLES"))
    370417    {
    371418      unsigned long max = EXPANSION_INCREMENT (strlen (var->value));
     
    403450      *(p-1) = '\0';
    404451
    405       /* Remember how many variables are in our current count.  Since we never
    406          remove variables from the list, this is a reliable way to know whether
    407          the list is up to date or needs to be recomputed.  */
    408 
    409       last_var_count = global_variable_set.table.ht_fill;
     452      /* Remember the current variable change number.  */
     453      last_changenum = variable_changenum;
    410454    }
    411455
     
    417461/* Lookup a variable whose name is a string starting at NAME
    418462   and with LENGTH chars.  NAME need not be null-terminated.
    419    Returns address of the `struct variable' containing all info
     463   Returns address of the 'struct variable' containing all info
    420464   on the variable, or nil if no such variable is defined.  */
    421465
     
    438482      v = (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key);
    439483      if (v && (!is_parent || !v->private_var))
    440         return v->special ? lookup_special_var (v) : v;
     484        return v->special ? lookup_special_var (v) : v;
    441485
    442486      is_parent |= setlist->next_is_parent;
     
    444488
    445489#ifdef VMS
    446   /* since we don't read envp[] on startup, try to get the
    447      variable via getenv() here. */
     490  /* VMS does not populate envp[] with DCL symbols and logical names which
     491     historically are mapped to enviroment varables and returned by getenv() */
    448492  {
    449493    char *vname = alloca (length + 1);
     
    505549/* Lookup a variable whose name is a string starting at NAME
    506550   and with LENGTH chars in set SET.  NAME need not be null-terminated.
    507    Returns address of the `struct variable' containing all info
     551   Returns address of the 'struct variable' containing all info
    508552   on the variable, or nil if no such variable is defined.  */
    509553
     
    538582    {
    539583      l = (struct variable_set_list *)
    540         xmalloc (sizeof (struct variable_set_list));
     584        xmalloc (sizeof (struct variable_set_list));
    541585      l->set = xmalloc (sizeof (struct variable_set));
    542586      hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS,
     
    642686  set = xmalloc (sizeof (struct variable_set));
    643687  hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS,
    644              variable_hash_1, variable_hash_2, variable_hash_cmp);
     688             variable_hash_1, variable_hash_2, variable_hash_cmp);
    645689
    646690  setlist = (struct variable_set_list *)
     
    653697}
    654698
    655 static void
    656 free_variable_name_and_value (const void *item)
    657 {
    658   struct variable *v = (struct variable *) item;
    659   free (v->name);
    660   free (v->value);
    661 }
    662 
    663 void
    664 free_variable_set (struct variable_set_list *list)
    665 {
    666   hash_map (&list->set->table, free_variable_name_and_value);
    667   hash_free (&list->set->table, 1);
    668   free (list->set);
    669   free (list);
    670 }
    671 
    672699/* Create a new variable set and push it on the current setlist.
    673700   If we're pushing a global scope (that is, the current scope is the global
     
    679706push_new_variable_scope (void)
    680707{
    681   current_variable_set_list = create_new_variable_set();
     708  current_variable_set_list = create_new_variable_set ();
    682709  if (current_variable_set_list->next == &global_setlist)
    683710    {
     
    702729
    703730  /* Can't call this if there's no scope to pop!  */
    704   assert(current_variable_set_list->next != NULL);
     731  assert (current_variable_set_list->next != NULL);
    705732
    706733  if (current_variable_set_list != &global_setlist)
     
    740767  struct variable **from_var_end = from_var_slot + from_set->table.ht_size;
    741768
     769  int inc = to_set == &global_variable_set ? 1 : 0;
     770
    742771  for ( ; from_var_slot < from_var_end; from_var_slot++)
    743772    if (! HASH_VACANT (*from_var_slot))
    744773      {
    745         struct variable *from_var = *from_var_slot;
    746         struct variable **to_var_slot
    747           = (struct variable **) hash_find_slot (&to_set->table, *from_var_slot);
    748         if (HASH_VACANT (*to_var_slot))
    749           hash_insert_at (&to_set->table, from_var, to_var_slot);
    750         else
    751           {
    752             /* GKM FIXME: delete in from_set->table */
    753             free (from_var->value);
    754             free (from_var);
    755           }
     774        struct variable *from_var = *from_var_slot;
     775        struct variable **to_var_slot
     776          = (struct variable **) hash_find_slot (&to_set->table, *from_var_slot);
     777        if (HASH_VACANT (*to_var_slot))
     778          {
     779            hash_insert_at (&to_set->table, from_var, to_var_slot);
     780            variable_changenum += inc;
     781          }
     782        else
     783          {
     784            /* GKM FIXME: delete in from_set->table */
     785            free (from_var->value);
     786            free (from_var);
     787          }
    756788      }
    757789}
     
    787819    {
    788820      if (last0 == 0)
    789         *setlist0 = setlist1;
     821        *setlist0 = setlist1;
    790822      else
    791         last0->next = setlist1;
     823        last0->next = setlist1;
    792824    }
    793825}
     
    800832define_automatic_variables (void)
    801833{
    802 #if defined(WINDOWS32) || defined(__EMX__)
    803   extern char* default_shell;
    804 #else
    805   extern char default_shell[];
    806 #endif
    807   register struct variable *v;
     834  struct variable *v;
    808835  char buf[200];
    809836
     
    812839
    813840  sprintf (buf, "%s%s%s",
    814            version_string,
    815            (remote_description == 0 || remote_description[0] == '\0')
    816            ? "" : "-",
    817            (remote_description == 0 || remote_description[0] == '\0')
    818            ? "" : remote_description);
     841           version_string,
     842           (remote_description == 0 || remote_description[0] == '\0')
     843           ? "" : "-",
     844           (remote_description == 0 || remote_description[0] == '\0')
     845           ? "" : remote_description);
    819846  define_variable_cname ("MAKE_VERSION", buf, o_default, 0);
     847  define_variable_cname ("MAKE_HOST", make_host, o_default, 0);
    820848
    821849#ifdef  __MSDOS__
     
    831859    if (mshp)
    832860      (void) define_variable (shell_str, shlen,
    833                               mshp->value, o_env_override, 0);
     861                              mshp->value, o_env_override, 0);
    834862    else if (comp)
    835863      {
    836         /* $(COMSPEC) shouldn't override $(SHELL).  */
    837         struct variable *shp = lookup_variable (shell_str, shlen);
    838 
    839         if (!shp)
    840           (void) define_variable (shell_str, shlen, comp->value, o_env, 0);
     864        /* $(COMSPEC) shouldn't override $(SHELL).  */
     865        struct variable *shp = lookup_variable (shell_str, shlen);
     866
     867        if (!shp)
     868          (void) define_variable (shell_str, shlen, comp->value, o_env, 0);
    841869      }
    842870  }
     
    856884    if (!replace || !*replace->value)
    857885      if (shell && *shell->value && (shell->origin == o_env
    858           || shell->origin == o_env_override))
    859         {
    860           /* overwrite whatever we got from the environment */
    861           free(shell->value);
    862           shell->value = xstrdup (default_shell);
    863           shell->origin = o_default;
    864         }
     886          || shell->origin == o_env_override))
     887        {
     888          /* overwrite whatever we got from the environment */
     889          free (shell->value);
     890          shell->value = xstrdup (default_shell);
     891          shell->origin = o_default;
     892        }
    865893
    866894    /* Some people do not like cmd to be used as the default
     
    882910      /* overwrite $SHELL */
    883911      (void) define_variable (shell_str, shlen, replace->value,
    884                               replace->origin, 0);
     912                              replace->origin, 0);
    885913    else
    886914      /* provide a definition if there is none */
    887915      (void) define_variable (shell_str, shlen, default_shell,
    888                               o_default, 0);
     916                              o_default, 0);
    889917  }
    890918
     
    919947     the automatic variables they are variations of.  */
    920948
    921 #ifdef VMS
    922   define_variable_cname ("@D", "$(dir $@)", o_automatic, 1);
    923   define_variable_cname ("%D", "$(dir $%)", o_automatic, 1);
    924   define_variable_cname ("*D", "$(dir $*)", o_automatic, 1);
    925   define_variable_cname ("<D", "$(dir $<)", o_automatic, 1);
    926   define_variable_cname ("?D", "$(dir $?)", o_automatic, 1);
    927   define_variable_cname ("^D", "$(dir $^)", o_automatic, 1);
    928   define_variable_cname ("+D", "$(dir $+)", o_automatic, 1);
    929 #else
     949#if defined(__MSDOS__) || defined(WINDOWS32)
     950  /* For consistency, remove the trailing backslash as well as slash.  */
     951  define_variable_cname ("@D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $@)))",
     952                         o_automatic, 1);
     953  define_variable_cname ("%D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $%)))",
     954                         o_automatic, 1);
     955  define_variable_cname ("*D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $*)))",
     956                         o_automatic, 1);
     957  define_variable_cname ("<D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $<)))",
     958                         o_automatic, 1);
     959  define_variable_cname ("?D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $?)))",
     960                         o_automatic, 1);
     961  define_variable_cname ("^D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $^)))",
     962                         o_automatic, 1);
     963  define_variable_cname ("+D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $+)))",
     964                         o_automatic, 1);
     965#else  /* not __MSDOS__, not WINDOWS32 */
    930966  define_variable_cname ("@D", "$(patsubst %/,%,$(dir $@))", o_automatic, 1);
    931967  define_variable_cname ("%D", "$(patsubst %/,%,$(dir $%))", o_automatic, 1);
     
    949985
    950986/* Create a new environment for FILE's commands.
    951    If FILE is nil, this is for the `shell' function.
     987   If FILE is nil, this is for the 'shell' function.
    952988   The child's MAKELEVEL variable is incremented.  */
    953989
     
    9701006
    9711007  hash_init (&table, VARIABLE_BUCKETS,
    972              variable_hash_1, variable_hash_2, variable_hash_cmp);
     1008             variable_hash_1, variable_hash_2, variable_hash_cmp);
    9731009
    9741010  /* Run through all the variable sets in the list,
     
    9801016      v_end = v_slot + set->table.ht_size;
    9811017      for ( ; v_slot < v_end; v_slot++)
    982         if (! HASH_VACANT (*v_slot))
    983           {
    984             struct variable **new_slot;
    985             struct variable *v = *v_slot;
    986 
    987             /* If this is a per-target variable and it hasn't been touched
    988                already then look up the global version and take its export
    989                value.  */
    990             if (v->per_target && v->export == v_default)
    991               {
    992                 struct variable *gv;
    993 
    994                 gv = lookup_variable_in_set (v->name, strlen(v->name),
     1018        if (! HASH_VACANT (*v_slot))
     1019          {
     1020            struct variable **new_slot;
     1021            struct variable *v = *v_slot;
     1022
     1023            /* If this is a per-target variable and it hasn't been touched
     1024               already then look up the global version and take its export
     1025               value.  */
     1026            if (v->per_target && v->export == v_default)
     1027              {
     1028                struct variable *gv;
     1029
     1030                gv = lookup_variable_in_set (v->name, strlen (v->name),
    9951031                                             &global_variable_set);
    996                 if (gv)
    997                   v->export = gv->export;
    998               }
    999 
    1000             switch (v->export)
    1001               {
    1002               case v_default:
    1003                 if (v->origin == o_default || v->origin == o_automatic)
    1004                   /* Only export default variables by explicit request.  */
    1005                   continue;
     1032                if (gv)
     1033                  v->export = gv->export;
     1034              }
     1035
     1036            switch (v->export)
     1037              {
     1038              case v_default:
     1039                if (v->origin == o_default || v->origin == o_automatic)
     1040                  /* Only export default variables by explicit request.  */
     1041                  continue;
    10061042
    10071043                /* The variable doesn't have a name that can be exported.  */
     
    10091045                  continue;
    10101046
    1011                 if (! export_all_variables
    1012                     && v->origin != o_command
    1013                     && v->origin != o_env && v->origin != o_env_override)
    1014                   continue;
    1015                 break;
    1016 
    1017               case v_export:
    1018                 break;
    1019 
    1020               case v_noexport:
    1021                 {
    1022                   /* If this is the SHELL variable and it's not exported,
    1023                      then add the value from our original environment, if
    1024                      the original environment defined a value for SHELL.  */
    1025                   extern struct variable shell_var;
    1026                   if (streq (v->name, "SHELL") && shell_var.value)
    1027                     {
    1028                       v = &shell_var;
    1029                       break;
    1030                     }
    1031                   continue;
    1032                 }
    1033 
    1034               case v_ifset:
    1035                 if (v->origin == o_default)
    1036                   continue;
    1037                 break;
    1038               }
    1039 
    1040             new_slot = (struct variable **) hash_find_slot (&table, v);
    1041             if (HASH_VACANT (*new_slot))
    1042               hash_insert_at (&table, v, new_slot);
    1043           }
    1044     }
    1045 
    1046   makelevel_key.name = MAKELEVEL_NAME;
     1047                if (! export_all_variables
     1048                    && v->origin != o_command
     1049                    && v->origin != o_env && v->origin != o_env_override)
     1050                  continue;
     1051                break;
     1052
     1053              case v_export:
     1054                break;
     1055
     1056              case v_noexport:
     1057                {
     1058                  /* If this is the SHELL variable and it's not exported,
     1059                     then add the value from our original environment, if
     1060                     the original environment defined a value for SHELL.  */
     1061                  if (streq (v->name, "SHELL") && shell_var.value)
     1062                    {
     1063                      v = &shell_var;
     1064                      break;
     1065                    }
     1066                  continue;
     1067                }
     1068
     1069              case v_ifset:
     1070                if (v->origin == o_default)
     1071                  continue;
     1072                break;
     1073              }
     1074
     1075            new_slot = (struct variable **) hash_find_slot (&table, v);
     1076            if (HASH_VACANT (*new_slot))
     1077              hash_insert_at (&table, v, new_slot);
     1078          }
     1079    }
     1080
     1081  makelevel_key.name = (char *)MAKELEVEL_NAME;
    10471082  makelevel_key.length = MAKELEVEL_LENGTH;
    10481083  hash_delete (&table, &makelevel_key);
     
    10551090    if (! HASH_VACANT (*v_slot))
    10561091      {
    1057         struct variable *v = *v_slot;
    1058 
    1059         /* If V is recursively expanded and didn't come from the environment,
    1060            expand its value.  If it came from the environment, it should
    1061            go back into the environment unchanged.  */
    1062         if (v->recursive
    1063             && v->origin != o_env && v->origin != o_env_override)
    1064           {
    1065             char *value = recursively_expand_for_file (v, file);
     1092        struct variable *v = *v_slot;
     1093
     1094        /* If V is recursively expanded and didn't come from the environment,
     1095           expand its value.  If it came from the environment, it should
     1096           go back into the environment unchanged.  */
     1097        if (v->recursive
     1098            && v->origin != o_env && v->origin != o_env_override)
     1099          {
     1100            char *value = recursively_expand_for_file (v, file);
    10661101#ifdef WINDOWS32
    1067             if (strcmp(v->name, "Path") == 0 ||
    1068                 strcmp(v->name, "PATH") == 0)
    1069               convert_Path_to_windows32(value, ';');
     1102            if (strcmp (v->name, "Path") == 0 ||
     1103                strcmp (v->name, "PATH") == 0)
     1104              convert_Path_to_windows32 (value, ';');
    10701105#endif
    1071             *result++ = xstrdup (concat (3, v->name, "=", value));
    1072             free (value);
    1073           }
    1074         else
    1075           {
     1106            *result++ = xstrdup (concat (3, v->name, "=", value));
     1107            free (value);
     1108          }
     1109        else
     1110          {
    10761111#ifdef WINDOWS32
    1077             if (strcmp(v->name, "Path") == 0 ||
    1078                 strcmp(v->name, "PATH") == 0)
    1079               convert_Path_to_windows32(v->value, ';');
     1112            if (strcmp (v->name, "Path") == 0 ||
     1113                strcmp (v->name, "PATH") == 0)
     1114              convert_Path_to_windows32 (v->value, ';');
    10801115#endif
    1081             *result++ = xstrdup (concat (3, v->name, "=", v->value));
    1082           }
     1116            *result++ = xstrdup (concat (3, v->name, "=", v->value));
     1117          }
    10831118      }
    10841119
     
    11081143
    11091144
     1145/* Given a string, shell-execute it and return a malloc'ed string of the
     1146 * result. This removes only ONE newline (if any) at the end, for maximum
     1147 * compatibility with the *BSD makes.  If it fails, returns NULL. */
     1148
     1149static char *
     1150shell_result (const char *p)
     1151{
     1152  char *buf;
     1153  unsigned int len;
     1154  char *args[2];
     1155  char *result;
     1156
     1157  install_variable_buffer (&buf, &len);
     1158
     1159  args[0] = (char *) p;
     1160  args[1] = NULL;
     1161  variable_buffer_output (func_shell_base (variable_buffer, args, 0), "\0", 1);
     1162  result = strdup (variable_buffer);
     1163
     1164  restore_variable_buffer (buf, len);
     1165  return result;
     1166}
     1167
     1168
    11101169/* Given a variable, a value, and a flavor, define the variable.
    11111170   See the try_variable_definition() function for details on the parameters. */
    11121171
    11131172struct variable *
    1114 do_variable_definition (const struct floc *flocp, const char *varname,
     1173do_variable_definition (const floc *flocp, const char *varname,
    11151174                        const char *value, enum variable_origin origin,
    11161175                        enum variable_flavor flavor, int target_var)
     
    11331192      /* A simple variable definition "var := value".  Expand the value.
    11341193         We have to allocate memory since otherwise it'll clobber the
    1135         variable buffer, and we may still need that if we're looking at a
     1194        variable buffer, and we may still need that if we're looking at a
    11361195         target-specific variable.  */
    11371196      p = alloc_value = allocated_variable_expand (value);
    11381197      break;
     1198    case f_shell:
     1199      {
     1200        /* A shell definition "var != value".  Expand value, pass it to
     1201           the shell, and store the result in recursively-expanded var. */
     1202        char *q = allocated_variable_expand (value);
     1203        p = alloc_value = shell_result (q);
     1204        free (q);
     1205        flavor = f_recursive;
     1206        break;
     1207      }
    11391208    case f_conditional:
    11401209      /* A conditional variable definition "var ?= value".
     
    11491218    case f_recursive:
    11501219      /* A recursive variable definition "var = value".
    1151         The value is used verbatim.  */
     1220        The value is used verbatim.  */
    11521221      p = value;
    11531222      break;
     
    12051274            memcpy (&alloc_value[oldlen + 1], val, vallen + 1);
    12061275
    1207             if (tp)
    1208               free (tp);
     1276            free (tp);
    12091277          }
    12101278      }
     
    12141282  /* Many Unix Makefiles include a line saying "SHELL=/bin/sh", but
    12151283     non-Unix systems don't conform to this default configuration (in
    1216      fact, most of them don't even have `/bin').  On the other hand,
     1284     fact, most of them don't even have '/bin').  On the other hand,
    12171285     $SHELL in the environment, if set, points to the real pathname of
    12181286     the shell.
     
    12331301      /* See if we can find "/bin/sh.exe", "/bin/sh.com", etc.  */
    12341302      if (__dosexec_find_on_path (p, NULL, shellpath))
    1235         {
    1236           char *tp;
    1237 
    1238           for (tp = shellpath; *tp; tp++)
     1303        {
     1304          char *tp;
     1305
     1306          for (tp = shellpath; *tp; tp++)
    12391307            if (*tp == '\\')
    12401308              *tp = '/';
    12411309
    1242           v = define_variable_loc (varname, strlen (varname),
     1310          v = define_variable_loc (varname, strlen (varname),
    12431311                                   shellpath, origin, flavor == f_recursive,
    12441312                                   flocp);
    1245         }
     1313        }
    12461314      else
    1247         {
    1248           const char *shellbase, *bslash;
    1249           struct variable *pathv = lookup_variable ("PATH", 4);
    1250           char *path_string;
    1251           char *fake_env[2];
    1252           size_t pathlen = 0;
    1253 
    1254           shellbase = strrchr (p, '/');
    1255           bslash = strrchr (p, '\\');
    1256           if (!shellbase || bslash > shellbase)
    1257             shellbase = bslash;
    1258           if (!shellbase && p[1] == ':')
    1259             shellbase = p + 1;
    1260           if (shellbase)
    1261             shellbase++;
    1262           else
    1263             shellbase = p;
    1264 
    1265           /* Search for the basename of the shell (with standard
    1266              executable extensions) along the $PATH.  */
    1267           if (pathv)
    1268             pathlen = strlen (pathv->value);
    1269           path_string = xmalloc (5 + pathlen + 2 + 1);
    1270           /* On MSDOS, current directory is considered as part of $PATH.  */
    1271           sprintf (path_string, "PATH=.;%s", pathv ? pathv->value : "");
    1272           fake_env[0] = path_string;
    1273           fake_env[1] = 0;
    1274           if (__dosexec_find_on_path (shellbase, fake_env, shellpath))
    1275             {
    1276               char *tp;
    1277 
    1278               for (tp = shellpath; *tp; tp++)
     1315        {
     1316          const char *shellbase, *bslash;
     1317          struct variable *pathv = lookup_variable ("PATH", 4);
     1318          char *path_string;
     1319          char *fake_env[2];
     1320          size_t pathlen = 0;
     1321
     1322          shellbase = strrchr (p, '/');
     1323          bslash = strrchr (p, '\\');
     1324          if (!shellbase || bslash > shellbase)
     1325            shellbase = bslash;
     1326          if (!shellbase && p[1] == ':')
     1327            shellbase = p + 1;
     1328          if (shellbase)
     1329            shellbase++;
     1330          else
     1331            shellbase = p;
     1332
     1333          /* Search for the basename of the shell (with standard
     1334             executable extensions) along the $PATH.  */
     1335          if (pathv)
     1336            pathlen = strlen (pathv->value);
     1337          path_string = xmalloc (5 + pathlen + 2 + 1);
     1338          /* On MSDOS, current directory is considered as part of $PATH.  */
     1339          sprintf (path_string, "PATH=.;%s", pathv ? pathv->value : "");
     1340          fake_env[0] = path_string;
     1341          fake_env[1] = 0;
     1342          if (__dosexec_find_on_path (shellbase, fake_env, shellpath))
     1343            {
     1344              char *tp;
     1345
     1346              for (tp = shellpath; *tp; tp++)
    12791347                if (*tp == '\\')
    12801348                  *tp = '/';
    12811349
    1282               v = define_variable_loc (varname, strlen (varname),
     1350              v = define_variable_loc (varname, strlen (varname),
    12831351                                       shellpath, origin,
    12841352                                       flavor == f_recursive, flocp);
    1285             }
    1286           else
    1287             v = lookup_variable (varname, strlen (varname));
    1288 
    1289           free (path_string);
    1290         }
     1353            }
     1354          else
     1355            v = lookup_variable (varname, strlen (varname));
     1356
     1357          free (path_string);
     1358        }
    12911359    }
    12921360  else
     
    12961364      && streq (varname, "SHELL"))
    12971365    {
    1298       extern char *default_shell;
     1366      extern const char *default_shell;
    12991367
    13001368      /* Call shell locator function. If it returns TRUE, then
    1301         set no_default_sh_exe to indicate sh was found and
     1369        set no_default_sh_exe to indicate sh was found and
    13021370         set new value for SHELL variable.  */
    13031371
     
    13311399            v = lookup_variable (varname, strlen (varname));
    13321400
    1333           if (tp)
    1334             free (tp);
     1401          free (tp);
    13351402        }
    13361403    }
     
    13521419  v->conditional = conditional;
    13531420
    1354   if (alloc_value)
    1355     free (alloc_value);
     1421  free (alloc_value);
    13561422
    13571423  return v->special ? set_special_var (v) : v;
     
    13611427/* Parse P (a null-terminated string) as a variable definition.
    13621428
    1363    If it is not a variable definition, return NULL.
     1429   If it is not a variable definition, return NULL and the contents of *VAR
     1430   are undefined, except NAME is set to the first non-space character or NIL.
    13641431
    13651432   If it is a variable definition, return a pointer to the char after the
    1366    assignment token and set *FLAVOR to the type of variable assignment.  */
     1433   assignment token and set the following fields (only) of *VAR:
     1434    name   : name of the variable (ALWAYS SET) (NOT NUL-TERMINATED!)
     1435    length : length of the variable name
     1436    value  : value of the variable (nul-terminated)
     1437    flavor : flavor of the variable
     1438   Other values in *VAR are unchanged.
     1439  */
    13671440
    13681441char *
    1369 parse_variable_definition (const char *p, enum variable_flavor *flavor)
     1442parse_variable_definition (const char *p, struct variable *var)
    13701443{
    13711444  int wspace = 0;
    1372 
    1373   p = next_token (p);
     1445  const char *e = NULL;
     1446
     1447  NEXT_TOKEN (p);
     1448  var->name = (char *)p;
     1449  var->length = 0;
    13741450
    13751451  while (1)
     
    13781454
    13791455      /* If we find a comment or EOS, it's not a variable definition.  */
    1380       if (c == '\0' || c == '#')
    1381         return NULL;
     1456      if (STOP_SET (c, MAP_COMMENT|MAP_NUL))
     1457        return NULL;
    13821458
    13831459      if (c == '$')
    1384         {
    1385           /* This begins a variable expansion reference.  Make sure we don't
    1386              treat chars inside the reference as assignment tokens.  */
    1387           char closeparen;
    1388           int count;
    1389           c = *p++;
    1390           if (c == '(')
    1391             closeparen = ')';
    1392           else if (c == '{')
    1393             closeparen = '}';
    1394           else
     1460        {
     1461          /* This begins a variable expansion reference.  Make sure we don't
     1462             treat chars inside the reference as assignment tokens.  */
     1463          char closeparen;
     1464          unsigned int count;
     1465
     1466          c = *p++;
     1467          if (c == '(')
     1468            closeparen = ')';
     1469          else if (c == '{')
     1470            closeparen = '}';
     1471          else if (c == '\0')
     1472            return NULL;
     1473          else
    13951474            /* '$$' or '$X'.  Either way, nothing special to do here.  */
    1396             continue;
    1397 
    1398           /* P now points past the opening paren or brace.
    1399              Count parens or braces until it is matched.  */
    1400           count = 0;
    1401           for (; *p != '\0'; ++p)
    1402             {
    1403               if (*p == c)
    1404                 ++count;
    1405               else if (*p == closeparen && --count < 0)
    1406                 {
    1407                   ++p;
    1408                   break;
    1409                 }
    1410             }
     1475            continue;
     1476
     1477          /* P now points past the opening paren or brace.
     1478             Count parens or braces until it is matched.  */
     1479          for (count = 1; *p != '\0'; ++p)
     1480            {
     1481              if (*p == closeparen && --count == 0)
     1482                {
     1483                  ++p;
     1484                  break;
     1485                }
     1486              if (*p == c)
     1487                ++count;
     1488            }
    14111489          continue;
    1412         }
     1490        }
    14131491
    14141492      /* If we find whitespace skip it, and remember we found it.  */
    1415       if (isblank ((unsigned char)c))
     1493      if (ISBLANK (c))
    14161494        {
    14171495          wspace = 1;
    1418           p = next_token (p);
     1496          e = p - 1;
     1497          NEXT_TOKEN (p);
    14191498          c = *p;
    14201499          if (c == '\0')
     
    14251504
    14261505      if (c == '=')
    1427         {
    1428           *flavor = f_recursive;
    1429           return (char *)p;
    1430         }
    1431 
    1432       /* Match assignment variants (:=, +=, ?=)  */
     1506        {
     1507          var->flavor = f_recursive;
     1508          if (! e)
     1509            e = p - 1;
     1510          break;
     1511        }
     1512
     1513      /* Match assignment variants (:=, +=, ?=, !=)  */
    14331514      if (*p == '=')
    14341515        {
     
    14361517            {
    14371518              case ':':
    1438                 *flavor = f_simple;
     1519                var->flavor = f_simple;
    14391520                break;
    14401521              case '+':
    1441                 *flavor = f_append;
     1522                var->flavor = f_append;
    14421523                break;
    14431524              case '?':
    1444                 *flavor = f_conditional;
     1525                var->flavor = f_conditional;
     1526                break;
     1527              case '!':
     1528                var->flavor = f_shell;
    14451529                break;
    14461530              default:
     
    14521536                continue;
    14531537            }
    1454           return (char *)++p;
     1538          if (! e)
     1539            e = p - 1;
     1540          ++p;
     1541          break;
    14551542        }
    1456       else if (c == ':')
    1457         /* A colon other than := is a rule line, not a variable defn.  */
    1458         return NULL;
     1543
     1544      /* Check for POSIX ::= syntax  */
     1545      if (c == ':')
     1546        {
     1547          /* A colon other than :=/::= is not a variable defn.  */
     1548          if (*p != ':' || p[1] != '=')
     1549            return NULL;
     1550
     1551          /* POSIX allows ::= to be the same as GNU make's := */
     1552          var->flavor = f_simple;
     1553          if (! e)
     1554            e = p - 1;
     1555          p += 2;
     1556          break;
     1557        }
    14591558
    14601559      /* If we skipped whitespace, non-assignments means no var.  */
     
    14631562    }
    14641563
     1564  var->length = e - var->name;
     1565  var->value = next_token (p);
    14651566  return (char *)p;
    14661567}
     
    14691570/* Try to interpret LINE (a null-terminated string) as a variable definition.
    14701571
    1471    If LINE was recognized as a variable definition, a pointer to its `struct
     1572   If LINE was recognized as a variable definition, a pointer to its 'struct
    14721573   variable' is returned.  If LINE is not a variable definition, NULL is
    14731574   returned.  */
    14741575
    14751576struct variable *
    1476 assign_variable_definition (struct variable *v, char *line)
    1477 {
    1478   char *beg;
    1479   char *end;
    1480   enum variable_flavor flavor;
     1577assign_variable_definition (struct variable *v, const char *line)
     1578{
    14811579  char *name;
    14821580
    1483   beg = next_token (line);
    1484   line = parse_variable_definition (beg, &flavor);
    1485   if (!line)
     1581  if (!parse_variable_definition (line, v))
    14861582    return NULL;
    14871583
    1488   end = line - (flavor == f_recursive ? 1 : 2);
    1489   while (end > beg && isblank ((unsigned char)end[-1]))
    1490     --end;
    1491   line = next_token (line);
    1492   v->value = line;
    1493   v->flavor = flavor;
    1494 
    14951584  /* Expand the name, so "$(foo)bar = baz" works.  */
    1496   name = alloca (end - beg + 1);
    1497   memcpy (name, beg, end - beg);
    1498   name[end - beg] = '\0';
     1585  name = alloca (v->length + 1);
     1586  memcpy (name, v->name, v->length);
     1587  name[v->length] = '\0';
    14991588  v->name = allocated_variable_expand (name);
    15001589
    15011590  if (v->name[0] == '\0')
    1502     fatal (&v->fileinfo, _("empty variable name"));
     1591    O (fatal, &v->fileinfo, _("empty variable name"));
    15031592
    15041593  return v;
     
    15151604   See the comments for assign_variable_definition().
    15161605
    1517    If LINE was recognized as a variable definition, a pointer to its `struct
     1606   If LINE was recognized as a variable definition, a pointer to its 'struct
    15181607   variable' is returned.  If LINE is not a variable definition, NULL is
    15191608   returned.  */
    15201609
    15211610struct variable *
    1522 try_variable_definition (const struct floc *flocp, char *line,
     1611try_variable_definition (const floc *flocp, const char *line,
    15231612                         enum variable_origin origin, int target_var)
    15241613{
     
    15541643  switch (v->origin)
    15551644    {
     1645    case o_automatic:
     1646      origin = _("automatic");
     1647      break;
    15561648    case o_default:
    15571649      origin = _("default");
     
    15701662      break;
    15711663    case o_override:
    1572       origin = _("`override' directive");
    1573       break;
    1574     case o_automatic:
    1575       origin = _("automatic");
     1664      origin = _("'override' directive");
    15761665      break;
    15771666    case o_invalid:
     
    15841673    fputs (" private", stdout);
    15851674  if (v->fileinfo.filenm)
    1586     printf (_(" (from `%s', line %lu)"),
    1587             v->fileinfo.filenm, v->fileinfo.lineno);
     1675    printf (_(" (from '%s', line %lu)"),
     1676            v->fileinfo.filenm, v->fileinfo.lineno + v->fileinfo.offset);
    15881677  putchar ('\n');
    15891678  fputs (prefix, stdout);
    15901679
    1591   /* Is this a `define'?  */
     1680  /* Is this a 'define'?  */
    15921681  if (v->recursive && strchr (v->value, '\n') != 0)
    15931682    printf ("define %s\n%s\nendef\n", v->name, v->value);
     
    16011690      p = next_token (v->value);
    16021691      if (p != v->value && *p == '\0')
    1603         /* All whitespace.  */
    1604         printf ("$(subst ,,%s)", v->value);
     1692        /* All whitespace.  */
     1693        printf ("$(subst ,,%s)", v->value);
    16051694      else if (v->recursive)
    1606         fputs (v->value, stdout);
     1695        fputs (v->value, stdout);
    16071696      else
    1608         /* Double up dollar signs.  */
    1609         for (p = v->value; *p != '\0'; ++p)
    1610           {
    1611             if (*p == '$')
    1612               putchar ('$');
    1613             putchar (*p);
    1614           }
     1697        /* Double up dollar signs.  */
     1698        for (p = v->value; *p != '\0'; ++p)
     1699          {
     1700            if (*p == '$')
     1701              putchar ('$');
     1702            putchar (*p);
     1703          }
    16151704      putchar ('\n');
    16161705    }
     1706}
     1707
     1708
     1709static void
     1710print_auto_variable (const void *item, void *arg)
     1711{
     1712  const struct variable *v = item;
     1713
     1714  if (v->origin == o_automatic)
     1715    print_variable (item, arg);
     1716}
     1717
     1718
     1719static void
     1720print_noauto_variable (const void *item, void *arg)
     1721{
     1722  const struct variable *v = item;
     1723
     1724  if (v->origin != o_automatic)
     1725    print_variable (item, arg);
    16171726}
    16181727
     
    16211730   the actual variable definitions (everything else is comments).  */
    16221731
    1623 void
    1624 print_variable_set (struct variable_set *set, char *prefix)
    1625 {
    1626   hash_map_arg (&set->table, print_variable, prefix);
     1732static void
     1733print_variable_set (struct variable_set *set, const char *prefix, int pauto)
     1734{
     1735  hash_map_arg (&set->table, (pauto ? print_auto_variable : print_variable),
     1736                (void *)prefix);
    16271737
    16281738  fputs (_("# variable set hash-table stats:\n"), stdout);
     
    16391749  puts (_("\n# Variables\n"));
    16401750
    1641   print_variable_set (&global_variable_set, "");
     1751  print_variable_set (&global_variable_set, "", 0);
    16421752
    16431753  puts (_("\n# Pattern-specific Variable Values"));
     
    16451755  {
    16461756    struct pattern_var *p;
    1647     int rules = 0;
     1757    unsigned int rules = 0;
    16481758
    16491759    for (p = pattern_vars; p != 0; p = p->next)
     
    16511761        ++rules;
    16521762        printf ("\n%s :\n", p->target);
    1653         print_variable (&p->variable, "# ");
     1763        print_variable (&p->variable, (void *)"# ");
    16541764      }
    16551765
     
    16681778{
    16691779  if (file->variables != 0)
    1670     print_variable_set (file->variables->set, "# ");
     1780    print_variable_set (file->variables->set, "# ", 1);
     1781}
     1782
     1783void
     1784print_target_variables (const struct file *file)
     1785{
     1786  if (file->variables != 0)
     1787    {
     1788      int l = strlen (file->name);
     1789      char *t = alloca (l + 3);
     1790
     1791      strcpy (t, file->name);
     1792      t[l] = ':';
     1793      t[l+1] = ' ';
     1794      t[l+2] = '\0';
     1795
     1796      hash_map_arg (&file->variables->set->table, print_noauto_variable, t);
     1797    }
    16711798}
    16721799
     
    16811808    return;
    16821809
    1683   /*
    1684    * If done this before, don't leak memory unnecessarily.
    1685    * Free the previous entry before allocating new one.
    1686    */
    1687   if (environ_path)
    1688     free (environ_path);
    1689 
    1690   /*
    1691    * Create something WINDOWS32 world can grok
    1692    */
     1810  /* If done this before, free the previous entry before allocating new one.  */
     1811  free (environ_path);
     1812
     1813  /* Create something WINDOWS32 world can grok.  */
    16931814  convert_Path_to_windows32 (path, ';');
    16941815  environ_path = xstrdup (concat (3, "PATH", "=", path));
  • vendor/gnumake/current/variable.h

    r2596 r3138  
    11/* Definitions for using variables in GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    2321enum variable_origin
    2422  {
    25     o_default,          /* Variable from the default set.  */
    26     o_env,              /* Variable from environment.  */
    27     o_file,             /* Variable given in a makefile.  */
    28     o_env_override,     /* Variable from environment, if -e.  */
    29     o_command,          /* Variable given by user.  */
    30     o_override,         /* Variable from an `override' directive.  */
    31     o_automatic,        /* Automatic variable -- cannot be set.  */
    32     o_invalid           /* Core dump time.  */
     23    o_default,          /* Variable from the default set.  */
     24    o_env,              /* Variable from environment.  */
     25    o_file,             /* Variable given in a makefile.  */
     26    o_env_override,     /* Variable from environment, if -e.  */
     27    o_command,          /* Variable given by user.  */
     28    o_override,         /* Variable from an 'override' directive.  */
     29    o_automatic,        /* Automatic variable -- cannot be set.  */
     30    o_invalid           /* Core dump time.  */
    3331  };
    3432
     
    3634  {
    3735    f_bogus,            /* Bogus (error) */
    38     f_simple,           /* Simple definition (:=) */
     36    f_simple,           /* Simple definition (:= or ::=) */
    3937    f_recursive,        /* Recursive definition (=) */
    4038    f_append,           /* Appending definition (+=) */
    41     f_conditional       /* Conditional definition (?=) */
     39    f_conditional,      /* Conditional definition (?=) */
     40    f_shell             /* Shell assignment (!=) */
    4241  };
    4342
    4443/* Structure that represents one variable definition.
    4544   Each bucket of the hash table is a chain of these,
    46    chained through `next'.  */
     45   chained through 'next'.  */
    4746
    4847#define EXP_COUNT_BITS  15      /* This gets all the bitfields into 32 bits */
     
    5150struct variable
    5251  {
    53     char *name;                 /* Variable name.  */
    54     int length;                 /* strlen (name) */
    55     char *value;                /* Variable value.  */
    56     struct floc fileinfo;       /* Where the variable was defined. */
    57     unsigned int recursive:1;   /* Gets recursively re-evaluated.  */
    58     unsigned int append:1;      /* Nonzero if an appending target-specific
     52    char *name;                 /* Variable name.  */
     53    char *value;                /* Variable value. */
     54    floc fileinfo;              /* Where the variable was defined.  */
     55    int length;                 /* strlen (name) */
     56    unsigned int recursive:1;   /* Gets recursively re-evaluated.  */
     57    unsigned int append:1;      /* Nonzero if an appending target-specific
    5958                                   variable.  */
    6059    unsigned int conditional:1; /* Nonzero if set with a ?=. */
    61     unsigned int per_target:1;  /* Nonzero if a target-specific variable.  */
     60    unsigned int per_target:1;  /* Nonzero if a target-specific variable.  */
    6261    unsigned int special:1;     /* Nonzero if this is a special variable.  */
    6362    unsigned int exportable:1;  /* Nonzero if the variable _could_ be
    6463                                   exported.  */
    65     unsigned int expanding:1;   /* Nonzero if currently being expanded.  */
     64    unsigned int expanding:1;   /* Nonzero if currently being expanded.  */
    6665    unsigned int private_var:1; /* Nonzero avoids inheritance of this
    6766                                   target-specific variable.  */
     
    7069                                   expansions.  */
    7170    enum variable_flavor
    72       flavor ENUM_BITFIELD (3); /* Variable flavor.  */
     71      flavor ENUM_BITFIELD (3); /* Variable flavor.  */
    7372    enum variable_origin
    74       origin ENUM_BITFIELD (3); /* Variable origin.  */
     73      origin ENUM_BITFIELD (3); /* Variable origin.  */
    7574    enum variable_export
    7675      {
    77         v_export,               /* Export this variable.  */
    78         v_noexport,             /* Don't export this variable.  */
    79         v_ifset,                /* Export it if it has a non-default value.  */
    80         v_default               /* Decide in target_environment.  */
     76        v_export,               /* Export this variable.  */
     77        v_noexport,             /* Don't export this variable.  */
     78        v_ifset,                /* Export it if it has a non-default value.  */
     79        v_default               /* Decide in target_environment.  */
    8180      } export ENUM_BITFIELD (2);
    8281  };
     
    8685struct variable_set
    8786  {
    88     struct hash_table table;    /* Hash table of variables.  */
     87    struct hash_table table;    /* Hash table of variables.  */
    8988  };
    9089
     
    9392struct variable_set_list
    9493  {
    95     struct variable_set_list *next;     /* Link in the chain.  */
    96     struct variable_set *set;           /* Variable set.  */
     94    struct variable_set_list *next;     /* Link in the chain.  */
     95    struct variable_set *set;           /* Variable set.  */
    9796    int next_is_parent;                 /* True if next is a parent target.  */
    9897  };
     
    112111extern struct variable_set_list *current_variable_set_list;
    113112extern struct variable *default_goal_var;
     113extern struct variable shell_var;
    114114
    115115/* expand.c */
     
    118118char *variable_expand_for_file (const char *line, struct file *file);
    119119char *allocated_variable_expand_for_file (const char *line, struct file *file);
    120 #define allocated_variable_expand(line) \
     120#define allocated_variable_expand(line) \
    121121  allocated_variable_expand_for_file (line, (struct file *) 0)
    122122char *expand_argument (const char *str, const char *end);
     
    135135                           const char *replace_percent);
    136136char *patsubst_expand (char *o, const char *text, char *pattern, char *replace);
     137char *func_shell_base (char *o, char **argv, int trim_newlines);
     138void shell_completed (int exit_code, int exit_sig);
    137139
    138140/* expand.c */
     
    148150void initialize_file_variables (struct file *file, int reading);
    149151void print_file_variables (const struct file *file);
    150 void print_variable_set (struct variable_set *set, char *prefix);
     152void print_target_variables (const struct file *file);
    151153void merge_variable_set_lists (struct variable_set_list **to_list,
    152154                               struct variable_set_list *from_list);
    153 struct variable *do_variable_definition (const struct floc *flocp,
     155struct variable *do_variable_definition (const floc *flocp,
    154156                                         const char *name, const char *value,
    155157                                         enum variable_origin origin,
     
    157159                                         int target_var);
    158160char *parse_variable_definition (const char *line,
    159                                  enum variable_flavor *flavor);
    160 struct variable *assign_variable_definition (struct variable *v, char *line);
    161 struct variable *try_variable_definition (const struct floc *flocp, char *line,
     161                                 struct variable *v);
     162struct variable *assign_variable_definition (struct variable *v, const char *line);
     163struct variable *try_variable_definition (const floc *flocp, const char *line,
    162164                                          enum variable_origin origin,
    163165                                          int target_var);
    164166void init_hash_global_variable_set (void);
    165167void hash_init_function_table (void);
     168void define_new_function(const floc *flocp, const char *name,
     169                         unsigned int min, unsigned int max, unsigned int flags,
     170                         gmk_func_ptr func);
    166171struct variable *lookup_variable (const char *name, unsigned int length);
    167172struct variable *lookup_variable_in_set (const char *name, unsigned int length,
     
    173178                                         int recursive,
    174179                                         struct variable_set *set,
    175                                          const struct floc *flocp);
     180                                         const floc *flocp);
    176181
    177182/* Define a variable in the current variable set.  */
     
    215220
    216221#define warn_undefined(n,l) do{\
    217                               if (warn_undefined_variables_flag) \
    218                                 error (reading_file, \
    219                                        _("warning: undefined variable `%.*s'"), \
    220                                 (int)(l), (n)); \
     222                              if (warn_undefined_variables_flag)        \
     223                                error (reading_file, (l),               \
     224                                       _("warning: undefined variable '%.*s'"), \
     225                                       (int)(l), (n));                  \
    221226                              }while(0)
    222227
     
    229234
    230235#define MAKELEVEL_NAME "MAKELEVEL"
    231 #define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1)
     236#define MAKELEVEL_LENGTH (CSTRLEN (MAKELEVEL_NAME))
  • vendor/gnumake/current/version.c

    r2596 r3138  
    11/* Record version and build host architecture for GNU make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1917/* We use <config.h> instead of "config.h" so that a compilation
    2018   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
    21    (which it would do because make.h was found in $srcdir).  */
     19   (which it would do because makeint.h was found in $srcdir).  */
    2220#include <config.h>
    2321
     
    2624#endif
    2725
    28 char *version_string = VERSION;
    29 char *make_host = MAKE_HOST;
     26const char *version_string = VERSION;
     27const char *make_host = MAKE_HOST;
    3028
    3129
  • vendor/gnumake/current/vmsdir.h

    r2596 r3138  
    11/* dirent.h for vms
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    4645    + 3) & ~3)
    4746
    48 #define d_ino   d_fileno                /* compatability */
     47#define d_ino   d_fileno                /* compatibility */
    4948
    5049
  • vendor/gnumake/current/vmsfunctions.c

    r2596 r3138  
    11/* VMS functions
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    1615this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1716
    18 #include "make.h"
     17#include "makeint.h"
    1918#include "debug.h"
    2019#include "job.h"
    2120
     21#include <ctype.h>
     22#include <string.h>
     23
    2224#ifdef __DECC
    2325#include <starlet.h>
    2426#endif
    25 #include <descrip.h>
     27
    2628#include <rms.h>
    27 #include <iodef.h>
    28 #include <atrdef.h>
    29 #include <fibdef.h>
    3029#include "vmsdir.h"
    3130
     
    120119      struct NAM *dnam = (struct NAM *)(dfab->fab$l_nam);
    121120      if (dnam != NULL)
    122         free (dnam->nam$l_esa);
     121        free (dnam->nam$l_esa);
    123122      free (dnam);
    124123      free (dir);
     
    129128#endif /* compiled for OpenVMS prior to V7.x */
    130129
    131 char *
    132 getwd (char *cwd)
    133 {
    134   static char buf[512];
    135 
    136   if (cwd)
    137     return (getcwd (cwd, 512));
    138   else
    139     return (getcwd (buf, 512));
    140 }
    141 
    142 #if 0
    143 /*
    144  * Is this used? I don't see any reference, so I suggest to remove it.
    145  */
    146 int
    147 vms_stat (char *name, struct stat *buf)
     130/* Argv0 will be a full vms file specification, like
     131   node$dka100:[utils.gnumake]make.exe;47
     132   prefix it with "mcr " to make it a vms command, executable for DCL. */
     133const char *
     134vms_command(const char* argv0)
     135{
     136  size_t l = strlen(argv0) + 1;
     137  char* s = xmalloc(l + 4);
     138  memcpy(s, "mcr ", 4);
     139  memcpy(s+4, argv0, l);
     140  return s;
     141}
     142
     143/* Argv0 aka argv[0] will be a full vms file specification, like
     144   node$dka100:[utils.gnumake]make.exe;47, set up by the CRTL.
     145   The vms progname should be ^^^^, the file name without
     146   file type .exe and ;version.
     147   Use sys$parse to get the name part of the file specification. That is
     148   in the above example, pick up "make" and return a copy of that string.
     149   If something goes wrong in sys$parse (unlikely, this is a VMS/CRTL supplied
     150   file specification) or if there is an empty name part (not easy to produce,
     151   but it is possible) just return "make".
     152   Somes notes ...
     153   NAM[L]$M_SYNCHK requests a syntax check, only.
     154   NAM is for ODS2 names (shorter parts, output usually converted to UPPERCASE).
     155   NAML is for ODS2/ODS5 names (longer parts, output unchanged).
     156   NAM$M_NO_SHORT_UPCASE may not be available for older versions of VMS.
     157   NAML is not available on older versions of VMS (NAML$C_BID not defined).
     158   argv[0] on older versions of VMS (no extended parse style and no
     159   CRTL feature DECC$ARGV_PARSE_STYLE) is always in lowercase. */
     160const char *
     161vms_progname(const char* argv0)
    148162{
    149163  int status;
    150   int i;
    151 
    152   static struct FAB Fab;
    153   static struct NAM Nam;
    154   static struct fibdef Fib;     /* short fib */
    155   static struct dsc$descriptor FibDesc =
    156   { sizeof (Fib), DSC$K_DTYPE_Z, DSC$K_CLASS_S, (char *) &Fib };
    157   static struct dsc$descriptor_s DevDesc =
    158   { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, &Nam.nam$t_dvi[1] };
    159   static char EName[NAM$C_MAXRSS];
    160   static char RName[NAM$C_MAXRSS];
    161   static struct dsc$descriptor_s FileName =
    162   { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0 };
    163   static struct dsc$descriptor_s string =
    164   { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0 };
    165   static unsigned long Rdate[2];
    166   static unsigned long Cdate[2];
    167   static struct atrdef Atr[] =
    168   {
    169 #if defined(VAX)
    170     /* Revision date */
    171     { sizeof (Rdate), ATR$C_REVDATE, (unsigned int) &Rdate[0] },
    172     /* Creation date */
    173     { sizeof (Cdate), ATR$C_CREDATE, (unsigned int) &Cdate[0] },
     164  static struct FAB fab;
     165  char *progname;
     166  const char *fallback = "make";
     167
     168#ifdef NAML$C_BID
     169  static char esa[NAML$C_MAXRSS];
     170  static struct NAML naml;
    174171#else
    175     /* Revision date */
    176     { sizeof (Rdate), ATR$C_REVDATE, &Rdate[0] },
    177     /* Creation date */
    178     { sizeof (Cdate), ATR$C_CREDATE, &Cdate[0]},
    179 #endif
    180     { 0, 0, 0 }
    181   };
    182   static short int DevChan;
    183   static short int iosb[4];
    184 
    185   name = vmsify (name, 0);
    186 
    187   /* initialize RMS structures, we need a NAM to retrieve the FID */
    188   Fab = cc$rms_fab;
    189   Fab.fab$l_fna = name;         /* name of file */
    190   Fab.fab$b_fns = strlen (name);
    191   Fab.fab$l_nam = &Nam;         /* FAB has an associated NAM */
    192 
    193   Nam = cc$rms_nam;
    194   Nam.nam$l_esa = EName;        /* expanded filename */
    195   Nam.nam$b_ess = sizeof (EName);
    196   Nam.nam$l_rsa = RName;        /* resultant filename */
    197   Nam.nam$b_rss = sizeof (RName);
    198 
    199   /* do $PARSE and $SEARCH here */
    200   status = sys$parse (&Fab);
     172  static char esa[NAM$C_MAXRSS];
     173  static struct NAM nam;
     174#endif
     175
     176  fab = cc$rms_fab;
     177  fab.fab$l_fna = (char*)argv0;
     178  fab.fab$b_fns = strlen(argv0);
     179
     180#ifdef NAML$C_BID
     181  fab.fab$l_naml = &naml;
     182  naml = cc$rms_naml;
     183  naml.naml$l_long_expand = esa;
     184  naml.naml$l_long_expand_alloc = NAML$C_MAXRSS;
     185  naml.naml$b_nop = NAML$M_SYNCHK;
     186  naml.naml$l_input_flags = NAML$M_NO_SHORT_OUTPUT;
     187#else
     188  fab.fab$l_nam = &nam;
     189  nam = cc$rms_nam;
     190  nam.nam$l_esa = esa;
     191  nam.nam$b_ess = NAM$C_MAXRSS;
     192# ifdef NAM$M_NO_SHORT_UPCASE
     193  nam.nam$b_nop = NAM$M_SYNCHK | NAM$M_NO_SHORT_UPCASE;
     194# else
     195  nam.nam$b_nop = NAM$M_SYNCHK;
     196# endif
     197#endif
     198
     199  status = sys$parse(&fab);
    201200  if (!(status & 1))
    202     return -1;
    203 
    204   DevDesc.dsc$w_length = Nam.nam$t_dvi[0];
    205   status = sys$assign (&DevDesc, &DevChan, 0, 0);
    206   if (!(status & 1))
    207     return -1;
    208 
    209   FileName.dsc$a_pointer = Nam.nam$l_name;
    210   FileName.dsc$w_length = Nam.nam$b_name + Nam.nam$b_type + Nam.nam$b_ver;
    211 
    212   /* Initialize the FIB */
    213   for (i = 0; i < 3; i++)
    214     {
    215 #ifndef __VAXC
    216       Fib.fib$w_fid[i] = Nam.nam$w_fid[i];
    217       Fib.fib$w_did[i] = Nam.nam$w_did[i];
     201    return fallback;
     202
     203#ifdef NAML$C_BID
     204  if (naml.naml$l_long_name_size == 0)
     205    return fallback;
     206  progname = xmalloc(naml.naml$l_long_name_size + 1);
     207  memcpy(progname, naml.naml$l_long_name, naml.naml$l_long_name_size);
     208  progname[naml.naml$l_long_name_size] = '\0';
    218209#else
    219       Fib.fib$r_fid_overlay.fib$w_fid[i] = Nam.nam$w_fid[i];
    220       Fib.fib$r_did_overlay.fib$w_did[i] = Nam.nam$w_did[i];
    221 #endif
    222     }
    223 
    224   status = sys$qiow (0, DevChan, IO$_ACCESS, &iosb, 0, 0,
    225                      &FibDesc, &FileName, 0, 0, &Atr, 0);
    226   sys$dassgn (DevChan);
    227   if (!(status & 1))
    228     return -1;
    229   status = iosb[0];
    230   if (!(status & 1))
    231     return -1;
    232 
    233   status = stat (name, buf);
    234   if (status)
    235     return -1;
    236 
    237   buf->st_mtime = ((Rdate[0] >> 24) & 0xff) + ((Rdate[1] << 8) & 0xffffff00);
    238   buf->st_ctime = ((Cdate[0] >> 24) & 0xff) + ((Cdate[1] << 8) & 0xffffff00);
    239 
    240   return 0;
    241 }
    242 #endif
    243 
    244 char *
    245 cvt_time (unsigned long tval)
    246 {
    247   static long int date[2];
    248   static char str[27];
    249   static struct dsc$descriptor date_str =
    250   { 26, DSC$K_DTYPE_T, DSC$K_CLASS_S, str };
    251 
    252   date[0] = (tval & 0xff) << 24;
    253   date[1] = ((tval >> 8) & 0xffffff);
    254 
    255   if ((date[0] == 0) && (date[1] == 0))
    256     return ("never");
    257 
    258   sys$asctim (0, &date_str, date, 0);
    259   str[26] = '\0';
    260 
    261   return (str);
    262 }
     210  if (nam.nam$b_name == 0)
     211    return fallback;
     212  progname = xmalloc(nam.nam$b_name + 1);
     213# ifdef NAM$M_NO_SHORT_UPCASE
     214  memcpy(progname, nam.nam$l_name, nam.nam$b_name);
     215# else
     216    {
     217      int i;
     218      for (i = 0; i < nam.nam$b_name; i++)
     219        progname[i] = tolower(nam.nam$l_name[i]);
     220    }
     221# endif
     222  progname[nam.nam$b_name] = '\0';
     223#endif
     224
     225  return progname;
     226}
  • vendor/gnumake/current/vmsify.c

    r2596 r3138  
    11/* vmsify.c -- Module for vms <-> unix file name conversion
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    2322#include <string.h>
    2423#include <ctype.h>
     24
     25#include "makeint.h"
    2526
    2627#if VMS
     
    139140  reslt[resltlen] = '\0';
    140141
    141   s = malloc (resltlen+1);
    142   if (s == 0)
    143     return "";
     142  s = xmalloc (resltlen+1);
    144143  strcpy (s, reslt);
    145144  return s;
     
    223222   max 5 version
    224223*/
    225 #define MAXPATHLEN 512
     224/* todo: VMSMAXPATHLEN is defined for ODS2 names: it needs to be adjusted. */
     225#define VMSMAXPATHLEN 512
    226226
    227227  enum namestate nstate;
    228   static char vmsname[MAXPATHLEN+1];
     228  static char vmsname[VMSMAXPATHLEN+1];
    229229  const char *fptr;
    230230  const char *t;
     
    404404            if (*fptr == 0)             /* just // */
    405405              {
    406                 char cwdbuf[MAXPATHLEN+1];
    407 
    408                 s1 = getcwd(cwdbuf, MAXPATHLEN);
     406                char cwdbuf[VMSMAXPATHLEN+1];
     407
     408                s1 = getcwd(cwdbuf, VMSMAXPATHLEN);
    409409                if (s1 == 0)
    410410                  {
     
    798798            {                                   /* got '..' or '../' */
    799799              char *vp;
    800               char cwdbuf[MAXPATHLEN+1];
    801 
    802               vp = getcwd(cwdbuf, MAXPATHLEN);
     800              char cwdbuf[VMSMAXPATHLEN+1];
     801
     802              vp = getcwd(cwdbuf, VMSMAXPATHLEN);
    803803              if (vp == 0)
    804804                {
     
    858858            {
    859859              char *vp;
    860               char cwdbuf[MAXPATHLEN+1];
    861 
    862               vp = getcwd(cwdbuf, MAXPATHLEN);
     860              char cwdbuf[VMSMAXPATHLEN+1];
     861
     862              vp = getcwd(cwdbuf, VMSMAXPATHLEN);
    863863              if (vp == 0)
    864864                {
  • vendor/gnumake/current/vmsjobs.c

    r2596 r3138  
    22   This file must be #included in job.c, as it accesses static functions.
    33
    4 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    5 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     4Copyright (C) 1996-2016 Free Software Foundation, Inc.
    65This file is part of GNU Make.
    76
     
    2221#include <clidef.h>
    2322
     23/* TODO - VMS specific header file conditionally included in makeint.h */
     24
     25#include <stsdef.h>
     26#include <ssdef.h>
     27void
     28decc$exit (int status);
     29
     30/* Lowest legal non-success VMS exit code is 8 */
     31/* GNU make only defines codes 0, 1, 2 */
     32/* So assume any exit code > 8 is a VMS exit code */
     33
     34#ifndef MAX_EXPECTED_EXIT_CODE
     35# define MAX_EXPECTED_EXIT_CODE 7
     36#endif
     37
     38
     39#if __CRTL_VER >= 70302000 && !defined(__VAX)
     40# define MAX_DCL_LINE_LENGTH 4095
     41# define MAX_DCL_CMD_LINE_LENGTH 8192
     42#else
     43# define MAX_DCL_LINE_LENGTH 255
     44# define MAX_DCL_CMD_LINE_LENGTH 1024
     45#endif
     46#define MAX_DCL_TOKEN_LENGTH 255
     47#define MAX_DCL_TOKENS 127
     48
     49enum auto_pipe { nopipe, add_pipe, dcl_pipe };
     50
    2451char *vmsify (char *name, int type);
    2552
    2653static int vms_jobsefnmask = 0;
     54
     55/* returns whether path is assumed to be a unix like shell. */
     56int
     57_is_unixy_shell (const char *path)
     58{
     59  return vms_gnv_shell;
     60}
     61
     62#define VMS_GETMSG_MAX 256
     63static char vms_strsignal_text[VMS_GETMSG_MAX + 2];
     64
     65char *
     66vms_strsignal (int status)
     67{
     68  if (status <= MAX_EXPECTED_EXIT_CODE)
     69    sprintf (vms_strsignal_text, "lib$spawn returned %x", status);
     70  else
     71    {
     72      int vms_status;
     73      unsigned short * msg_len;
     74      unsigned char out[4];
     75      vms_status = SYS$GETMSG (status, &msg_len,
     76                               vms_strsignal_text, 7, *out);
     77    }
     78
     79  return vms_strsignal_text;
     80}
     81
    2782
    2883/* Wait for nchildren children to terminate */
    2984static void
    30 vmsWaitForChildren(int *status)
     85vmsWaitForChildren (int *status)
    3186{
    3287  while (1)
    3388    {
    3489      if (!vms_jobsefnmask)
    35         {
    36           *status = 0;
    37           return;
    38         }
     90        {
     91          *status = 0;
     92          return;
     93        }
    3994
    4095      *status = sys$wflor (32, vms_jobsefnmask);
    4196    }
    4297  return;
    43 }
    44 
    45 /* Set up IO redirection.  */
    46 
    47 char *
    48 vms_redirect (struct dsc$descriptor_s *desc, char *fname, char *ibuf)
    49 {
    50   char *fptr;
    51 
    52   ibuf++;
    53   while (isspace ((unsigned char)*ibuf))
    54     ibuf++;
    55   fptr = ibuf;
    56   while (*ibuf && !isspace ((unsigned char)*ibuf))
    57     ibuf++;
    58   *ibuf = 0;
    59   if (strcmp (fptr, "/dev/null") != 0)
    60     {
    61       strcpy (fname, vmsify (fptr, 0));
    62       if (strchr (fname, '.') == 0)
    63         strcat (fname, ".");
    64     }
    65   desc->dsc$w_length = strlen(fname);
    66   desc->dsc$a_pointer = fname;
    67   desc->dsc$b_dtype = DSC$K_DTYPE_T;
    68   desc->dsc$b_class = DSC$K_CLASS_S;
    69 
    70   if (*fname == 0)
    71     printf (_("Warning: Empty redirection\n"));
    72   return ibuf;
    73 }
    74 
    75 
    76 /* found apostrophe at (p-1)
    77    inc p until after closing apostrophe.
    78  */
    79 
    80 char *
    81 vms_handle_apos (char *p)
    82 {
    83   int alast;
    84 
    85 #define SEPCHARS ",/()= "
    86 
    87   alast = 0;
    88 
    89   while (*p != 0)
    90     {
    91       if (*p == '"')
    92         {
    93           if (alast)
    94             {
    95               alast = 0;
    96               p++;
    97             }
    98           else
    99             {
    100               p++;
    101               if (strchr (SEPCHARS, *p))
    102                 break;
    103               alast = 1;
    104             }
    105         }
    106       else
    107         p++;
    108     }
    109 
    110   return p;
    11198}
    11299
     
    117104   inner mode level AST.
    118105*/
    119 int
    120 vmsHandleChildTerm(struct child *child)
     106static int
     107vmsHandleChildTerm (struct child *child)
    121108{
    122     int status;
    123     register struct child *lastc, *c;
    124     int child_failed;
    125 
     109  int exit_code;
     110  register struct child *lastc, *c;
     111  int child_failed;
     112
     113  /* The child efn is 0 when a built-in or null command is executed
     114     successfully with out actually creating a child.
     115  */
     116  if (child->efn > 0)
     117  {
    126118    vms_jobsefnmask &= ~(1 << (child->efn - 32));
    127119
    128     lib$free_ef(&child->efn);
    129     if (child->comname)
    130       {
    131         if (!ISDB (DB_JOBS)&&!ctrlYPressed)
    132           unlink (child->comname);
    133         free (child->comname);
    134       }
    135 
    136     (void) sigblock (fatal_signal_mask);
    137 
    138     child_failed = !(child->cstatus & 1 || ((child->cstatus & 7) == 0));
    139 
    140     /* Search for a child matching the deceased one.  */
    141     lastc = 0;
    142 #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */
    143     for (c = children; c != 0 && c != child; lastc = c, c = c->next)
    144       ;
     120    lib$free_ef (&child->efn);
     121  }
     122  if (child->comname)
     123    {
     124      if (!ISDB (DB_JOBS) && !ctrlYPressed)
     125        unlink (child->comname);
     126      free (child->comname);
     127    }
     128
     129  (void) sigblock (fatal_signal_mask);
     130
     131  /* First check to see if this is a POSIX exit status and handle */
     132  if ((child->cstatus & VMS_POSIX_EXIT_MASK) == VMS_POSIX_EXIT_MASK)
     133    {
     134      exit_code = (child->cstatus >> 3) & 255;
     135      if (exit_code != MAKE_SUCCESS)
     136        child_failed = 1;
     137    }
     138  else
     139    {
     140      child_failed = !$VMS_STATUS_SUCCESS (child->cstatus);
     141      if (child_failed)
     142        exit_code = child->cstatus;
     143    }
     144
     145  /* Search for a child matching the deceased one.  */
     146  lastc = 0;
     147#if defined(RECURSIVEJOBS)
     148  /* I've had problems with recursive stuff and process handling */
     149  for (c = children; c != 0 && c != child; lastc = c, c = c->next)
     150    ;
    145151#else
    146     c = child;
     152  c = child;
    147153#endif
    148154
    149     if (child_failed && !c->noerror && !ignore_errors_flag)
    150       {
    151         /* The commands failed.  Write an error message,
    152            delete non-precious targets, and abort.  */
    153         child_error (c->file->name, c->cstatus, 0, 0, 0);
    154         c->file->update_status = 1;
    155         delete_child_targets (c);
    156       }
    157     else
    158       {
    159         if (child_failed)
    160           {
    161             /* The commands failed, but we don't care.  */
    162             child_error (c->file->name, c->cstatus, 0, 0, 1);
    163             child_failed = 0;
    164           }
    165 
    166 #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */
    167         /* If there are more commands to run, try to start them.  */
    168         start_job (c);
    169 
    170         switch (c->file->command_state)
    171           {
    172           case cs_running:
    173             /* Successfully started.  */
    174             break;
    175 
    176           case cs_finished:
    177             if (c->file->update_status != 0) {
    178                 /* We failed to start the commands.  */
    179                 delete_child_targets (c);
    180             }
    181             break;
    182 
    183           default:
    184             error (NILF, _("internal error: `%s' command_state"),
    185                    c->file->name);
    186             abort ();
    187             break;
    188           }
    189 #endif /* RECURSIVEJOBS */
    190       }
    191 
    192     /* Set the state flag to say the commands have finished.  */
    193     c->file->command_state = cs_finished;
    194     notice_finished_file (c->file);
    195 
    196 #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */
    197     /* Remove the child from the chain and free it.  */
    198     if (lastc == 0)
    199       children = c->next;
    200     else
    201       lastc->next = c->next;
    202     free_child (c);
    203 #endif /* RECURSIVEJOBS */
    204 
    205     /* There is now another slot open.  */
    206     if (job_slots_used > 0)
    207       --job_slots_used;
    208 
    209     /* If the job failed, and the -k flag was not given, die.  */
    210     if (child_failed && !keep_going_flag)
    211       die (EXIT_FAILURE);
    212 
    213     (void) sigsetmask (sigblock (0) & ~(fatal_signal_mask));
    214 
    215     return 1;
     155  if ($VMS_STATUS_SUCCESS (child->vms_launch_status))
     156    {
     157      /* Convert VMS success status to 0 for UNIX code to be happy */
     158      child->vms_launch_status = 0;
     159    }
     160
     161  /* Set the state flag to say the commands have finished.  */
     162  c->file->command_state = cs_finished;
     163  notice_finished_file (c->file);
     164
     165  (void) sigsetmask (sigblock (0) & ~(fatal_signal_mask));
     166
     167  return 1;
    216168}
    217169
    218170/* VMS:
    219171   Spawn a process executing the command in ARGV and return its pid. */
    220 
    221 #define MAXCMDLEN 200
    222172
    223173/* local helpers to make ctrl+c and ctrl+y working, see below */
     
    234184reEnableAst(void)
    235185{
    236         lib$enable_ctrl (&oldCtrlMask,0);
     186  lib$enable_ctrl (&oldCtrlMask,0);
    237187}
    238188
     
    240190astYHandler (void)
    241191{
    242         struct child *c;
    243         for (c = children; c != 0; c = c->next)
    244                 sys$delprc (&c->pid, 0, 0);
    245         ctrlYPressed= 1;
    246         kill (getpid(),SIGQUIT);
    247         return SS$_NORMAL;
     192  struct child *c;
     193  for (c = children; c != 0; c = c->next)
     194    sys$delprc (&c->pid, 0, 0);
     195  ctrlYPressed= 1;
     196  kill (getpid(),SIGQUIT);
     197  return SS$_NORMAL;
    248198}
    249199
     
    251201tryToSetupYAst(void)
    252202{
    253         $DESCRIPTOR(inputDsc,"SYS$COMMAND");
    254         int     status;
    255         struct {
    256                 short int       status, count;
    257                 int     dvi;
    258         } iosb;
    259         unsigned short int loc_chan;
    260 
    261         setupYAstTried++;
    262 
    263         if (chan)
    264           loc_chan= chan;
    265         else {
    266                 status= sys$assign(&inputDsc,&loc_chan,0,0);
    267                 if (!(status&SS$_NORMAL)) {
    268                         lib$signal(status);
    269                         return;
    270                 }
    271         }
    272         status= sys$qiow (0, loc_chan, IO$_SETMODE|IO$M_CTRLYAST,&iosb,0,0,
    273                           astYHandler,0,0,0,0,0);
    274         if (status==SS$_NORMAL)
    275                 status= iosb.status;
    276         if (status!=SS$_NORMAL) {
    277                 if (!chan)
    278                         sys$dassgn(loc_chan);
    279                 if (status!=SS$_ILLIOFUNC && status!=SS$_NOPRIV)
    280                         lib$signal(status);
    281                 return;
    282         }
    283 
    284         /* called from AST handler ? */
    285         if (setupYAstTried>1)
    286                 return;
    287         if (atexit(reEnableAst))
    288                 fprintf (stderr,
    289                          _("-warning, you may have to re-enable CTRL-Y handling from DCL.\n"));
    290         status= lib$disable_ctrl (&ctrlMask, &oldCtrlMask);
    291         if (!(status&SS$_NORMAL)) {
    292                 lib$signal(status);
    293                 return;
    294         }
    295         if (!chan)
    296                 chan = loc_chan;
     203  $DESCRIPTOR(inputDsc,"SYS$COMMAND");
     204  int     status;
     205  struct {
     206    short int       status, count;
     207    int     dvi;
     208  } iosb;
     209  unsigned short int loc_chan;
     210
     211  setupYAstTried++;
     212
     213  if (chan)
     214    loc_chan= chan;
     215  else
     216    {
     217      status= sys$assign(&inputDsc,&loc_chan,0,0);
     218      if (!(status&SS$_NORMAL))
     219        {
     220          lib$signal(status);
     221          return;
     222        }
     223    }
     224  status= sys$qiow (0, loc_chan, IO$_SETMODE|IO$M_CTRLYAST,&iosb,0,0,
     225                    astYHandler,0,0,0,0,0);
     226  if (status==SS$_NORMAL)
     227    status= iosb.status;
     228  if (status!=SS$_NORMAL)
     229    {
     230      if (!chan)
     231        sys$dassgn(loc_chan);
     232      if (status!=SS$_ILLIOFUNC && status!=SS$_NOPRIV)
     233        lib$signal(status);
     234      return;
     235    }
     236
     237  /* called from AST handler ? */
     238  if (setupYAstTried>1)
     239    return;
     240  if (atexit(reEnableAst))
     241    fprintf (stderr,
     242             _("-warning, you may have to re-enable CTRL-Y handling from DCL.\n"));
     243  status= lib$disable_ctrl (&ctrlMask, &oldCtrlMask);
     244  if (!(status&SS$_NORMAL))
     245    {
     246      lib$signal(status);
     247      return;
     248    }
     249  if (!chan)
     250    chan = loc_chan;
    297251}
    298252
     253/* Check if a token is too long */
     254#define INC_TOKEN_LEN_OR_RETURN(x) {token->length++; \
     255  if (token->length >= MAX_DCL_TOKEN_LENGTH) \
     256    { token->cmd_errno = ERANGE; return x; }}
     257
     258#define INC_TOKEN_LEN_OR_BREAK {token->length++; \
     259  if (token->length >= MAX_DCL_TOKEN_LENGTH) \
     260    { token->cmd_errno = ERANGE; break; }}
     261
     262#define ADD_TOKEN_LEN_OR_RETURN(add_len, x) {token->length += add_len; \
     263  if (token->length >= MAX_DCL_TOKEN_LENGTH) \
     264    { token->cmd_errno = ERANGE; return x; }}
     265
     266/* Check if we are out of space for more tokens */
     267#define V_NEXT_TOKEN { if (cmd_tkn_index < MAX_DCL_TOKENS) \
     268  cmd_tokens[++cmd_tkn_index] = NULL; \
     269  else { token.cmd_errno = E2BIG; break; } \
     270  token.length = 0;}
     271
     272
     273#define UPDATE_TOKEN {cmd_tokens[cmd_tkn_index] = strdup(token.text); \
     274  V_NEXT_TOKEN;}
     275
     276#define EOS_ERROR(x) { if (*x == 0) { token->cmd_errno = ERANGE; break; }}
     277
     278struct token_info
     279  {
     280    char *text;       /* Parsed text */
     281    int length;       /* Length of parsed text */
     282    char *src;        /* Pointer to source text */
     283    int cmd_errno;    /* Error status of parse */
     284    int use_cmd_file; /* Force use of a command file */
     285  };
     286
     287
     288/* Extract a Posix single quoted string from input line */
     289static char *
     290posix_parse_sq (struct token_info *token)
     291{
     292  /* A Posix quoted string with no expansion unless in a string
     293     Unix simulation means no lexical functions present.
     294  */
     295  char * q;
     296  char * p;
     297  q = token->text;
     298  p = token->src;
     299
     300  *q++ = '"';
     301  p++;
     302  INC_TOKEN_LEN_OR_RETURN (p);
     303
     304  while (*p != '\'' && (token->length < MAX_DCL_TOKEN_LENGTH))
     305    {
     306      EOS_ERROR (p);
     307      if (*p == '"')
     308        {
     309          /* Embedded double quotes need to be doubled */
     310          *q++ = '"';
     311          INC_TOKEN_LEN_OR_BREAK;
     312          *q = '"';
     313        }
     314      else
     315        *q = *p;
     316
     317      q++;
     318      p++;
     319      INC_TOKEN_LEN_OR_BREAK;
     320    }
     321  *q++ = '"';
     322  p++;
     323  INC_TOKEN_LEN_OR_RETURN (p);
     324  *q = 0;
     325  return p;
     326}
     327
     328/* Extract a Posix double quoted string from input line */
     329static char *
     330posix_parse_dq (struct token_info *token)
     331{
     332  /* Unix mode:  Any imbedded \" becomes doubled.
     333                 \t is tab, \\, \$ leading character stripped.
     334                 $ character replaced with \' unless escaped.
     335  */
     336  char * q;
     337  char * p;
     338  q = token->text;
     339  p = token->src;
     340  *q++ = *p++;
     341  INC_TOKEN_LEN_OR_RETURN (p);
     342  while (*p != 0)
     343    {
     344      if (*p == '\\')
     345        {
     346          switch(p[1])
     347            {
     348            case 't':     /* Convert tabs */
     349              *q = '\t';
     350              p++;
     351              break;
     352            case '\\':     /* Just remove leading backslash */
     353            case '$':
     354              p++;
     355              *q = *p;
     356              break;
     357            case '"':
     358              p++;
     359              *q = *p;
     360              *q++ = '"';
     361              INC_TOKEN_LEN_OR_BREAK;
     362            default:      /* Pass through unchanged */
     363              *q++ = *p++;
     364              INC_TOKEN_LEN_OR_BREAK;
     365            }
     366          INC_TOKEN_LEN_OR_BREAK;
     367        }
     368      else if (*p == '$' && isalpha (p[1]))
     369        {
     370          /* A symbol we should be able to substitute */
     371          *q++ = '\'';
     372          INC_TOKEN_LEN_OR_BREAK;
     373          *q = '\'';
     374          INC_TOKEN_LEN_OR_BREAK;
     375          token->use_cmd_file = 1;
     376        }
     377      else
     378        {
     379          *q = *p;
     380          INC_TOKEN_LEN_OR_BREAK;
     381          if (*p == '"')
     382            {
     383              p++;
     384              q++;
     385              break;
     386            }
     387        }
     388      p++;
     389      q++;
     390    }
     391  *q = 0;
     392  return p;
     393}
     394
     395/* Extract a VMS quoted string or substitution string from input line */
     396static char *
     397vms_parse_quotes (struct token_info *token)
     398{
     399  /* VMS mode, the \' means that a symbol substitution is starting
     400     so while you might think you can just copy until the next
     401     \'.  Unfortunately the substitution can be a lexical function
     402     which can contain embedded strings and lexical functions.
     403     Messy, so both types need to be handled together.
     404  */
     405  char * q;
     406  char * p;
     407  q = token->text;
     408  p = token->src;
     409  int parse_level[MAX_DCL_TOKENS + 1];
     410  int nest = 0;
     411
     412  parse_level[0] = *p;
     413  if (parse_level[0] == '\'')
     414    token->use_cmd_file = 1;
     415
     416  *q++ = *p++;
     417  INC_TOKEN_LEN_OR_RETURN (p);
     418
     419
     420  /* Copy everything until after the next single quote at nest == 0 */
     421  while (token->length < MAX_DCL_TOKEN_LENGTH)
     422    {
     423      EOS_ERROR (p);
     424      *q = *p;
     425      INC_TOKEN_LEN_OR_BREAK;
     426      if ((*p == parse_level[nest]) && (p[1] != '"'))
     427        {
     428          if (nest == 0)
     429            {
     430              *q++ = *p++;
     431              break;
     432            }
     433          nest--;
     434        }
     435      else
     436        {
     437          switch(*p)
     438            {
     439            case '\\':
     440              /* Handle continuation on to next line */
     441              if (p[1] != '\n')
     442                break;
     443              p++;
     444              p++;
     445              *q = *p;
     446              break;
     447            case '(':
     448              /* Parenthesis only in single quote level */
     449              if (parse_level[nest] == '\'')
     450                {
     451                  nest++;
     452                  parse_level[nest] == ')';
     453                }
     454              break;
     455            case '"':
     456              /* Double quotes only in parenthesis */
     457              if (parse_level[nest] == ')')
     458                {
     459                  nest++;
     460                  parse_level[nest] == '"';
     461                }
     462              break;
     463            case '\'':
     464              /* Symbol substitution ony in double quotes */
     465              if ((p[1] == '\'') && (parse_level[nest] == '"'))
     466                {
     467                  nest++;
     468                  parse_level[nest] == '\'';
     469                  *p++ = *q++;
     470                  token->use_cmd_file = 1;
     471                  INC_TOKEN_LEN_OR_BREAK;
     472                  break;
     473                }
     474              *q = *p;
     475            }
     476        }
     477      p++;
     478      q++;
     479      /* Pass through doubled double quotes */
     480      if ((*p == '"') && (p[1] == '"') && (parse_level[nest] == '"'))
     481      {
     482        *p++ = *q++;
     483        INC_TOKEN_LEN_OR_BREAK;
     484        *p++ = *q++;
     485        INC_TOKEN_LEN_OR_BREAK;
     486      }
     487    }
     488  *q = 0;
     489  return p;
     490}
     491
     492/* Extract a $ string from the input line */
     493static char *
     494posix_parse_dollar (struct token_info *token)
     495{
     496  /* $foo becomes 'foo' */
     497  char * q;
     498  char * p;
     499  q = token->text;
     500  p = token->src;
     501  token->use_cmd_file = 1;
     502
     503  p++;
     504  *q++ = '\'';
     505  INC_TOKEN_LEN_OR_RETURN (p);
     506
     507  while ((isalnum (*p)) || (*p == '_'))
     508    {
     509      *q++ = *p++;
     510      INC_TOKEN_LEN_OR_BREAK;
     511    }
     512  *q++ = '\'';
     513  while (1)
     514    {
     515      INC_TOKEN_LEN_OR_BREAK;
     516      break;
     517    }
     518  *q = 0;
     519  return p;
     520}
     521
     522const char *vms_filechars = "0123456789abcdefghijklmnopqrstuvwxyz" \
     523   "ABCDEFGHIJKLMNOPQRSTUVWXYZ[]<>:/_-.$";
     524
     525/* Simple text copy */
     526static char *
     527parse_text (struct token_info *token, int assignment_hack)
     528{
     529  char * q;
     530  char * p;
     531  int str_len;
     532  q = token->text;
     533  p = token->src;
     534
     535  /* If assignment hack, then this text needs to be double quoted. */
     536  if (vms_unix_simulation && (assignment_hack == 2))
     537    {
     538      *q++ = '"';
     539      INC_TOKEN_LEN_OR_RETURN (p);
     540    }
     541
     542  *q++ = *p++;
     543  INC_TOKEN_LEN_OR_RETURN (p);
     544
     545  while (*p != 0)
     546    {
     547      str_len = strspn (p, vms_filechars);
     548      if (str_len == 0)
     549        {
     550          /* Pass through backslash escapes in Unix simulation
     551             probably will not work anyway.
     552             All any character after a ^ otherwise to support EFS.
     553          */
     554          if (vms_unix_simulation && (p[0] == '\\') && (p[1] != 0))
     555            str_len = 2;
     556          else if ((p[0] == '^') && (p[1] != 0))
     557            str_len = 2;
     558          else if (!vms_unix_simulation && (p[0] == ';'))
     559            str_len = 1;
     560
     561          if (str_len == 0)
     562            {
     563              /* If assignment hack, then this needs to be double quoted. */
     564              if (vms_unix_simulation && (assignment_hack == 2))
     565              {
     566                *q++ = '"';
     567                INC_TOKEN_LEN_OR_RETURN (p);
     568              }
     569              *q = 0;
     570              return p;
     571            }
     572        }
     573      if (str_len > 0)
     574        {
     575          ADD_TOKEN_LEN_OR_RETURN (str_len, p);
     576          strncpy (q, p, str_len);
     577          p += str_len;
     578          q += str_len;
     579          *q = 0;
     580        }
     581    }
     582  /* If assignment hack, then this text needs to be double quoted. */
     583  if (vms_unix_simulation && (assignment_hack == 2))
     584    {
     585      *q++ = '"';
     586      INC_TOKEN_LEN_OR_RETURN (p);
     587    }
     588  return p;
     589}
     590
     591/* single character copy */
     592static char *
     593parse_char (struct token_info *token, int count)
     594{
     595  char * q;
     596  char * p;
     597  q = token->text;
     598  p = token->src;
     599
     600  while (count > 0)
     601    {
     602      *q++ = *p++;
     603      INC_TOKEN_LEN_OR_RETURN (p);
     604      count--;
     605    }
     606  *q = 0;
     607  return p;
     608}
     609
     610/* Build a command string from the collected tokens
     611   and process built-ins now
     612*/
     613static struct dsc$descriptor_s *
     614build_vms_cmd (char **cmd_tokens,
     615               enum auto_pipe use_pipe_cmd,
     616               int append_token)
     617{
     618  struct dsc$descriptor_s *cmd_dsc;
     619  int cmd_tkn_index;
     620  char * cmd;
     621  int cmd_len;
     622  int semicolon_seen;
     623
     624  cmd_tkn_index = 0;
     625  cmd_dsc = xmalloc (sizeof (struct dsc$descriptor_s));
     626
     627  /* Empty command? */
     628  if (cmd_tokens[0] == NULL)
     629    {
     630      cmd_dsc->dsc$a_pointer = NULL;
     631      cmd_dsc->dsc$w_length = 0;
     632      return cmd_dsc;
     633    }
     634
     635  /* Max DCL command + 1 extra token and trailing space */
     636  cmd = xmalloc (MAX_DCL_CMD_LINE_LENGTH + 256);
     637
     638  cmd[0] = '$';
     639  cmd[1] = 0;
     640  cmd_len = 1;
     641
     642  /* Handle real or auto-pipe */
     643  if (use_pipe_cmd == add_pipe)
     644    {
     645      /* We need to auto convert to a pipe command */
     646      strcat (cmd, "pipe ");
     647      cmd_len += 5;
     648    }
     649
     650  semicolon_seen = 0;
     651  while (cmd_tokens[cmd_tkn_index] != NULL)
     652    {
     653
     654      /* Check for buffer overflow */
     655      if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
     656        {
     657          errno = E2BIG;
     658          break;
     659        }
     660
     661      /* Eliminate double ';' */
     662      if (semicolon_seen && (cmd_tokens[cmd_tkn_index][0] == ';'))
     663        {
     664          semicolon_seen = 0;
     665          free (cmd_tokens[cmd_tkn_index++]);
     666          if (cmd_tokens[cmd_tkn_index] == NULL)
     667            break;
     668        }
     669
     670      /* Special handling for CD built-in */
     671      if (strncmp (cmd_tokens[cmd_tkn_index], "builtin_cd", 11) == 0)
     672        {
     673          int result;
     674          semicolon_seen = 0;
     675          free (cmd_tokens[cmd_tkn_index]);
     676          cmd_tkn_index++;
     677          if (cmd_tokens[cmd_tkn_index] == NULL)
     678            break;
     679          DB(DB_JOBS, (_("BUILTIN CD %s\n"), cmd_tokens[cmd_tkn_index]));
     680
     681          /* TODO: chdir fails with some valid syntaxes */
     682          result = chdir (cmd_tokens[cmd_tkn_index]);
     683          if (result != 0)
     684            {
     685              /* TODO: Handle failure better */
     686              free (cmd);
     687              while (cmd_tokens[cmd_tkn_index] == NULL)
     688                free (cmd_tokens[cmd_tkn_index++]);
     689              cmd_dsc->dsc$w_length = -1;
     690              cmd_dsc->dsc$a_pointer = NULL;
     691              return cmd_dsc;
     692            }
     693        }
     694      else if (strncmp (cmd_tokens[cmd_tkn_index], "exit", 5) == 0)
     695        {
     696          /* Copy the exit command */
     697          semicolon_seen = 0;
     698          strcpy (&cmd[cmd_len], cmd_tokens[cmd_tkn_index]);
     699          cmd_len += strlen (cmd_tokens[cmd_tkn_index]);
     700          free (cmd_tokens[cmd_tkn_index++]);
     701          if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
     702            {
     703              errno = E2BIG;
     704              break;
     705            }
     706
     707          /* Optional whitespace */
     708          if (isspace (cmd_tokens[cmd_tkn_index][0]))
     709            {
     710              strcpy (&cmd[cmd_len], cmd_tokens[cmd_tkn_index]);
     711              cmd_len += strlen (cmd_tokens[cmd_tkn_index]);
     712              free (cmd_tokens[cmd_tkn_index++]);
     713              if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
     714              {
     715                errno = E2BIG;
     716                break;
     717              }
     718            }
     719
     720          /* There should be a status, but it is optional */
     721          if (cmd_tokens[cmd_tkn_index][0] == ';')
     722            continue;
     723
     724          /* If Unix simulation, add '((' */
     725          if (vms_unix_simulation)
     726            {
     727              strcpy (&cmd[cmd_len], "((");
     728              cmd_len += 2;
     729              if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
     730                {
     731                  errno = E2BIG;
     732                  break;
     733                }
     734            }
     735
     736          /* Add the parameter */
     737          strcpy (&cmd[cmd_len], cmd_tokens[cmd_tkn_index]);
     738          cmd_len += strlen (cmd_tokens[cmd_tkn_index]);
     739          free (cmd_tokens[cmd_tkn_index++]);
     740          if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
     741            {
     742              errno = E2BIG;
     743              break;
     744            }
     745
     746          /* Add " * 8) .and. %x7f8) .or. %x1035a002" */
     747          if (vms_unix_simulation)
     748            {
     749              const char *end_str = " * 8) .and. %x7f8) .or. %x1035a002";
     750              strcpy (&cmd[cmd_len], end_str);
     751              cmd_len += strlen (end_str);
     752              if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
     753                {
     754                  errno = E2BIG;
     755                  break;
     756                }
     757            }
     758          continue;
     759        }
     760
     761      /* auto pipe needs spaces before semicolon */
     762      if (use_pipe_cmd == add_pipe)
     763        if (cmd_tokens[cmd_tkn_index][0] == ';')
     764          {
     765            cmd[cmd_len++] = ' ';
     766            semicolon_seen = 1;
     767            if (cmd_len > MAX_DCL_CMD_LINE_LENGTH)
     768              {
     769                errno = E2BIG;
     770                break;
     771              }
     772          }
     773        else
     774          {
     775            char ch;
     776            ch = cmd_tokens[cmd_tkn_index][0];
     777            if (!(ch == ' ' || ch == '\t'))
     778              semicolon_seen = 0;
     779          }
     780
     781      strcpy (&cmd[cmd_len], cmd_tokens[cmd_tkn_index]);
     782      cmd_len += strlen (cmd_tokens[cmd_tkn_index]);
     783
     784      free (cmd_tokens[cmd_tkn_index++]);
     785
     786      /* Skip the append tokens if they exist */
     787      if (cmd_tkn_index == append_token)
     788        {
     789          free (cmd_tokens[cmd_tkn_index++]);
     790          if (isspace (cmd_tokens[cmd_tkn_index][0]))
     791            free (cmd_tokens[cmd_tkn_index++]);
     792          free (cmd_tokens[cmd_tkn_index++]);
     793        }
     794    }
     795
     796  cmd[cmd_len] = 0;
     797  cmd_dsc->dsc$w_length = cmd_len;
     798  cmd_dsc->dsc$a_pointer = cmd;
     799  cmd_dsc->dsc$b_dtype = DSC$K_DTYPE_T;
     800  cmd_dsc->dsc$b_class = DSC$K_CLASS_S;
     801
     802  return cmd_dsc;
     803}
     804
    299805int
    300 child_execute_job (char *argv, struct child *child)
     806child_execute_job (struct child *child, char *argv)
    301807{
    302808  int i;
    303   static struct dsc$descriptor_s cmddsc;
     809
     810  static struct dsc$descriptor_s *cmd_dsc;
    304811  static struct dsc$descriptor_s pnamedsc;
    305   static struct dsc$descriptor_s ifiledsc;
    306   static struct dsc$descriptor_s ofiledsc;
    307   static struct dsc$descriptor_s efiledsc;
    308   int have_redirection = 0;
    309   int have_append = 0;
    310   int have_newline = 0;
    311 
    312812  int spflags = CLI$M_NOWAIT;
    313813  int status;
    314   char *cmd = alloca (strlen (argv) + 512), *p, *q;
    315   char ifile[256], ofile[256], efile[256];
    316814  int comnamelen;
    317815  char procname[100];
    318   int in_string;
     816
     817  char *p;
     818  char *cmd_tokens[(MAX_DCL_TOKENS * 2) + 1]; /* whitespace does not count */
     819  char token_str[MAX_DCL_TOKEN_LENGTH + 1];
     820  struct token_info token;
     821  int cmd_tkn_index;
     822  int paren_level = 0;
     823  enum auto_pipe use_pipe_cmd = nopipe;
     824  int append_token = -1;
     825  char *append_file = NULL;
     826  int unix_echo_cmd = 0;  /* Special handle Unix echo command */
     827  int assignment_hack = 0; /* Handle x=y command as piped command */
    319828
    320829  /* Parse IO redirection.  */
    321830
    322   ifile[0] = 0;
    323   ofile[0] = 0;
    324   efile[0] = 0;
    325831  child->comname = NULL;
    326832
     
    331837
    332838  if (*argv == 0)
    333     return 0;
     839    {
     840      /* Only a built-in or a null command - Still need to run term AST */
     841      child->cstatus = VMS_POSIX_EXIT_MASK;
     842      child->vms_launch_status = SS$_NORMAL;
     843      /* TODO what is this "magic number" */
     844      child->pid = 270163; /* Special built-in */
     845      child->efn = 0;
     846      vmsHandleChildTerm (child);
     847      return 1;
     848    }
    334849
    335850  sprintf (procname, "GMAKE_%05x", getpid () & 0xfffff);
    336   pnamedsc.dsc$w_length = strlen(procname);
     851  pnamedsc.dsc$w_length = strlen (procname);
    337852  pnamedsc.dsc$a_pointer = procname;
    338853  pnamedsc.dsc$b_dtype = DSC$K_DTYPE_T;
    339854  pnamedsc.dsc$b_class = DSC$K_CLASS_S;
    340855
    341   in_string = 0;
    342   /* Handle comments and redirection. */
    343   for (p = argv, q = cmd; *p; p++, q++)
    344     {
    345       if (*p == '"')
    346         in_string = !in_string;
    347       if (in_string)
    348         {
    349           *q = *p;
    350           continue;
    351         }
     856  /* Old */
     857  /* Handle comments and redirection.
     858     For ONESHELL, the redirection must be on the first line. Any other
     859     redirection token is handled by DCL, that is, the pipe command with
     860     redirection can be used, but it should not be used on the first line
     861     for ONESHELL. */
     862
     863  /* VMS parser notes:
     864     1. A token is any of DCL verbs, qualifiers, parameters, or punctuation.
     865     2. Only MAX_DCL_TOKENS per line in both one line or command file mode.
     866     3. Each token limited to MAC_DCL_TOKEN_LENGTH
     867     4. If the line to DCL is greater than MAX_DCL_LINE_LENGTH then a
     868        command file must be used.
     869     5. Currently a command file must be used symbol substitution is to
     870        be performed.
     871     6. Currently limiting command files to 2 * MAX_DCL_TOKENS.
     872
     873     Build both a command file token list and command line token list
     874     until it is determined that the command line limits are exceeded.
     875  */
     876
     877  cmd_tkn_index = 0;
     878  cmd_tokens[cmd_tkn_index] = NULL;
     879  p = argv;
     880
     881  token.text = token_str;
     882  token.length = 0;
     883  token.cmd_errno = 0;
     884  token.use_cmd_file = 0;
     885
     886  while (*p != 0)
     887    {
     888      /* We can not build this command so give up */
     889      if (token.cmd_errno != 0)
     890        break;
     891
     892      token.src = p;
     893
    352894      switch (*p)
    353         {
    354           case '#':
    355             *p-- = 0;
    356             *q-- = 0;
    357             break;
    358           case '\\':
    359             p++;
    360             if (*p == '\n')
    361               p++;
    362             if (isspace ((unsigned char)*p))
    363               {
    364                 do { p++; } while (isspace ((unsigned char)*p));
    365                 p--;
    366               }
    367             *q = *p;
    368             break;
    369           case '<':
    370             p = vms_redirect (&ifiledsc, ifile, p);
    371             *q = ' ';
    372             have_redirection = 1;
    373             break;
    374           case '>':
    375             have_redirection = 1;
    376             if (*(p-1) == '2')
    377               {
    378                 q--;
    379                 if (strncmp (p, ">&1", 3) == 0)
    380                   {
    381                     p += 3;
    382                     strcpy (efile, "sys$output");
    383                     efiledsc.dsc$w_length = strlen(efile);
    384                     efiledsc.dsc$a_pointer = efile;
    385                     efiledsc.dsc$b_dtype = DSC$K_DTYPE_T;
    386                     efiledsc.dsc$b_class = DSC$K_CLASS_S;
    387                   }
    388                 else
    389                   {
    390                     p = vms_redirect (&efiledsc, efile, p);
    391                   }
    392               }
    393             else
    394               {
    395                 if (*(p+1) == '>')
    396                   {
    397                     have_append = 1;
    398                     p += 1;
    399                   }
    400                 p = vms_redirect (&ofiledsc, ofile, p);
    401               }
    402             *q = ' ';
    403             break;
    404           case '\n':
    405             have_newline = 1;
    406           default:
    407             *q = *p;
    408             break;
    409         }
    410     }
    411   *q = *p;
    412   while (isspace ((unsigned char)*--q))
    413     *q = '\0';
    414 
    415   if (strncmp (cmd, "builtin_", 8) == 0)
    416     {
    417       child->pid = 270163;
     895        {
     896        case '\'':
     897          if (vms_unix_simulation || unix_echo_cmd)
     898            {
     899              p = posix_parse_sq (&token);
     900              UPDATE_TOKEN;
     901              break;
     902            }
     903
     904          /* VMS mode, the \' means that a symbol substitution is starting
     905             so while you might think you can just copy until the next
     906             \'.  Unfortunately the substitution can be a lexical function
     907             which can contain embedded strings and lexical functions.
     908             Messy.
     909          */
     910          p = vms_parse_quotes (&token);
     911          UPDATE_TOKEN;
     912          break;
     913        case '"':
     914          if (vms_unix_simulation)
     915            {
     916              p = posix_parse_dq (&token);
     917              UPDATE_TOKEN;
     918              break;
     919            }
     920
     921          /* VMS quoted string, can contain lexical functions with
     922             quoted strings and nested lexical functions.
     923          */
     924          p = vms_parse_quotes (&token);
     925          UPDATE_TOKEN;
     926          break;
     927
     928        case '$':
     929          if (vms_unix_simulation)
     930            {
     931              p = posix_parse_dollar (&token);
     932              UPDATE_TOKEN;
     933              break;
     934            }
     935
     936          /* Otherwise nothing special */
     937          p = parse_text (&token, 0);
     938          UPDATE_TOKEN;
     939          break;
     940        case '\\':
     941          if (p[1] == '\n')
     942            {
     943              /* Line continuation, remove it */
     944              p += 2;
     945              break;
     946            }
     947
     948          /* Ordinary character otherwise */
     949          if (assignment_hack != 0)
     950            assignment_hack++;
     951          if (assignment_hack > 2)
     952            {
     953              assignment_hack = 0;          /* Reset */
     954              if (use_pipe_cmd == nopipe)   /* force pipe use */
     955                use_pipe_cmd = add_pipe;
     956              token_str[0] = ';';              /* add ; token */
     957              token_str[1] = 0;
     958              UPDATE_TOKEN;
     959            }
     960          p = parse_text (&token, assignment_hack);
     961          UPDATE_TOKEN;
     962          break;
     963        case '!':
     964        case '#':
     965          /* Unix '#' is VMS '!' which comments out the rest of the line.
     966             Historically the rest of the line has been skipped.
     967             Not quite the right thing to do, as the f$verify lexical
     968             function works in comments.  But this helps keep the line
     969             lengths short.
     970          */
     971          unix_echo_cmd = 0;
     972          while (*p != '\n' && *p != 0)
     973            p++;
     974          break;
     975        case '(':
     976          /* Subshell, equation, or lexical function argument start */
     977          p = parse_char (&token, 1);
     978          UPDATE_TOKEN;
     979          paren_level++;
     980          break;
     981        case ')':
     982          /* Close out a paren level */
     983          p = parse_char (&token, 1);
     984          UPDATE_TOKEN;
     985          paren_level--;
     986          /* TODO: Should we diagnose if paren_level goes negative? */
     987          break;
     988        case '&':
     989          if (isalpha (p[1]) && !vms_unix_simulation)
     990            {
     991              /* VMS symbol substitution */
     992              p = parse_text (&token, 0);
     993              token.use_cmd_file = 1;
     994              UPDATE_TOKEN;
     995              break;
     996            }
     997          if (use_pipe_cmd == nopipe)
     998            use_pipe_cmd = add_pipe;
     999          if (p[1] != '&')
     1000            p = parse_char (&token, 1);
     1001          else
     1002            p = parse_char (&token, 2);
     1003          UPDATE_TOKEN;
     1004          break;
     1005        case '|':
     1006          if (use_pipe_cmd == nopipe)
     1007            use_pipe_cmd = add_pipe;
     1008          if (p[1] != '|')
     1009            p = parse_char (&token, 1);
     1010          else
     1011            p = parse_char (&token, 2);
     1012          UPDATE_TOKEN;
     1013          break;
     1014        case ';':
     1015          /* Separator - convert to a pipe command. */
     1016          unix_echo_cmd = 0;
     1017        case '<':
     1018          if (use_pipe_cmd == nopipe)
     1019            use_pipe_cmd = add_pipe;
     1020          p = parse_char (&token, 1);
     1021          UPDATE_TOKEN;
     1022          break;
     1023        case '>':
     1024          if (use_pipe_cmd == nopipe)
     1025            use_pipe_cmd = add_pipe;
     1026          if (p[1] == '>')
     1027            {
     1028              /* Parsing would have been simple until support for the >>
     1029                 append redirect was added.
     1030                 Implementation needs:
     1031                 * if not exist output file create empty
     1032                 * open/append gnv$make_temp??? output_file
     1033                 * define/user sys$output gnv$make_temp???
     1034                 ** And all this done before the command previously tokenized.
     1035                 * command previously tokenized
     1036                 * close gnv$make_temp???
     1037              */
     1038              p = parse_char (&token, 2);
     1039              append_token = cmd_tkn_index;
     1040              token.use_cmd_file = 1;
     1041            }
     1042          else
     1043            p = parse_char (&token, 1);
     1044          UPDATE_TOKEN;
     1045          break;
     1046        case '/':
     1047          /* Unix path or VMS option start, read until non-path symbol */
     1048          if (assignment_hack != 0)
     1049            assignment_hack++;
     1050          if (assignment_hack > 2)
     1051            {
     1052              assignment_hack = 0;          /* Reset */
     1053              if (use_pipe_cmd == nopipe)   /* force pipe use */
     1054                use_pipe_cmd = add_pipe;
     1055              token_str[0] = ';';              /* add ; token */
     1056              token_str[1] = 0;
     1057              UPDATE_TOKEN;
     1058            }
     1059          p = parse_text (&token, assignment_hack);
     1060          UPDATE_TOKEN;
     1061          break;
     1062        case ':':
     1063          if ((p[1] == 0) || isspace (p[1]))
     1064            {
     1065              /* Unix Null command - treat as comment until next command */
     1066              unix_echo_cmd = 0;
     1067              p++;
     1068              while (*p != 0)
     1069                {
     1070                  if (*p == ';')
     1071                    {
     1072                      /* Remove Null command from pipeline */
     1073                      p++;
     1074                      break;
     1075                    }
     1076                  p++;
     1077                }
     1078              break;
     1079            }
     1080
     1081          /* String assignment */
     1082          /* := :== or : */
     1083          if (p[1] != '=')
     1084            p = parse_char (&token, 1);
     1085          else if (p[2] != '=')
     1086            p = parse_char (&token, 2);
     1087          else
     1088            p = parse_char (&token, 3);
     1089          UPDATE_TOKEN;
     1090          break;
     1091        case '=':
     1092          /* = or == */
     1093          /* If this is not an echo statement, this could be a shell
     1094             assignment.  VMS requires the target to be quoted if it
     1095             is not a macro substitution */
     1096          if (!unix_echo_cmd && vms_unix_simulation && (assignment_hack == 0))
     1097            assignment_hack = 1;
     1098          if (p[1] != '=')
     1099            p = parse_char (&token, 1);
     1100          else
     1101            p = parse_char (&token, 2);
     1102          UPDATE_TOKEN;
     1103          break;
     1104        case '+':
     1105        case '-':
     1106        case '*':
     1107          p = parse_char (&token, 1);
     1108          UPDATE_TOKEN;
     1109          break;
     1110        case '.':
     1111          /* .xxx. operation, VMS does not require the trailing . */
     1112          p = parse_text (&token, 0);
     1113          UPDATE_TOKEN;
     1114          break;
     1115        default:
     1116          /* Skip repetitive whitespace */
     1117          if (isspace (*p))
     1118            {
     1119              p = parse_char (&token, 1);
     1120
     1121              /* Force to a space or a tab */
     1122              if ((token_str[0] != ' ') ||
     1123                  (token_str[0] != '\t'))
     1124                token_str[0] = ' ';
     1125              UPDATE_TOKEN;
     1126
     1127              while (isspace (*p))
     1128                p++;
     1129              if (assignment_hack != 0)
     1130                assignment_hack++;
     1131              break;
     1132            }
     1133
     1134          if (assignment_hack != 0)
     1135            assignment_hack++;
     1136          if (assignment_hack > 2)
     1137            {
     1138              assignment_hack = 0;          /* Reset */
     1139              if (use_pipe_cmd == nopipe)   /* force pipe use */
     1140                use_pipe_cmd = add_pipe;
     1141              token_str[0] = ';';              /* add ; token */
     1142              token_str[1] = 0;
     1143              UPDATE_TOKEN;
     1144            }
     1145          p = parse_text (&token, assignment_hack);
     1146          if (strncasecmp (token.text, "echo", 4) == 0)
     1147            unix_echo_cmd = 1;
     1148          else if (strncasecmp (token.text, "pipe", 4) == 0)
     1149            use_pipe_cmd = dcl_pipe;
     1150          UPDATE_TOKEN;
     1151          break;
     1152        }
     1153    }
     1154
     1155  /* End up here with a list of tokens to build a command line.
     1156     Deal with errors detected during parsing.
     1157   */
     1158  if (token.cmd_errno != 0)
     1159    {
     1160      while (cmd_tokens[cmd_tkn_index] == NULL)
     1161        free (cmd_tokens[cmd_tkn_index++]);
     1162      child->cstatus = VMS_POSIX_EXIT_MASK | (MAKE_TROUBLE << 3);
     1163      child->vms_launch_status = SS$_ABORT;
     1164      /* TODO what is this "magic number" */
     1165      child->pid = 270163; /* Special built-in */
    4181166      child->efn = 0;
    419       child->cstatus = 1;
    420 
    421       DB (DB_JOBS, (_("BUILTIN [%s][%s]\n"), cmd, cmd+8));
    422 
    423       p = cmd + 8;
    424 
    425       if ((*(p) == 'c')
    426           && (*(p+1) == 'd')
    427           && ((*(p+2) == ' ') || (*(p+2) == '\t')))
    428         {
    429           p += 3;
    430           while ((*p == ' ') || (*p == '\t'))
    431             p++;
    432           DB (DB_JOBS, (_("BUILTIN CD %s\n"), p));
    433           if (chdir (p))
    434             return 0;
    435           else
    436             return 1;
    437         }
    438       else if ((*(p) == 'r')
    439           && (*(p+1) == 'm')
    440           && ((*(p+2) == ' ') || (*(p+2) == '\t')))
    441         {
    442           int in_arg;
    443 
    444           /* rm  */
    445           p += 3;
    446           while ((*p == ' ') || (*p == '\t'))
    447             p++;
    448           in_arg = 1;
    449 
    450           DB (DB_JOBS, (_("BUILTIN RM %s\n"), p));
    451           while (*p)
    452             {
    453               switch (*p)
    454                 {
    455                   case ' ':
    456                   case '\t':
    457                     if (in_arg)
    458                       {
    459                         *p++ = ';';
    460                         in_arg = 0;
    461                       }
    462                     break;
    463                   default:
    464                     break;
    465                 }
    466               p++;
    467             }
    468         }
     1167      errno = token.cmd_errno;
     1168      return 0;
     1169    }
     1170
     1171  /* Save any redirection to append file */
     1172  if (append_token != -1)
     1173    {
     1174      int file_token;
     1175      char * lastdot;
     1176      char * lastdir;
     1177      char * raw_append_file;
     1178      file_token = append_token;
     1179      file_token++;
     1180      if (isspace (cmd_tokens[file_token][0]))
     1181        file_token++;
     1182      raw_append_file = vmsify (cmd_tokens[file_token], 0);
     1183      /* VMS DCL needs a trailing dot if null file extension */
     1184      lastdot = strrchr(raw_append_file, '.');
     1185      lastdir = strrchr(raw_append_file, ']');
     1186      if (lastdir == NULL)
     1187        lastdir = strrchr(raw_append_file, '>');
     1188      if (lastdir == NULL)
     1189        lastdir = strrchr(raw_append_file, ':');
     1190      if ((lastdot == NULL) || (lastdot > lastdir))
     1191        {
     1192          append_file = xmalloc (strlen (raw_append_file) + 1);
     1193          strcpy (append_file, raw_append_file);
     1194          strcat (append_file, ".");
     1195        }
    4691196      else
    470         {
    471           printf(_("Unknown builtin command '%s'\n"), cmd);
    472           fflush(stdout);
    473           return 0;
    474         }
    475     }
    476 
    477   /* Create a *.com file if either the command is too long for
    478      lib$spawn, or the command contains a newline, or if redirection
    479      is desired. Forcing commands with newlines into DCLs allows to
    480      store search lists on user mode logicals.  */
    481 
    482   if (strlen (cmd) > MAXCMDLEN
    483       || (have_redirection != 0)
    484       || (have_newline != 0))
     1197        append_file = strdup(raw_append_file);
     1198    }
     1199
     1200  cmd_dsc = build_vms_cmd (cmd_tokens, use_pipe_cmd, append_token);
     1201  if (cmd_dsc->dsc$a_pointer == NULL)
     1202    {
     1203      if (cmd_dsc->dsc$w_length < 0)
     1204        {
     1205          free (cmd_dsc);
     1206          child->cstatus = VMS_POSIX_EXIT_MASK | (MAKE_TROUBLE << 3);
     1207          child->vms_launch_status = SS$_ABORT;
     1208          /* TODO what is this "magic number" */
     1209          child->pid = 270163; /* Special built-in */
     1210          child->efn = 0;
     1211          return 0;
     1212        }
     1213
     1214      /* Only a built-in or a null command - Still need to run term AST */
     1215      free (cmd_dsc);
     1216      child->cstatus = VMS_POSIX_EXIT_MASK;
     1217      child->vms_launch_status = SS$_NORMAL;
     1218      /* TODO what is this "magic number" */
     1219      child->pid = 270163; /* Special built-in */
     1220      child->efn = 0;
     1221      vmsHandleChildTerm (child);
     1222      return 1;
     1223    }
     1224
     1225  if (cmd_dsc->dsc$w_length > MAX_DCL_LINE_LENGTH)
     1226    token.use_cmd_file = 1;
     1227
     1228  DB(DB_JOBS, (_("DCL: %s\n"), cmd_dsc->dsc$a_pointer));
     1229
     1230  /* Enforce the creation of a command file if "vms_always_use_cmd_file" is
     1231     non-zero.
     1232     Further, this way DCL reads the input stream and therefore does
     1233     'forced' symbol substitution, which it doesn't do for one-liners when
     1234     they are 'lib$spawn'ed.
     1235
     1236     Otherwise the behavior is:
     1237
     1238     Create a *.com file if either the command is too long for
     1239     lib$spawn, or if a redirect appending to a file is desired, or
     1240     symbol substitition.
     1241  */
     1242
     1243  if (vms_always_use_cmd_file || token.use_cmd_file)
    4851244    {
    4861245      FILE *outfile;
    487       char c;
    488       char *sep;
    489       int alevel = 0;   /* apostrophe level */
    490 
    491       if (strlen (cmd) == 0)
    492         {
    493           printf (_("Error, empty command\n"));
    494           fflush (stdout);
    495           return 0;
    496         }
    497 
    498       outfile = open_tmpfile (&child->comname, "sys$scratch:CMDXXXXXX.COM");
     1246      int cmd_len;
     1247
     1248      outfile = output_tmpfile (&child->comname,
     1249                                "sys$scratch:gnv$make_cmdXXXXXX.com");
     1250      /*                                          012345678901234567890 */
    4991251      if (outfile == 0)
    500         pfatal_with_name (_("fopen (temporary file)"));
     1252        pfatal_with_name (_("fopen (temporary file)"));
    5011253      comnamelen = strlen (child->comname);
    5021254
    503       if (ifile[0])
    504         {
    505           fprintf (outfile, "$ assign/user %s sys$input\n", ifile);
    506           DB (DB_JOBS, (_("Redirected input from %s\n"), ifile));
    507           ifiledsc.dsc$w_length = 0;
    508         }
    509 
    510       if (efile[0])
    511         {
    512           fprintf (outfile, "$ define sys$error %s\n", efile);
    513           DB (DB_JOBS, (_("Redirected error to %s\n"), efile));
    514           efiledsc.dsc$w_length = 0;
    515         }
    516 
    517       if (ofile[0])
    518         {
    519           if (have_append)
    520             {
    521               fprintf (outfile, "$ set noon\n");
    522               fprintf (outfile, "$ define sys$output %.*s\n", comnamelen-3, child->comname);
    523               DB (DB_JOBS, (_("Append output to %s\n"), ofile));
    524               ofiledsc.dsc$w_length = 0;
    525             }
    526           else
    527             {
    528               fprintf (outfile, "$ define sys$output %s\n", ofile);
    529               DB (DB_JOBS, (_("Redirected output to %s\n"), ofile));
    530               ofiledsc.dsc$w_length = 0;
    531             }
    532         }
    533 
    534       p = sep = q = cmd;
    535       for (c = '\n'; c; c = *q++)
    536         {
    537           switch (c)
    538             {
    539             case '\n':
    540               /* At a newline, skip any whitespace around a leading $
    541                  from the command and issue exactly one $ into the DCL. */
    542               while (isspace ((unsigned char)*p))
    543                 p++;
    544               if (*p == '$')
    545                 p++;
    546               while (isspace ((unsigned char)*p))
    547                 p++;
    548               fwrite (p, 1, q - p, outfile);
    549               fputc ('$', outfile);
    550               fputc (' ', outfile);
    551               /* Reset variables. */
    552               p = sep = q;
    553               break;
    554 
    555               /* Nice places for line breaks are after strings, after
    556                  comma or space and before slash. */
    557             case '"':
    558               q = vms_handle_apos (q);
    559               sep = q;
    560               break;
    561             case ',':
    562             case ' ':
    563               sep = q;
    564               break;
    565             case '/':
    566             case '\0':
    567               sep = q - 1;
    568               break;
    569             default:
    570               break;
    571             }
    572           if (sep - p > 78)
    573             {
    574               /* Enough stuff for a line. */
    575               fwrite (p, 1, sep - p, outfile);
    576               p = sep;
    577               if (*sep)
    578                 {
    579                   /* The command continues.  */
    580                   fputc ('-', outfile);
    581                 }
    582               fputc ('\n', outfile);
    583             }
    584         }
    585 
    586       if (*p)
    587         {
    588           fwrite (p, 1, --q - p, outfile);
    589       fputc ('\n', outfile);
    590         }
    591 
    592       if (have_append)
    593         {
    594           fprintf (outfile, "$ deassign sys$output ! 'f$verify(0)\n");
    595           fprintf (outfile, "$ append:=append\n");
    596           fprintf (outfile, "$ delete:=delete\n");
    597           fprintf (outfile, "$ append/new %.*s %s\n", comnamelen-3, child->comname, ofile);
    598           fprintf (outfile, "$ delete %.*s;*\n", comnamelen-3, child->comname);
    599           DB (DB_JOBS, (_("Append %.*s and cleanup\n"), comnamelen-3, child->comname));
    600         }
     1255      /* The whole DCL "script" is executed as one action, and it behaves as
     1256         any DCL "script", that is errors stop it but warnings do not. Usually
     1257         the command on the last line, defines the exit code.  However, with
     1258         redirections there is a prolog and possibly an epilog to implement
     1259         the redirection.  Both are part of the script which is actually
     1260         executed. So if the redirection encounters an error in the prolog,
     1261         the user actions will not run; if in the epilog, the user actions
     1262         ran, but output is not captured. In both error cases, the error of
     1263         redirection is passed back and not the exit code of the actions. The
     1264         user should be able to enable DCL "script" verification with "set
     1265         verify". However, the prolog and epilog commands are not shown. Also,
     1266         if output redirection is used, the verification output is redirected
     1267         into that file as well. */
     1268      fprintf (outfile, "$ gnv$$make_verify = \"''f$verify(0)'\"\n");
     1269      fprintf (outfile, "$ gnv$$make_pid = f$getjpi(\"\",\"pid\")\n");
     1270      fprintf (outfile, "$ on error then $ goto gnv$$make_error\n");
     1271
     1272      /* Handle append redirection */
     1273      if (append_file != NULL)
     1274        {
     1275          /* If file does not exist, create it */
     1276          fprintf (outfile,
     1277                   "$ gnv$$make_al = \"gnv$$make_append''gnv$$make_pid'\"\n");
     1278          fprintf (outfile,
     1279                   "$ if f$search(\"%s\") .eqs. \"\" then create %s\n",
     1280                   append_file, append_file);
     1281
     1282          fprintf (outfile,
     1283                   "$ open/append 'gnv$$make_al' %s\n", append_file);
     1284
     1285          /* define sys$output to that file */
     1286          fprintf (outfile,
     1287                   "$ define/user sys$output 'gnv$$make_al'\n");
     1288          DB (DB_JOBS, (_("Append output to %s\n"), append_file));
     1289          free(append_file);
     1290        }
     1291
     1292      fprintf (outfile, "$ gnv$$make_verify = f$verify(gnv$$make_verify)\n");
     1293
     1294      /* TODO:
     1295         Only for ONESHELL there will be several commands separated by
     1296         '\n'. But there can always be multiple continuation lines.
     1297      */
     1298
     1299      fprintf (outfile, "%s\n", cmd_dsc->dsc$a_pointer);
     1300      fprintf (outfile, "$ gnv$$make_status_2 = $status\n");
     1301      fprintf (outfile, "$ goto gnv$$make_exit\n");
     1302
     1303      /* Exit and clean up */
     1304      fprintf (outfile, "$ gnv$$make_error: ! 'f$verify(0)\n");
     1305      fprintf (outfile, "$ gnv$$make_status_2 = $status\n");
     1306
     1307      if (append_token != -1)
     1308        {
     1309          fprintf (outfile, "$ deassign sys$output\n");
     1310          fprintf (outfile, "$ close 'gnv$$make_al'\n");
     1311
     1312          DB (DB_JOBS,
     1313              (_("Append %.*s and cleanup\n"), comnamelen-3, child->comname));
     1314        }
     1315      fprintf (outfile, "$ gnv$$make_exit: ! 'f$verify(0)\n");
     1316      fprintf (outfile,
     1317             "$ exit 'gnv$$make_status_2' + (0*f$verify(gnv$$make_verify))\n");
    6011318
    6021319      fclose (outfile);
    6031320
    604       sprintf (cmd, "$ @%s", child->comname);
    605 
    606       DB (DB_JOBS, (_("Executing %s instead\n"), cmd));
    607     }
    608 
    609   cmddsc.dsc$w_length = strlen(cmd);
    610   cmddsc.dsc$a_pointer = cmd;
    611   cmddsc.dsc$b_dtype = DSC$K_DTYPE_T;
    612   cmddsc.dsc$b_class = DSC$K_CLASS_S;
     1321      free (cmd_dsc->dsc$a_pointer);
     1322      cmd_dsc->dsc$a_pointer = xmalloc (256 + 4);
     1323      sprintf (cmd_dsc->dsc$a_pointer, "$ @%s", child->comname);
     1324      cmd_dsc->dsc$w_length = strlen (cmd_dsc->dsc$a_pointer);
     1325
     1326      DB (DB_JOBS, (_("Executing %s instead\n"), child->comname));
     1327    }
    6131328
    6141329  child->efn = 0;
    6151330  while (child->efn < 32 || child->efn > 63)
    6161331    {
    617       status = lib$get_ef ((unsigned long *)&child->efn);
    618       if (!(status & 1))
     1332      status = LIB$GET_EF ((unsigned long *)&child->efn);
     1333      if (!$VMS_STATUS_SUCCESS (status))
    6191334        {
    6201335          if (child->comname)
     
    6281343    }
    6291344
    630   sys$clref (child->efn);
     1345  SYS$CLREF (child->efn);
    6311346
    6321347  vms_jobsefnmask |= (1 << (child->efn - 32));
    6331348
    634 /*
    635              LIB$SPAWN  [command-string]
    636                         [,input-file]
    637                         [,output-file]
    638                         [,flags]
    639                         [,process-name]
    640                         [,process-id] [,completion-status-address] [,byte-integer-event-flag-num]
    641                         [,AST-address] [,varying-AST-argument]
    642                         [,prompt-string] [,cli] [,table]
    643 */
     1349  /* Export the child environment into DCL symbols */
     1350  if (child->environment != 0)
     1351    {
     1352      char **ep = child->environment;
     1353      while (*ep != 0)
     1354        {
     1355          vms_putenv_symbol (*ep);
     1356          *ep++;
     1357        }
     1358    }
     1359
     1360  /*
     1361    LIB$SPAWN  [command-string]
     1362    [,input-file]
     1363    [,output-file]
     1364    [,flags]
     1365    [,process-name]
     1366    [,process-id] [,completion-status-address] [,byte-integer-event-flag-num]
     1367    [,AST-address] [,varying-AST-argument]
     1368    [,prompt-string] [,cli] [,table]
     1369  */
    6441370
    6451371#ifndef DONTWAITFORCHILD
    646 /*
    647  *      Code to make ctrl+c and ctrl+y working.
    648  *      The problem starts with the synchronous case where after lib$spawn is
    649  *      called any input will go to the child. But with input re-directed,
    650  *      both control characters won't make it to any of the programs, neither
    651  *      the spawning nor to the spawned one. Hence the caller needs to spawn
    652  *      with CLI$M_NOWAIT to NOT give up the input focus. A sys$waitfr
    653  *      has to follow to simulate the wanted synchronous behaviour.
    654  *      The next problem is ctrl+y which isn't caught by the crtl and
    655  *      therefore isn't converted to SIGQUIT (for a signal handler which is
    656  *      already established). The only way to catch ctrl+y, is an AST
    657  *      assigned to the input channel. But ctrl+y handling of DCL needs to be
    658  *      disabled, otherwise it will handle it. Not to mention the previous
    659  *      ctrl+y handling of DCL needs to be re-established before make exits.
    660  *      One more: At the time of LIB$SPAWN signals are blocked. SIGQUIT will
    661  *      make it to the signal handler after the child "normally" terminates.
    662  *      This isn't enough. It seems reasonable for simple command lines like
    663  *      a 'cc foobar.c' spawned in a subprocess but it is unacceptable for
    664  *      spawning make. Therefore we need to abort the process in the AST.
    665  *
    666  *      Prior to the spawn it is checked if an AST is already set up for
    667  *      ctrl+y, if not one is set up for a channel to SYS$COMMAND. In general
    668  *      this will work except if make is run in a batch environment, but there
    669  *      nobody can press ctrl+y. During the setup the DCL handling of ctrl+y
    670  *      is disabled and an exit handler is established to re-enable it.
    671  *      If the user interrupts with ctrl+y, the assigned AST will fire, force
    672  *      an abort to the subprocess and signal SIGQUIT, which will be caught by
    673  *      the already established handler and will bring us back to common code.
    674  *      After the spawn (now /nowait) a sys$waitfr simulates the /wait and
    675  *      enables the ctrl+y be delivered to this code. And the ctrl+c too,
    676  *      which the crtl converts to SIGINT and which is caught by the common
    677  *      signal handler. Because signals were blocked before entering this code
    678  *      sys$waitfr will always complete and the SIGQUIT will be processed after
    679  *      it (after termination of the current block, somewhere in common code).
    680  *      And SIGINT too will be delayed. That is ctrl+c can only abort when the
    681  *      current command completes. Anyway it's better than nothing :-)
    682  */
     1372  /*
     1373   * Code to make ctrl+c and ctrl+y working.
     1374   * The problem starts with the synchronous case where after lib$spawn is
     1375   * called any input will go to the child. But with input re-directed,
     1376   * both control characters won't make it to any of the programs, neither
     1377   * the spawning nor to the spawned one. Hence the caller needs to spawn
     1378   * with CLI$M_NOWAIT to NOT give up the input focus. A sys$waitfr
     1379   * has to follow to simulate the wanted synchronous behaviour.
     1380   * The next problem is ctrl+y which isn't caught by the crtl and
     1381   * therefore isn't converted to SIGQUIT (for a signal handler which is
     1382   * already established). The only way to catch ctrl+y, is an AST
     1383   * assigned to the input channel. But ctrl+y handling of DCL needs to be
     1384   * disabled, otherwise it will handle it. Not to mention the previous
     1385   * ctrl+y handling of DCL needs to be re-established before make exits.
     1386   * One more: At the time of LIB$SPAWN signals are blocked. SIGQUIT will
     1387   * make it to the signal handler after the child "normally" terminates.
     1388   * This isn't enough. It seems reasonable for simple command lines like
     1389   * a 'cc foobar.c' spawned in a subprocess but it is unacceptable for
     1390   * spawning make. Therefore we need to abort the process in the AST.
     1391   *
     1392   * Prior to the spawn it is checked if an AST is already set up for
     1393   * ctrl+y, if not one is set up for a channel to SYS$COMMAND. In general
     1394   * this will work except if make is run in a batch environment, but there
     1395   * nobody can press ctrl+y. During the setup the DCL handling of ctrl+y
     1396   * is disabled and an exit handler is established to re-enable it.
     1397   * If the user interrupts with ctrl+y, the assigned AST will fire, force
     1398   * an abort to the subprocess and signal SIGQUIT, which will be caught by
     1399   * the already established handler and will bring us back to common code.
     1400   * After the spawn (now /nowait) a sys$waitfr simulates the /wait and
     1401   * enables the ctrl+y be delivered to this code. And the ctrl+c too,
     1402   * which the crtl converts to SIGINT and which is caught by the common
     1403   * signal handler. Because signals were blocked before entering this code
     1404   * sys$waitfr will always complete and the SIGQUIT will be processed after
     1405   * it (after termination of the current block, somewhere in common code).
     1406   * And SIGINT too will be delayed. That is ctrl+c can only abort when the
     1407   * current command completes. Anyway it's better than nothing :-)
     1408   */
    6831409
    6841410  if (!setupYAstTried)
    6851411    tryToSetupYAst();
    686   status = lib$spawn (&cmddsc,                                  /* cmd-string  */
    687                       (ifiledsc.dsc$w_length == 0)?0:&ifiledsc, /* input-file  */
    688                       (ofiledsc.dsc$w_length == 0)?0:&ofiledsc, /* output-file */
    689                       &spflags,                                 /* flags  */
    690                       &pnamedsc,                                /* proc name  */
    691                       &child->pid, &child->cstatus, &child->efn,
    692                       0, 0,
    693                       0, 0, 0);
    694   if (status & 1)
    695     {
    696       status= sys$waitfr (child->efn);
    697       vmsHandleChildTerm(child);
     1412  child->vms_launch_status = lib$spawn (cmd_dsc,               /* cmd-string */
     1413                     NULL, /* input-file */
     1414                     NULL, /* output-file */
     1415                     &spflags,                                 /* flags */
     1416                     &pnamedsc,                                /* proc name */
     1417                     &child->pid, &child->cstatus, &child->efn,
     1418                     0, 0,
     1419                     0, 0, 0);
     1420
     1421  status = child->vms_launch_status;
     1422  if ($VMS_STATUS_SUCCESS (status))
     1423    {
     1424      status = sys$waitfr (child->efn);
     1425      vmsHandleChildTerm (child);
    6981426    }
    6991427#else
    700   status = lib$spawn (&cmddsc,
    701                       (ifiledsc.dsc$w_length == 0)?0:&ifiledsc,
    702                       (ofiledsc.dsc$w_length == 0)?0:&ofiledsc,
    703                       &spflags,
    704                       &pnamedsc,
    705                       &child->pid, &child->cstatus, &child->efn,
    706                       vmsHandleChildTerm, child,
    707                       0, 0, 0);
     1428  child->vms_launch_status = lib$spawn (cmd_dsc,
     1429                      NULL,
     1430                      NULL,
     1431                      &spflags,
     1432                      &pnamedsc,
     1433                      &child->pid, &child->cstatus, &child->efn,
     1434                      vmsHandleChildTerm, child,
     1435                      0, 0, 0);
     1436   status = child->vms_launch_status;
    7081437#endif
    7091438
    710   if (!(status & 1))
    711     {
    712       printf (_("Error spawning, %d\n") ,status);
    713       fflush (stdout);
     1439  /* Free the pointer if not a command file */
     1440  if (!vms_always_use_cmd_file && !token.use_cmd_file)
     1441    free (cmd_dsc->dsc$a_pointer);
     1442  free (cmd_dsc);
     1443
     1444  if (!$VMS_STATUS_SUCCESS (status))
     1445    {
    7141446      switch (status)
    7151447        {
    716         case 0x1c:
     1448        case SS$_EXQUOTA:
    7171449          errno = EPROCLIM;
    7181450          break;
     
    7221454    }
    7231455
     1456  /* Restore the VMS symbols that were changed */
     1457  if (child->environment != 0)
     1458    {
     1459      char **ep = child->environment;
     1460      while (*ep != 0)
     1461        {
     1462          vms_restore_symbol (*ep);
     1463          *ep++;
     1464        }
     1465    }
     1466
    7241467  return (status & 1);
    7251468}
  • vendor/gnumake/current/vpath.c

    r2596 r3138  
    11/* Implementation of pattern-matching file search paths for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018#include "filedef.h"
    2119#include "variable.h"
     
    2927struct vpath
    3028  {
    31     struct vpath *next; /* Pointer to next struct in the linked list.  */
     29    struct vpath *next; /* Pointer to next struct in the linked list.  */
    3230    const char *pattern;/* The pattern to match.  */
    33     const char *percent;/* Pointer into `pattern' where the `%' is.  */
     31    const char *percent;/* Pointer into 'pattern' where the '%' is.  */
    3432    unsigned int patlen;/* Length of the pattern.  */
    3533    const char **searchpath; /* Null-terminated list of directories.  */
     
    5654
    5755void
    58 build_vpath_lists ()
     56build_vpath_lists (void)
    5957{
    6058  register struct vpath *new = 0;
     
    9290      char gp[] = "%";
    9391
    94       /* Empty `vpaths' so the new one will have no next, and `vpaths'
    95         will still be nil if P contains no existing directories.  */
     92      /* Empty 'vpaths' so the new one will have no next, and 'vpaths'
     93        will still be nil if P contains no existing directories.  */
    9694      vpaths = 0;
    9795
     
    10098
    10199      /* Store the created path as the general path,
    102         and restore the old list of vpaths.  */
     100        and restore the old list of vpaths.  */
    103101      general_vpath = vpaths;
    104102      vpaths = save_vpaths;
     
    125123      char gp[] = "%";
    126124
    127       /* Empty `vpaths' so the new one will have no next, and `vpaths'
    128         will still be nil if P contains no existing directories.  */
     125      /* Empty 'vpaths' so the new one will have no next, and 'vpaths'
     126        will still be nil if P contains no existing directories.  */
    129127      vpaths = 0;
    130128
     
    133131
    134132      /* Store the created path as the GPATH,
    135         and restore the old list of vpaths.  */
     133        and restore the old list of vpaths.  */
    136134      gpaths = vpaths;
    137135      vpaths = save_vpaths;
     
    151149   pattern.  If PATTERN is nil, remove all VPATH listings.  Existing
    152150   and readable directories that are not "." given in the DIRPATH
    153    separated by the path element separator (defined in make.h) are
     151   separated by the path element separator (defined in makeint.h) are
    154152   loaded into the directory hash table if they are not there already
    155153   and put in the VPATH searchpath for the given pattern with trailing
     
    180178      path = vpaths;
    181179      while (path != 0)
    182         {
    183           struct vpath *next = path->next;
    184 
    185           if (pattern == 0
    186               || (((percent == 0 && path->percent == 0)
    187                    || (percent - pattern == path->percent - path->pattern))
    188                   && streq (pattern, path->pattern)))
    189             {
    190               /* Remove it from the linked list.  */
    191               if (lastpath == 0)
    192                 vpaths = path->next;
    193               else
    194                 lastpath->next = next;
    195 
    196               /* Free its unused storage.  */
     180        {
     181          struct vpath *next = path->next;
     182
     183          if (pattern == 0
     184              || (((percent == 0 && path->percent == 0)
     185                   || (percent - pattern == path->percent - path->pattern))
     186                  && streq (pattern, path->pattern)))
     187            {
     188              /* Remove it from the linked list.  */
     189              if (lastpath == 0)
     190                vpaths = path->next;
     191              else
     192                lastpath->next = next;
     193
     194              /* Free its unused storage.  */
    197195              /* MSVC erroneously warns without a cast here.  */
    198               free ((void *)path->searchpath);
    199               free (path);
    200             }
    201           else
    202             lastpath = path;
    203 
    204           path = next;
    205         }
     196              free ((void *)path->searchpath);
     197              free (path);
     198            }
     199          else
     200            lastpath = path;
     201
     202          path = next;
     203        }
    206204
    207205      return;
     
    209207
    210208#ifdef WINDOWS32
    211     convert_vpath_to_windows32(dirpath, ';');
     209    convert_vpath_to_windows32 (dirpath, ';');
    212210#endif
    213211
    214212  /* Skip over any initial separators and blanks.  */
    215   while (*dirpath == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*dirpath))
     213  while (STOP_SET (*dirpath, MAP_BLANK|MAP_PATHSEP))
    216214    ++dirpath;
    217215
     
    223221  p = dirpath;
    224222  while (*p != '\0')
    225     if (*p++ == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))
     223    if (STOP_SET (*p++, MAP_BLANK|MAP_PATHSEP))
    226224      ++maxelem;
    227225
     
    240238      while (*p != '\0'
    241239#if defined(HAVE_DOS_PATHS) && (PATH_SEPARATOR_CHAR == ':')
    242              /* Platforms whose PATH_SEPARATOR_CHAR is ':' and which
    243                 also define HAVE_DOS_PATHS would like us to recognize
    244                 colons after the drive letter in the likes of
    245                 "D:/foo/bar:C:/xyzzy".  */
    246              && (*p != PATH_SEPARATOR_CHAR
    247                 || (p == v + 1 && (p[1] == '/' || p[1] == '\\')))
     240             /* Platforms whose PATH_SEPARATOR_CHAR is ':' and which
     241                also define HAVE_DOS_PATHS would like us to recognize
     242                colons after the drive letter in the likes of
     243                "D:/foo/bar:C:/xyzzy".  */
     244             && (*p != PATH_SEPARATOR_CHAR
     245                || (p == v + 1 && (p[1] == '/' || p[1] == '\\')))
    248246#else
    249              && *p != PATH_SEPARATOR_CHAR
    250 #endif
    251              && !isblank ((unsigned char)*p))
    252         ++p;
     247             && *p != PATH_SEPARATOR_CHAR
     248#endif
     249             && !ISBLANK (*p))
     250        ++p;
    253251
    254252      len = p - v;
    255253      /* Make sure there's no trailing slash,
    256         but still allow "/" as a directory.  */
     254        but still allow "/" as a directory.  */
    257255#if defined(__MSDOS__) || defined(__EMX__) || defined(HAVE_DOS_PATHS)
    258256      /* We need also to leave alone a trailing slash in "d:/".  */
     
    260258#endif
    261259      if (len > 1 && p[-1] == '/')
    262         --len;
     260        --len;
    263261
    264262      /* Put the directory on the vpath list.  */
    265263      if (len > 1 || *v != '.')
    266         {
     264        {
    267265          vpath[elem++] = dir_name (strcache_add_len (v, len));
    268266          if (len > maxvpath)
    269267            maxvpath = len;
    270         }
     268        }
    271269
    272270      /* Skip over separators and blanks between entries.  */
    273       while (*p == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))
    274         ++p;
     271      while (STOP_SET (*p, MAP_BLANK|MAP_PATHSEP))
     272        ++p;
    275273    }
    276274
     
    279277      struct vpath *path;
    280278      /* ELEM is now incremented one element past the last
    281         entry, to where the nil-pointer terminator goes.
    282         Usually this is maxelem - 1.  If not, shrink down.  */
     279        entry, to where the nil-pointer terminator goes.
     280        Usually this is maxelem - 1.  If not, shrink down.  */
    283281      if (elem < (maxelem - 1))
    284         vpath = xrealloc (vpath, (elem+1) * sizeof (const char *));
     282        vpath = xrealloc (vpath, (elem+1) * sizeof (const char *));
    285283
    286284      /* Put the nil-pointer terminator on the end of the VPATH list.  */
     
    312310gpath_search (const char *file, unsigned int len)
    313311{
    314   const char **gp;
    315 
    316312  if (gpaths && (len <= gpaths->maxlen))
    317     for (gp = gpaths->searchpath; *gp != NULL; ++gp)
    318       if (strneq (*gp, file, len) && (*gp)[len] == '\0')
    319         return 1;
     313    {
     314      const char **gp;
     315      for (gp = gpaths->searchpath; *gp != NULL; ++gp)
     316        if (strneq (*gp, file, len) && (*gp)[len] == '\0')
     317          return 1;
     318    }
    320319
    321320  return 0;
     
    341340  unsigned int maxvpath = path->maxlen;
    342341  unsigned int i;
    343   unsigned int flen, vlen, name_dplen;
     342  unsigned int flen, name_dplen;
    344343  int exists = 0;
    345344
     
    362361  /* We need the rightmost slash or backslash.  */
    363362  {
    364     const char *bslash = strrchr(file, '\\');
     363    const char *bslash = strrchr (file, '\\');
    365364    if (!n || bslash > n)
    366365      n = bslash;
     
    381380    {
    382381      int exists_in_cache = 0;
    383       char *p;
    384 
    385       p = name;
     382      char *p = name;
     383      unsigned int vlen = strlen (vpath[i]);
    386384
    387385      /* Put the next VPATH entry into NAME at P and increment P past it.  */
    388       vlen = strlen (vpath[i]);
    389386      memcpy (p, vpath[i], vlen);
    390387      p += vlen;
     
    392389      /* Add the directory prefix already in *FILE.  */
    393390      if (name_dplen > 0)
    394         {
     391        {
    395392#ifndef VMS
    396           *p++ = '/';
    397 #endif
    398           memcpy (p, file, name_dplen);
    399           p += name_dplen;
    400         }
     393          *p++ = '/';
     394#else
     395          /* VMS: if this is not in VMS format, treat as Unix format */
     396          if ((*p != ':') && (*p != ']') && (*p != '>'))
     397            *p++ = '/';
     398#endif
     399          memcpy (p, file, name_dplen);
     400          p += name_dplen;
     401        }
    401402
    402403#ifdef HAVE_DOS_PATHS
    403404      /* Cause the next if to treat backslash and slash alike.  */
    404405      if (p != name && p[-1] == '\\' )
    405         p[-1] = '/';
     406        p[-1] = '/';
    406407#endif
    407408      /* Now add the name-within-directory at the end of NAME.  */
    408409#ifndef VMS
    409410      if (p != name && p[-1] != '/')
    410         {
    411           *p = '/';
    412           memcpy (p + 1, filename, flen + 1);
    413         }
     411        {
     412          *p = '/';
     413          memcpy (p + 1, filename, flen + 1);
     414        }
    414415      else
    415 #endif
    416         memcpy (p, filename, flen + 1);
     416#else
     417      /* VMS use a slash if no directory terminator present */
     418      if (p != name && p[-1] != '/' && p[-1] != ':' &&
     419          p[-1] != '>' && p[-1] != ']')
     420        {
     421          *p = '/';
     422          memcpy (p + 1, filename, flen + 1);
     423        }
     424      else
     425#endif
     426        memcpy (p, filename, flen + 1);
    417427
    418428      /* Check if the file is mentioned in a makefile.  If *FILE is not
    419         a target, that is enough for us to decide this file exists.
    420         If *FILE is a target, then the file must be mentioned in the
    421         makefile also as a target to be chosen.
    422 
    423         The restriction that *FILE must not be a target for a
    424         makefile-mentioned file to be chosen was added by an
    425         inadequately commented change in July 1990; I am not sure off
    426         hand what problem it fixes.
    427 
    428         In December 1993 I loosened this restriction to allow a file
    429         to be chosen if it is mentioned as a target in a makefile.  This
    430         seem logical.
     429        a target, that is enough for us to decide this file exists.
     430        If *FILE is a target, then the file must be mentioned in the
     431        makefile also as a target to be chosen.
     432
     433        The restriction that *FILE must not be a target for a
     434        makefile-mentioned file to be chosen was added by an
     435        inadequately commented change in July 1990; I am not sure off
     436        hand what problem it fixes.
     437
     438        In December 1993 I loosened this restriction to allow a file
     439        to be chosen if it is mentioned as a target in a makefile.  This
     440        seem logical.
    431441
    432442         Special handling for -W / -o: make sure we preserve the special
     
    438448      */
    439449      {
    440         struct file *f = lookup_file (name);
    441         if (f != 0)
     450        struct file *f = lookup_file (name);
     451        if (f != 0)
    442452          {
    443453            exists = not_target || f->is_target;
     
    452462
    453463      if (!exists)
    454         {
    455           /* That file wasn't mentioned in the makefile.
    456              See if it actually exists.  */
     464        {
     465          /* That file wasn't mentioned in the makefile.
     466             See if it actually exists.  */
    457467
    458468#ifdef VMS
    459           exists_in_cache = exists = dir_file_exists_p (vpath[i], filename);
     469          /* For VMS syntax just use the original vpath */
     470          if (*p != '/')
     471            exists_in_cache = exists = dir_file_exists_p (vpath[i], filename);
     472          else
     473#endif
     474            {
     475              /* Clobber a null into the name at the last slash.
     476                 Now NAME is the name of the directory to look in.  */
     477              *p = '\0';
     478              /* We know the directory is in the hash table now because either
     479                 construct_vpath_list or the code just above put it there.
     480                 Does the file we seek exist in it?  */
     481              exists_in_cache = exists = dir_file_exists_p (name, filename);
     482            }
     483        }
     484
     485      if (exists)
     486        {
     487          /* The file is in the directory cache.
     488             Now check that it actually exists in the filesystem.
     489             The cache may be out of date.  When vpath thinks a file
     490             exists, but stat fails for it, confusion results in the
     491             higher levels.  */
     492
     493          struct stat st;
     494
     495#ifndef VMS
     496          /* Put the slash back in NAME.  */
     497          *p = '/';
    460498#else
    461           /* Clobber a null into the name at the last slash.
    462              Now NAME is the name of the directory to look in.  */
    463           *p = '\0';
    464 
    465           /* We know the directory is in the hash table now because either
    466              construct_vpath_list or the code just above put it there.
    467              Does the file we seek exist in it?  */
    468           exists_in_cache = exists = dir_file_exists_p (name, filename);
    469 #endif
    470         }
    471 
    472       if (exists)
    473         {
    474           /* The file is in the directory cache.
    475              Now check that it actually exists in the filesystem.
    476              The cache may be out of date.  When vpath thinks a file
    477              exists, but stat fails for it, confusion results in the
    478              higher levels.  */
    479 
    480           struct stat st;
    481 
    482 #ifndef VMS
    483           /* Put the slash back in NAME.  */
    484           *p = '/';
    485 #endif
    486 
    487           if (exists_in_cache)  /* Makefile-mentioned file need not exist.  */
    488             {
     499          /* If the slash was removed, put it back */
     500          if (*p == 0)
     501            *p = '/';
     502#endif
     503
     504          if (exists_in_cache)  /* Makefile-mentioned file need not exist.  */
     505            {
    489506              int e;
    490507
     
    516533
    517534          return strcache_add_len (name, (p + 1 - name) + flen);
    518         }
     535        }
    519536    }
    520537
     
    601618
    602619      for (i = 0; v->searchpath[i] != 0; ++i)
    603         printf ("%s%c", v->searchpath[i],
    604                 v->searchpath[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR);
     620        printf ("%s%c", v->searchpath[i],
     621                v->searchpath[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR);
    605622    }
    606623
    607624  if (vpaths == 0)
    608     puts (_("# No `vpath' search paths."));
     625    puts (_("# No 'vpath' search paths."));
    609626  else
    610     printf (_("\n# %u `vpath' search paths.\n"), nvpaths);
     627    printf (_("\n# %u 'vpath' search paths.\n"), nvpaths);
    611628
    612629  if (general_vpath == 0)
    613     puts (_("\n# No general (`VPATH' variable) search path."));
     630    puts (_("\n# No general ('VPATH' variable) search path."));
    614631  else
    615632    {
     
    617634      unsigned int i;
    618635
    619       fputs (_("\n# General (`VPATH' variable) search path:\n# "), stdout);
     636      fputs (_("\n# General ('VPATH' variable) search path:\n# "), stdout);
    620637
    621638      for (i = 0; path[i] != 0; ++i)
    622         printf ("%s%c", path[i],
    623                 path[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR);
     639        printf ("%s%c", path[i],
     640                path[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR);
    624641    }
    625642}
  • vendor/gnumake/current/w32/Makefile.am

    r2596 r3138  
    11# Makefile.am to create libw32.a for mingw32 host.
    2 # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 # 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2# Copyright (C) 1997-2016 Free Software Foundation, Inc.
    43# This file is part of GNU Make.
    54#
     
    1716# this program.  If not, see <http://www.gnu.org/licenses/>.
    1817
     18AUTOMAKE_OPTIONS = subdir-objects
     19
    1920noinst_LIBRARIES = libw32.a
    2021
    2122libw32_a_SOURCES =  subproc/misc.c subproc/sub_proc.c subproc/w32err.c \
    22                     pathstuff.c
     23                    compat/posixfcn.c pathstuff.c w32os.c
    2324
    24 libw32_a_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/subproc -I$(top_srcdir)
     25libw32_a_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/subproc -I$(top_srcdir) \
     26                    -I$(top_srcdir)/glob
  • vendor/gnumake/current/w32/compat/dirent.c

    r2596 r3138  
    11/* Directory entry code for Window platforms.
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    2928opendir(const char* pDirName)
    3029{
    31         struct stat sb;
    32         DIR*    pDir;
    33         char*   pEndDirName;
    34         int     nBufferLen;
    35 
    36         /* sanity checks */
    37         if (!pDirName) {
    38                 errno = EINVAL;
    39                 return NULL;
    40         }
    41         if (stat(pDirName, &sb) != 0) {
    42                 errno = ENOENT;
    43                 return NULL;
    44         }
    45         if ((sb.st_mode & S_IFMT) != S_IFDIR) {
    46                 errno = ENOTDIR;
    47                 return NULL;
    48         }
    49 
    50         /* allocate a DIR structure to return */
    51         pDir = (DIR *) malloc(sizeof (DIR));
    52 
    53         if (!pDir)
    54                 return NULL;
    55 
    56         /* input directory name length */
    57         nBufferLen = strlen(pDirName);
    58 
    59         /* copy input directory name to DIR buffer */
    60         strcpy(pDir->dir_pDirectoryName, pDirName);
    61 
    62         /* point to end of the copied directory name */
    63         pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1];
    64 
    65         /* if directory name did not end in '/' or '\', add '/' */
    66         if ((*pEndDirName != '/') && (*pEndDirName != '\\')) {
    67                 pEndDirName++;
    68                 *pEndDirName = '/';
    69         }
    70 
    71         /* now append the wildcard character to the buffer */
    72         pEndDirName++;
    73         *pEndDirName = '*';
    74         pEndDirName++;
    75         *pEndDirName = '\0';
    76 
    77         /* other values defaulted */
    78         pDir->dir_nNumFiles = 0;
    79         pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
    80         pDir->dir_ulCookie = __DIRENT_COOKIE;
    81 
    82         return pDir;
     30        struct stat sb;
     31        DIR*    pDir;
     32        char*   pEndDirName;
     33        int     nBufferLen;
     34
     35        /* sanity checks */
     36        if (!pDirName) {
     37                errno = EINVAL;
     38                return NULL;
     39        }
     40        if (stat(pDirName, &sb) != 0) {
     41                errno = ENOENT;
     42                return NULL;
     43        }
     44        if ((sb.st_mode & S_IFMT) != S_IFDIR) {
     45                errno = ENOTDIR;
     46                return NULL;
     47        }
     48
     49        /* allocate a DIR structure to return */
     50        pDir = (DIR *) malloc(sizeof (DIR));
     51
     52        if (!pDir)
     53                return NULL;
     54
     55        /* input directory name length */
     56        nBufferLen = strlen(pDirName);
     57
     58        /* copy input directory name to DIR buffer */
     59        strcpy(pDir->dir_pDirectoryName, pDirName);
     60
     61        /* point to end of the copied directory name */
     62        pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1];
     63
     64        /* if directory name did not end in '/' or '\', add '/' */
     65        if ((*pEndDirName != '/') && (*pEndDirName != '\\')) {
     66                pEndDirName++;
     67                *pEndDirName = '/';
     68        }
     69
     70        /* now append the wildcard character to the buffer */
     71        pEndDirName++;
     72        *pEndDirName = '*';
     73        pEndDirName++;
     74        *pEndDirName = '\0';
     75
     76        /* other values defaulted */
     77        pDir->dir_nNumFiles = 0;
     78        pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
     79        pDir->dir_ulCookie = __DIRENT_COOKIE;
     80
     81        return pDir;
    8382}
    8483
     
    8685closedir(DIR *pDir)
    8786{
    88         /* got a valid pointer? */
    89         if (!pDir) {
    90                 errno = EINVAL;
    91                 return;
    92         }
    93 
    94         /* sanity check that this is a DIR pointer */
    95         if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
    96                 errno = EINVAL;
    97                 return;
    98         }
    99 
    100         /* close the WINDOWS32 directory handle */
    101         if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
    102                 FindClose(pDir->dir_hDirHandle);
    103 
    104         free(pDir);
    105 
    106         return;
     87        /* got a valid pointer? */
     88        if (!pDir) {
     89                errno = EINVAL;
     90                return;
     91        }
     92
     93        /* sanity check that this is a DIR pointer */
     94        if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
     95                errno = EINVAL;
     96                return;
     97        }
     98
     99        /* close the WINDOWS32 directory handle */
     100        if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
     101                FindClose(pDir->dir_hDirHandle);
     102
     103        free(pDir);
     104
     105        return;
    107106}
    108107
     
    110109readdir(DIR* pDir)
    111110{
    112         WIN32_FIND_DATA wfdFindData;
    113 
    114         if (!pDir) {
    115                 errno = EINVAL;
    116                 return NULL;
    117         }
    118 
    119         /* sanity check that this is a DIR pointer */
    120         if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
    121                 errno = EINVAL;
    122                 return NULL;
    123         }
    124 
    125         if (pDir->dir_nNumFiles == 0) {
    126                 pDir->dir_hDirHandle = FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData);
    127                 if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE)
    128                         return NULL;
    129         } else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData))
    130                         return NULL;
    131 
    132         /* bump count for next call to readdir() or telldir() */
    133         pDir->dir_nNumFiles++;
    134 
    135         /* fill in struct dirent values */
    136         pDir->dir_sdReturn.d_ino = (ino_t)-1;
    137         strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
    138 
    139         return &pDir->dir_sdReturn;
     111        WIN32_FIND_DATA wfdFindData;
     112
     113        if (!pDir) {
     114                errno = EINVAL;
     115                return NULL;
     116        }
     117
     118        /* sanity check that this is a DIR pointer */
     119        if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
     120                errno = EINVAL;
     121                return NULL;
     122        }
     123
     124        if (pDir->dir_nNumFiles == 0) {
     125                pDir->dir_hDirHandle = FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData);
     126                if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE)
     127                        return NULL;
     128        } else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData))
     129                        return NULL;
     130
     131        /* bump count for next call to readdir() or telldir() */
     132        pDir->dir_nNumFiles++;
     133
     134        /* fill in struct dirent values */
     135        pDir->dir_sdReturn.d_ino = (ino_t)-1;
     136        strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
     137
     138        return &pDir->dir_sdReturn;
    140139}
    141140
     
    143142rewinddir(DIR* pDir)
    144143{
    145         if (!pDir) {
    146                 errno = EINVAL;
    147                 return;
    148         }
    149 
    150         /* sanity check that this is a DIR pointer */
    151         if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
    152                 errno = EINVAL;
    153                 return;
    154         }
    155 
    156         /* close the WINDOWS32 directory handle */
    157         if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
    158                 if (!FindClose(pDir->dir_hDirHandle))
    159                         errno = EBADF;
    160 
    161         /* reset members which control readdir() */
    162         pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
    163         pDir->dir_nNumFiles = 0;
    164 
    165         return;
     144        if (!pDir) {
     145                errno = EINVAL;
     146                return;
     147        }
     148
     149        /* sanity check that this is a DIR pointer */
     150        if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
     151                errno = EINVAL;
     152                return;
     153        }
     154
     155        /* close the WINDOWS32 directory handle */
     156        if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
     157                if (!FindClose(pDir->dir_hDirHandle))
     158                        errno = EBADF;
     159
     160        /* reset members which control readdir() */
     161        pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
     162        pDir->dir_nNumFiles = 0;
     163
     164        return;
    166165}
    167166
     
    169168telldir(DIR* pDir)
    170169{
    171         if (!pDir) {
    172                 errno = EINVAL;
    173                 return -1;
    174         }
    175 
    176         /* sanity check that this is a DIR pointer */
    177         if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
    178                 errno = EINVAL;
    179                 return -1;
    180         }
    181 
    182         /* return number of times readdir() called */
    183         return pDir->dir_nNumFiles;
     170        if (!pDir) {
     171                errno = EINVAL;
     172                return -1;
     173        }
     174
     175        /* sanity check that this is a DIR pointer */
     176        if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
     177                errno = EINVAL;
     178                return -1;
     179        }
     180
     181        /* return number of times readdir() called */
     182        return pDir->dir_nNumFiles;
    184183}
    185184
     
    187186seekdir(DIR* pDir, long nPosition)
    188187{
    189         if (!pDir)
    190                 return;
    191 
    192         /* sanity check that this is a DIR pointer */
    193         if (pDir->dir_ulCookie != __DIRENT_COOKIE)
    194                 return;
    195 
    196         /* go back to beginning of directory */
    197         rewinddir(pDir);
    198 
    199         /* loop until we have found position we care about */
    200         for (--nPosition; nPosition && readdir(pDir); nPosition--);
    201 
    202         /* flag invalid nPosition value */
    203         if (nPosition)
    204                 errno = EINVAL;
    205 
    206         return;
    207 }
     188        if (!pDir)
     189                return;
     190
     191        /* sanity check that this is a DIR pointer */
     192        if (pDir->dir_ulCookie != __DIRENT_COOKIE)
     193                return;
     194
     195        /* go back to beginning of directory */
     196        rewinddir(pDir);
     197
     198        /* loop until we have found position we care about */
     199        for (--nPosition; nPosition && readdir(pDir); nPosition--);
     200
     201        /* flag invalid nPosition value */
     202        if (nPosition)
     203                errno = EINVAL;
     204
     205        return;
     206}
  • vendor/gnumake/current/w32/include/dirent.h

    r2596 r3138  
    11/* Windows version of dirent.h
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    3837struct dirent
    3938{
    40   ino_t d_ino;                  /* unused - no equivalent on WINDOWS32 */
     39  ino_t d_ino;                  /* unused - no equivalent on WINDOWS32 */
    4140  char d_name[NAME_MAX+1];
    4241};
    4342
    4443typedef struct dir_struct {
    45         ULONG   dir_ulCookie;
    46         HANDLE  dir_hDirHandle;
    47         DWORD   dir_nNumFiles;
    48         char    dir_pDirectoryName[NAME_MAX+1];
    49         struct dirent dir_sdReturn;
     44        ULONG   dir_ulCookie;
     45        HANDLE  dir_hDirHandle;
     46        DWORD   dir_nNumFiles;
     47        char    dir_pDirectoryName[NAME_MAX+1];
     48        struct dirent dir_sdReturn;
    5049} DIR;
    5150
  • vendor/gnumake/current/w32/include/pathstuff.h

    r2596 r3138  
    11/* Definitions for Windows path manipulation.
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
  • vendor/gnumake/current/w32/include/sub_proc.h

    r2596 r3138  
    11/* Definitions for Windows process invocation.
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    2221 * Component Name:
    2322 *
    24  * $Date: 2010/07/13 01:20:43 $
     23 * $Date$
    2524 *
    26  * $Source: /sources/make/make/w32/include/sub_proc.h,v $
     25 * $Source$
    2726 *
    28  * $Id: sub_proc.h,v 1.12 2010/07/13 01:20:43 psmith Exp $
     27 * $Id$
    2928 */
    3029
     
    3433EXTERN_DECL(HANDLE process_init, (VOID_DECL));
    3534EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth,
    36         HANDLE stderrh));
     35                                     HANDLE stderrh));
    3736EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp,
    38         char *exec_path, char *as_user));
     37                                 char *exec_path, char *as_user));
    3938EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data,
    40         int stdin_data_len));
     39                                   int stdin_data_len));
    4140EXTERN_DECL(long process_file_io, (HANDLE proc));
    4241EXTERN_DECL(void process_cleanup, (HANDLE proc));
    43 EXTERN_DECL(HANDLE process_wait_for_any, (VOID_DECL));
     42EXTERN_DECL(HANDLE process_wait_for_any, (int block, DWORD* pdwWaitStatus));
    4443EXTERN_DECL(void process_register, (HANDLE proc));
    45 EXTERN_DECL(HANDLE process_easy, (char** argv, char** env));
     44EXTERN_DECL(HANDLE process_easy, (char** argv, char** env,
     45                                  int outfd, int errfd));
    4646EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal));
    4747EXTERN_DECL(int process_used_slots, (VOID_DECL));
     48EXTERN_DECL(DWORD process_set_handles, (HANDLE *handles));
    4849
    4950/* support routines */
     
    5758EXTERN_DECL(int process_errcnt, (HANDLE proc));
    5859EXTERN_DECL(void process_pipes, (HANDLE proc, int pipes[3]));
     60EXTERN_DECL(void process_noinherit, (int fildes));
    5961
    6062#endif
  • vendor/gnumake/current/w32/include/w32err.h

    r2596 r3138  
    11/* Definitions for Windows error handling.
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    2322#endif
    2423
    25 EXTERN_DECL(char * map_windows32_error_to_string, (DWORD error));
     24EXTERN_DECL(const char * map_windows32_error_to_string, (DWORD error));
    2625
    2726#endif /* !_W32ERR_H */
  • vendor/gnumake/current/w32/pathstuff.c

    r2596 r3138  
    11/* Path conversion for Windows pathnames.
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    1615this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1716
    18 #include "make.h"
     17#include "makeint.h"
    1918#include <string.h>
    2019#include <stdlib.h>
     
    2928    char *etok;            /* token separator for old Path */
    3029
    31         /*
    32         * Convert all spaces to delimiters. Note that pathnames which
    33         * contain blanks get trounced here. Use 8.3 format as a workaround.
    34         */
    35         for (etok = Path; etok && *etok; etok++)
    36                 if (isblank ((unsigned char) *etok))
    37                         *etok = to_delim;
    38 
    39         return (convert_Path_to_windows32(Path, to_delim));
     30        /*
     31        * Convert all spaces to delimiters. Note that pathnames which
     32        * contain blanks get trounced here. Use 8.3 format as a workaround.
     33        */
     34        for (etok = Path; etok && *etok; etok++)
     35                if (ISBLANK ((unsigned char) *etok))
     36                        *etok = to_delim;
     37
     38        return (convert_Path_to_windows32(Path, to_delim));
    4039}
    4140
     
    8180                *etok = to_delim;
    8281                p = ++etok;
    83             } else
     82            } else
    8483                p += strlen(p);
    8584        } else {
     
    116115getcwd_fs(char* buf, int len)
    117116{
    118         char *p = getcwd(buf, len);
    119 
    120         if (p) {
    121                 char *q = w32ify(buf, 0);
    122                 strncpy(buf, q, len);
    123         }
    124 
    125         return p;
     117        char *p = getcwd(buf, len);
     118
     119        if (p) {
     120                char *q = w32ify(buf, 0);
     121                strncpy(buf, q, len);
     122        }
     123
     124        return p;
    126125}
    127126
  • vendor/gnumake/current/w32/subproc/NMakefile

    r2596 r3138  
    1 # NOTE: If you have no `make' program at all to process this makefile, run
    2 # `build.bat' instead.
     1# NOTE: If you have no 'make' program at all to process this makefile, run
     2# 'build.bat' instead.
    33#
    4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    5 # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     4# Copyright (C) 1996-2016 Free Software Foundation, Inc.
    65# This file is part of GNU Make.
    76#
  • vendor/gnumake/current/w32/subproc/misc.c

    r2596 r3138  
    11/* Process handling for Windows
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    2625/*
    2726 * Description:  Convert a NULL string terminated UNIX environment block to
    28  *              an environment block suitable for a windows32 system call
     27 *              an environment block suitable for a windows32 system call
    2928 *
    3029 * Returns:  TRUE= success, FALSE=fail
    3130 *
    3231 * Notes/Dependencies:  the environment block is sorted in case-insensitive
    33  *      order, is double-null terminated, and is a char *, not a char **
     32 *      order, is double-null terminated, and is a char *, not a char **
    3433 */
    3534int _cdecl compare(const void *a1, const void *a2)
    3635{
    37         return _stricoll(*((char**)a1),*((char**)a2));
     36        return _stricoll(*((char**)a1),*((char**)a2));
    3837}
    3938bool_t
    40 arr2envblk(char **arr, char **envblk_out)
     39arr2envblk(char **arr, char **envblk_out, int *envsize_needed)
    4140{
    42         char **tmp;
    43         int size_needed;
    44         int arrcnt;
    45         char *ptr;
     41        char **tmp;
     42        int size_needed;
     43        int arrcnt;
     44        char *ptr;
    4645
    47         arrcnt = 0;
    48         while (arr[arrcnt]) {
    49                 arrcnt++;
    50         }
     46        arrcnt = 0;
     47        while (arr[arrcnt]) {
     48                arrcnt++;
     49        }
    5150
    52         tmp = (char**) calloc(arrcnt + 1, sizeof(char *));
    53         if (!tmp) {
    54                 return FALSE;
    55         }
     51        tmp = (char**) calloc(arrcnt + 1, sizeof(char *));
     52        if (!tmp) {
     53                return FALSE;
     54        }
    5655
    57         arrcnt = 0;
    58         size_needed = 0;
    59         while (arr[arrcnt]) {
    60                 tmp[arrcnt] = arr[arrcnt];
    61                 size_needed += strlen(arr[arrcnt]) + 1;
    62                 arrcnt++;
    63         }
    64         size_needed++;
     56        arrcnt = 0;
     57        size_needed = *envsize_needed = 0;
     58        while (arr[arrcnt]) {
     59                tmp[arrcnt] = arr[arrcnt];
     60                size_needed += strlen(arr[arrcnt]) + 1;
     61                arrcnt++;
     62        }
     63        size_needed++;
     64        *envsize_needed = size_needed;
    6565
    66         qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare);
     66        qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare);
    6767
    68         ptr = *envblk_out = calloc(size_needed, 1);
    69         if (!ptr) {
    70                 free(tmp);
    71                 return FALSE;
    72         }
     68        ptr = *envblk_out = calloc(size_needed, 1);
     69        if (!ptr) {
     70                free(tmp);
     71                return FALSE;
     72        }
    7373
    74         arrcnt = 0;
    75         while (tmp[arrcnt]) {
    76                 strcpy(ptr, tmp[arrcnt]);
    77                 ptr += strlen(tmp[arrcnt]) + 1;
    78                 arrcnt++;
    79         }
     74        arrcnt = 0;
     75        while (tmp[arrcnt]) {
     76                strcpy(ptr, tmp[arrcnt]);
     77                ptr += strlen(tmp[arrcnt]) + 1;
     78                arrcnt++;
     79        }
    8080
    81         free(tmp);
    82         return TRUE;
     81        free(tmp);
     82        return TRUE;
    8383}
  • vendor/gnumake/current/w32/subproc/proc.h

    r2596 r3138  
    11/* Definitions for Windows
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    2120typedef int bool_t;
    2221
    23 #define E_SCALL         101
    24 #define E_IO            102
    25 #define E_NO_MEM        103
    26 #define E_FORK          104
     22#define E_SCALL         101
     23#define E_IO            102
     24#define E_NO_MEM        103
     25#define E_FORK          104
    2726
    28 extern bool_t arr2envblk(char **arr, char **envblk_out);
     27extern bool_t arr2envblk(char **arr, char **envblk_out, int *envsize_needed);
    2928
    3029#endif
  • vendor/gnumake/current/w32/subproc/sub_proc.c

    r2596 r3138  
    11/* Process handling for Windows.
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    1918#include <stdlib.h>
    2019#include <stdio.h>
     20#include <io.h>         /* for _get_osfhandle */
    2121#ifdef _MSC_VER
    2222# include <stddef.h>    /* for intptr_t */
     
    2424# include <stdint.h>
    2525#endif
     26#include <string.h>
    2627#include <process.h>  /* for msvc _beginthreadex, _endthreadex */
    2728#include <signal.h>
    2829#include <windows.h>
    2930
     31#include "makeint.h"
     32#include "filedef.h"
     33#include "variable.h"
    3034#include "sub_proc.h"
    3135#include "proc.h"
     
    3438
    3539static char *make_command_line(char *shell_name, char *exec_path, char **argv);
    36 extern char *xmalloc (unsigned int);
    3740
    3841typedef struct sub_process_t {
    39         intptr_t sv_stdin[2];
    40         intptr_t sv_stdout[2];
    41         intptr_t sv_stderr[2];
    42         int using_pipes;
    43         char *inp;
    44         DWORD incnt;
    45         char * volatile outp;
    46         volatile DWORD outcnt;
    47         char * volatile errp;
    48         volatile DWORD errcnt;
    49         pid_t pid;
    50         int exit_code;
    51         int signal;
    52         long last_err;
    53         long lerrno;
     42        intptr_t sv_stdin[2];
     43        intptr_t sv_stdout[2];
     44        intptr_t sv_stderr[2];
     45        int using_pipes;
     46        char *inp;
     47        DWORD incnt;
     48        char * volatile outp;
     49        volatile DWORD outcnt;
     50        char * volatile errp;
     51        volatile DWORD errcnt;
     52        pid_t pid;
     53        int exit_code;
     54        int signal;
     55        long last_err;
     56        long lerrno;
    5457} sub_process;
    5558
     
    5861static int proc_index = 0;
    5962static int fake_exits_pending = 0;
     63
     64
     65/*
     66 * Fill a HANDLE list with handles to wait for.
     67 */
     68DWORD
     69process_set_handles(HANDLE *handles)
     70{
     71    DWORD count = 0;
     72    int i;
     73
     74    /* Build array of handles to wait for */
     75    for (i = 0; i < proc_index; i++) {
     76        /* Don't wait on child processes that have already finished */
     77        if (fake_exits_pending && proc_array[i]->exit_code)
     78            continue;
     79
     80        handles[count++] = (HANDLE) proc_array[i]->pid;
     81    }
     82
     83    return count;
     84}
    6085
    6186/*
     
    6691process_adjust_wait_state(sub_process* pproc)
    6792{
    68         int i;
    69 
    70         if (!proc_index)
    71                 return;
    72 
    73         for (i = 0; i < proc_index; i++)
    74                 if (proc_array[i]->pid == pproc->pid)
    75                         break;
    76 
    77         if (i < proc_index) {
    78                 proc_index--;
    79                 if (i != proc_index)
    80                         memmove(&proc_array[i], &proc_array[i+1],
    81                                 (proc_index-i) * sizeof(sub_process*));
    82                 proc_array[proc_index] = NULL;
    83         }
     93        int i;
     94
     95        if (!proc_index)
     96                return;
     97
     98        for (i = 0; i < proc_index; i++)
     99                if (proc_array[i]->pid == pproc->pid)
     100                        break;
     101
     102        if (i < proc_index) {
     103                proc_index--;
     104                if (i != proc_index)
     105                        memmove(&proc_array[i], &proc_array[i+1],
     106                                (proc_index-i) * sizeof(sub_process*));
     107                proc_array[proc_index] = NULL;
     108        }
    84109}
    85110
     
    88113 */
    89114static sub_process *
    90 process_wait_for_any_private(void)
    91 {
    92         HANDLE handles[MAXIMUM_WAIT_OBJECTS];
    93         DWORD retval, which;
    94         int i;
    95 
    96         if (!proc_index)
    97                 return NULL;
    98 
    99         /* build array of handles to wait for */
    100         for (i = 0; i < proc_index; i++) {
    101                 handles[i] = (HANDLE) proc_array[i]->pid;
    102 
    103                 if (fake_exits_pending && proc_array[i]->exit_code)
    104                         break;
    105         }
    106 
    107         /* wait for someone to exit */
    108         if (!fake_exits_pending) {
    109                 retval = WaitForMultipleObjects(proc_index, handles, FALSE, INFINITE);
    110                 which = retval - WAIT_OBJECT_0;
    111         } else {
    112                 fake_exits_pending--;
    113                 retval = !WAIT_FAILED;
    114                 which = i;
    115         }
    116 
    117         /* return pointer to process */
    118         if (retval != WAIT_FAILED) {
    119                 sub_process* pproc = proc_array[which];
    120                 process_adjust_wait_state(pproc);
    121                 return pproc;
    122         } else
    123                 return NULL;
     115process_wait_for_any_private(int block, DWORD* pdwWaitStatus)
     116{
     117        HANDLE handles[MAXIMUM_WAIT_OBJECTS];
     118        DWORD retval, which;
     119        int i;
     120
     121        if (!proc_index)
     122                return NULL;
     123
     124        /* build array of handles to wait for */
     125        for (i = 0; i < proc_index; i++) {
     126                handles[i] = (HANDLE) proc_array[i]->pid;
     127
     128                if (fake_exits_pending && proc_array[i]->exit_code)
     129                        break;
     130        }
     131
     132        /* wait for someone to exit */
     133        if (!fake_exits_pending) {
     134                retval = WaitForMultipleObjects(proc_index, handles, FALSE, (block ? INFINITE : 0));
     135                which = retval - WAIT_OBJECT_0;
     136        } else {
     137                fake_exits_pending--;
     138                retval = !WAIT_FAILED;
     139                which = i;
     140        }
     141
     142        /* If the pointer is not NULL, set the wait status result variable. */
     143        if (pdwWaitStatus)
     144            *pdwWaitStatus = retval;
     145
     146        /* return pointer to process */
     147        if ((retval == WAIT_TIMEOUT) || (retval == WAIT_FAILED)) {
     148                return NULL;
     149        }
     150        else {
     151                sub_process* pproc = proc_array[which];
     152                process_adjust_wait_state(pproc);
     153                return pproc;
     154        }
    124155}
    125156
     
    130161process_kill(HANDLE proc, int signal)
    131162{
    132         sub_process* pproc = (sub_process*) proc;
    133         pproc->signal = signal;
    134         return (TerminateProcess((HANDLE) pproc->pid, signal));
     163        sub_process* pproc = (sub_process*) proc;
     164        pproc->signal = signal;
     165        return (TerminateProcess((HANDLE) pproc->pid, signal));
    135166}
    136167
     
    144175process_register(HANDLE proc)
    145176{
    146         if (proc_index < MAXIMUM_WAIT_OBJECTS)
    147                 proc_array[proc_index++] = (sub_process *) proc;
     177        if (proc_index < MAXIMUM_WAIT_OBJECTS)
     178                proc_array[proc_index++] = (sub_process *) proc;
    148179}
    149180
     
    154185process_used_slots(void)
    155186{
    156         return proc_index;
     187        return proc_index;
    157188}
    158189
     
    162193 * you must do 1 of things:
    163194 *
    164  *      x = process_easy(...);
     195 *      x = process_easy(...);
    165196 *
    166197 * or
    167198 *
    168  *      x = process_init_fd();
    169  *      process_register(x);
     199 *      x = process_init_fd();
     200 *      process_register(x);
    170201 *
    171202 * or
    172203 *
    173  *      x = process_init();
    174  *      process_register(x);
     204 *      x = process_init();
     205 *      process_register(x);
    175206 *
    176207 * You must NOT then call process_pipe_io() because this function is
     
    180211
    181212HANDLE
    182 process_wait_for_any(void)
    183 {
    184         sub_process* pproc = process_wait_for_any_private();
    185 
    186         if (!pproc)
    187                 return NULL;
    188         else {
    189                 /*
    190                 * Ouch! can't tell caller if this fails directly. Caller
    191                 * will have to use process_last_err()
     213process_wait_for_any(int block, DWORD* pdwWaitStatus)
     214{
     215        sub_process* pproc = process_wait_for_any_private(block, pdwWaitStatus);
     216
     217        if (!pproc)
     218                return NULL;
     219        else {
     220                /*
     221                * Ouch! can't tell caller if this fails directly. Caller
     222                * will have to use process_last_err()
    192223                 */
    193                 (void) process_file_io(pproc);
    194                 return ((HANDLE) pproc);
    195         }
     224                (void) process_file_io(pproc);
     225                return ((HANDLE) pproc);
     226        }
    196227}
    197228
     
    207238{
    208239        if (proc == INVALID_HANDLE_VALUE) return ERROR_INVALID_HANDLE;
    209         return (((sub_process *)proc)->last_err);
     240        return (((sub_process *)proc)->last_err);
    210241}
    211242
     
    214245{
    215246        if (proc == INVALID_HANDLE_VALUE) return EXIT_FAILURE;
    216         return (((sub_process *)proc)->exit_code);
     247        return (((sub_process *)proc)->exit_code);
     248}
     249
     250void
     251process_noinherit(int fd)
     252{
     253  HANDLE fh = (HANDLE)_get_osfhandle(fd);
     254
     255  if (fh && fh != INVALID_HANDLE_VALUE)
     256        SetHandleInformation(fh, HANDLE_FLAG_INHERIT, 0);
    217257}
    218258
     
    227267process_outbuf(HANDLE proc)
    228268{
    229         return (((sub_process *)proc)->outp);
     269        return (((sub_process *)proc)->outp);
    230270}
    231271
     
    233273process_errbuf(HANDLE proc)
    234274{
    235         return (((sub_process *)proc)->errp);
     275        return (((sub_process *)proc)->errp);
    236276}
    237277
     
    239279process_outcnt(HANDLE proc)
    240280{
    241         return (((sub_process *)proc)->outcnt);
     281        return (((sub_process *)proc)->outcnt);
    242282}
    243283
     
    245285process_errcnt(HANDLE proc)
    246286{
    247         return (((sub_process *)proc)->errcnt);
     287        return (((sub_process *)proc)->errcnt);
    248288}
    249289
     
    251291process_pipes(HANDLE proc, int pipes[3])
    252292{
    253         pipes[0] = ((sub_process *)proc)->sv_stdin[0];
    254         pipes[1] = ((sub_process *)proc)->sv_stdout[0];
    255         pipes[2] = ((sub_process *)proc)->sv_stderr[0];
    256         return;
     293        pipes[0] = ((sub_process *)proc)->sv_stdin[0];
     294        pipes[1] = ((sub_process *)proc)->sv_stdout[0];
     295        pipes[2] = ((sub_process *)proc)->sv_stderr[0];
     296        return;
    257297}
    258298*/
    259299
    260         HANDLE
     300        HANDLE
    261301process_init()
    262302{
    263         sub_process *pproc;
    264         /*
    265         * open file descriptors for attaching stdin/stdout/sterr
    266         */
    267         HANDLE stdin_pipes[2];
    268         HANDLE stdout_pipes[2];
    269         HANDLE stderr_pipes[2];
    270         SECURITY_ATTRIBUTES inherit;
    271         BYTE sd[SECURITY_DESCRIPTOR_MIN_LENGTH];
    272 
    273         pproc = malloc(sizeof(*pproc));
    274         memset(pproc, 0, sizeof(*pproc));
    275 
    276         /* We can't use NULL for lpSecurityDescriptor because that
    277            uses the default security descriptor of the calling process.
    278            Instead we use a security descriptor with no DACL.  This
    279            allows nonrestricted access to the associated objects. */
    280 
    281         if (!InitializeSecurityDescriptor((PSECURITY_DESCRIPTOR)(&sd),
    282                                           SECURITY_DESCRIPTOR_REVISION)) {
    283                 pproc->last_err = GetLastError();
    284                 pproc->lerrno = E_SCALL;
    285                 return((HANDLE)pproc);
    286         }
    287 
    288         inherit.nLength = sizeof(inherit);
    289         inherit.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)(&sd);
    290         inherit.bInheritHandle = TRUE;
    291 
    292         // By convention, parent gets pipe[0], and child gets pipe[1]
    293         // This means the READ side of stdin pipe goes into pipe[1]
    294         // and the WRITE side of the stdout and stderr pipes go into pipe[1]
    295         if (CreatePipe( &stdin_pipes[1], &stdin_pipes[0], &inherit, 0) == FALSE ||
    296         CreatePipe( &stdout_pipes[0], &stdout_pipes[1], &inherit, 0) == FALSE ||
    297         CreatePipe( &stderr_pipes[0], &stderr_pipes[1], &inherit, 0) == FALSE) {
    298 
    299                 pproc->last_err = GetLastError();
    300                 pproc->lerrno = E_SCALL;
    301                 return((HANDLE)pproc);
    302         }
    303 
    304         //
    305         // Mark the parent sides of the pipes as non-inheritable
    306         //
    307         if (SetHandleInformation(stdin_pipes[0],
    308                                 HANDLE_FLAG_INHERIT, 0) == FALSE ||
    309                 SetHandleInformation(stdout_pipes[0],
    310                                 HANDLE_FLAG_INHERIT, 0) == FALSE ||
    311                 SetHandleInformation(stderr_pipes[0],
    312                                 HANDLE_FLAG_INHERIT, 0) == FALSE) {
    313 
    314                 pproc->last_err = GetLastError();
    315                 pproc->lerrno = E_SCALL;
    316                 return((HANDLE)pproc);
    317         }
    318         pproc->sv_stdin[0]  = (intptr_t) stdin_pipes[0];
    319         pproc->sv_stdin[1]  = (intptr_t) stdin_pipes[1];
    320         pproc->sv_stdout[0] = (intptr_t) stdout_pipes[0];
    321         pproc->sv_stdout[1] = (intptr_t) stdout_pipes[1];
    322         pproc->sv_stderr[0] = (intptr_t) stderr_pipes[0];
    323         pproc->sv_stderr[1] = (intptr_t) stderr_pipes[1];
    324 
    325         pproc->using_pipes = 1;
    326 
    327         pproc->lerrno = 0;
    328 
    329         return((HANDLE)pproc);
    330 }
    331 
    332 
    333         HANDLE
     303        sub_process *pproc;
     304        /*
     305        * open file descriptors for attaching stdin/stdout/sterr
     306        */
     307        HANDLE stdin_pipes[2];
     308        HANDLE stdout_pipes[2];
     309        HANDLE stderr_pipes[2];
     310        SECURITY_ATTRIBUTES inherit;
     311        BYTE sd[SECURITY_DESCRIPTOR_MIN_LENGTH];
     312
     313        pproc = malloc(sizeof(*pproc));
     314        memset(pproc, 0, sizeof(*pproc));
     315
     316        /* We can't use NULL for lpSecurityDescriptor because that
     317           uses the default security descriptor of the calling process.
     318           Instead we use a security descriptor with no DACL.  This
     319           allows nonrestricted access to the associated objects. */
     320
     321        if (!InitializeSecurityDescriptor((PSECURITY_DESCRIPTOR)(&sd),
     322                                          SECURITY_DESCRIPTOR_REVISION)) {
     323                pproc->last_err = GetLastError();
     324                pproc->lerrno = E_SCALL;
     325                return((HANDLE)pproc);
     326        }
     327
     328        inherit.nLength = sizeof(inherit);
     329        inherit.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)(&sd);
     330        inherit.bInheritHandle = TRUE;
     331
     332        // By convention, parent gets pipe[0], and child gets pipe[1]
     333        // This means the READ side of stdin pipe goes into pipe[1]
     334        // and the WRITE side of the stdout and stderr pipes go into pipe[1]
     335        if (CreatePipe( &stdin_pipes[1], &stdin_pipes[0], &inherit, 0) == FALSE ||
     336        CreatePipe( &stdout_pipes[0], &stdout_pipes[1], &inherit, 0) == FALSE ||
     337        CreatePipe( &stderr_pipes[0], &stderr_pipes[1], &inherit, 0) == FALSE) {
     338
     339                pproc->last_err = GetLastError();
     340                pproc->lerrno = E_SCALL;
     341                return((HANDLE)pproc);
     342        }
     343
     344        //
     345        // Mark the parent sides of the pipes as non-inheritable
     346        //
     347        if (SetHandleInformation(stdin_pipes[0],
     348                                HANDLE_FLAG_INHERIT, 0) == FALSE ||
     349                SetHandleInformation(stdout_pipes[0],
     350                                HANDLE_FLAG_INHERIT, 0) == FALSE ||
     351                SetHandleInformation(stderr_pipes[0],
     352                                HANDLE_FLAG_INHERIT, 0) == FALSE) {
     353
     354                pproc->last_err = GetLastError();
     355                pproc->lerrno = E_SCALL;
     356                return((HANDLE)pproc);
     357        }
     358        pproc->sv_stdin[0]  = (intptr_t) stdin_pipes[0];
     359        pproc->sv_stdin[1]  = (intptr_t) stdin_pipes[1];
     360        pproc->sv_stdout[0] = (intptr_t) stdout_pipes[0];
     361        pproc->sv_stdout[1] = (intptr_t) stdout_pipes[1];
     362        pproc->sv_stderr[0] = (intptr_t) stderr_pipes[0];
     363        pproc->sv_stderr[1] = (intptr_t) stderr_pipes[1];
     364
     365        pproc->using_pipes = 1;
     366
     367        pproc->lerrno = 0;
     368
     369        return((HANDLE)pproc);
     370}
     371
     372
     373        HANDLE
    334374process_init_fd(HANDLE stdinh, HANDLE stdouth, HANDLE stderrh)
    335375{
    336         sub_process *pproc;
    337 
    338         pproc = malloc(sizeof(*pproc));
    339         memset(pproc, 0, sizeof(*pproc));
    340 
    341         /*
    342          * Just pass the provided file handles to the 'child side' of the
    343          * pipe, bypassing pipes altogether.
    344          */
    345         pproc->sv_stdin[1]  = (intptr_t) stdinh;
    346         pproc->sv_stdout[1] = (intptr_t) stdouth;
    347         pproc->sv_stderr[1] = (intptr_t) stderrh;
    348 
    349         pproc->last_err = pproc->lerrno = 0;
    350 
    351         return((HANDLE)pproc);
     376        sub_process *pproc;
     377
     378        pproc = malloc(sizeof(*pproc));
     379        if (pproc) {
     380                memset(pproc, 0, sizeof(*pproc));
     381
     382                /*
     383                 * Just pass the provided file handles to the 'child
     384                 * side' of the pipe, bypassing pipes altogether.
     385                 */
     386                pproc->sv_stdin[1]  = (intptr_t) stdinh;
     387                pproc->sv_stdout[1] = (intptr_t) stdouth;
     388                pproc->sv_stderr[1] = (intptr_t) stderrh;
     389
     390                pproc->last_err = pproc->lerrno = 0;
     391        }
     392
     393        return((HANDLE)pproc);
    352394}
    353395
     
    355397static HANDLE
    356398find_file(const char *exec_path, const char *path_var,
    357           char *full_fname, DWORD full_len)
    358 {
    359         HANDLE exec_handle;
    360         char *fname;
    361         char *ext;
    362         DWORD req_len;
    363         int i;
    364         static const char *extensions[] =
    365           /* Should .com come before no-extension case?  */
    366           { ".exe", ".cmd", ".bat", "", ".com", NULL };
    367 
    368         fname = xmalloc(strlen(exec_path) + 5);
    369         strcpy(fname, exec_path);
    370         ext = fname + strlen(fname);
    371 
    372         for (i = 0; extensions[i]; i++) {
    373                 strcpy(ext, extensions[i]);
    374                 if (((req_len = SearchPath (path_var, fname, NULL, full_len,
    375                                             full_fname, NULL)) > 0
    376                      /* For compatibility with previous code, which
    377                         used OpenFile, and with Windows operation in
    378                         general, also look in various default
    379                         locations, such as Windows directory and
    380                         Windows System directory.  Warning: this also
    381                         searches PATH in the Make's environment, which
    382                         might not be what the Makefile wants, but it
    383                         seems to be OK as a fallback, after the
    384                         previous SearchPath failed to find on child's
    385                         PATH.  */
    386                      || (req_len = SearchPath (NULL, fname, NULL, full_len,
    387                                                full_fname, NULL)) > 0)
    388                     && req_len <= full_len
    389                     && (exec_handle =
    390                                 CreateFile(full_fname,
    391                                            GENERIC_READ,
    392                                            FILE_SHARE_READ | FILE_SHARE_WRITE,
    393                                            NULL,
    394                                            OPEN_EXISTING,
    395                                            FILE_ATTRIBUTE_NORMAL,
    396                                            NULL)) != INVALID_HANDLE_VALUE) {
    397                         free(fname);
    398                         return(exec_handle);
    399                 }
    400         }
    401 
    402         free(fname);
    403         return INVALID_HANDLE_VALUE;
     399          char *full_fname, DWORD full_len)
     400{
     401        HANDLE exec_handle;
     402        char *fname;
     403        char *ext;
     404        DWORD req_len;
     405        int i;
     406        static const char *extensions[] =
     407          /* Should .com come before no-extension case?  */
     408          { ".exe", ".cmd", ".bat", "", ".com", NULL };
     409
     410        fname = xmalloc(strlen(exec_path) + 5);
     411        strcpy(fname, exec_path);
     412        ext = fname + strlen(fname);
     413
     414        for (i = 0; extensions[i]; i++) {
     415                strcpy(ext, extensions[i]);
     416                if (((req_len = SearchPath (path_var, fname, NULL, full_len,
     417                                            full_fname, NULL)) > 0
     418                     /* For compatibility with previous code, which
     419                        used OpenFile, and with Windows operation in
     420                        general, also look in various default
     421                        locations, such as Windows directory and
     422                        Windows System directory.  Warning: this also
     423                        searches PATH in the Make's environment, which
     424                        might not be what the Makefile wants, but it
     425                        seems to be OK as a fallback, after the
     426                        previous SearchPath failed to find on child's
     427                        PATH.  */
     428                     || (req_len = SearchPath (NULL, fname, NULL, full_len,
     429                                               full_fname, NULL)) > 0)
     430                    && req_len <= full_len
     431                    && (exec_handle =
     432                                CreateFile(full_fname,
     433                                           GENERIC_READ,
     434                                           FILE_SHARE_READ | FILE_SHARE_WRITE,
     435                                           NULL,
     436                                           OPEN_EXISTING,
     437                                           FILE_ATTRIBUTE_NORMAL,
     438                                           NULL)) != INVALID_HANDLE_VALUE) {
     439                        free(fname);
     440                        return(exec_handle);
     441                }
     442        }
     443
     444        free(fname);
     445        return INVALID_HANDLE_VALUE;
     446}
     447
     448/*
     449 * Return non-zero of FNAME specifies a batch file and its name
     450 * includes embedded whitespace.
     451 */
     452
     453static int
     454batch_file_with_spaces(const char *fname)
     455{
     456        size_t fnlen = strlen(fname);
     457
     458        return (fnlen > 4
     459                && (_strnicmp(fname + fnlen - 4, ".bat", 4) == 0
     460                    || _strnicmp(fname + fnlen - 4, ".cmd", 4) == 0)
     461                /* The set of characters in the 2nd arg to strpbrk
     462                   should be the same one used by make_command_line
     463                   below to decide whether an argv[] element needs
     464                   quoting.  */
     465                && strpbrk(fname, " \t") != NULL);
    404466}
    405467
     
    414476long
    415477process_begin(
    416         HANDLE proc,
    417         char **argv,
    418         char **envp,
    419         char *exec_path,
    420         char *as_user)
    421 {
    422         sub_process *pproc = (sub_process *)proc;
    423         char *shell_name = 0;
    424         int file_not_found=0;
    425         HANDLE exec_handle;
    426         char exec_fname[MAX_PATH];
    427         const char *path_var = NULL;
    428         char **ep;
    429         char buf[256];
    430         DWORD bytes_returned;
    431         DWORD flags;
    432         char *command_line;
    433         STARTUPINFO startInfo;
    434         PROCESS_INFORMATION procInfo;
    435         char *envblk=NULL;
    436 
    437         /*
    438          *  Shell script detection...  if the exec_path starts with #! then
    439          *  we want to exec shell-script-name exec-path, not just exec-path
    440          *  NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl.  We do not
    441          *  hard-code the path to the shell or perl or whatever:  Instead, we
    442          *  assume it's in the path somewhere (generally, the NT tools
    443          *  bin directory)
    444          */
    445 
    446         /* Use the Makefile's value of PATH to look for the program to
    447            execute, because it could be different from Make's PATH
    448            (e.g., if the target sets its own value.  */
    449         if (envp)
    450                 for (ep = envp; *ep; ep++) {
    451                         if (strncmp (*ep, "PATH=", 5) == 0
    452                             || strncmp (*ep, "Path=", 5) == 0) {
    453                                 path_var = *ep + 5;
    454                                 break;
    455                         }
    456                 }
    457         exec_handle = find_file(exec_path, path_var,
    458                                 exec_fname, sizeof(exec_fname));
    459 
    460         /*
    461          * If we couldn't open the file, just assume that Windows will be
    462          * somehow able to find and execute it.
    463          */
    464         if (exec_handle == INVALID_HANDLE_VALUE) {
    465                 file_not_found++;
    466         }
    467         else {
    468                 /* Attempt to read the first line of the file */
    469                 if (ReadFile( exec_handle,
    470                                 buf, sizeof(buf) - 1, /* leave room for trailing NULL */
    471                                 &bytes_returned, 0) == FALSE || bytes_returned < 2) {
    472 
    473                         pproc->last_err = GetLastError();
    474                         pproc->lerrno = E_IO;
    475                         CloseHandle(exec_handle);
    476                         return(-1);
    477                 }
    478                 if (buf[0] == '#' && buf[1] == '!') {
    479                         /*
    480                          *  This is a shell script...  Change the command line from
    481                          *      exec_path args to shell_name exec_path args
    482                          */
    483                         char *p;
    484 
    485                         /*  Make sure buf is NULL terminated */
    486                         buf[bytes_returned] = 0;
    487                         /*
    488                          * Depending on the file system type, etc. the first line
    489                          * of the shell script may end with newline or newline-carriage-return
    490                          * Whatever it ends with, cut it off.
    491                          */
    492                         p= strchr(buf, '\n');
    493                         if (p)
    494                                 *p = 0;
    495                         p = strchr(buf, '\r');
    496                         if (p)
    497                                 *p = 0;
    498 
    499                         /*
    500                          *  Find base name of shell
    501                          */
    502                         shell_name = strrchr( buf, '/');
    503                         if (shell_name) {
    504                                 shell_name++;
    505                         } else {
    506                                 shell_name = &buf[2];/* skipping "#!" */
    507                         }
    508 
    509                 }
    510                 CloseHandle(exec_handle);
    511         }
    512 
    513         flags = 0;
    514 
    515         if (file_not_found)
    516                 command_line = make_command_line( shell_name, exec_path, argv);
    517         else
    518                 command_line = make_command_line( shell_name, exec_fname, argv);
    519 
    520         if ( command_line == NULL ) {
    521                 pproc->last_err = 0;
    522                 pproc->lerrno = E_NO_MEM;
    523                 return(-1);
    524         }
    525 
    526         if (envp) {
    527                 if (arr2envblk(envp, &envblk) ==FALSE) {
    528                         pproc->last_err = 0;
    529                         pproc->lerrno = E_NO_MEM;
    530                         free( command_line );
    531                         return(-1);
    532                 }
    533         }
    534 
    535         if ((shell_name) || (file_not_found)) {
    536                 exec_path = 0;  /* Search for the program in %Path% */
    537         } else {
    538                 exec_path = exec_fname;
    539         }
    540 
    541         /*
    542          *  Set up inherited stdin, stdout, stderr for child
    543          */
    544         GetStartupInfo(&startInfo);
    545         startInfo.dwFlags = STARTF_USESTDHANDLES;
    546         startInfo.lpReserved = 0;
    547         startInfo.cbReserved2 = 0;
    548         startInfo.lpReserved2 = 0;
    549         startInfo.lpTitle = shell_name ? shell_name : exec_path;
    550         startInfo.hStdInput = (HANDLE)pproc->sv_stdin[1];
    551         startInfo.hStdOutput = (HANDLE)pproc->sv_stdout[1];
    552         startInfo.hStdError = (HANDLE)pproc->sv_stderr[1];
    553 
    554         if (as_user) {
    555                 if (envblk) free(envblk);
    556                 return -1;
    557         } else {
    558                 DB (DB_JOBS, ("CreateProcess(%s,%s,...)\n",
    559                         exec_path ? exec_path : "NULL",
    560                         command_line ? command_line : "NULL"));
    561                 if (CreateProcess(
    562                         exec_path,
    563                         command_line,
    564                         NULL,
    565                         0, /* default security attributes for thread */
    566                         TRUE, /* inherit handles (e.g. helper pipes, oserv socket) */
    567                         flags,
    568                         envblk,
    569                         0, /* default starting directory */
    570                         &startInfo,
    571                         &procInfo) == FALSE) {
    572 
    573                         pproc->last_err = GetLastError();
    574                         pproc->lerrno = E_FORK;
    575                         fprintf(stderr, "process_begin: CreateProcess(%s, %s, ...) failed.\n",
     478        HANDLE proc,
     479        char **argv,
     480        char **envp,
     481        char *exec_path,
     482        char *as_user)
     483{
     484        sub_process *pproc = (sub_process *)proc;
     485        char *shell_name = 0;
     486        int file_not_found=0;
     487        HANDLE exec_handle;
     488        char exec_fname[MAX_PATH];
     489        const char *path_var = NULL;
     490        char **ep;
     491        char buf[MAX_PATH];
     492        DWORD bytes_returned;
     493        DWORD flags;
     494        char *command_line;
     495        STARTUPINFO startInfo;
     496        PROCESS_INFORMATION procInfo;
     497        char *envblk=NULL;
     498        int envsize_needed = 0;
     499        int pass_null_exec_path = 0;
     500
     501        /*
     502         *  Shell script detection...  if the exec_path starts with #! then
     503         *  we want to exec shell-script-name exec-path, not just exec-path
     504         *  NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl.  We do not
     505         *  hard-code the path to the shell or perl or whatever:  Instead, we
     506         *  assume it's in the path somewhere (generally, the NT tools
     507         *  bin directory)
     508         */
     509
     510        /* Use the Makefile's value of PATH to look for the program to
     511           execute, because it could be different from Make's PATH
     512           (e.g., if the target sets its own value.  */
     513        if (envp)
     514                for (ep = envp; *ep; ep++) {
     515                        if (strncmp (*ep, "PATH=", 5) == 0
     516                            || strncmp (*ep, "Path=", 5) == 0) {
     517                                path_var = *ep + 5;
     518                                break;
     519                        }
     520                }
     521        exec_handle = find_file(exec_path, path_var,
     522                                exec_fname, sizeof(exec_fname));
     523
     524        /*
     525         * If we couldn't open the file, just assume that Windows will be
     526         * somehow able to find and execute it.  If the first character
     527         * of the command is '/', assume they set SHELL to a Unixy shell
     528         * that have some magic mounts known only to it, and run the whole
     529         * command via $SHELL -c "COMMAND" instead.
     530         */
     531        if (exec_handle == INVALID_HANDLE_VALUE) {
     532                if (exec_path[0] == '/') {
     533                        char *new_argv0;
     534                        char **argvi = argv;
     535                        int arglen = 0;
     536
     537                        strcpy(buf, variable_expand ("$(SHELL)"));
     538                        shell_name = &buf[0];
     539                        strcpy(exec_fname, "-c");
     540                        /* Construct a single command string in argv[0].  */
     541                        while (*argvi) {
     542                                arglen += strlen(*argvi) + 1;
     543                                argvi++;
     544                        }
     545                        new_argv0 = xmalloc(arglen + 1);
     546                        new_argv0[0] = '\0';
     547                        for (argvi = argv; *argvi; argvi++) {
     548                                strcat(new_argv0, *argvi);
     549                                strcat(new_argv0, " ");
     550                        }
     551                        /* Remove the extra blank at the end.  */
     552                        new_argv0[arglen-1] = '\0';
     553                        free(argv[0]);
     554                        argv[0] = new_argv0;
     555                        argv[1] = NULL;
     556                }
     557                else
     558                        file_not_found++;
     559        }
     560        else {
     561                /* Attempt to read the first line of the file */
     562                if (ReadFile( exec_handle,
     563                                buf, sizeof(buf) - 1, /* leave room for trailing NULL */
     564                                &bytes_returned, 0) == FALSE || bytes_returned < 2) {
     565
     566                        pproc->last_err = GetLastError();
     567                        pproc->lerrno = E_IO;
     568                        CloseHandle(exec_handle);
     569                        return(-1);
     570                }
     571                if (buf[0] == '#' && buf[1] == '!') {
     572                        /*
     573                         *  This is a shell script...  Change the command line from
     574                         *      exec_path args to shell_name exec_path args
     575                         */
     576                        char *p;
     577
     578                        /*  Make sure buf is NULL terminated */
     579                        buf[bytes_returned] = 0;
     580                        /*
     581                         * Depending on the file system type, etc. the first line
     582                         * of the shell script may end with newline or newline-carriage-return
     583                         * Whatever it ends with, cut it off.
     584                         */
     585                        p= strchr(buf, '\n');
     586                        if (p)
     587                                *p = 0;
     588                        p = strchr(buf, '\r');
     589                        if (p)
     590                                *p = 0;
     591
     592                        /*
     593                         *  Find base name of shell
     594                         */
     595                        shell_name = strrchr( buf, '/');
     596                        if (shell_name) {
     597                                shell_name++;
     598                        } else {
     599                                shell_name = &buf[2];/* skipping "#!" */
     600                        }
     601
     602                }
     603                CloseHandle(exec_handle);
     604        }
     605
     606        flags = 0;
     607
     608        if (file_not_found)
     609                command_line = make_command_line( shell_name, exec_path, argv);
     610        else {
     611                /* If exec_fname includes whitespace, CreateProcess
     612                   behaves erratically and unreliably, and often fails
     613                   if argv[0] also includes whitespace (and thus will
     614                   be quoted by make_command_line below).  So in that
     615                   case, we don't pass exec_fname as the 1st arg to
     616                   CreateProcess, but instead replace argv[0] with
     617                   exec_fname (to keep its leading directories and
     618                   extension as found by find_file), and pass NULL to
     619                   CreateProcess as its 1st arg.  This works around
     620                   the bugs in CreateProcess, which are probably
     621                   caused by its passing the command to cmd.exe with
     622                   some incorrect quoting.  */
     623                if (!shell_name
     624                    && batch_file_with_spaces(exec_fname)
     625                    && _stricmp(exec_path, argv[0]) == 0) {
     626                        char *new_argv, *p;
     627                        char **argvi;
     628                        int arglen, i;
     629                        pass_null_exec_path = 1;
     630                        /* Rewrite argv[] replacing argv[0] with exec_fname.  */
     631                        for (argvi = argv + 1, arglen = strlen(exec_fname) + 1;
     632                             *argvi;
     633                             argvi++) {
     634                                arglen += strlen(*argvi) + 1;
     635                        }
     636                        new_argv = xmalloc(arglen);
     637                        p = strcpy(new_argv, exec_fname) + strlen(exec_fname) + 1;
     638                        for (argvi = argv + 1, i = 1; *argvi; argvi++, i++) {
     639                                strcpy(p, *argvi);
     640                                argv[i] = p;
     641                                p += strlen(*argvi) + 1;
     642                        }
     643                        argv[i] = NULL;
     644                        free (argv[0]);
     645                        argv[0] = new_argv;
     646                }
     647                command_line = make_command_line( shell_name, exec_fname, argv);
     648        }
     649
     650        if ( command_line == NULL ) {
     651                pproc->last_err = 0;
     652                pproc->lerrno = E_NO_MEM;
     653                return(-1);
     654        }
     655
     656        if (envp) {
     657                if (arr2envblk(envp, &envblk, &envsize_needed) == FALSE) {
     658                        pproc->lerrno = E_NO_MEM;
     659                        free( command_line );
     660                        if ((pproc->last_err == ERROR_INVALID_PARAMETER
     661                             || pproc->last_err == ERROR_MORE_DATA)
     662                            && envsize_needed > 32*1024) {
     663                                fprintf (stderr, "CreateProcess failed, probably because environment is too large (%d bytes).\n",
     664                                         envsize_needed);
     665                        }
     666                        pproc->last_err = 0;
     667                        return(-1);
     668                }
     669        }
     670
     671        if (shell_name || file_not_found || pass_null_exec_path) {
     672                exec_path = 0;  /* Search for the program in %Path% */
     673        } else {
     674                exec_path = exec_fname;
     675        }
     676
     677        /*
     678         *  Set up inherited stdin, stdout, stderr for child
     679         */
     680        memset(&startInfo, '\0', sizeof(startInfo));
     681        GetStartupInfo(&startInfo);
     682        startInfo.dwFlags = STARTF_USESTDHANDLES;
     683        startInfo.lpReserved = 0;
     684        startInfo.cbReserved2 = 0;
     685        startInfo.lpReserved2 = 0;
     686        startInfo.hStdInput = (HANDLE)pproc->sv_stdin[1];
     687        startInfo.hStdOutput = (HANDLE)pproc->sv_stdout[1];
     688        startInfo.hStdError = (HANDLE)pproc->sv_stderr[1];
     689
     690        if (as_user) {
     691                free(envblk);
     692                return -1;
     693        } else {
     694                DB (DB_JOBS, ("CreateProcess(%s,%s,...)\n",
     695                        exec_path ? exec_path : "NULL",
     696                        command_line ? command_line : "NULL"));
     697                if (CreateProcess(
     698                        exec_path,
     699                        command_line,
     700                        NULL,
     701                        0, /* default security attributes for thread */
     702                        TRUE, /* inherit handles (e.g. helper pipes, oserv socket) */
     703                        flags,
     704                        envblk,
     705                        0, /* default starting directory */
     706                        &startInfo,
     707                        &procInfo) == FALSE) {
     708
     709                        pproc->last_err = GetLastError();
     710                        pproc->lerrno = E_FORK;
     711                        fprintf(stderr, "process_begin: CreateProcess(%s, %s, ...) failed.\n",
    576712                                exec_path ? exec_path : "NULL", command_line);
    577                         if (envblk) free(envblk);
    578                         free( command_line );
    579                         return(-1);
    580                 }
    581         }
    582 
    583         pproc->pid = (pid_t)procInfo.hProcess;
    584         /* Close the thread handle -- we'll just watch the process */
    585         CloseHandle(procInfo.hThread);
    586 
    587         /* Close the halves of the pipes we don't need */
    588         CloseHandle((HANDLE)pproc->sv_stdin[1]);
    589         CloseHandle((HANDLE)pproc->sv_stdout[1]);
    590         CloseHandle((HANDLE)pproc->sv_stderr[1]);
     713                        free(envblk);
     714                        free( command_line );
     715                        return(-1);
     716                }
     717        }
     718
     719        pproc->pid = (pid_t)procInfo.hProcess;
     720        /* Close the thread handle -- we'll just watch the process */
     721        CloseHandle(procInfo.hThread);
     722
     723        /* Close the halves of the pipes we don't need */
     724        if ((HANDLE)pproc->sv_stdin[1] != INVALID_HANDLE_VALUE)
     725          CloseHandle((HANDLE)pproc->sv_stdin[1]);
     726        if ((HANDLE)pproc->sv_stdout[1] != INVALID_HANDLE_VALUE)
     727          CloseHandle((HANDLE)pproc->sv_stdout[1]);
     728        if ((HANDLE)pproc->sv_stderr[1] != INVALID_HANDLE_VALUE)
     729          CloseHandle((HANDLE)pproc->sv_stderr[1]);
    591730        pproc->sv_stdin[1] = 0;
    592731        pproc->sv_stdout[1] = 0;
    593732        pproc->sv_stderr[1] = 0;
    594733
    595         free( command_line );
    596         if (envblk) free(envblk);
    597         pproc->lerrno=0;
    598         return 0;
    599 }
    600 
    601 
    602 
     734        free( command_line );
     735        free(envblk);
     736        pproc->lerrno=0;
     737        return 0;
     738}
     739
     740
     741
     742#if 0   /* unused */
    603743static DWORD
    604744proc_stdin_thread(sub_process *pproc)
    605745{
    606         DWORD in_done;
    607         for (;;) {
    608                 if (WriteFile( (HANDLE) pproc->sv_stdin[0], pproc->inp, pproc->incnt,
    609                                         &in_done, NULL) == FALSE)
    610                         _endthreadex(0);
    611                 // This if should never be true for anonymous pipes, but gives
    612                 // us a chance to change I/O mechanisms later
    613                 if (in_done < pproc->incnt) {
    614                         pproc->incnt -= in_done;
    615                         pproc->inp += in_done;
    616                 } else {
    617                         _endthreadex(0);
    618                 }
    619         }
    620         return 0; // for compiler warnings only.. not reached
     746        DWORD in_done;
     747        for (;;) {
     748                if (WriteFile( (HANDLE) pproc->sv_stdin[0], pproc->inp, pproc->incnt,
     749                                        &in_done, NULL) == FALSE)
     750                        _endthreadex(0);
     751                // This if should never be true for anonymous pipes, but gives
     752                // us a chance to change I/O mechanisms later
     753                if (in_done < pproc->incnt) {
     754                        pproc->incnt -= in_done;
     755                        pproc->inp += in_done;
     756                } else {
     757                        _endthreadex(0);
     758                }
     759        }
     760        return 0; // for compiler warnings only.. not reached
    621761}
    622762
     
    624764proc_stdout_thread(sub_process *pproc)
    625765{
    626         DWORD bufsize = 1024;
    627         char c;
    628         DWORD nread;
    629         pproc->outp = malloc(bufsize);
    630         if (pproc->outp == NULL)
    631                 _endthreadex(0);
    632         pproc->outcnt = 0;
    633 
    634         for (;;) {
    635                 if (ReadFile( (HANDLE)pproc->sv_stdout[0], &c, 1, &nread, NULL)
    636                                         == FALSE) {
    637 /*                      map_windows32_error_to_string(GetLastError());*/
    638                         _endthreadex(0);
    639                 }
    640                 if (nread == 0)
    641                         _endthreadex(0);
    642                 if (pproc->outcnt + nread > bufsize) {
    643                         bufsize += nread + 512;
    644                         pproc->outp = realloc(pproc->outp, bufsize);
    645                         if (pproc->outp == NULL) {
    646                                 pproc->outcnt = 0;
    647                                 _endthreadex(0);
    648                         }
    649                 }
    650                 pproc->outp[pproc->outcnt++] = c;
    651         }
    652         return 0;
     766        DWORD bufsize = 1024;
     767        char c;
     768        DWORD nread;
     769        pproc->outp = malloc(bufsize);
     770        if (pproc->outp == NULL)
     771                _endthreadex(0);
     772        pproc->outcnt = 0;
     773
     774        for (;;) {
     775                if (ReadFile( (HANDLE)pproc->sv_stdout[0], &c, 1, &nread, NULL)
     776                                        == FALSE) {
     777/*                      map_windows32_error_to_string(GetLastError());*/
     778                        _endthreadex(0);
     779                }
     780                if (nread == 0)
     781                        _endthreadex(0);
     782                if (pproc->outcnt + nread > bufsize) {
     783                        bufsize += nread + 512;
     784                        pproc->outp = realloc(pproc->outp, bufsize);
     785                        if (pproc->outp == NULL) {
     786                                pproc->outcnt = 0;
     787                                _endthreadex(0);
     788                        }
     789                }
     790                pproc->outp[pproc->outcnt++] = c;
     791        }
     792        return 0;
    653793}
    654794
     
    656796proc_stderr_thread(sub_process *pproc)
    657797{
    658         DWORD bufsize = 1024;
    659         char c;
    660         DWORD nread;
    661         pproc->errp = malloc(bufsize);
    662         if (pproc->errp == NULL)
    663                 _endthreadex(0);
    664         pproc->errcnt = 0;
    665 
    666         for (;;) {
    667                 if (ReadFile( (HANDLE)pproc->sv_stderr[0], &c, 1, &nread, NULL) == FALSE) {
    668                         map_windows32_error_to_string(GetLastError());
    669                         _endthreadex(0);
    670                 }
    671                 if (nread == 0)
    672                         _endthreadex(0);
    673                 if (pproc->errcnt + nread > bufsize) {
    674                         bufsize += nread + 512;
    675                         pproc->errp = realloc(pproc->errp, bufsize);
    676                         if (pproc->errp == NULL) {
    677                                 pproc->errcnt = 0;
    678                                 _endthreadex(0);
    679                         }
    680                 }
    681                 pproc->errp[pproc->errcnt++] = c;
    682         }
    683         return 0;
     798        DWORD bufsize = 1024;
     799        char c;
     800        DWORD nread;
     801        pproc->errp = malloc(bufsize);
     802        if (pproc->errp == NULL)
     803                _endthreadex(0);
     804        pproc->errcnt = 0;
     805
     806        for (;;) {
     807                if (ReadFile( (HANDLE)pproc->sv_stderr[0], &c, 1, &nread, NULL) == FALSE) {
     808                        map_windows32_error_to_string(GetLastError());
     809                        _endthreadex(0);
     810                }
     811                if (nread == 0)
     812                        _endthreadex(0);
     813                if (pproc->errcnt + nread > bufsize) {
     814                        bufsize += nread + 512;
     815                        pproc->errp = realloc(pproc->errp, bufsize);
     816                        if (pproc->errp == NULL) {
     817                                pproc->errcnt = 0;
     818                                _endthreadex(0);
     819                        }
     820                }
     821                pproc->errp[pproc->errcnt++] = c;
     822        }
     823        return 0;
    684824}
    685825
     
    694834 * Notes/Dependencies:
    695835 */
    696         long
     836        long
    697837process_pipe_io(
    698         HANDLE proc,
    699         char *stdin_data,
    700         int stdin_data_len)
    701 {
    702         sub_process *pproc = (sub_process *)proc;
    703         bool_t stdin_eof = FALSE, stdout_eof = FALSE, stderr_eof = FALSE;
    704         HANDLE childhand = (HANDLE) pproc->pid;
    705         HANDLE tStdin = NULL, tStdout = NULL, tStderr = NULL;
    706         unsigned int dwStdin, dwStdout, dwStderr;
    707         HANDLE wait_list[4];
    708         DWORD wait_count;
    709         DWORD wait_return;
    710         HANDLE ready_hand;
    711         bool_t child_dead = FALSE;
    712         BOOL GetExitCodeResult;
    713 
    714         /*
    715         *  Create stdin thread, if needed
    716         */
    717         pproc->inp = stdin_data;
    718         pproc->incnt = stdin_data_len;
    719         if (!pproc->inp) {
    720                 stdin_eof = TRUE;
    721                 CloseHandle((HANDLE)pproc->sv_stdin[0]);
    722                 pproc->sv_stdin[0] = 0;
    723         } else {
    724                 tStdin = (HANDLE) _beginthreadex( 0, 1024,
    725                         (unsigned (__stdcall *) (void *))proc_stdin_thread,
    726                                                   pproc, 0, &dwStdin);
    727                 if (tStdin == 0) {
    728                         pproc->last_err = GetLastError();
    729                         pproc->lerrno = E_SCALL;
    730                         goto done;
    731                 }
    732         }
    733 
    734         /*
    735         *   Assume child will produce stdout and stderr
    736         */
    737         tStdout = (HANDLE) _beginthreadex( 0, 1024,
    738                 (unsigned (__stdcall *) (void *))proc_stdout_thread, pproc, 0,
    739                 &dwStdout);
    740         tStderr = (HANDLE) _beginthreadex( 0, 1024,
    741                 (unsigned (__stdcall *) (void *))proc_stderr_thread, pproc, 0,
    742                 &dwStderr);
    743 
    744         if (tStdout == 0 || tStderr == 0) {
    745 
    746                 pproc->last_err = GetLastError();
    747                 pproc->lerrno = E_SCALL;
    748                 goto done;
    749         }
    750 
    751 
    752         /*
    753         *  Wait for all I/O to finish and for the child process to exit
    754         */
    755 
    756         while (!stdin_eof || !stdout_eof || !stderr_eof || !child_dead) {
    757                 wait_count = 0;
    758                 if (!stdin_eof) {
    759                         wait_list[wait_count++] = tStdin;
    760                 }
    761                 if (!stdout_eof) {
    762                         wait_list[wait_count++] = tStdout;
    763                 }
    764                 if (!stderr_eof) {
    765                         wait_list[wait_count++] = tStderr;
    766                 }
    767                 if (!child_dead) {
    768                         wait_list[wait_count++] = childhand;
    769                 }
    770 
    771                 wait_return = WaitForMultipleObjects(wait_count, wait_list,
    772                         FALSE, /* don't wait for all: one ready will do */
    773                         child_dead? 1000 :INFINITE); /* after the child dies, subthreads have
    774                                 one second to collect all remaining output */
    775 
    776                 if (wait_return == WAIT_FAILED) {
    777 /*                      map_windows32_error_to_string(GetLastError());*/
    778                         pproc->last_err = GetLastError();
    779                         pproc->lerrno = E_SCALL;
    780                         goto done;
    781                 }
    782 
    783                 ready_hand = wait_list[wait_return - WAIT_OBJECT_0];
    784 
    785                 if (ready_hand == tStdin) {
    786                         CloseHandle((HANDLE)pproc->sv_stdin[0]);
    787                         pproc->sv_stdin[0] = 0;
    788                         CloseHandle(tStdin);
    789                         tStdin = 0;
    790                         stdin_eof = TRUE;
    791 
    792                 } else if (ready_hand == tStdout) {
    793 
    794                         CloseHandle((HANDLE)pproc->sv_stdout[0]);
    795                         pproc->sv_stdout[0] = 0;
    796                         CloseHandle(tStdout);
    797                         tStdout = 0;
    798                         stdout_eof = TRUE;
    799 
    800                 } else if (ready_hand == tStderr) {
    801 
    802                         CloseHandle((HANDLE)pproc->sv_stderr[0]);
    803                         pproc->sv_stderr[0] = 0;
    804                         CloseHandle(tStderr);
    805                         tStderr = 0;
    806                         stderr_eof = TRUE;
    807 
    808                 } else if (ready_hand == childhand) {
    809 
    810                         DWORD ierr;
    811                         GetExitCodeResult = GetExitCodeProcess(childhand, &ierr);
    812                         if (ierr == CONTROL_C_EXIT) {
    813                                 pproc->signal = SIGINT;
    814                         } else {
    815                                 pproc->exit_code = ierr;
    816                         }
    817                         if (GetExitCodeResult == FALSE) {
    818                                 pproc->last_err = GetLastError();
    819                                 pproc->lerrno = E_SCALL;
    820                                 goto done;
    821                         }
    822                         child_dead = TRUE;
    823 
    824                 } else {
    825 
    826                         /* ?? Got back a handle we didn't query ?? */
    827                         pproc->last_err = 0;
    828                         pproc->lerrno = E_FAIL;
    829                         goto done;
    830                 }
    831         }
     838        HANDLE proc,
     839        char *stdin_data,
     840        int stdin_data_len)
     841{
     842        sub_process *pproc = (sub_process *)proc;
     843        bool_t stdin_eof = FALSE, stdout_eof = FALSE, stderr_eof = FALSE;
     844        HANDLE childhand = (HANDLE) pproc->pid;
     845        HANDLE tStdin = NULL, tStdout = NULL, tStderr = NULL;
     846        unsigned int dwStdin, dwStdout, dwStderr;
     847        HANDLE wait_list[4];
     848        DWORD wait_count;
     849        DWORD wait_return;
     850        HANDLE ready_hand;
     851        bool_t child_dead = FALSE;
     852        BOOL GetExitCodeResult;
     853
     854        /*
     855        *  Create stdin thread, if needed
     856        */
     857        pproc->inp = stdin_data;
     858        pproc->incnt = stdin_data_len;
     859        if (!pproc->inp) {
     860                stdin_eof = TRUE;
     861                CloseHandle((HANDLE)pproc->sv_stdin[0]);
     862                pproc->sv_stdin[0] = 0;
     863        } else {
     864                tStdin = (HANDLE) _beginthreadex( 0, 1024,
     865                        (unsigned (__stdcall *) (void *))proc_stdin_thread,
     866                                                  pproc, 0, &dwStdin);
     867                if (tStdin == 0) {
     868                        pproc->last_err = GetLastError();
     869                        pproc->lerrno = E_SCALL;
     870                        goto done;
     871                }
     872        }
     873
     874        /*
     875        *   Assume child will produce stdout and stderr
     876        */
     877        tStdout = (HANDLE) _beginthreadex( 0, 1024,
     878                (unsigned (__stdcall *) (void *))proc_stdout_thread, pproc, 0,
     879                &dwStdout);
     880        tStderr = (HANDLE) _beginthreadex( 0, 1024,
     881                (unsigned (__stdcall *) (void *))proc_stderr_thread, pproc, 0,
     882                &dwStderr);
     883
     884        if (tStdout == 0 || tStderr == 0) {
     885
     886                pproc->last_err = GetLastError();
     887                pproc->lerrno = E_SCALL;
     888                goto done;
     889        }
     890
     891
     892        /*
     893        *  Wait for all I/O to finish and for the child process to exit
     894        */
     895
     896        while (!stdin_eof || !stdout_eof || !stderr_eof || !child_dead) {
     897                wait_count = 0;
     898                if (!stdin_eof) {
     899                        wait_list[wait_count++] = tStdin;
     900                }
     901                if (!stdout_eof) {
     902                        wait_list[wait_count++] = tStdout;
     903                }
     904                if (!stderr_eof) {
     905                        wait_list[wait_count++] = tStderr;
     906                }
     907                if (!child_dead) {
     908                        wait_list[wait_count++] = childhand;
     909                }
     910
     911                wait_return = WaitForMultipleObjects(wait_count, wait_list,
     912                        FALSE, /* don't wait for all: one ready will do */
     913                        child_dead? 1000 :INFINITE); /* after the child dies, subthreads have
     914                                one second to collect all remaining output */
     915
     916                if (wait_return == WAIT_FAILED) {
     917/*                      map_windows32_error_to_string(GetLastError());*/
     918                        pproc->last_err = GetLastError();
     919                        pproc->lerrno = E_SCALL;
     920                        goto done;
     921                }
     922
     923                ready_hand = wait_list[wait_return - WAIT_OBJECT_0];
     924
     925                if (ready_hand == tStdin) {
     926                        CloseHandle((HANDLE)pproc->sv_stdin[0]);
     927                        pproc->sv_stdin[0] = 0;
     928                        CloseHandle(tStdin);
     929                        tStdin = 0;
     930                        stdin_eof = TRUE;
     931
     932                } else if (ready_hand == tStdout) {
     933
     934                        CloseHandle((HANDLE)pproc->sv_stdout[0]);
     935                        pproc->sv_stdout[0] = 0;
     936                        CloseHandle(tStdout);
     937                        tStdout = 0;
     938                        stdout_eof = TRUE;
     939
     940                } else if (ready_hand == tStderr) {
     941
     942                        CloseHandle((HANDLE)pproc->sv_stderr[0]);
     943                        pproc->sv_stderr[0] = 0;
     944                        CloseHandle(tStderr);
     945                        tStderr = 0;
     946                        stderr_eof = TRUE;
     947
     948                } else if (ready_hand == childhand) {
     949
     950                        DWORD ierr;
     951                        GetExitCodeResult = GetExitCodeProcess(childhand, &ierr);
     952                        if (ierr == CONTROL_C_EXIT) {
     953                                pproc->signal = SIGINT;
     954                        } else {
     955                                pproc->exit_code = ierr;
     956                        }
     957                        if (GetExitCodeResult == FALSE) {
     958                                pproc->last_err = GetLastError();
     959                                pproc->lerrno = E_SCALL;
     960                                goto done;
     961                        }
     962                        child_dead = TRUE;
     963
     964                } else {
     965
     966                        /* ?? Got back a handle we didn't query ?? */
     967                        pproc->last_err = 0;
     968                        pproc->lerrno = E_FAIL;
     969                        goto done;
     970                }
     971        }
    832972
    833973 done:
    834         if (tStdin != 0)
    835                 CloseHandle(tStdin);
    836         if (tStdout != 0)
    837                 CloseHandle(tStdout);
    838         if (tStderr != 0)
    839                 CloseHandle(tStderr);
    840 
    841         if (pproc->lerrno)
    842                 return(-1);
    843         else
    844                 return(0);
    845 
    846 }
     974        if (tStdin != 0)
     975                CloseHandle(tStdin);
     976        if (tStdout != 0)
     977                CloseHandle(tStdout);
     978        if (tStderr != 0)
     979                CloseHandle(tStderr);
     980
     981        if (pproc->lerrno)
     982                return(-1);
     983        else
     984                return(0);
     985
     986}
     987#endif  /* unused */
    847988
    848989/*
     
    855996 * Notes/Dependencies:
    856997 */
    857         long
     998        long
    858999process_file_io(
    859         HANDLE proc)
    860 {
    861         sub_process *pproc;
    862         HANDLE childhand;
    863         DWORD wait_return;
    864         BOOL GetExitCodeResult;
     1000        HANDLE proc)
     1001{
     1002        sub_process *pproc;
     1003        HANDLE childhand;
     1004        DWORD wait_return;
     1005        BOOL GetExitCodeResult;
    8651006        DWORD ierr;
    8661007
    867         if (proc == NULL)
    868                 pproc = process_wait_for_any_private();
    869         else
    870                 pproc = (sub_process *)proc;
    871 
    872         /* some sort of internal error */
    873         if (!pproc)
    874                 return -1;
    875 
    876         childhand = (HANDLE) pproc->pid;
    877 
    878         /*
    879         * This function is poorly named, and could also be used just to wait
    880         * for child death if you're doing your own pipe I/O.  If that is
    881         * the case, close the pipe handles here.
    882         */
    883         if (pproc->sv_stdin[0]) {
    884                 CloseHandle((HANDLE)pproc->sv_stdin[0]);
    885                 pproc->sv_stdin[0] = 0;
    886         }
    887         if (pproc->sv_stdout[0]) {
    888                 CloseHandle((HANDLE)pproc->sv_stdout[0]);
    889                 pproc->sv_stdout[0] = 0;
    890         }
    891         if (pproc->sv_stderr[0]) {
    892                 CloseHandle((HANDLE)pproc->sv_stderr[0]);
    893                 pproc->sv_stderr[0] = 0;
    894         }
    895 
    896         /*
    897         *  Wait for the child process to exit
    898         */
    899 
    900         wait_return = WaitForSingleObject(childhand, INFINITE);
    901 
    902         if (wait_return != WAIT_OBJECT_0) {
    903 /*              map_windows32_error_to_string(GetLastError());*/
    904                 pproc->last_err = GetLastError();
    905                 pproc->lerrno = E_SCALL;
    906                 goto done2;
    907         }
    908 
    909         GetExitCodeResult = GetExitCodeProcess(childhand, &ierr);
    910         if (ierr == CONTROL_C_EXIT) {
    911                 pproc->signal = SIGINT;
    912         } else {
    913                 pproc->exit_code = ierr;
    914         }
    915         if (GetExitCodeResult == FALSE) {
    916                 pproc->last_err = GetLastError();
    917                 pproc->lerrno = E_SCALL;
    918         }
     1008        if (proc == NULL)
     1009                pproc = process_wait_for_any_private(1, 0);
     1010        else
     1011                pproc = (sub_process *)proc;
     1012
     1013        /* some sort of internal error */
     1014        if (!pproc)
     1015                return -1;
     1016
     1017        childhand = (HANDLE) pproc->pid;
     1018
     1019        /*
     1020        * This function is poorly named, and could also be used just to wait
     1021        * for child death if you're doing your own pipe I/O.  If that is
     1022        * the case, close the pipe handles here.
     1023        */
     1024        if (pproc->sv_stdin[0]) {
     1025                CloseHandle((HANDLE)pproc->sv_stdin[0]);
     1026                pproc->sv_stdin[0] = 0;
     1027        }
     1028        if (pproc->sv_stdout[0]) {
     1029                CloseHandle((HANDLE)pproc->sv_stdout[0]);
     1030                pproc->sv_stdout[0] = 0;
     1031        }
     1032        if (pproc->sv_stderr[0]) {
     1033                CloseHandle((HANDLE)pproc->sv_stderr[0]);
     1034                pproc->sv_stderr[0] = 0;
     1035        }
     1036
     1037        /*
     1038        *  Wait for the child process to exit
     1039        */
     1040
     1041        wait_return = WaitForSingleObject(childhand, INFINITE);
     1042
     1043        if (wait_return != WAIT_OBJECT_0) {
     1044/*              map_windows32_error_to_string(GetLastError());*/
     1045                pproc->last_err = GetLastError();
     1046                pproc->lerrno = E_SCALL;
     1047                goto done2;
     1048        }
     1049
     1050        GetExitCodeResult = GetExitCodeProcess(childhand, &ierr);
     1051        if (ierr == CONTROL_C_EXIT) {
     1052                pproc->signal = SIGINT;
     1053        } else {
     1054                pproc->exit_code = ierr;
     1055        }
     1056        if (GetExitCodeResult == FALSE) {
     1057                pproc->last_err = GetLastError();
     1058                pproc->lerrno = E_SCALL;
     1059        }
    9191060
    9201061done2:
    921         if (pproc->lerrno)
    922                 return(-1);
    923         else
    924                 return(0);
     1062        if (pproc->lerrno)
     1063                return(-1);
     1064        else
     1065                return(0);
    9251066
    9261067}
     
    9281069/*
    9291070 * Description:  Clean up any leftover handles, etc.  It is up to the
    930  * caller to manage and free the input, ouput, and stderr buffers.
     1071 * caller to manage and free the input, output, and stderr buffers.
    9311072 */
    932         void
     1073        void
    9331074process_cleanup(
    934         HANDLE proc)
    935 {
    936         sub_process *pproc = (sub_process *)proc;
    937         int i;
    938 
    939         if (pproc->using_pipes) {
    940                 for (i= 0; i <= 1; i++) {
    941                         if ((HANDLE)pproc->sv_stdin[i])
    942                                 CloseHandle((HANDLE)pproc->sv_stdin[i]);
    943                         if ((HANDLE)pproc->sv_stdout[i])
    944                                 CloseHandle((HANDLE)pproc->sv_stdout[i]);
    945                         if ((HANDLE)pproc->sv_stderr[i])
    946                                 CloseHandle((HANDLE)pproc->sv_stderr[i]);
    947                 }
    948         }
    949         if ((HANDLE)pproc->pid)
    950                 CloseHandle((HANDLE)pproc->pid);
    951 
    952         free(pproc);
     1075        HANDLE proc)
     1076{
     1077        sub_process *pproc = (sub_process *)proc;
     1078        int i;
     1079
     1080        if (pproc->using_pipes) {
     1081                for (i= 0; i <= 1; i++) {
     1082                        if ((HANDLE)pproc->sv_stdin[i]
     1083                            && (HANDLE)pproc->sv_stdin[i] != INVALID_HANDLE_VALUE)
     1084                                CloseHandle((HANDLE)pproc->sv_stdin[i]);
     1085                        if ((HANDLE)pproc->sv_stdout[i]
     1086                            && (HANDLE)pproc->sv_stdout[i] != INVALID_HANDLE_VALUE)
     1087                                CloseHandle((HANDLE)pproc->sv_stdout[i]);
     1088                        if ((HANDLE)pproc->sv_stderr[i]
     1089                            && (HANDLE)pproc->sv_stderr[i] != INVALID_HANDLE_VALUE)
     1090                                CloseHandle((HANDLE)pproc->sv_stderr[i]);
     1091                }
     1092        }
     1093        if ((HANDLE)pproc->pid)
     1094                CloseHandle((HANDLE)pproc->pid);
     1095
     1096        free(pproc);
    9531097}
    9541098
     
    9561100/*
    9571101 * Description:
    958  *      Create a command line buffer to pass to CreateProcess
     1102 *      Create a command line buffer to pass to CreateProcess
    9591103 *
    9601104 * Returns:  the buffer or NULL for failure
    961  *      Shell case:  sh_name a:/full/path/to/script argv[1] argv[2] ...
     1105 *      Shell case:  sh_name a:/full/path/to/script argv[1] argv[2] ...
    9621106 *  Otherwise:   argv[0] argv[1] argv[2] ...
    9631107 *
     
    9701114make_command_line( char *shell_name, char *full_exec_path, char **argv)
    9711115{
    972         int             argc = 0;
    973         char**          argvi;
    974         int*            enclose_in_quotes = NULL;
    975         int*            enclose_in_quotes_i;
    976         unsigned int    bytes_required = 0;
    977         char*           command_line;
    978         char*           command_line_i;
    979         int  cygwin_mode = 0; /* HAVE_CYGWIN_SHELL */
    980         int have_sh = 0; /* HAVE_CYGWIN_SHELL */
     1116        int             argc = 0;
     1117        char**          argvi;
     1118        int*            enclose_in_quotes = NULL;
     1119        int*            enclose_in_quotes_i;
     1120        unsigned int    bytes_required = 0;
     1121        char*           command_line;
     1122        char*           command_line_i;
     1123        int  cygwin_mode = 0; /* HAVE_CYGWIN_SHELL */
     1124        int have_sh = 0; /* HAVE_CYGWIN_SHELL */
    9811125
    9821126#ifdef HAVE_CYGWIN_SHELL
    983         have_sh = (shell_name != NULL || strstr(full_exec_path, "sh.exe"));
    984         cygwin_mode = 1;
     1127        have_sh = (shell_name != NULL || strstr(full_exec_path, "sh.exe"));
     1128        cygwin_mode = 1;
    9851129#endif
    9861130
    987         if (shell_name && full_exec_path) {
    988                 bytes_required
    989                   = strlen(shell_name) + 1 + strlen(full_exec_path);
    990                 /*
    991                  * Skip argv[0] if any, when shell_name is given.
    992                  */
    993                 if (*argv) argv++;
    994                 /*
    995                  * Add one for the intervening space.
    996                  */
    997                 if (*argv) bytes_required++;
    998         }
    999 
    1000         argvi = argv;
    1001         while (*(argvi++)) argc++;
    1002 
    1003         if (argc) {
    1004                 enclose_in_quotes = (int*) calloc(1, argc * sizeof(int));
    1005 
    1006                 if (!enclose_in_quotes) {
    1007                         return NULL;
    1008                 }
    1009         }
    1010 
    1011         /* We have to make one pass through each argv[i] to see if we need
    1012          * to enclose it in ", so we might as well figure out how much
    1013          * memory we'll need on the same pass.
    1014          */
    1015 
    1016         argvi = argv;
    1017         enclose_in_quotes_i = enclose_in_quotes;
    1018         while(*argvi) {
    1019                 char* p = *argvi;
    1020                 unsigned int backslash_count = 0;
    1021 
    1022                 /*
    1023                  * We have to enclose empty arguments in ".
    1024                  */
    1025                 if (!(*p)) *enclose_in_quotes_i = 1;
    1026 
    1027                 while(*p) {
    1028                         switch (*p) {
    1029                         case '\"':
    1030                                 /*
    1031                                  * We have to insert a backslash for each "
    1032                                  * and each \ that precedes the ".
    1033                                  */
    1034                                 bytes_required += (backslash_count + 1);
    1035                                 backslash_count = 0;
    1036                                 break;
     1131        if (shell_name && full_exec_path) {
     1132                bytes_required
     1133                  = strlen(shell_name) + 1 + strlen(full_exec_path);
     1134                /*
     1135                 * Skip argv[0] if any, when shell_name is given.
     1136                 * The special case of "-c" in full_exec_path means
     1137                 * argv[0] is not the shell name, but the command string
     1138                 * to pass to the shell.
     1139                 */
     1140                if (*argv && strcmp(full_exec_path, "-c")) argv++;
     1141                /*
     1142                 * Add one for the intervening space.
     1143                 */
     1144                if (*argv) bytes_required++;
     1145        }
     1146
     1147        argvi = argv;
     1148        while (*(argvi++)) argc++;
     1149
     1150        if (argc) {
     1151                enclose_in_quotes = (int*) calloc(1, argc * sizeof(int));
     1152
     1153                if (!enclose_in_quotes) {
     1154                        return NULL;
     1155                }
     1156        }
     1157
     1158        /* We have to make one pass through each argv[i] to see if we need
     1159         * to enclose it in ", so we might as well figure out how much
     1160         * memory we'll need on the same pass.
     1161         */
     1162
     1163        argvi = argv;
     1164        enclose_in_quotes_i = enclose_in_quotes;
     1165        while(*argvi) {
     1166                char* p = *argvi;
     1167                unsigned int backslash_count = 0;
     1168
     1169                /*
     1170                 * We have to enclose empty arguments in ".
     1171                 */
     1172                if (!(*p)) *enclose_in_quotes_i = 1;
     1173
     1174                while(*p) {
     1175                        switch (*p) {
     1176                        case '\"':
     1177                                /*
     1178                                 * We have to insert a backslash for each "
     1179                                 * and each \ that precedes the ".
     1180                                 */
     1181                                bytes_required += (backslash_count + 1);
     1182                                backslash_count = 0;
     1183                                break;
    10371184
    10381185#if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL)
    1039                         case '\\':
    1040                                 backslash_count++;
    1041                                 break;
     1186                        case '\\':
     1187                                backslash_count++;
     1188                                break;
    10421189#endif
    1043         /*
    1044         * At one time we set *enclose_in_quotes_i for '*' or '?' to suppress
    1045         * wildcard expansion in programs linked with MSVC's SETARGV.OBJ so
    1046         * that argv in always equals argv out. This was removed.  Say you have
    1047         * such a program named glob.exe.  You enter
    1048         * glob '*'
    1049         * at the sh command prompt.  Obviously the intent is to make glob do the
    1050         * wildcarding instead of sh.  If we set *enclose_in_quotes_i for '*' or '?',
    1051         * then the command line that glob would see would be
    1052         * glob "*"
    1053         * and the _setargv in SETARGV.OBJ would _not_ expand the *.
    1054         */
    1055                         case ' ':
    1056                         case '\t':
    1057                                 *enclose_in_quotes_i = 1;
    1058                                 /* fall through */
    1059 
    1060                         default:
    1061                                 backslash_count = 0;
    1062                                 break;
    1063                         }
    1064 
    1065                         /*
    1066                         * Add one for each character in argv[i].
    1067                         */
    1068                         bytes_required++;
    1069 
    1070                         p++;
    1071                 }
    1072 
    1073                 if (*enclose_in_quotes_i) {
    1074                         /*
    1075                         * Add one for each enclosing ",
    1076                         * and one for each \ that precedes the
    1077                         * closing ".
    1078                         */
    1079                         bytes_required += (backslash_count + 2);
    1080                 }
    1081 
    1082                 /*
    1083                 * Add one for the intervening space.
    1084                 */
    1085                 if (*(++argvi)) bytes_required++;
    1086                 enclose_in_quotes_i++;
    1087         }
    1088 
    1089         /*
    1090         * Add one for the terminating NULL.
    1091         */
    1092         bytes_required++;
    1093 
    1094         command_line = (char*) malloc(bytes_required);
    1095 
    1096         if (!command_line) {
    1097                 if (enclose_in_quotes) free(enclose_in_quotes);
    1098                 return NULL;
    1099         }
    1100 
    1101         command_line_i = command_line;
    1102 
    1103         if (shell_name && full_exec_path) {
    1104                 while(*shell_name) {
    1105                         *(command_line_i++) = *(shell_name++);
    1106                 }
    1107 
    1108                 *(command_line_i++) = ' ';
    1109 
    1110                 while(*full_exec_path) {
    1111                         *(command_line_i++) = *(full_exec_path++);
    1112                 }
    1113 
    1114                 if (*argv) {
    1115                         *(command_line_i++) = ' ';
    1116                 }
    1117         }
    1118 
    1119         argvi = argv;
    1120         enclose_in_quotes_i = enclose_in_quotes;
    1121 
    1122         while(*argvi) {
    1123                 char* p = *argvi;
    1124                 unsigned int backslash_count = 0;
    1125 
    1126                 if (*enclose_in_quotes_i) {
    1127                         *(command_line_i++) = '\"';
    1128                 }
    1129 
    1130                 while(*p) {
    1131                         if (*p == '\"') {
    1132                                 if (cygwin_mode && have_sh) { /* HAVE_CYGWIN_SHELL */
    1133                                         /* instead of a \", cygwin likes "" */
    1134                                         *(command_line_i++) = '\"';
    1135                                 } else {
    1136 
    1137                                 /*
    1138                                 * We have to insert a backslash for the "
    1139                                 * and each \ that precedes the ".
    1140                                 */
    1141                                 backslash_count++;
    1142 
    1143                                 while(backslash_count) {
    1144                                         *(command_line_i++) = '\\';
    1145                                         backslash_count--;
    1146                                 };
    1147                                 }
     1190        /*
     1191        * At one time we set *enclose_in_quotes_i for '*' or '?' to suppress
     1192        * wildcard expansion in programs linked with MSVC's SETARGV.OBJ so
     1193        * that argv in always equals argv out. This was removed.  Say you have
     1194        * such a program named glob.exe.  You enter
     1195        * glob '*'
     1196        * at the sh command prompt.  Obviously the intent is to make glob do the
     1197        * wildcarding instead of sh.  If we set *enclose_in_quotes_i for '*' or '?',
     1198        * then the command line that glob would see would be
     1199        * glob "*"
     1200        * and the _setargv in SETARGV.OBJ would _not_ expand the *.
     1201        */
     1202                        case ' ':
     1203                        case '\t':
     1204                                *enclose_in_quotes_i = 1;
     1205                                /* fall through */
     1206
     1207                        default:
     1208                                backslash_count = 0;
     1209                                break;
     1210                        }
     1211
     1212                        /*
     1213                        * Add one for each character in argv[i].
     1214                        */
     1215                        bytes_required++;
     1216
     1217                        p++;
     1218                }
     1219
     1220                if (*enclose_in_quotes_i) {
     1221                        /*
     1222                        * Add one for each enclosing ",
     1223                        * and one for each \ that precedes the
     1224                        * closing ".
     1225                        */
     1226                        bytes_required += (backslash_count + 2);
     1227                }
     1228
     1229                /*
     1230                * Add one for the intervening space.
     1231                */
     1232                if (*(++argvi)) bytes_required++;
     1233                enclose_in_quotes_i++;
     1234        }
     1235
     1236        /*
     1237        * Add one for the terminating NULL.
     1238        */
     1239        bytes_required++;
     1240
     1241        command_line = (char*) malloc(bytes_required);
     1242
     1243        if (!command_line) {
     1244                free(enclose_in_quotes);
     1245                return NULL;
     1246        }
     1247
     1248        command_line_i = command_line;
     1249
     1250        if (shell_name && full_exec_path) {
     1251                while(*shell_name) {
     1252                        *(command_line_i++) = *(shell_name++);
     1253                }
     1254
     1255                *(command_line_i++) = ' ';
     1256
     1257                while(*full_exec_path) {
     1258                        *(command_line_i++) = *(full_exec_path++);
     1259                }
     1260
     1261                if (*argv) {
     1262                        *(command_line_i++) = ' ';
     1263                }
     1264        }
     1265
     1266        argvi = argv;
     1267        enclose_in_quotes_i = enclose_in_quotes;
     1268
     1269        while(*argvi) {
     1270                char* p = *argvi;
     1271                unsigned int backslash_count = 0;
     1272
     1273                if (*enclose_in_quotes_i) {
     1274                        *(command_line_i++) = '\"';
     1275                }
     1276
     1277                while(*p) {
     1278                        if (*p == '\"') {
     1279                                if (cygwin_mode && have_sh) { /* HAVE_CYGWIN_SHELL */
     1280                                        /* instead of a \", cygwin likes "" */
     1281                                        *(command_line_i++) = '\"';
     1282                                } else {
     1283
     1284                                /*
     1285                                * We have to insert a backslash for the "
     1286                                * and each \ that precedes the ".
     1287                                */
     1288                                backslash_count++;
     1289
     1290                                while(backslash_count) {
     1291                                        *(command_line_i++) = '\\';
     1292                                        backslash_count--;
     1293                                };
     1294                                }
    11481295#if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL)
    1149                         } else if (*p == '\\') {
    1150                                 backslash_count++;
    1151                         } else {
    1152                                 backslash_count = 0;
     1296                        } else if (*p == '\\') {
     1297                                backslash_count++;
     1298                        } else {
     1299                                backslash_count = 0;
    11531300#endif
    1154                         }
    1155 
    1156                         /*
    1157                         * Copy the character.
    1158                         */
    1159                         *(command_line_i++) = *(p++);
    1160                 }
    1161 
    1162                 if (*enclose_in_quotes_i) {
     1301                        }
     1302
     1303                        /*
     1304                        * Copy the character.
     1305                        */
     1306                        *(command_line_i++) = *(p++);
     1307                }
     1308
     1309                if (*enclose_in_quotes_i) {
    11631310#if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL)
    1164                         /*
    1165                         * Add one \ for each \ that precedes the
    1166                         * closing ".
    1167                         */
    1168                         while(backslash_count--) {
    1169                                 *(command_line_i++) = '\\';
    1170                         };
     1311                        /*
     1312                        * Add one \ for each \ that precedes the
     1313                        * closing ".
     1314                        */
     1315                        while(backslash_count--) {
     1316                                *(command_line_i++) = '\\';
     1317                        };
    11711318#endif
    1172                         *(command_line_i++) = '\"';
    1173                 }
    1174 
    1175                 /*
    1176                 * Append an intervening space.
    1177                 */
    1178                 if (*(++argvi)) {
    1179                         *(command_line_i++) = ' ';
    1180                 }
    1181 
    1182                 enclose_in_quotes_i++;
    1183         }
    1184 
    1185         /*
    1186         * Append the terminating NULL.
    1187         */
    1188         *command_line_i = '\0';
    1189 
    1190         if (enclose_in_quotes) free(enclose_in_quotes);
    1191         return command_line;
     1319                        *(command_line_i++) = '\"';
     1320                }
     1321
     1322                /*
     1323                * Append an intervening space.
     1324                */
     1325                if (*(++argvi)) {
     1326                        *(command_line_i++) = ' ';
     1327                }
     1328
     1329                enclose_in_quotes_i++;
     1330        }
     1331
     1332        /*
     1333        * Append the terminating NULL.
     1334        */
     1335        *command_line_i = '\0';
     1336
     1337        free(enclose_in_quotes);
     1338        return command_line;
    11921339}
    11931340
     
    11961343 *              using the default stdin, stdout, and stderr handles.
    11971344 *              Also, register process so that process_wait_for_any_private()
    1198  *              can be used via process_file_io(NULL) or
    1199  *              process_wait_for_any().
     1345 *              can be used via process_file_io(NULL) or
     1346 *              process_wait_for_any().
    12001347 *
    12011348 * Returns:
     
    12051352HANDLE
    12061353process_easy(
    1207         char **argv,
    1208         char **envp)
    1209 {
    1210   HANDLE hIn;
    1211   HANDLE hOut;
    1212   HANDLE hErr;
    1213   HANDLE hProcess;
     1354        char **argv,
     1355        char **envp,
     1356        int outfd,
     1357        int errfd)
     1358{
     1359  HANDLE hIn = INVALID_HANDLE_VALUE;
     1360  HANDLE hOut = INVALID_HANDLE_VALUE;
     1361  HANDLE hErr = INVALID_HANDLE_VALUE;
     1362  HANDLE hProcess, tmpIn, tmpOut, tmpErr;
     1363  DWORD e;
    12141364
    12151365  if (proc_index >= MAXIMUM_WAIT_OBJECTS) {
    1216         DB (DB_JOBS, ("process_easy: All process slots used up\n"));
    1217         return INVALID_HANDLE_VALUE;
     1366        DB (DB_JOBS, ("process_easy: All process slots used up\n"));
     1367        return INVALID_HANDLE_VALUE;
    12181368  }
     1369  /* Standard handles returned by GetStdHandle can be NULL or
     1370     INVALID_HANDLE_VALUE if the parent process closed them.  If that
     1371     happens, we open the null device and pass its handle to
     1372     CreateProcess as the corresponding handle to inherit.  */
     1373  tmpIn = GetStdHandle(STD_INPUT_HANDLE);
    12191374  if (DuplicateHandle(GetCurrentProcess(),
    1220                       GetStdHandle(STD_INPUT_HANDLE),
     1375                      tmpIn,
    12211376                      GetCurrentProcess(),
    12221377                      &hIn,
     
    12241379                      TRUE,
    12251380                      DUPLICATE_SAME_ACCESS) == FALSE) {
    1226     fprintf(stderr,
    1227             "process_easy: DuplicateHandle(In) failed (e=%ld)\n",
    1228             GetLastError());
    1229     return INVALID_HANDLE_VALUE;
     1381    if ((e = GetLastError()) == ERROR_INVALID_HANDLE) {
     1382      tmpIn = CreateFile("NUL", GENERIC_READ,
     1383                         FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
     1384                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     1385      if (tmpIn != INVALID_HANDLE_VALUE
     1386          && DuplicateHandle(GetCurrentProcess(),
     1387                             tmpIn,
     1388                             GetCurrentProcess(),
     1389                             &hIn,
     1390                             0,
     1391                             TRUE,
     1392                             DUPLICATE_SAME_ACCESS) == FALSE)
     1393        CloseHandle(tmpIn);
     1394    }
     1395    if (hIn == INVALID_HANDLE_VALUE) {
     1396      fprintf(stderr, "process_easy: DuplicateHandle(In) failed (e=%ld)\n", e);
     1397      return INVALID_HANDLE_VALUE;
     1398    }
    12301399  }
     1400  if (outfd >= 0)
     1401    tmpOut = (HANDLE)_get_osfhandle (outfd);
     1402  else
     1403    tmpOut = GetStdHandle (STD_OUTPUT_HANDLE);
    12311404  if (DuplicateHandle(GetCurrentProcess(),
    1232                       GetStdHandle(STD_OUTPUT_HANDLE),
     1405                      tmpOut,
    12331406                      GetCurrentProcess(),
    12341407                      &hOut,
     
    12361409                      TRUE,
    12371410                      DUPLICATE_SAME_ACCESS) == FALSE) {
    1238     fprintf(stderr,
    1239            "process_easy: DuplicateHandle(Out) failed (e=%ld)\n",
    1240            GetLastError());
    1241     return INVALID_HANDLE_VALUE;
     1411    if ((e = GetLastError()) == ERROR_INVALID_HANDLE) {
     1412      tmpOut = CreateFile("NUL", GENERIC_WRITE,
     1413                          FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
     1414                          OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     1415      if (tmpOut != INVALID_HANDLE_VALUE
     1416          && DuplicateHandle(GetCurrentProcess(),
     1417                             tmpOut,
     1418                             GetCurrentProcess(),
     1419                             &hOut,
     1420                             0,
     1421                             TRUE,
     1422                             DUPLICATE_SAME_ACCESS) == FALSE)
     1423        CloseHandle(tmpOut);
     1424    }
     1425    if (hOut == INVALID_HANDLE_VALUE) {
     1426      fprintf(stderr, "process_easy: DuplicateHandle(Out) failed (e=%ld)\n", e);
     1427      return INVALID_HANDLE_VALUE;
     1428    }
    12421429  }
     1430  if (errfd >= 0)
     1431    tmpErr = (HANDLE)_get_osfhandle (errfd);
     1432  else
     1433    tmpErr = GetStdHandle(STD_ERROR_HANDLE);
    12431434  if (DuplicateHandle(GetCurrentProcess(),
    1244                       GetStdHandle(STD_ERROR_HANDLE),
     1435                      tmpErr,
    12451436                      GetCurrentProcess(),
    12461437                      &hErr,
     
    12481439                      TRUE,
    12491440                      DUPLICATE_SAME_ACCESS) == FALSE) {
    1250     fprintf(stderr,
    1251             "process_easy: DuplicateHandle(Err) failed (e=%ld)\n",
    1252             GetLastError());
    1253     return INVALID_HANDLE_VALUE;
     1441    if ((e = GetLastError()) == ERROR_INVALID_HANDLE) {
     1442      tmpErr = CreateFile("NUL", GENERIC_WRITE,
     1443                          FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
     1444                          OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     1445      if (tmpErr != INVALID_HANDLE_VALUE
     1446          && DuplicateHandle(GetCurrentProcess(),
     1447                             tmpErr,
     1448                             GetCurrentProcess(),
     1449                             &hErr,
     1450                             0,
     1451                             TRUE,
     1452                             DUPLICATE_SAME_ACCESS) == FALSE)
     1453        CloseHandle(tmpErr);
     1454    }
     1455    if (hErr == INVALID_HANDLE_VALUE) {
     1456      fprintf(stderr, "process_easy: DuplicateHandle(Err) failed (e=%ld)\n", e);
     1457      return INVALID_HANDLE_VALUE;
     1458    }
    12541459  }
    12551460
     
    12641469
    12651470    /* close up unused handles */
    1266     CloseHandle(hIn);
    1267     CloseHandle(hOut);
    1268     CloseHandle(hErr);
     1471    if (hIn != INVALID_HANDLE_VALUE)
     1472      CloseHandle(hIn);
     1473    if (hOut != INVALID_HANDLE_VALUE)
     1474      CloseHandle(hOut);
     1475    if (hErr != INVALID_HANDLE_VALUE)
     1476      CloseHandle(hErr);
    12691477  }
    12701478
  • vendor/gnumake/current/w32/subproc/w32err.c

    r2596 r3138  
    11/* Error handling for Windows
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    1615this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1716
     17#include <stdlib.h>
    1818#include <windows.h>
     19#include "makeint.h"
    1920#include "w32err.h"
    2021
     
    2728 *      comp.os.ms-windows.programmer.win32
    2829 */
    29 char *
     30const char *
    3031map_windows32_error_to_string (DWORD ercode) {
    31 /* __declspec (thread) necessary if you will use multiple threads on MSVC */
    32 #ifdef _MSC_VER
    33 __declspec (thread) static char szMessageBuffer[128];
    34 #else
    35 static char szMessageBuffer[128];
    36 #endif
    37         /* Fill message buffer with a default message in
    38          * case FormatMessage fails
    39          */
     32/*
     33 * We used to have an MSVC-specific '__declspec (thread)' qualifier
     34 * here, with the following comment:
     35 *
     36 * __declspec (thread) necessary if you will use multiple threads on MSVC
     37 *
     38 * However, Make was never multithreaded on Windows (except when
     39 * Ctrl-C is hit, in which case the main thread is stopped
     40 * immediately, so it doesn't matter in this context).  The functions
     41 * on sub_proc.c that started and stopped additional threads were
     42 * never used, and are now #ifdef'ed away.  Until we need more than
     43 * one thread, we have no problems with the following buffer being
     44 * static.  (If and when we do need it to be in thread-local storage,
     45 * the corresponding GCC qualifier is '__thread'.)
     46 */
     47    static char szMessageBuffer[128];
     48        /* Fill message buffer with a default message in
     49         * case FormatMessage fails
     50         */
    4051    wsprintf (szMessageBuffer, "Error %ld\n", ercode);
    4152
    42         /*
    43          *  Special code for winsock error handling.
    44          */
    45         if (ercode > WSABASEERR) {
    46                 HMODULE hModule = GetModuleHandle("wsock32");
    47                 if (hModule != NULL) {
    48                         FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
    49                                 hModule,
    50                                 ercode,
    51                                 LANG_NEUTRAL,
    52                                 szMessageBuffer,
    53                                 sizeof(szMessageBuffer),
    54                                 NULL);
    55                         FreeLibrary(hModule);
    56                 }
    57         } else {
    58                 /*
    59                  *  Default system message handling
    60                  */
    61         FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
    62                   NULL,
    63                   ercode,
    64                   LANG_NEUTRAL,
    65                   szMessageBuffer,
    66                   sizeof(szMessageBuffer),
    67                   NULL);
    68         }
     53        /*
     54         *  Special code for winsock error handling.
     55         */
     56        if (ercode > WSABASEERR) {
     57#if 0
     58                HMODULE hModule = GetModuleHandle("wsock32");
     59                if (hModule != NULL) {
     60                        FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
     61                                hModule,
     62                                ercode,
     63                                LANG_NEUTRAL,
     64                                szMessageBuffer,
     65                                sizeof(szMessageBuffer),
     66                                NULL);
     67                        FreeLibrary(hModule);
     68                }
     69#else
     70                O (fatal, NILF, szMessageBuffer);
     71#endif
     72        } else {
     73                /*
     74                 *  Default system message handling
     75                 */
     76                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
     77                        NULL,
     78                        ercode,
     79                        LANG_NEUTRAL,
     80                        szMessageBuffer,
     81                        sizeof(szMessageBuffer),
     82                        NULL);
     83        }
    6984    return szMessageBuffer;
    7085}
Note: See TracChangeset for help on using the changeset viewer.