Changeset 3138 for vendor/gnumake/current
- Timestamp:
- Mar 12, 2018, 8:32:29 PM (7 years ago)
- Location:
- vendor/gnumake/current
- Files:
-
- 46 added
- 11 deleted
- 158 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/AUTHORS
r2596 r3138 38 38 DJ Delorie <dj@delorie.com> 39 39 Rob Tulloh <rob_tulloh@tivoli.com> 40 Eli Zaretskii <eliz@ is.elta.co.il>40 Eli Zaretskii <eliz@gnu.org> 41 41 Jonathan Grant <jg@jguk.org> 42 42 Andreas Beuning <andreas.buening@nexgo.de> 43 43 Earnie Boyd <earnie@uses.sf.net> 44 Troy Runkel <Troy.Runkel@mathworks.com> 44 45 45 46 ----------------------------------- … … 48 49 Janet Carson <janet_carson@tivoli.com> 49 50 Howard Chu <hyc@highlandsun.com> 51 Ludovic CourtÚs <ludo@gnu.org> 50 52 Paul Eggert <eggert@twinsun.com> 53 Ramon Garcia Fernandez <ramon.garcia.f@gmail.com> 51 54 Klaus Heinz <kamar@ease.rhein-main.de> 52 55 Michael Joosten … … 56 59 Markus Mauhart <qwe123@chello.at> 57 60 Greg McGary <greg@mcgary.org> 61 Thien-Thi Nguyen <ttn@gnuvola.org> 58 62 Thomas Riedl <thomas.riedl@siemens.com> 59 63 Han-Wen Nienhuys <hanwen@cs.uu.nl> … … 61 65 Carl Staelin (Princeton University) 62 66 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> 64 70 65 71 With suggestions/comments/bug reports from a cast of ... well ... … … 67 73 68 74 ------------------------------------------------------------------------------- 69 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 70 2008, 2009, 2010 Free Software Foundation, Inc. 75 Copyright (C) 1997-2016 Free Software Foundation, Inc. 71 76 This file is part of GNU Make. 72 77 -
vendor/gnumake/current/ChangeLog.1
r2596 r3138 1704 1704 1705 1705 * load.c: Use the symbol KERNEL_FILE_NAME instead of KERNEL_FILE. 1706 * compatMakefile: Changed the comment for `LOAD_AVG' accordin ly.1706 * compatMakefile: Changed the comment for `LOAD_AVG' accordingly. 1707 1707 1708 1708 Thu Sep 7 16:46:26 1989 Roland McGrath (mcgrath at paris.Berkeley.EDU) … … 3219 3219 `shell_function_completed'. Block children before forking and 3220 3220 unblock after `shell_function_pid' is set properly and 3221 `shell_funct on_completed' is reset to 0.3221 `shell_function_completed' is reset to 0. 3222 3222 3223 3223 * commands.c (child_handler): When the child of the `shell' function … … 4466 4466 4467 4467 * rule.c (pattern_search): If an existent (non-intermediate) 4468 dependen dency was found via a terminal rule, set its4468 dependency was found via a terminal rule, set its 4469 4469 `tried_implicit' flag, so it will never have implicit rule search done. 4470 4470 … … 4827 4827 4828 4828 * dir.c: Re-indented the `struct dir' definition to be right. 4829 (dir_load): Cleaned up slight y.4829 (dir_load): Cleaned up slightly. 4830 4830 (file_exists_p): Removed comment saying we could use `access', since 4831 4831 that is a bad idea (except for setuid programs). Cleaned up slightly. … … 4983 4983 4984 4984 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. 4985 Copyright (C) 1988-2009 Free Software Foundation, Inc. 4988 4986 This file is part of GNU Make. 4989 4987 -
vendor/gnumake/current/ChangeLog.2
r1989 r3138 3081 3081 stores now the names of the variables only and reads their contents 3082 3082 when they are accessed to reflect that these variables are really 3083 global (i e.they CAN change WHILE make runs !) This handling is3083 global (i.e., they CAN change WHILE make runs !) This handling is 3084 3084 made in lookup_variable() 3085 3085 … … 6632 6632 6633 6633 6634 See ChangeLog.1, available in the CVSrepository at:6635 6636 http:// savannah.gnu.org/cvs/?group=make6634 See ChangeLog.1, available in the Git repository at: 6635 6636 http://git.savannah.gnu.org/cgit/make.git/tree/ 6637 6637 6638 6638 for earlier changes. 6639 6639 6640 6640 6641 Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 6642 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. 6641 Copyright (C) 1991-2007 Free Software Foundation, Inc. 6643 6642 This file is part of GNU Make. 6644 6643 -
vendor/gnumake/current/ChangeLog.3
r3137 r3138 1 2013-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 13 2013-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 19 2013-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 42 2013-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 47 2013-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 59 2013-10-01 Paul Smith <psmith@gnu.org> 60 61 * configure.ac: Update version to 3.99.93. 62 * NEWS: Ditto. 63 64 2013-09-30 Paul Smith <psmith@gnu.org> 65 66 * guile.c: Portability fixes for Guile 1.8. 67 68 2013-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 101 2013-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 107 2013-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 150 2013-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 194 2013-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 201 2013-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 206 2013-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 211 2013-09-16 Paul Smith <psmith@gnu.org> 212 213 * configure.ac: Update version to 3.99.91. 214 * NEWS: Ditto. 215 216 2013-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 236 2013-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 251 2013-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 268 2013-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 309 2013-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 314 2013-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 328 2013-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 354 2013-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 381 2013-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 387 2013-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 394 2013-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 410 2013-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 446 2013-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 456 2013-05-27 Paul Smith <psmith@gnu.org> 457 458 * variable.c (define_automatic_variables): Create a new variable 459 MAKE_HOST. 460 461 2013-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 471 2013-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 482 2013-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 494 2013-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 509 2013-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 516 2013-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 524 2013-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 551 2013-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 557 2013-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 584 2013-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 590 2013-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 601 2013-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 621 2013-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 633 2013-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 638 2013-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 651 2013-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 657 2013-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 702 2013-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 711 2013-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 716 2013-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 724 2013-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 738 2013-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 751 2013-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 775 2013-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 792 2013-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 798 2013-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 831 2013-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 841 2013-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 848 2013-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 853 2013-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 858 2013-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 922 2013-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 930 2013-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 937 2013-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 949 2013-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 957 2013-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 962 2013-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 989 2013-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 1001 2013-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 1024 2013-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 1029 2013-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 1045 2012-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 1050 2012-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 1068 2012-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 1080 2012-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 1085 2012-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 1109 2012-09-09 Eli Zaretskii <eliz@gnu.org> 1110 1111 * read.c (unescape_char): Fix a thinko in the last change. 1112 1113 2012-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 1123 2012-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 1131 2012-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 1136 2012-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 1152 2012-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 1174 2012-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 1179 2012-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 1190 2012-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 1217 2012-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 1254 2012-01-25 Eli Zaretskii <eliz@gnu.org> 1255 1256 * function.c (define_new_function): Fix format strings in calls to 1257 `fatal'. 1258 1259 2012-01-17 Paul Smith <psmith@gnu.org> 1260 1261 * guile.c (func_guile): Handle NULL returns from Guile. 1262 1263 2012-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 1269 2012-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 1281 2012-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 1315 2011-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 1326 2011-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 1332 2011-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 1354 2011-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 1382 2011-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 1392 2011-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 1397 2011-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 1402 2011-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 1410 2011-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 1415 2011-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 1423 2011-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 1432 2011-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 1441 2011-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 1448 2011-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 1462 2011-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 1468 2011-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 1473 2011-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 1490 2011-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 1503 2011-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 1508 2010-12-27 Paul Smith <psmith@gnu.org> 1509 1510 * make.1: Update the header/footer info in the man page. 1511 1512 2010-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 1517 2010-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 1539 2010-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 1544 2010-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 1551 2010-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 1578 2010-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 1584 2010-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 1598 2010-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 1603 2010-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 1613 2010-08-07 Juan Manuel Guerrero <juan.guerrero@gmx.de> 1614 1615 * configh.dos.template (HAVE_STRNCASECMP): Define. 1616 1 1617 2010-07-28 Paul Smith <psmith@gnu.org> 2 1618 … … 3996 5612 3997 5613 3998 See ChangeLog.2, available in the CVSrepository at:3999 4000 http:// savannah.gnu.org/cvs/?group=make5614 See ChangeLog.2, available in the Git repository at: 5615 5616 http://git.savannah.gnu.org/cgit/make.git/tree/ 4001 5617 4002 5618 for earlier changes. 4003 5619 4004 5620 4005 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free 4006 Software Foundation, Inc. 5621 Copyright (C) 2000-2013 Free Software Foundation, Inc. 4007 5622 This file is part of GNU Make. 4008 5623 -
vendor/gnumake/current/Makefile.DOS.template
r2596 r3138 2 2 # Makefile.in generated automatically by automake 1.2 from Makefile.am 3 3 # 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. 6 5 # This file is part of GNU Make. 7 6 # … … 90 89 BUILT_SOURCES = README build.sh-in 91 90 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.c91 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 gmk-default.scm gmk-default.h 93 92 94 93 SUBDIRS = glob doc … … 124 123 125 124 NROFF = 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. ingetloadavg.c125 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.ac getloadavg.c 127 126 128 127 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) … … 508 507 dist-hook: 509 508 (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`; \ 511 510 tar chf - $$w32) \ 512 511 | (cd $(distdir); tar xfBp -) -
vendor/gnumake/current/Makefile.am
r2596 r3138 1 1 # This is a -*-Makefile-*-, or close enough 2 2 # 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. 5 4 # This file is part of GNU Make. 6 5 # … … 18 17 # this program. If not, see <http://www.gnu.org/licenses/>. 19 18 20 AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news21 ACLOCAL_AMFLAGS =-I config19 AUTOMAKE_OPTIONS = dist-bzip2 silent-rules std-options 20 ACLOCAL_AMFLAGS = -I config 22 21 23 22 MAKE_HOST = @MAKE_HOST@ … … 28 27 W32INC = -I $(top_srcdir)/w32/include 29 28 W32LIB = -Lw32 -lw32 29 ossrc = 30 else 31 ossrc = posixos.c 30 32 endif 31 33 … … 33 35 34 36 bin_PROGRAMS = make 37 include_HEADERS = gnumake.h 35 38 36 39 if USE_CUSTOMS … … 40 43 endif 41 44 42 43 45 make_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) 47 50 48 51 EXTRA_make_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c 49 52 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@ 53 noinst_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 56 make_LDADD = @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@ \ 57 $(GUILE_LIBS) 54 58 # Only process if target is MS-Windows 55 59 if WINDOWSENV … … 62 66 63 67 AM_CPPFLAGS = $(GLOBINC) 68 AM_CFLAGS = $(GUILE_CFLAGS) 64 69 # Only process if target is MS-Windows 65 70 if WINDOWSENV … … 70 75 # Extra stuff to include in the distribution. 71 76 72 EXTRA_DIST = README build.sh.in $(man_MANS) \77 EXTRA_DIST = ChangeLog README build.sh.in $(man_MANS) \ 73 78 README.customs README.OS2 \ 74 79 SCOPTIONS SMakefile \ … … 77 82 README.W32 NMakefile config.h.W32 build_w32.bat subproc.bat \ 78 83 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 81 88 82 89 # This is built during configure, but behind configure's back … … 84 91 DISTCLEANFILES = build.sh 85 92 86 # Forward targets87 88 html:89 cd doc && $(MAKE) $(AM_MAKEFLAGS) $@90 91 .PHONY: html92 93 93 # --------------- Internationalization Section 94 94 … … 101 101 102 102 # 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' 105 105 # switch) will not work unless make is installed setgid kmem. 106 106 # … … 118 118 else \ 119 119 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."; \ 121 121 echo "You may need special privileges to complete the installation"; \ 122 122 echo "of $$app."; \ … … 124 124 else true; fi 125 125 126 # --------------- Generate the Guile default module content 127 128 guile.$(OBJEXT): gmk-default.h 129 gmk-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 126 135 # --------------- Local DIST Section 127 136 … … 130 139 dist-hook: 131 140 (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`; \ 133 142 tar chf - $$sub) \ 134 143 | (cd $(distdir); tar xfBp -) … … 168 177 MAKETESTFLAGS = 169 178 170 check-regression: 171 @if test -f "$(srcdir)/tests/run_make_tests"; then \ 179 check-regression: tests/config-flags.pm 180 @if test -f '$(srcdir)/tests/run_make_tests'; then \ 181 ulimit -n 128; \ 172 182 if $(PERL) -v >/dev/null 2>&1; then \ 173 case `cd $(srcdir); pwd` in `pwd`) : ;; \183 case `cd '$(srcdir)'; pwd` in `pwd`) : ;; \ 174 184 *) test -d tests || mkdir tests; \ 175 185 rm -f srctests; \ 176 if ln -s "$(srcdir)/tests"srctests; then \186 if ln -s '$(srcdir)/tests' srctests; then \ 177 187 for f in run_make_tests run_make_tests.pl test_driver.pl scripts; do \ 178 188 rm -f tests/$$f; ln -s ../srctests/$$f tests; \ 179 189 done; fi ;; \ 180 190 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); \ 183 193 else \ 184 194 echo "Can't find a working Perl ($(PERL)); the test suite requires Perl."; \ 185 195 fi; \ 186 196 else \ 187 197 echo "Can't find the GNU Make test suite ($(srcdir)/tests)."; \ 188 198 fi 189 199 190 200 … … 192 202 193 203 # 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 CVS204 # created before we build a distribution (see maintMakefile in the Git 195 205 # distribution). 196 206 -
vendor/gnumake/current/Makefile.ami
r2596 r3138 1 1 # -*-Makefile-*- for GNU make on Amiga 2 2 # 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. 8 7 # This file is part of GNU Make. 9 8 # … … 33 32 34 33 # Define these for your system as follows: 35 # -DNO_ARCHIVES To disable `ar' archive support.34 # -DNO_ARCHIVES To disable 'ar' archive support. 36 35 # -DNO_FLOAT To avoid using floating-point numbers. 37 36 # -DENUM_BITFIELDS If the compiler isn't GCC but groks enum foo:2. … … 40 39 # so beware. 41 40 # NeXT 1.0a uses an old version of GCC, which required -D__inline=inline. 42 # See also `config.h'.41 # See also 'config.h'. 43 42 defines = 44 43 45 44 # 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'. 47 46 REMOTE = stub 48 47 … … 78 77 exec_prefix = 79 78 80 # Directory to install `make' in.79 # Directory to install 'make' in. 81 80 bindir = sc:c 82 # Directory to find libraries in for `-lXXX'.81 # Directory to find libraries in for '-lXXX'. 83 82 libdir = lib: 84 83 # Directory to search by default for included makefiles. … … 90 89 # Number to put on the man page filename. 91 90 manext = 1 92 # Prefix to put on installed `make' binary file name.91 # Prefix to put on installed 'make' binary file name. 93 92 binprefix = 94 # Prefix to put on installed `make' man page file name.93 # Prefix to put on installed 'make' man page file name. 95 94 manprefix = $(binprefix) 96 95 97 96 # 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' 100 99 # switch) will not work unless make is installed setgid kmem. 101 100 install_setgid = false … … 103 102 group = sys 104 103 105 # Program to install `make'.104 # Program to install 'make'. 106 105 INSTALL_PROGRAM = copy 107 106 # Program to install the man page. … … 119 118 CTAGS = ctags -w 120 119 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 122 objs = 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 125 127 srcs = $(srcdir)commands.c $(srcdir)job.c $(srcdir)dir.c \ 126 128 $(srcdir)file.c $(srcdir)getloadavg.c $(srcdir)misc.c \ … … 129 131 $(srcdir)variable.c $(srcdir)expand.c $(srcdir)function.c \ 130 132 $(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 \ 136 138 $(srcdir)variable.h $(ALLOCA_SRC) $(srcdir)config.h.in 137 139 … … 143 145 info: make.info 144 146 dvi: 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'. 146 148 .PHONY: all check info dvi 147 149 … … 179 181 cd glob; $(MAKE) libglob.a 180 182 FORCE: 181 182 tagsrcs = $(srcs) $(srcdir)remote-*.c183 183 184 184 .PHONY: install installdirs … … 197 197 else \ 198 198 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."; \ 200 200 echo "You may need special privileges to install $@."; \ 201 201 fi; \ … … 214 214 done 215 215 # Run install-info only if it exists. 216 # Use `if' instead of just prepending `-' to the216 # Use 'if' instead of just prepending '-' to the 217 217 # line so we notice real errors from install-info. 218 # We use `$(SHELL) -c' because some shells do not218 # We use '$(SHELL) -c' because some shells do not 219 219 # fail gracefully when there is an unknown command. 220 220 if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ … … 267 267 268 268 # The automatically generated dependencies below may omit config.h 269 # because it is included with ``#include <config.h>'' rather than270 # ``#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. 271 271 $(objs): config.h 272 272 … … 274 274 275 275 # Automatically generated dependencies. 276 commands.o: commands.c make .h dep.h filedef.h variable.h job.h \276 commands.o: commands.c makeint.h dep.h filedef.h variable.h job.h \ 277 277 commands.h 278 job.o: job.c make .h job.h filedef.h commands.h variable.h279 dir.o: dir.c make .h280 file.o: file.c make .h dep.h filedef.h job.h commands.h variable.h281 misc.o: misc.c make .h dep.h282 main.o: main.c make .h dep.h filedef.h variable.h job.h commands.h \278 job.o: job.c makeint.h job.h filedef.h commands.h variable.h 279 dir.o: dir.c makeint.h 280 file.o: file.c makeint.h dep.h filedef.h job.h commands.h variable.h 281 misc.o: misc.c makeint.h dep.h 282 main.o: main.c makeint.h dep.h filedef.h variable.h job.h commands.h \ 283 283 getopt.h 284 read.o: read.c make.h dep.h filedef.h job.h commands.h variable.h \ 284 guile.o: guile.c makeint.h dep.h debug.h variable.h gmk-default.h 285 read.o: read.c makeint.h dep.h filedef.h job.h commands.h variable.h \ 285 286 glob/glob.h 286 remake.o: remake.c make .h filedef.h job.h commands.h dep.h287 rule.o: rule.c make .h dep.h filedef.h job.h commands.h variable.h \287 remake.o: remake.c makeint.h filedef.h job.h commands.h dep.h 288 rule.o: rule.c makeint.h dep.h filedef.h job.h commands.h variable.h \ 288 289 rule.h 289 implicit.o: implicit.c make .h rule.h dep.h filedef.h290 default.o: default.c make .h rule.h dep.h filedef.h job.h commands.h \290 implicit.o: implicit.c makeint.h rule.h dep.h filedef.h 291 default.o: default.c makeint.h rule.h dep.h filedef.h job.h commands.h \ 291 292 variable.h 292 variable.o: variable.c make .h dep.h filedef.h job.h commands.h \293 variable.o: variable.c makeint.h dep.h filedef.h job.h commands.h \ 293 294 variable.h 294 expand.o: expand.c make .h filedef.h job.h commands.h variable.h295 function.o: function.c make .h filedef.h variable.h dep.h job.h \295 expand.o: expand.c makeint.h filedef.h job.h commands.h variable.h 296 function.o: function.c makeint.h filedef.h variable.h dep.h job.h \ 296 297 commands.h amiga.h 297 vpath.o: vpath.c make .h filedef.h variable.h298 strcache.o: strcache.c make .h hash.h298 vpath.o: vpath.c makeint.h filedef.h variable.h 299 strcache.o: strcache.c makeint.h hash.h 299 300 version.o: version.c 300 ar.o: ar.c make .h filedef.h dep.h301 arscan.o: arscan.c make .h301 ar.o: ar.c makeint.h filedef.h dep.h 302 arscan.o: arscan.c makeint.h 302 303 signame.o: signame.c signame.h 303 remote-stub.o: remote-stub.c make .h filedef.h job.h commands.h304 remote-stub.o: remote-stub.c makeint.h filedef.h job.h commands.h 304 305 getopt.o: getopt.c 305 306 getopt1.o : getopt1.c getopt.h 306 307 getloadavg.o: getloadavg.c 307 amiga.o: amiga.c make .h variable.h amiga.h308 amiga.o: amiga.c makeint.h variable.h amiga.h -
vendor/gnumake/current/NEWS
r2596 r3138 1 1 GNU make NEWS -*-indented-text-*- 2 2 History of user-visible changes. 3 28 July 20103 10 June 2016 4 4 5 5 See the end of this file for copyrights and conditions. … … 11 11 12 12 13 Version 3.82 13 Version 4.2.1 (10 Jun 2016) 14 15 A complete list of bugs fixed in this version is available here: 16 h 17 ttp://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=107&set=custom 18 19 This release is a bug-fix release. 20 21 22 23 Version 4.2 (22 May 2016) 24 25 A complete list of bugs fixed in this version is available here: 26 27 http://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 63 Version 4.1 (05 Oct 2014) 64 65 A complete list of bugs fixed in this version is available here: 66 67 http://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 112 Version 4.0 (09 Oct 2013) 113 114 A complete list of bugs fixed in this version is available here: 115 116 http://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 217 Version 3.82 (28 Jul 2010) 14 218 15 219 A complete list of bugs fixed in this version is available here: … … 19 223 * Compiling GNU make now requires a conforming ISO C 1989 compiler and 20 224 standard runtime library. 21 22 * WARNING: Future backward-incompatibility!23 Wildcards are not documented as returning sorted values, but up to and24 including this release the results have been sorted and some makefiles are25 apparently depending on that. In the next release of GNU make, for26 performance reasons, we may remove that sorting. If your makefiles27 require sorted results from wildcard expansions, use the $(sort ...)28 function to request it explicitly.29 225 30 226 * WARNING: Backward-incompatibility! … … 44 240 45 241 * 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! 46 248 As a result of parser enhancements, three backward-compatibility issues 47 249 exist: first, a prerequisite containing an "=" cannot be escaped with a … … 116 318 multi-line variable assignment. 117 319 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 373 Version 3.81 (01 Apr 2006) 121 374 122 375 * GNU make is ported to OS/2. … … 131 384 might have caused the target to rebuild. Starting with the _next_ 132 385 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=16051386 the target to be considered out of date. 387 See http://savannah.gnu.org/bugs/?16051 135 388 136 389 * WARNING: Backward-incompatibility! … … 241 494 242 495 * On VMS there is now support for case-sensitive filesystems such as ODS5. 243 See the readme.vmsfile for information.496 See the README.VMS file for information. 244 497 245 498 * Parallel builds (-jN) no longer require a working Bourne shell on … … 260 513 261 514 262 Version 3.80 515 Version 3.80 (03 Oct 2002) 263 516 264 517 * A new feature exists: order-only prerequisites. These prerequisites … … 337 590 * Updated to autoconf 2.54 and automake 1.7. Users should not be impacted. 338 591 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 339 628 A complete list of bugs fixed in this version is available here: 340 629 … … 343 632 344 633 345 Version 3.79.1 634 Version 3.79.1 (23 Jun 2000) 346 635 347 636 * .SECONDARY with no prerequisites now prevents any target from being … … 353 642 354 643 355 Version 3.79 644 Version 3.79 (04 Apr 2000) 356 645 357 646 * GNU make optionally supports internationalization and locales via the … … 394 683 395 684 * 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 738 Version 3.78 (22 Sep 1999) 400 739 401 740 * Two new functions, $(error ...) and $(warning ...) are available. The … … 454 793 455 794 456 Version 3.77 795 Version 3.77 (28 Jul 1998) 457 796 458 797 * Implement BSD make's "?=" variable assignment operator. The variable … … 500 839 and to the DOS port from Eli Zaretski (see README.DOS). 501 840 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 881 Version 3.76.1 (19 Sep 1997) 504 882 505 883 * Small (but serious) bug fix. Quick rollout to get into the GNU source CD. 506 884 507 885 508 Version 3.76 886 Version 3.76 (16 Sep 1997) 509 887 510 888 * GNU make now uses automake to control Makefile.in generation. This … … 549 927 Delorie <dj@delorie.com>. 550 928 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 977 Version 3.75 (27 Aug 1996) 555 978 556 979 * The directory messages printed by `-w' and implicitly in sub-makes, … … 573 996 <rob_tulloh@tivoli.com>. 574 997 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 1007 Version 3.73 (05 Apr 1995) 577 1008 578 1009 * Converted to use Autoconf version 2, so `configure' has some new options. … … 583 1014 584 1015 585 Version 3.72 1016 Version 3.72 (04 Nov 1994) 586 1017 587 1018 * DJ Delorie has ported Make to MS-DOS using the GO32 extender. … … 618 1049 619 1050 620 Version 3.71 1051 Version 3.71 (21 May 1994) 621 1052 622 1053 * The automatic variables `$(@D)', `$(%D)', `$(*D)', `$(<D)', `$(?D)', and … … 641 1072 642 1073 643 Version 3.70 1074 Version 3.70 (03 Jan 1994) 644 1075 645 1076 * It is no longer a fatal error to have a NUL character in a makefile. … … 653 1084 654 1085 655 Version 3.69 1086 Version 3.69 (07 Nov 1993) 656 1087 657 1088 * Implicit rule search for archive member references is now done in the … … 672 1103 cause a paradoxical situation in cases like: 673 1104 674 1105 export variable = $(shell echo value) 675 1106 676 1107 When Make attempted to put this variable in the environment for a … … 684 1115 685 1116 686 Version 3.68 1117 Version 3.68 (28 Jul 1993) 687 1118 688 1119 * You can list several archive member names inside parenthesis: … … 696 1127 697 1128 * A suffix rule `.X.a' now produces two pattern rules: 698 699 1129 (%.o): %.X # Previous versions produced only this. 1130 %.a: %.X # Now produces this as well, just like other suffixes. 700 1131 701 1132 * The new flag `--warn-undefined-variables' says to issue a warning message … … 711 1142 712 1143 713 Version 3.66 1144 Version 3.66 (21 May 1993) 714 1145 715 1146 * `make --version' (or `make -v') now exits immediately after printing … … 717 1148 718 1149 719 Version 3.65 1150 Version 3.65 (09 May 1993) 720 1151 721 1152 * Make now supports long-named members in `ar' archive files. 722 1153 723 1154 724 Version 3.64 1155 Version 3.64 (21 Apr 1993) 725 1156 726 1157 * Make now supports the `+=' syntax for a variable definition which appends … … 737 1168 738 1169 739 Version 3.63 1170 Version 3.63 (22 Jan 1993) 740 1171 741 1172 * Make now uses a standard GNU `configure' script. See the new file … … 771 1202 Make runs. Instead, only variables specified on the command line or in 772 1203 the environment are exported by default. To export others, use: 773 1204 export VARIABLE 774 1205 or you can define variables with: 775 1206 export VARIABLE = VALUE 776 1207 or: 777 1208 export VARIABLE := VALUE 778 1209 You can use just: 779 1210 export 780 1211 or: 781 1212 .EXPORT_ALL_VARIABLES: 782 1213 to get the old behavior. See the node `Variables/Recursion' in the manual 783 1214 for a full description. … … 799 1230 * A single `include' directive can now specify more than one makefile to 800 1231 include, like this: 801 1232 include file1 file2 802 1233 You can also use shell file name patterns in an `include' directive: 803 1234 include *.mk 804 1235 805 1236 * The default directories to search for included makefiles, and for … … 946 1377 947 1378 * Messages indicating failed recipe lines now contain the target name: 948 1379 make: *** [target] Error 1 949 1380 950 1381 * The `-p' output format has been changed somewhat to look more like … … 1150 1581 1151 1582 ------------------------------------------------------------------------------- 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. 1583 Copyright (C) 1988-2016 Free Software Foundation, Inc. 1584 This file is part of GNU Make. 1155 1585 1156 1586 GNU Make is free software; you can redistribute it and/or modify it under the -
vendor/gnumake/current/NMakefile.template
r2596 r3138 4 4 # run 'build_w32.bat' instead. 5 5 # 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. 8 7 # This file is part of GNU Make. 9 8 # … … 34 33 35 34 LDFLAGS_debug = w32\subproc\WinDebug\subproc.lib /NOLOGO /SUBSYSTEM:console\ 36 / INCREMENTAL:no /PDB:WinDebug/make.pdb /OUT:WinDebug/make.exe /DEBUG35 /STACK:0x400000 /INCREMENTAL:no /PDB:WinDebug/make.pdb /OUT:WinDebug/make.exe /DEBUG 37 36 LDFLAGS_release = w32\subproc\WinRel\subproc.lib /NOLOGO /SUBSYSTEM:console\ 38 / INCREMENTAL:no /OUT:WinRel/make.exe37 /STACK:0x400000 /INCREMENTAL:no /OUT:WinRel/make.exe 39 38 40 39 all: config.h subproc Release Debug … … 74 73 LIBS = kernel32.lib user32.lib advapi32.lib 75 74 75 guile = $(OUTDIR)/guile.obj 76 76 77 OBJS = \ 77 78 $(OUTDIR)/ar.obj \ … … 89 90 $(OUTDIR)/implicit.obj \ 90 91 $(OUTDIR)/job.obj \ 92 $(OUTDIR)/load.obj \ 91 93 $(OUTDIR)/main.obj \ 92 94 $(OUTDIR)/misc.obj \ 95 $(OUTDIR)/output.obj \ 93 96 $(OUTDIR)/read.obj \ 94 97 $(OUTDIR)/remake.obj \ … … 103 106 $(OUTDIR)/fnmatch.obj \ 104 107 $(OUTDIR)/dirent.obj \ 105 $(OUTDIR)/pathstuff.obj 108 $(OUTDIR)/pathstuff.obj \ 109 $(OUTDIR)/posixfcn.obj \ 110 $(OUTDIR)/w32os.obj \ 111 $(guile) 106 112 107 113 $(OUTDIR)/make.exe: $(OUTDIR) $(OBJS) … … 119 125 $(OUTDIR)/dirent.obj : w32/compat/dirent.c 120 126 $(CC) $(CFLAGS) /c $? 127 $(OUTDIR)/posixfcn.obj : w32/compat/posixfcn.c 128 $(CC) $(CFLAGS) /c $? 121 129 $(OUTDIR)/pathstuff.obj : w32/pathstuff.c 122 130 $(CC) $(CFLAGS) /c $? 131 $(OUTDIR)/w32os.obj : w32/w32os.c 132 $(CC) $(CFLAGS) /c $? -
vendor/gnumake/current/README.Amiga
r2596 r3138 12 12 - Allows to use Device-Names in targets: 13 13 14 14 c:make : make.o 15 15 16 16 is ok. To distinguish between device-names and target : or ::, MAKE … … 20 20 - Replaces @@ by a newline in any command line: 21 21 22 23 24 25 26 22 if exists make @@\ 23 delete make.bak quiet @@\ 24 rename make make.bak @@\ 25 endif @@\ 26 $(CC) Link Make.o To make 27 27 28 works. Note that the @@ must stand alone (i e."make@@\" is illegal).29 Also be careful l that there is a space after the "\" (ie, at the28 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 30 30 beginning of the next line). 31 31 - Can be made resident to save space and time … … 37 37 dummy.h : src/*.c 38 38 39 tries to make dummy.h from "src/*.c" (i e.no wildcard-expansion takes39 tries to make dummy.h from "src/*.c" (i.e., no wildcard-expansion takes 40 40 place). You have to use "$(wildcard src/*.c)" instead. 41 41 … … 43 43 ---------------------- 44 44 45 To recompile, you need SAS/C 6.51. make itself is not nec cessary, there45 To recompile, you need SAS/C 6.51. make itself is not necessary, there 46 46 is an smakefile. 47 47 48 48 1. Copy config.ami to config.h 49 2. If you use make to compi e, copy Makefile.ami to Makefile and49 2. If you use make to compile, copy Makefile.ami to Makefile and 50 50 glob/Makefile.ami to glob/Makefile. Copy make into the current 51 51 directory. … … 55 55 INSTALLATION 56 56 57 Copy make somewhere in your search path (e g.sc:c or sc:bin).57 Copy make somewhere in your search path (e.g., sc:c or sc:bin). 58 58 If you plan to use recursive makes, install make resident: 59 59 … … 63 63 64 64 ------------------------------------------------------------------------------- 65 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 66 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 65 Copyright (C) 1995-2016 Free Software Foundation, Inc. 67 66 This file is part of GNU Make. 68 67 -
vendor/gnumake/current/README.DOS.template
r2596 r3138 9 9 10 10 2. Supports both stock DOS COMMAND.COM and Unix-style shells 11 (details in ``Notes'' below).11 (details in 'Notes' below). 12 12 13 13 3. Supports DOS drive letters in dependencies and pattern rules. 14 14 15 15 4. Better support for DOS-style backslashes in pathnames (but see 16 ``Notes'' below).16 'Notes' below). 17 17 18 18 5. The $(shell) built-in can run arbitrary complex commands, … … 56 56 environment), or the DJGPP port of GNU Tar. 57 57 58 2. Invoke the `configure.bat' batch file.58 2. Invoke the 'configure.bat' batch file. 59 59 60 60 If you are building Make in-place, i.e. in the same directory … … 63 63 directory as an argument to the batch file, like this: 64 64 65 65 c:\djgpp\gnu\make-%VERSION%\configure.bat c:/djgpp/gnu/make-%VERSION% 66 66 67 67 Note the forward slashes in the source path argument: you MUST … … 69 69 70 70 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 it71 use the 'dosbuild.bat' batch file to build Make. Either do as it 72 72 suggests or install another Make program (a pre-compiled binary 73 73 should be available from the usual DJGPP sites) and rerun … … 85 85 need to tell Make where the sources are, like this: 86 86 87 87 make srcdir=c:/djgpp/gnu/make-%VERSION% 88 88 89 89 (configure.bat will tell you this when it finishes). You MUST … … 92 92 93 93 6. After Make finishes, if you have a Unix-style shell installed, 94 you can use the `install' target to install the package. You94 you can use the 'install' target to install the package. You 95 95 will also need GNU Fileutils and GNU Sed for this (they should 96 96 be available from the DJGPP sites). … … 100 100 DESTDIR variable when invoking "make install", like this: 101 101 102 102 make install DESTDIR=c:/other/dir 103 103 104 104 This causes the make executable to be placed in c:/other/dir/bin, … … 108 108 and the docs manually. Copy make.exe to a directory on your 109 109 PATH, make.i* info files to your Info directory, and update the 110 file `dir' in your Info directory by adding the following item110 file 'dir' in your Info directory by adding the following item 111 111 to the main menu: 112 112 113 114 115 If you have the `install-info' program (from the GNU Texinfo113 * Make: (make.info). The GNU make utility. 114 115 If you have the 'install-info' program (from the GNU Texinfo 116 116 package), it will do that for you if you invoke it like this: 117 117 118 118 install-info --info-dir=c:/djgpp/info c:/djgpp/info/make.info 119 119 120 120 (If your Info directory is other than C:\DJGPP\INFO, change this 121 121 command accordingly.) 122 122 123 7. The `clean' targets also require Unix-style shell, and GNU Sed124 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). 125 125 126 126 8. To run the test suite, type "make check". This requires a Unix … … 145 145 This port supports both DOS shells (the stock COMMAND.COM and its 146 146 4DOS/NDOS replacements), and Unix-style shells (tested with the 147 venerable Stewartson's `ms_sh' 2.3 and the DJGPP port of `bash' by147 venerable Stewartson's 'ms_sh' 2.3 and the DJGPP port of 'bash' by 148 148 Daisuke Aoyama <jack@st.rim.or.jp>). 149 149 … … 167 167 batch file or a command internal to the shell is invoked. (Even 168 168 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 called169 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 171 171 in that case.) 172 172 173 The key to all this is the extended functionality of `spawn' and174 `system' functions from the DJGPP library; this port just calls175 `system' where it would invoke the shell on Unix. The most173 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 176 176 important aspect of these functions is that they use a special 177 177 mechanism to pass long (up to 16KB) command lines to DJGPP 178 programs. In addition, `system' emulates some internal179 commands, like `cd' (so that you can now use forward slashes178 programs. In addition, 'system' emulates some internal 179 commands, like 'cd' (so that you can now use forward slashes 180 180 with it, and can also change the drive if the directory is on 181 181 another drive). Another aspect worth mentioning is that you can … … 187 187 188 188 The $(shell) built-in is implemented in this port by calling 189 `popen'. Since `popen' calls `system', the above considerations189 'popen'. Since 'popen' calls 'system', the above considerations 190 190 are valid for $(shell) as well. In particular, you can put 191 191 arbitrary complex commands, including pipes and redirection, … … 198 198 Many Unix Makefiles include a line which sets the SHELL, for 199 199 those versions of Make which don't have this as the default. 200 Since many DOS systems don't have `sh' installed (in fact, most201 of them don't even have a `/bin' directory), this port takes200 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 202 202 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 the203 directive if the basename of the shell name (like 'sh' in the 204 204 above example) can indeed be found in the directory that is 205 mentioned in the SHELL= line ( `/bin' in the above example), or205 mentioned in the SHELL= line ('/bin' in the above example), or 206 206 in the current working directory, or anywhere on the $PATH (in 207 207 that order). If the basename doesn't include a filename … … 238 238 Makefiles to MSDOS and leave the line which sets the shell 239 239 intact, so that people who do have Unixy shell could use it for 240 targets which aren't converted to DOS (like `install' and241 `uninstall', for example).240 targets which aren't converted to DOS (like 'install' and 241 'uninstall', for example). 242 242 243 243 … … 259 259 letter-case issue. Make is internally case-sensitive, but all 260 260 file operations are case-insensitive on Windows 9x, so 261 e.g. files `FAQ', `faq' and `Faq' all refer to the same file, as261 e.g. files 'FAQ', 'faq' and 'Faq' all refer to the same file, as 262 262 far as Windows is concerned. The underlying DJGPP C library 263 263 functions honor the letter-case of the filenames they get from … … 266 266 many Makefiles otherwise. (The details of which filenames are 267 267 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' 269 269 functions, but as a thumb rule, any filename that is stored in 270 270 upper case in the directory, is a valid DOS 8+3 filename and … … 283 283 There are a lot of places throughout the program sources which 284 284 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 be285 particular, the directories are assumed to be separated by '/', 286 and any pathname which doesn't begin with a '/' is assumed to be 287 287 relative to the current directory. This port attempts to 288 288 support DOS-style pathnames which might include the drive letter … … 297 297 are advised to stay away from backslashes whenever possible. In 298 298 particular, filename globbing won't work on pathnames with 299 backslashes, because the GNU `glob' library doesn't support them299 backslashes, because the GNU 'glob' library doesn't support them 300 300 (backslash is special in filename wildcards, and I didn't want 301 301 to break that). … … 316 316 group). For other bugs, please follow the procedure explained in 317 317 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 text318 reader, look up that chapter in the 'make.i1' file with any text 319 319 browser/editor. 320 320 321 321 322 322 Enjoy, 323 323 Eli Zaretskii <eliz@is.elta.co.il> 324 324 325 325 326 326 327 327 ------------------------------------------------------------------------------- 328 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 329 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 328 Copyright (C) 1996-2016 Free Software Foundation, Inc. 330 329 This file is part of GNU Make. 331 330 -
vendor/gnumake/current/README.OS2.template
r2596 r3138 141 141 _getcwd2() are NOT used). The testsuite interpretes the whole output of 142 142 make, especially statements like make[1]: Entering directory 143 `C:/somewhere/make-3.79.1/tests' where the testsuite does not expect the143 'C:/somewhere/make-3.79.1/tests' where the testsuite does not expect the 144 144 drive letter. This would be interpreted as an error even if there is 145 145 none. … … 162 162 163 163 ------------------------------------------------------------------------------- 164 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 165 Foundation, Inc. 164 Copyright (C) 2003-2016 Free Software Foundation, Inc. 166 165 This file is part of GNU Make. 167 166 -
vendor/gnumake/current/README.W32.template
r2596 r3138 1 This version of GNU make has been tested on Microsoft Windows 2000/XP/2003. 1 This version of GNU make has been tested on: 2 Microsoft Windows 2000/XP/2003/Vista/7/8/10 2 3 It has also been used on Windows 95/98/NT, and on OS/2. 3 4 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. 5 It builds with the MinGW port of GCC (tested with GCC 3.4.2, 4.8.1, 6 and 4.9.3). 7 8 It also builds with MSVC 2.x, 4.x, 5.x, 6.x, 2003, and 14 (2015) as 9 well as with .NET 7.x and .NET 2003. 10 11 As of version 4.0, a build with Guile is supported (tested with Guile 12 2.0.3). To build with Guile, you will need, in addition to Guile 13 itself, its dependency libraries and the pkg-config program. The 14 latter is used to figure out which compilation and link switches and 15 libraries need to be mentioned on the compiler command lines to 16 correctly link with Guile. A Windows port of pkg-config can be found 17 on ezwinports site: 18 19 http://sourceforge.net/projects/ezwinports/ 20 21 The libraries on which Guile depends can vary depending on your 22 version and build of Guile. At the very least, the Boehm's GC library 23 will be needed, and typically also GNU MP, libffi, libunistring, and 24 libtool's libltdl. Whoever built the port of Guile you have should 25 also provide you with these dependencies or a URL where to download 26 them. A precompiled 32-bit Windows build of Guile is available from 27 the ezwinports site mentioned above. 28 29 The Windows port of GNU make is maintained jointly by various people. 30 It was originally made by Rob Tulloh. 31 It is currently maintained by Eli Zaretskii. 11 32 12 33 … … 14 35 --------------------------------------------------------- 15 36 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 22 38 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.) 24 43 25 44 … … 38 57 correct PATH and other environment variables for it, then execute ... 39 58 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 43 70 44 71 … … 52 79 menue entry from the cl-installation), then execute EITHER ... 53 80 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. 57 86 58 87 ... OR ... 59 88 60 89 nmake /f NMakefile 61 90 62 91 (this produces WinDebug/make.exe and WinRel/make.exe). 63 92 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 64 98 65 99 ------------------- … … 69 103 GNU make on Windows 32-bit platforms: 70 104 71 72 73 74 75 76 77 78 79 80 81 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. 82 116 83 117 GNU make and sh.exe: 84 118 85 86 87 88 89 90 91 92 93 94 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 95 129 your own with a package like NutCracker (DataFocus) or Portage 96 130 (Consensys). Also MinGW includes sh (http://mingw.org/). … … 98 132 GNU make and brain-dead shells (BATCH_MODE_ONLY_SHELL): 99 133 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 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. 118 152 119 153 Support for parallel builds 120 154 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. 133 159 134 160 GNU make and Cygnus GNU Windows32 tools: 135 161 136 137 138 139 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. 140 166 141 167 GNU make and the MKS shell: 142 168 143 144 145 146 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. 147 173 148 174 GNU make handling of drive letters in pathnames (PATH, vpath, VPATH): 149 175 150 151 single character pathnames on Windows systems.When colon is152 153 154 letter.Unfortunately, something as simple as the string 'x:/'155 156 157 158 drive letter pathname.If it is necessary to use single159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 specification of paths.Make is able to figure out the intended176 177 178 179 180 181 182 problems which exist between platforms.If colon is used on183 184 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. 185 211 186 212 GNU make test suite: 187 213 188 189 190 191 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. 192 218 193 219 Pathnames and white space: 194 220 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 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. 212 238 213 239 Pathnames and Case insensitivity: 214 240 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 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. 244 270 245 271 SAMBA/NTFS/VFAT: 246 272 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 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. 262 288 263 289 FAT: 264 290 265 266 267 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. 268 294 269 295 Bug reports: 270 296 271 272 297 Please submit bugs via the normal bug reporting mechanism which 298 is described in the GNU make manual and the base README. 273 299 274 300 275 301 ------------------------------------------------------------------------------- 276 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 277 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 302 Copyright (C) 1996-2016 Free Software Foundation, Inc. 278 303 This file is part of GNU Make. 279 304 -
vendor/gnumake/current/README.customs
r2596 r3138 36 36 documentation. You should also install the man pages (contrary to 37 37 comments 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 ``pmake39 install' 'there directly).38 me; I had to cd to the 'pmake-2.1.33/doc' directory and run 'pmake 39 install' there directly). 40 40 41 41 … … 44 44 45 45 Once 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''46 configuring GNU make, merely use the '--with-customs=DIR' option. 47 Provide the directory containing the 'lib' and 'include/customs' 48 48 subdirectories as DIR. For example, if you installed the customs 49 49 library 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.50 then you'd pass '--with-customs=/usr/local' as an option to configure. 51 51 52 52 Run make (or use build.sh) normally to build GNU make as described in … … 98 98 99 99 ------------------------------------------------------------------------------- 100 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 101 2009, 2010 Free Software Foundation, Inc. 100 Copyright (C) 1998-2016 Free Software Foundation, Inc. 102 101 This file is part of GNU Make. 103 102 -
vendor/gnumake/current/README.template
r2596 r3138 9 9 For general building and installation instructions, see the file INSTALL. 10 10 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 run13 `configure' as described in INSTALL. Then, instead of typing `make' to14 build the program, type `sh build.sh'. This should compile the program11 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 15 15 in the current directory. Then you will have a Make program that you can 16 use for `./make install', or whatever else.16 use for './make install', or whatever else. 17 17 18 18 Some systems' Make programs are broken and cannot process the Makefile for 19 19 GNU Make. If you get errors from your system's Make when building GNU 20 Make, try using `build.sh' instead.20 Make, try using 'build.sh' instead. 21 21 22 22 23 23 GNU Make is free software. See the file COPYING for copying conditions. 24 24 GNU Make is copyright by the Free Software Foundation. Copyright notices 25 condense sequential years into a range; e.g. "1987-1994" means all years 26 from 1987 to 1994 inclusive. 25 27 26 28 Downloading … … 65 67 66 68 You 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' for69 section of the GNU make manual entitled 'Problems and Bugs' for 68 70 information on submitting useful and complete bug reports. 69 71 … … 80 82 news:gnu.utils.bug 81 83 82 http://savannah.gnu.org/support/?group=make83 84 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 85 Git Access 95 86 ---------- 96 87 97 The GNU make source repository is available via anonymous CVSfrom the98 GNU S ubversions CVSserver; look here for details:88 The GNU make source repository is available via Git from the 89 GNU Savannah Git server; look here for details: 99 90 100 http://savannah.gnu.org/ cvs/?group=make91 http://savannah.gnu.org/git/?group=make 101 92 102 Please note: you won't be able to build GNU make from CVSwithout93 Please note: you won't be able to build GNU make from Git without 103 94 installing appropriate maintainer's tools, such as GNU m4, automake, 104 autoconf, Perl, GNU make, and GCC. See the README. cvsfile for hints on95 autoconf, Perl, GNU make, and GCC. See the README.git file for hints on 105 96 how 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 CVS97 guarantees about the contents or quality of the latest code in the Git 107 98 repository: it is not unheard of for code that is known to be broken to 108 99 be checked in. Use at your own risk. … … 113 104 114 105 It 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 work116 correctly. It is said that using `cc' without `-O' does work.106 that if you compile make with 'cc -O' on AIX 3.2, it will not work 107 correctly. It is said that using 'cc' without '-O' does work. 117 108 118 109 The standard /bin/sh on SunOS 4.1.3_U1 and 4.1.4 is broken and cannot be … … 124 115 One area that is often a problem in configuration and porting is the code 125 116 to 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 works127 properly on your system. (You must run `configure' beforehand, but you117 debug this code, you can do 'make check-loadavg' to see if it works 118 properly on your system. (You must run 'configure' beforehand, but you 128 119 need not build Make itself to run this test.) 129 120 … … 132 123 Please report any bugs that you find in this area. If you run into 133 124 difficulties, then as a workaround you should be able to disable LFS by 134 adding the `--disable-largefile' option to the `configure' script.125 adding the '--disable-largefile' option to the 'configure' script. 135 126 136 127 On systems that support micro- and nano-second timestamp values and … … 152 143 Customs distributed build environment from the Pmake distribution. 153 144 154 - See readme.vmsfor details about GNU Make on OpenVMS.145 - See README.VMS for details about GNU Make on OpenVMS. 155 146 156 147 - See README.Amiga for details about GNU Make on AmigaDOS. … … 173 164 174 165 ------------------------------------------------------------------------------- 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. 166 Copyright (C) 1988-2016 Free Software Foundation, Inc. 178 167 This file is part of GNU Make. 179 168 -
vendor/gnumake/current/SMakefile.template
r2596 r3138 4 4 # run 'build.sh' instead. 5 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. 6 # Copyright (C) 1995-2016 Free Software Foundation, Inc. 8 7 # This file is part of GNU Make. 9 8 # … … 27 26 # Ultrix 2.2 make doesn't expand the value of VPATH. 28 27 VPATH = /make-%VERSION%/ 29 # This must repeat the value, because configure will remove `VPATH = .'.28 # This must repeat the value, because configure will remove 'VPATH = .'. 30 29 srcdir = /make-%VERSION%/ 31 30 … … 39 38 40 39 # Define these for your system as follows: 41 # -DNO_ARCHIVES To disable `ar' archive support.40 # -DNO_ARCHIVES To disable 'ar' archive support. 42 41 # -DNO_FLOAT To avoid using floating-point numbers. 43 42 # -DENUM_BITFIELDS If the compiler isn't GCC but groks enum foo:2. … … 46 45 # so beware. 47 46 # NeXT 1.0a uses an old version of GCC, which required -D__inline=inline. 48 # See also `config.h'.47 # See also 'config.h'. 49 48 defines = 50 49 51 50 # 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'. 53 52 REMOTE = stub 54 53 … … 84 83 exec_prefix = 85 84 86 # Directory to install `make' in.85 # Directory to install 'make' in. 87 86 bindir = sc:c 88 # Directory to find libraries in for `-lXXX'.87 # Directory to find libraries in for '-lXXX'. 89 88 libdir = lib: 90 89 # Directory to search by default for included makefiles. … … 96 95 # Number to put on the man page filename. 97 96 manext = 1 98 # Prefix to put on installed `make' binary file name.97 # Prefix to put on installed 'make' binary file name. 99 98 binprefix = 100 # Prefix to put on installed `make' man page file name.99 # Prefix to put on installed 'make' man page file name. 101 100 manprefix = $(binprefix) 102 101 103 102 # 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' 106 105 # switch) will not work unless make is installed setgid kmem. 107 106 install_setgid = false … … 109 108 group = sys 110 109 111 # Program to install `make'.110 # Program to install 'make'. 112 111 INSTALL_PROGRAM = copy 113 112 # Program to install the man page. … … 125 124 CTAGS = ctags -w 126 125 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 128 objs = 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 131 134 srcs = $(srcdir)commands.c $(srcdir)job.c $(srcdir)dir.c \ 132 135 $(srcdir)file.c $(srcdir)getloadavg.c $(srcdir)misc.c \ … … 135 138 $(srcdir)variable.c $(srcdir)expand.c $(srcdir)function.c \ 136 139 $(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) \ 140 143 $(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 \ 142 146 $(srcdir)variable.h $(ALLOCA_SRC) $(srcdir)config.h.in 143 147 … … 149 153 info: make.info 150 154 dvi: 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'. 152 156 .PHONY: all check info dvi 153 157 -
vendor/gnumake/current/TODO.private
r2596 r3138 7 7 They are listed in no particular order! 8 8 9 Also, I don't g aurantee that all of them will be ultimately deemed "good9 Also, I don't guarantee that all of them will be ultimately deemed "good 10 10 ideas" and implemented. These are just the ones that, at first blush, 11 11 seem to have some merit (and that I can remember). … … 100 100 means this isn't 100% trivial, but it probably won't be hard. 101 101 102 8) Integration of Guile as an embedded scripting language. This means:103 allowing Guile functions to be declared in makefiles somehow, then104 providing a syntax for invoking them. At least one formulation of105 that would have the function resolve to a string which would be106 substituted in the makefile, kind of like $(shell ...) does now, but107 using the embedded interpreter so there's no process forked of108 course. Obviously this is an optional add-on feature.109 110 It could be more advanced than that, even, who knows? Maybe make111 could provide Guile functions that allow Guile scripts more direct112 access to internal make structures, somehow. This kind of thing113 needs a lot of thought.114 115 Also there's always the flip side: in some very fundamental ways116 make isn't the best choice right now for a complex build tool. It's117 great for simple-to-medium tasks, but there are already other tools118 available for the really tough situations. Ask yourself,119 realistically, how much work is worthwhile to add to make, given the120 fundamentals you can't really overcome without significantly121 affecting backward compatibility--and then why not use another tool122 in the first place?123 124 Something to think about.125 126 102 127 103 128 104 ------------------------------------------------------------------------------- 129 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 130 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 105 Copyright (C) 1997-2016 Free Software Foundation, Inc. 131 106 This file is part of GNU Make. 132 107 -
vendor/gnumake/current/acinclude.m4
r2596 r3138 2 2 dnl 3 3 dnl 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. 4 dnl Copyright (C) 1998-2016 Free Software Foundation, Inc. 6 5 dnl This file is part of GNU Make. 7 6 dnl … … 101 100 dnl --------------------------------------------------------------------------- 102 101 dnl From Paul Eggert <eggert@twinsun.com> 102 dnl Update for Darwin by Troy Runkel <Troy.Runkel@mathworks.com> 103 dnl Update for AIX by Olexiy Buyanskyy (Savannah bug 32485) 103 104 104 105 AC_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], 106 107 ac_cv_struct_st_mtim_nsec, 107 108 [ac_save_CPPFLAGS="$CPPFLAGS" 108 109 ac_cv_struct_st_mtim_nsec=no 109 # tv_nsec -- the usual case110 # _tv_nsec -- Solaris 2.6, if110 # st_mtim.tv_nsec -- the usual case 111 # st_mtim._tv_nsec -- Solaris 2.6, if 111 112 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1 112 113 # && !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 115 118 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val" 116 119 AC_TRY_COMPILE([#include <sys/types.h> 117 120 #include <sys/stat.h> 118 ], [struct stat s; s. st_mtim.ST_MTIM_NSEC;],121 ], [struct stat s; s.ST_MTIM_NSEC;], 119 122 [ac_cv_struct_st_mtim_nsec=$ac_val; break]) 120 123 done -
vendor/gnumake/current/alloca.c
r54 r3138 117 117 find_stack_direction (void) 118 118 { 119 static char *addr = NULL; /* Address of first `dummy', once known. */119 static char *addr = NULL; /* Address of first 'dummy', once known. */ 120 120 auto char dummy; /* To get stack address. */ 121 121 -
vendor/gnumake/current/amiga.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1995-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 16 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 17 16 18 #include "make .h"17 #include "makeint.h" 19 18 #include "variable.h" 20 19 #include "amiga.h" … … 26 25 27 26 static const char Amiga_version[] = "$VER: Make 3.74.3 (12.05.96) \n" 28 27 "Amiga Port by A. Digulla (digulla@home.lake.de)"; 29 28 30 29 int … … 38 37 for (aptr=argv; *aptr; aptr++) 39 38 { 40 39 len += strlen (*aptr) + 4; 41 40 } 42 41 … … 44 43 45 44 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"); 47 46 48 47 ptr = buffer; … … 50 49 for (aptr=argv; *aptr; aptr++) 51 50 { 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 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; 71 70 } 72 71 … … 74 73 75 74 status = SystemTags (buffer, 76 77 75 SYS_UserShell, TRUE, 76 TAG_END); 78 77 79 78 FreeMem (buffer, len); 80 79 81 if (SetSignal (0L,0L) & SIGBREAKF_CTRL_C)82 80 if (SetSignal (0L,0L) & SIGBREAKF_CTRL_C) 81 status = 20; 83 82 84 83 /* Warnings don't count */ 85 84 if (status == 5) 86 85 status = 0; 87 86 88 87 return status; … … 92 91 wildcard_expansion (char *wc, char *o) 93 92 { 94 # define PATH_SIZE 93 # define PATH_SIZE 1024 95 94 struct AnchorPath * apath; 96 95 97 96 if ( (apath = AllocMem (sizeof (struct AnchorPath) + PATH_SIZE, 98 99 97 MEMF_CLEAR)) 98 ) 100 99 { 101 100 apath->ap_Strlen = PATH_SIZE; 102 101 103 104 105 106 107 108 109 110 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 } 112 111 113 114 112 MatchEnd (apath); 113 FreeMem (apath, sizeof (struct AnchorPath) + PATH_SIZE); 115 114 } 116 115 -
vendor/gnumake/current/amiga.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1995-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 -
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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 6 4 This file is part of GNU Make. … … 18 16 this program. If not, see <http://www.gnu.org/licenses/>. */ 19 17 20 #include "make .h"21 22 #ifndef 18 #include "makeint.h" 19 20 #ifndef NO_ARCHIVES 23 21 24 22 #include "filedef.h" … … 27 25 28 26 /* 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 a27 archive-member reference is a name like 'lib(member)' where member is a 30 28 non-empty string. 31 If a name like `lib((entry))' is used, a fatal error is signaled at29 If a name like 'lib((entry))' is used, a fatal error is signaled at 32 30 the attempt to use this unsupported feature. */ 33 31 … … 46 44 47 45 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); 49 47 50 48 return 1; … … 64 62 p = strchr (*arname_p, '('); 65 63 *(p++) = '\0'; 66 p[strlen (p) - 1] = '\0';64 p[strlen (p) - 1] = '\0'; 67 65 *memname_p = p; 68 66 } … … 70 68 71 69 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. */ 73 71 74 72 /* ARGSUSED */ 75 73 static long int 76 74 ar_member_date_1 (int desc UNUSED, const char *mem, int truncated, 77 75 long int hdrpos UNUSED, long int datapos UNUSED, 78 76 long int size UNUSED, long int date, 79 int uid UNUSED, int gid UNUSED, int mode UNUSED,80 77 int uid UNUSED, int gid UNUSED, unsigned int mode UNUSED, 78 const void *name) 81 79 { 82 80 return ar_name_equal (name, mem, truncated) ? date : 0; … … 125 123 ar_touch (const char *name) 126 124 { 127 error (NILF, _("touch archive member is not available on VMS"));125 O (error, NILF, _("touch archive member is not available on VMS")); 128 126 return -1; 129 127 } … … 149 147 { 150 148 case -1: 151 error (NILF, _("touch: Archive `%s' does not exist"), arname);149 OS (error, NILF, _("touch: Archive '%s' does not exist"), arname); 152 150 break; 153 151 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); 155 153 break; 156 154 case -3: … … 158 156 break; 159 157 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); 162 160 break; 163 161 case 0: … … 165 163 break; 166 164 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); 169 167 } 170 168 … … 176 174 177 175 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). */ 179 184 180 185 struct ar_glob_state … … 182 187 const char *arname; 183 188 const char *pattern; 189 #ifdef VMS 190 char *suffix; 191 #endif 184 192 unsigned int size; 185 193 struct nameseq *chain; … … 187 195 }; 188 196 189 /* This function is called by `ar_scan' to match one archive197 /* This function is called by 'ar_scan' to match one archive 190 198 element against the pattern in STATE. */ 191 199 192 200 static long int 193 201 ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED, 194 202 long int hdrpos UNUSED, long int datapos UNUSED, 195 203 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) 197 205 { 198 206 struct ar_glob_state *state = (struct ar_glob_state *)arg; … … 202 210 /* We have a match. Add it to the chain. */ 203 211 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, ")")); 205 219 new->next = state->chain; 206 220 state->chain = new; … … 214 228 Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ 215 229 static int 216 glob_pattern_p (const char *pattern, int quote)230 ar_glob_pattern_p (const char *pattern, int quote) 217 231 { 218 232 const char *p; … … 224 238 case '?': 225 239 case '*': 226 240 return 1; 227 241 228 242 case '\\': 229 230 231 243 if (quote) 244 ++p; 245 break; 232 246 233 247 case '[': 234 235 248 opened = 1; 249 break; 236 250 237 251 case ']': 238 239 240 252 if (opened) 253 return 1; 254 break; 241 255 } 242 256 … … 254 268 const char **names; 255 269 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)) 258 274 return 0; 259 275 … … 262 278 state.arname = arname; 263 279 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 264 296 state.size = size; 265 297 state.chain = 0; 266 298 state.n = 0; 267 299 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 268 309 269 310 if (state.chain == 0) … … 288 329 } 289 330 290 #endif 331 #endif /* Not NO_ARCHIVES. */ -
vendor/gnumake/current/arscan.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1987-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 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 20 23 21 24 #ifdef HAVE_FCNTL_H … … 25 28 #endif 26 29 27 #ifndef 30 #ifndef NO_ARCHIVES 28 31 29 32 #ifdef VMS … … 33 36 #include <descrip.h> 34 37 #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 46 extern unsigned int LBR$_HDRTRUNC; 47 #pragma extern_model restore 48 #endif 49 36 50 #include <unixlib.h> 37 51 #include <lbr$routines.h> 38 #endif 39 52 53 const char * 54 vmsify (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. */ 59 static time_t 60 vms_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 */ 40 74 static void *VMS_lib_idx; 41 75 42 static char *VMS_saved_memname; 43 44 static time_t VMS_member_date; 76 static const void *VMS_saved_arg; 45 77 46 78 static long int (*VMS_function) (); 47 79 80 static long int VMS_function_ret; 81 82 83 /* This is a callback procedure for lib$get_index */ 48 84 static int 49 VMS_get_member_info 85 VMS_get_member_info(struct dsc$descriptor_s *module, unsigned long *rfa) 50 86 { 51 87 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 */ 55 102 56 103 static struct dsc$descriptor_s bufdesc = 57 104 { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL }; 58 105 106 /* Only need the module definition */ 59 107 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) 68 111 { 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; 75 113 } 76 114 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 */ 108 163 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]); 110 165 111 166 filename[i] = '\0'; 112 167 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; 126 174 } 175 127 176 128 177 /* Takes three arguments ARCHIVE, FUNCTION and ARG. … … 156 205 157 206 long int 158 ar_scan (const char *archive, ar_member_func_t function, const void * arg)207 ar_scan (const char *archive, ar_member_func_t function, const void *varg) 159 208 { 160 char * p;209 char *vms_archive; 161 210 162 211 static struct dsc$descriptor_s libdesc = 163 212 { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL }; 164 213 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; 169 218 int status; 170 219 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) 174 224 { 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); 176 237 return -2; 177 238 } 178 239 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)) 186 246 { 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 } 190 267 } 191 268 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 200 269 VMS_function = function; 201 270 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; 212 290 } 213 291 … … 215 293 216 294 /* SCO Unix's compiler defines both of these. */ 217 #ifdef 218 #undef 295 #ifdef M_UNIX 296 #undef M_XENIX 219 297 #endif 220 298 … … 225 303 226 304 #if (!defined (PORTAR) || PORTAR == 0) && (!defined (PORT5AR) || PORT5AR == 0) 227 #undef 305 #undef PORTAR 228 306 #ifdef M_XENIX 229 307 /* According to Jim Sievert <jas1@rsvl.unisys.com>, for SCO XENIX defining … … 254 332 255 333 #ifndef WINDOWS32 256 # if ndef __BEOS__334 # if !defined (__ANDROID__) && !defined (__BEOS__) 257 335 # include <ar.h> 258 336 # else 259 /* BeOS 5 doesn't have <ar.h> but hasarchives in the same format337 /* These platforms don't have <ar.h> but have archives in the same format 260 338 * as many other Unices. This was taken from GNU binutils for BeOS. 261 339 */ 262 # define ARMAG "!<arch>\n"/* String that begins an archive file. */263 # define SARMAG 8 264 # define ARFMAG "`\n" 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. */ 265 343 struct ar_hdr 266 344 { 267 char ar_name[16]; 268 char ar_date[12]; 269 char ar_uid[6], ar_gid[6]; 270 char ar_mode[8]; 271 char ar_size[10]; 272 char ar_fmag[2]; 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. */ 273 351 }; 274 352 # endif … … 295 373 296 374 /* Cray's <ar.h> apparently defines this. */ 297 #ifndef 298 # define AR_HDR_SIZE 375 #ifndef AR_HDR_SIZE 376 # define AR_HDR_SIZE (sizeof (struct ar_hdr)) 299 377 #endif 300 378 … … 332 410 #ifdef AIAMAG 333 411 FL_HDR fl_header; 334 # ifdef AIAMAGBIG412 # ifdef AIAMAGBIG 335 413 int big_archive = 0; 336 414 FL_HDR_BIG fl_header_big; 337 #endif 338 #else 339 int long_name = 0; 415 # endif 340 416 #endif 341 417 char *namemap = 0; … … 346 422 { 347 423 char buf[SARMAG]; 348 register int nread = read (desc, buf, SARMAG); 424 int nread; 425 EINTRLOOP (nread, read (desc, buf, SARMAG)); 349 426 if (nread != SARMAG || memcmp (buf, ARMAG, SARMAG)) 350 427 { 351 352 428 (void) close (desc); 429 return -2; 353 430 } 354 431 } … … 356 433 #ifdef AIAMAG 357 434 { 358 register int nread = read (desc, &fl_header, FL_HSZ);359 435 int nread; 436 EINTRLOOP (nread, read (desc, &fl_header, FL_HSZ)); 360 437 if (nread != FL_HSZ) 361 438 { 362 363 439 (void) close (desc); 440 return -2; 364 441 } 365 442 #ifdef AIAMAGBIG … … 368 445 if (!memcmp (fl_header.fl_magic, AIAMAGBIG, SAIAMAG)) 369 446 { 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 } 386 466 } 387 467 else … … 389 469 /* Check to make sure this is a "normal" archive. */ 390 470 if (memcmp (fl_header.fl_magic, AIAMAG, SAIAMAG)) 391 471 { 392 472 (void) close (desc); 393 473 return -2; 394 474 } 395 475 } 396 476 #else … … 401 481 unsigned short int buf; 402 482 #endif 403 register int nread = read(desc, &buf, sizeof (buf)); 483 int nread; 484 EINTRLOOP (nread, read (desc, &buf, sizeof (buf))); 404 485 if (nread != sizeof (buf) || buf != ARMAG) 405 486 { 406 407 487 (void) close (desc); 488 return -2; 408 489 } 409 490 } … … 423 504 if ( big_archive ) 424 505 { 425 426 506 sscanf (fl_header_big.fl_fstmoff, "%20ld", &member_offset); 507 sscanf (fl_header_big.fl_lstmoff, "%20ld", &last_member_offset); 427 508 } 428 509 else 429 510 #endif 430 511 { 431 432 512 sscanf (fl_header.fl_fstmoff, "%12ld", &member_offset); 513 sscanf (fl_header.fl_lstmoff, "%12ld", &last_member_offset); 433 514 } 434 515 435 516 if (member_offset == 0) 436 517 { 437 438 439 518 /* Empty archive. */ 519 close (desc); 520 return 0; 440 521 } 441 522 #else 442 #ifndef 523 #ifndef M_XENIX 443 524 register long int member_offset = sizeof (int); 444 #else 525 #else /* Xenix. */ 445 526 register long int member_offset = sizeof (unsigned short int); 446 #endif 527 #endif /* Not Xenix. */ 447 528 #endif 448 529 #endif … … 450 531 while (1) 451 532 { 452 453 533 register int nread; 534 struct ar_hdr member_header; 454 535 #ifdef AIAMAGBIG 455 536 struct ar_hdr_big member_header_big; 456 537 #endif 457 538 #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 } 477 561 478 562 #ifdef AIAMAG … … 480 564 481 565 #ifdef AIAMAGBIG 482 483 484 nread =read (desc, &member_header_big,485 AR_MEMHDR_SZ(member_header_big));486 487 488 489 490 491 492 493 494 nread = read (desc, name, name_len);495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 #endif 515 516 nread =read (desc, &member_header,517 AR_MEMHDR_SZ(member_header));518 519 520 521 522 523 524 525 526 nread = read (desc, name, name_len);527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 #else 554 nread = read (desc, &member_header, AR_HDR_SIZE);555 556 557 558 559 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 560 644 #if defined(ARFMAG) || defined(ARFZMAG) 561 645 || ( 562 646 # ifdef ARFMAG 563 647 memcmp (member_header.ar_fmag, ARFMAG, 2) … … 573 657 ) 574 658 #endif 575 576 577 578 579 580 581 582 583 584 585 586 587 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 == ' '); 588 672 589 673 #ifndef AIAMAG 590 591 592 593 594 595 596 597 598 #endif 599 600 601 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'; 602 686 603 687 #ifndef AIAMAG 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 nread = read (desc, name, namesize);624 625 626 627 628 629 630 631 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 } 633 717 #endif /* Not AIAMAG. */ 634 635 636 #ifndef 637 638 639 #else 640 641 642 #endif 643 644 645 646 647 #ifndef 648 649 650 651 #else 652 653 654 655 #endif 656 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); 657 741 658 742 #endif /* AIAMAG. */ 659 743 660 661 662 663 664 744 if (fnval) 745 { 746 (void) close (desc); 747 return fnval; 748 } 665 749 666 750 #ifdef AIAMAG 667 668 669 751 if (member_offset == last_member_offset) 752 /* End of the chain. */ 753 break; 670 754 671 755 #ifdef AIAMAGBIG 672 756 if (big_archive) 673 757 sscanf (member_header_big.ar_nxtmem, "%20ld", &member_offset); 674 675 #endif 676 677 678 679 680 681 682 683 #else 684 685 686 687 688 689 690 691 692 693 694 nread = read (desc, namemap, eltsize);695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 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++; 721 805 #endif 722 806 } … … 751 835 struct ar_hdr hdr; 752 836 #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); 756 840 #endif /* !__hpux && !cray */ 757 841 #endif /* !AIAMAG */ 758 842 } 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 } 759 868 #endif /* !VMS */ 760 761 return !strcmp (name, mem);762 869 } 763 870 … … 767 874 static long int 768 875 ar_member_pos (int desc UNUSED, const char *mem, int truncated, 769 876 long int hdrpos, long int datapos UNUSED, long int size UNUSED, 770 877 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) 772 879 { 773 880 if (!ar_name_equal (name, mem, truncated)) … … 789 896 int fd; 790 897 struct ar_hdr ar_hdr; 791 int i; 898 off_t o; 899 int r; 792 900 unsigned int ui; 793 901 struct stat statbuf; … … 798 906 return 1; 799 907 800 fd = open (arname, O_RDWR, 0666);908 EINTRLOOP (fd, open (arname, O_RDWR, 0666)); 801 909 if (fd < 0) 802 910 return -3; 803 911 /* Read in this member's header */ 804 if (lseek (fd, pos, 0) < 0) 912 EINTRLOOP (o, lseek (fd, pos, 0)); 913 if (o < 0) 805 914 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) 807 917 goto lose; 808 918 /* 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) 810 921 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) 812 924 goto lose; 813 925 /* 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) 816 928 goto lose; 817 929 #if defined(ARFMAG) || defined(ARFZMAG) || defined(AIAMAG) || defined(WINDOWS32) … … 819 931 for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++) 820 932 ar_hdr.ar_date[ui] = ' '; 821 sprintf (TOCHAR (ar_hdr.ar_date), "%l d", (long int) statbuf.st_mtime);933 sprintf (TOCHAR (ar_hdr.ar_date), "%lu", (long unsigned) statbuf.st_mtime); 822 934 #ifdef AIAMAG 823 ar_hdr.ar_date[strlen (ar_hdr.ar_date)] = ' ';935 ar_hdr.ar_date[strlen (ar_hdr.ar_date)] = ' '; 824 936 #endif 825 937 #else … … 827 939 #endif 828 940 /* Write back this member's header */ 829 if (lseek (fd, pos, 0) < 0) 941 EINTRLOOP (o, lseek (fd, pos, 0)); 942 if (o < 0) 830 943 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) 832 946 goto lose; 833 947 close (fd); … … 835 949 836 950 lose: 837 i= errno;951 r = errno; 838 952 close (fd); 839 errno = i;953 errno = r; 840 954 return -3; 841 955 } … … 847 961 long int 848 962 describe_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) 851 966 { 852 967 extern char *ctime (); 853 968 854 printf (_("Member `%s'%s: %ld bytes at %ld (%ld).\n"),855 856 969 printf (_("Member '%s'%s: %ld bytes at %ld (%ld).\n"), 970 name, truncated ? _(" (name might be truncated)") : "", 971 size, hdrpos, datapos); 857 972 printf (_(" Date %s"), ctime (&date)); 858 973 printf (_(" uid = %d, gid = %d, mode = 0%o.\n"), uid, gid, mode); … … 868 983 } 869 984 870 #endif 871 #endif 985 #endif /* TEST. */ 986 #endif /* NO_ARCHIVES. */ -
vendor/gnumake/current/build.template
r2596 r3138 1 1 #!/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. 3 3 # @configure_input@ 4 4 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. 7 6 # This file is part of GNU Make. 8 7 # … … 24 23 srcdir='@srcdir@' 25 24 CC='@CC@' 26 CFLAGS='@CFLAGS@ '25 CFLAGS='@CFLAGS@ @GUILE_CFLAGS@' 27 26 CPPFLAGS='@CPPFLAGS@' 28 LDFLAGS='@ LDFLAGS@'27 LDFLAGS='@AM_LDFLAGS@ @LDFLAGS@' 29 28 ALLOCA='@ALLOCA@' 30 LOADLIBES='@LIBS@ @ LIBINTL@'29 LOADLIBES='@LIBS@ @GUILE_LIBS@ @LIBINTL@' 31 30 eval extras=\'@LIBOBJS@\' 32 31 REMOTE='@REMOTE@' … … 40 39 # Common prefix for machine-dependent installed files. 41 40 exec_prefix=`eval echo @exec_prefix@` 42 # Directory to find libraries in for `-lXXX'.41 # Directory to find libraries in for '-lXXX'. 43 42 libdir=${exec_prefix}/lib 44 43 # Directory to search by default for included makefiles. … … 48 47 aliaspath=${localedir}${PATH_SEPARATOR}. 49 48 50 defines="-D ALIASPATH=\"${aliaspath}\" -DLOCALEDIR=\"${localedir}\" -DLIBDIR=\"${libdir}\" -DINCLUDEDIR=\"${includedir}\""' @DEFS@'49 defines="-DLOCALEDIR=\"${localedir}\" -DLIBDIR=\"${libdir}\" -DINCLUDEDIR=\"${includedir}\""' @DEFS@' 51 50 52 51 # Exit as soon as any command fails. -
vendor/gnumake/current/build_w32.bat
r2596 r3138 1 1 @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. 2 rem Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 rem This file is part of GNU Make. 5 4 rem … … 17 16 rem with this program. If not, see <http://www.gnu.org/licenses/>. 18 17 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 18 call :Reset 19 20 if "%1" == "-h" goto Usage 21 if "%1" == "--help" goto Usage 22 23 set MAKE=gnumake 24 set GUILE=Y 25 set COMPILER=msvc 26 27 :ParseSW 28 if "%1" == "--debug" goto SetDebug 29 if "%1" == "--without-guile" goto NoGuile 30 if "%1" == "gcc" goto SetCC 31 if "%1" == "" goto DoneSW 32 33 :SetDebug 34 set DEBUG=Y 35 shift 36 goto ParseSW 37 38 :NoGuile 39 set GUILE=N 40 echo Building without Guile 41 shift 42 goto ParseSW 43 44 :SetCC 45 set COMPILER=gcc 46 echo Building with GCC 47 shift 48 goto ParseSW 49 50 rem Build with Guile is supported only on NT and later versions 51 :DoneSW 52 echo. 53 echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8 54 if "%DEBUG%" == "Y" echo Building without compiler optimizations 55 56 if "%COMPILER%" == "gcc" goto GccBuild 57 58 set OUTDIR=.\WinRel 59 set "OPTS=/O2 /D NDEBUG" 60 set LINKOPTS= 61 if "%DEBUG%" == "Y" set OUTDIR=.\WinDebug 62 if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG" 63 if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG 64 call :Build 65 goto Done 66 67 :GccBuild 68 set OUTDIR=.\GccRel 69 set OPTS=-O2 70 if "%DEBUG%" == "Y" set OPTS=-O0 71 if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug 72 call :Build 73 goto Done 74 75 :Done 76 call :Reset 77 goto :EOF 78 79 :Build 80 :: Clean the directory if it exists 81 if exist %OUTDIR%\nul rmdir /S /Q %OUTDIR% 82 83 :: Recreate it 84 mkdir %OUTDIR% 85 mkdir %OUTDIR%\glob 86 mkdir %OUTDIR%\w32 87 mkdir %OUTDIR%\w32\compat 88 mkdir %OUTDIR%\w32\subproc 89 90 if "%GUILE%" == "Y" call :ChkGuile 91 92 echo. 93 echo Compiling %OUTDIR% version 94 95 if exist config.h.W32.template call :ConfigSCM 96 copy config.h.W32 %OUTDIR%\config.h 97 98 call :Compile ar 99 call :Compile arscan 100 call :Compile commands 101 call :Compile default 102 call :Compile dir 103 call :Compile expand 104 call :Compile file 105 call :Compile function 106 call :Compile getloadavg 107 call :Compile getopt 108 call :Compile getopt1 109 call :Compile glob\fnmatch 110 call :Compile glob\glob 111 call :Compile guile GUILE 112 call :Compile hash 113 call :Compile implicit 114 call :Compile job 115 call :Compile load 116 call :Compile loadapi 117 call :Compile main GUILE 118 call :Compile misc 119 call :Compile output 120 call :Compile read 121 call :Compile remake 122 call :Compile remote-stub 123 call :Compile rule 124 call :Compile signame 125 call :Compile strcache 126 call :Compile variable 127 call :Compile version 128 call :Compile vpath 129 call :Compile w32\compat\posixfcn 130 call :Compile w32\pathstuff 131 call :Compile w32\subproc\misc 132 call :Compile w32\subproc\sub_proc 133 call :Compile w32\subproc\w32err 134 call :Compile w32\w32os 135 136 if not "%COMPILER%" == "gcc" call :Compile w32\compat\dirent 137 138 call :Link 139 140 echo. 141 if not exist %OUTDIR%\%MAKE%.exe echo %OUTDIR% build FAILED! 142 if exist %OUTDIR%\%MAKE%.exe echo %OUTDIR% build succeeded. 143 goto :EOF 144 145 :Compile 146 set EXTRAS= 147 if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%" 148 if "%COMPILER%" == "gcc" goto GccCompile 149 150 :: MSVC Compile 151 echo on 152 cl.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 154 echo %OUTDIR%\%1.obj >>%OUTDIR%\link.sc 155 goto :EOF 156 157 :GccCompile 158 :: GCC Compile 159 echo on 160 gcc -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 162 goto :EOF 163 164 :Link 165 echo Linking %OUTDIR%/%MAKE%.exe 166 if "%COMPILER%" == "gcc" goto GccLink 167 168 :: MSVC Link 169 echo %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 170 echo on 171 link.exe /NOLOGO /SUBSYSTEM:console /PDB:%OUTDIR%\%MAKE%.pdb %LINKOPTS% /OUT:%OUTDIR%\%MAKE%.exe @%OUTDIR%\link.sc 172 @echo off 173 goto :EOF 174 175 :GccLink 176 :: GCC Link 177 echo on 178 gcc -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 180 goto :EOF 181 182 :ConfigSCM 183 echo Generating config from SCM templates 184 sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.ac > %OUTDIR%\config.h.W32.sed 185 echo s,%%PACKAGE%%,make,g >> %OUTDIR%\config.h.W32.sed 186 sed -f %OUTDIR%\config.h.W32.sed config.h.W32.template > config.h.W32 187 echo static const char *const GUILE_module_defn = ^" \> gmk-default.h 188 sed -e "s/;.*//" -e "/^[ \t]*$/d" -e "s/\"/\\\\\"/g" -e "s/$/ \\\/" gmk-default.scm >> gmk-default.h 189 echo ^";>> gmk-default.h 190 goto :EOF 191 192 :ChkGuile 193 if not "%OS%" == "Windows_NT" goto NoGuile 194 pkg-config --help > %OUTDIR%\guile.tmp 2> NUL 195 if ERRORLEVEL 1 goto NoPkgCfg 196 197 echo Checking for Guile 2.0 198 if not "%COMPILER%" == "gcc" set PKGMSC=--msvc-syntax 199 pkg-config --cflags --short-errors "guile-2.0" > %OUTDIR%\guile.tmp 200 if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp 201 202 pkg-config --libs --static --short-errors %PKGMSC% "guile-2.0" > %OUTDIR%\guile.tmp 203 if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp 204 205 if not "%GUILECFLAGS%" == "" goto GuileDone 206 207 echo Checking for Guile 1.8 208 pkg-config --cflags --short-errors "guile-1.8" > %OUTDIR%\guile.tmp 209 if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp 210 211 pkg-config --libs --static --short-errors %PKGMSC% "guile-1.8" > %OUTDIR%\guile.tmp 212 if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp 213 214 if not "%GUILECFLAGS%" == "" goto GuileDone 215 216 echo No Guile found, building without Guile 217 goto GuileDone 218 219 :NoPkgCfg 220 echo pkg-config not found, building without Guile 221 222 :GuileDone 223 if "%GUILECFLAGS%" == "" goto :EOF 224 225 echo Guile found, building with Guile 226 set "GUILECFLAGS=%GUILECFLAGS% -DHAVE_GUILE" 227 goto :EOF 228 229 :Usage 230 echo Usage: %0 [options] [gcc] 231 echo Options: 232 echo. --debug For GCC only, make a debug build 233 echo. (MSVC build always makes both debug and release) 234 echo. --without-guile Do not compile Guile support even if found 235 echo. --help Display these instructions and exit 236 goto :EOF 237 238 :Reset 239 set COMPILER= 240 set DEBUG= 241 set GUILE= 242 set GUILECFLAGS= 243 set GUILELIBS= 244 set LINKOPTS= 245 set MAKE= 246 set NOGUILE= 247 set OPTS= 248 set OUTDIR= 249 set PKGMSC= 250 goto :EOF -
vendor/gnumake/current/commands.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make.h" 17 #include "makeint.h" 18 #include "filedef.h" 20 19 #include "dep.h" 21 #include "filedef.h"22 20 #include "variable.h" 23 21 #include "job.h" … … 29 27 30 28 #if VMS 31 # define FILE_LIST_SEPARATOR ','29 # define FILE_LIST_SEPARATOR (vms_comma_separator ? ',' : ' ') 32 30 #else 33 31 # define FILE_LIST_SEPARATOR ' ' 34 32 #endif 35 33 36 int remote_kill (int id, int sig); 37 38 #ifndef HAVE_UNISTD_H 34 #ifndef HAVE_UNISTD_H 39 35 int getpid (); 40 36 #endif … … 72 68 const char *at, *percent, *star, *less; 73 69 74 #ifndef 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'. */ 77 73 78 74 if (ar_name (file->name)) … … 94 90 } 95 91 else 96 #endif 92 #endif /* NO_ARCHIVES. */ 97 93 { 98 94 at = file->name; … … 104 100 { 105 101 /* In Unix make, $* is set to the target name with 106 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. */ 108 104 const char *name; 109 105 unsigned int len; 110 106 111 #ifndef 107 #ifndef NO_ARCHIVES 112 108 if (ar_name (file->name)) 113 114 115 116 109 { 110 name = strchr (file->name, '(') + 1; 111 len = strlen (name) - 1; 112 } 117 113 else 118 114 #endif 119 120 121 122 115 { 116 name = file->name; 117 len = strlen (name); 118 } 123 119 124 120 for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next) 125 126 127 128 129 130 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 } 133 129 if (d == 0) 134 130 file->stem = ""; 135 131 } 136 132 star = file->stem; … … 151 147 less = at; 152 148 153 #define 149 #define DEFINE_VARIABLE(name, len, value) \ 154 150 (void) define_variable_for_file (name,len,value,o_automatic,0,file) 155 151 … … 204 200 cp = plus_value; 205 201 206 qmark_len = plus_len + 1; 202 qmark_len = plus_len + 1; /* Will be this or less. */ 207 203 for (d = file->deps; d != 0; d = d->next) 208 204 if (! d->ignore_mtime && ! d->need_2nd_expansion) … … 210 206 const char *c = dep_name (d); 211 207 212 #ifndef 208 #ifndef NO_ARCHIVES 213 209 if (ar_name (c)) 214 210 { … … 224 220 *cp++ = FILE_LIST_SEPARATOR; 225 221 if (! (d->changed || always_make_flag)) 226 qmark_len -= len + 1; 222 qmark_len -= len + 1; /* Don't space in $? for this one. */ 227 223 } 228 224 … … 279 275 280 276 c = dep_name (d); 281 #ifndef 277 #ifndef NO_ARCHIVES 282 278 if (ar_name (c)) 283 284 285 286 287 288 #endif 289 279 { 280 c = strchr (c, '(') + 1; 281 len = strlen (c) - 1; 282 } 283 else 284 #endif 285 len = strlen (c); 290 286 291 287 if (d->ignore_mtime) 292 288 { 293 289 memcpy (bp, c, len); 294 295 296 297 290 bp += len; 291 *bp++ = FILE_LIST_SEPARATOR; 292 } 293 else 298 294 { 299 295 memcpy (cp, c, len); … … 323 319 } 324 320 325 #undef 321 #undef DEFINE_VARIABLE 326 322 } 327 323 328 324 329 325 /* 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. */ 331 327 332 328 void … … 405 401 CMDS->any_recurse flag. */ 406 402 403 if (nlines > USHRT_MAX) 404 ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines); 405 407 406 cmds->ncommand_lines = nlines; 408 407 cmds->command_lines = lines; … … 413 412 for (idx = 0; idx < nlines; ++idx) 414 413 { 415 intflags = 0;414 unsigned char flags = 0; 416 415 const char *p = lines[idx]; 417 416 418 while ( isblank(*p) || *p == '-' || *p == '@' || *p == '+')417 while (ISBLANK (*p) || *p == '-' || *p == '@' || *p == '+') 419 418 switch (*(p++)) 420 419 { … … 436 435 437 436 cmds->lines_flags[idx] = flags; 438 cmds->any_recurse |= flags & COMMANDS_RECURSE ;437 cmds->any_recurse |= flags & COMMANDS_RECURSE ? 1 : 0; 439 438 } 440 439 } … … 454 453 455 454 for (p = file->cmds->commands; *p != '\0'; ++p) 456 if (! isspace ((unsigned char)*p) && *p != '-' && *p != '@')455 if (!ISSPACE (*p) && *p != '-' && *p != '@' && *p != '+') 457 456 break; 458 457 if (*p == '\0') … … 460 459 /* If there are no commands, assume everything worked. */ 461 460 set_command_state (file, cs_running); 462 file->update_status = 0;461 file->update_status = us_success; 463 462 notice_finished_file (file); 464 463 return; … … 470 469 471 470 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); 472 476 473 477 /* Start the commands running. */ … … 516 520 517 521 if (susp_count != 0) 518 522 fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count); 519 523 else if (susp_count == (DWORD)-1) 520 521 522 523 524 525 524 { 525 DWORD ierr = GetLastError (); 526 527 fprintf (stderr, "SuspendThread: error %ld: %s\n", 528 ierr, map_windows32_error_to_string (ierr)); 529 } 526 530 } 527 531 #endif … … 539 543 struct child *c; 540 544 for (c = children; c != 0; c = c->next) 541 542 545 if (!c->remote) 546 (void) kill (c->pid, SIGTERM); 543 547 } 544 548 … … 558 562 559 563 /* Remote children won't automatically get signals sent 560 564 to the process group, so we must send them. */ 561 565 for (c = children; c != 0; c = c->next) 562 563 566 if (c->remote) 567 (void) remote_kill (c->pid, sig); 564 568 565 569 for (c = children; c != 0; c = c->next) 566 570 delete_child_targets (c); 567 571 568 572 /* Clean up the children. We don't just use the call below because 569 573 we don't want to print the "Waiting for children" message. */ 570 574 while (job_slots_used > 0) 571 575 reap_children (1, 0); 572 576 } 573 577 else … … 584 588 /* We don't want to send ourselves SIGQUIT, because it will 585 589 cause a core dump. Just exit instead. */ 586 exit ( EXIT_FAILURE);590 exit (MAKE_TROUBLE); 587 591 #endif 588 592 … … 620 624 { 621 625 time_t file_date = (file->last_mtime == NONEXISTENT_MTIME 622 623 626 ? (time_t) -1 627 : (time_t) FILE_TIMESTAMP_S (file->last_mtime)); 624 628 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 } 633 639 return; 634 640 } … … 641 647 { 642 648 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); 644 651 else 645 error (NILF, _("*** Deleting file `%s'"), file->name);652 OS (error, NILF, _("*** Deleting file '%s'"), file->name); 646 653 if (unlink (file->name) < 0 647 && errno != ENOENT)/* It disappeared; so what. */648 654 && errno != ENOENT) /* It disappeared; so what. */ 655 perror_with_name ("unlink: ", file->name); 649 656 } 650 657 } … … 665 672 delete_target (child->file, NULL); 666 673 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. */ 668 675 for (d = child->file->also_make; d != 0; d = d->next) 669 676 delete_target (d->file, child->file->name); … … 685 692 puts (_(" (built-in):")); 686 693 else 687 printf (_(" (from `%s', line %lu):\n"),694 printf (_(" (from '%s', line %lu):\n"), 688 695 cmds->fileinfo.filenm, cmds->fileinfo.lineno); 689 696 … … 692 699 { 693 700 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 } 698 711 699 712 printf ("%c%.*s\n", cmd_prefix, (int) (end - s), s); -
vendor/gnumake/current/commands.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 22 20 struct commands 23 21 { 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. */ 31 30 }; 32 31 33 /* Bits in `lines_flags'. */34 #define COMMANDS_RECURSE1 /* Recurses: + or $(MAKE). */35 #define COMMANDS_SILENT2 /* Silent: @. */36 #define COMMANDS_NOERROR4 /* 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: -. */ 37 36 37 RETSIGTYPE fatal_error_signal (int sig); 38 38 void execute_file_commands (struct file *file); 39 39 void print_commands (const struct commands *cmds); -
vendor/gnumake/current/config.ami.template
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1995-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 18 17 /* Define if on AIX 3. 19 18 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. */ 21 20 #ifndef _ALL_SOURCE 22 21 /* #undef _ALL_SOURCE */ … … 39 38 /* #undef DGUX */ 40 39 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. */ 42 41 /* #undef GETLOADAVG_PRIVILEGED */ 43 42 44 /* Define to `unsigned long' or `unsigned long long'43 /* Define to 'unsigned long' or 'unsigned long long' 45 44 if <inttypes.h> doesn't define. */ 46 45 #define uintmax_t unsigned long 47 46 48 /* Define to `int' if <sys/types.h> doesn't define. */47 /* Define to 'int' if <sys/types.h> doesn't define. */ 49 48 #define gid_t int 50 49 … … 55 54 /* #undef HAVE_ALLOCA_H */ 56 55 57 /* Define if you don't have vprintf but do have _doprnt. */58 /* #undef HAVE_DOPRNT */59 60 56 /* Define if your system has a working fnmatch function. */ 61 57 /* #undef HAVE_FNMATCH */ 62 58 63 /* Define if your system has its own `getloadavg' function. */59 /* Define if your system has its own 'getloadavg' function. */ 64 60 /* #undef HAVE_GETLOADAVG */ 65 61 … … 67 63 /* #undef HAVE_GETMNTENT */ 68 64 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. */ 70 69 /* #undef HAVE_LONG_DOUBLE */ 71 70 72 /* Define if you support file names longer than 14 characters. 71 /* Define if you support file names longer than 14 characters. */ 73 72 #define HAVE_LONG_FILE_NAMES 1 74 73 75 /* Define if you have a working `mmap' system call. */74 /* Define if you have a working 'mmap' system call. */ 76 75 /* #undef HAVE_MMAP */ 77 76 … … 86 85 /* #undef HAVE_ST_BLOCKS */ 87 86 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. */ 89 88 #define HAVE_STRCOLL 1 90 89 … … 95 94 #define HAVE_STRFTIME 1 96 95 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. */ 98 97 /* #undef HAVE_SYS_WAIT_H */ 99 98 … … 111 110 /* #undef HAVE_UTIME_NULL */ 112 111 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 1118 119 112 /* Define if you have the wait3 system call. */ 120 113 /* #undef HAVE_WAIT3 */ 121 114 122 /* Define if on MINIX. 115 /* Define if on MINIX. */ 123 116 /* #undef _MINIX */ 124 117 … … 132 125 /* #undef NO_MINUS_C_MINUS_O */ 133 126 134 /* Define to `int' if <sys/types.h> doesn't define. */127 /* Define to 'int' if <sys/types.h> doesn't define. */ 135 128 #define pid_t int 136 129 … … 153 146 direction of stack growth for your system; otherwise it will be 154 147 automatically deduced at run-time. 155 156 157 148 STACK_DIRECTION > 0 => grows toward higher addresses 149 STACK_DIRECTION < 0 => grows toward lower addresses 150 STACK_DIRECTION = 0 => direction of growth unknown 158 151 */ 159 152 #define STACK_DIRECTION -1 160 153 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. */ 162 155 /* #undef STAT_MACROS_BROKEN */ 163 156 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. */ 168 158 #define STDC_HEADERS 169 159 … … 171 161 /* #undef SVR4 */ 172 162 173 /* Define if `sys_siglist' is declared by <signal.h>. */163 /* Define if 'sys_siglist' is declared by <signal.h>. */ 174 164 /* #undef SYS_SIGLIST_DECLARED */ 175 165 176 /* Define to `int' if <sys/types.h> doesn't define. */166 /* Define to 'int' if <sys/types.h> doesn't define. */ 177 167 #define uid_t int 178 168 … … 184 174 /* #undef UMAX4_3 */ 185 175 186 /* Define vfork as fork if vfork does not work. */187 /* #undef vfork */188 189 176 /* Name of this package (needed by automake) */ 190 177 #define PACKAGE "%PACKAGE%" … … 193 180 #define VERSION "%VERSION%" 194 181 195 /* Define to the name of the SCCS `get' command. */182 /* Define to the name of the SCCS 'get' command. */ 196 183 #define SCCS_GET "get" 197 184 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. */ 199 186 /* #undef SCCS_GET_MINUS_G */ 200 187 … … 206 193 /* #undef ST_MTIM_NSEC */ 207 194 208 /* Define this if the C library defines the variable `sys_siglist'. */195 /* Define this if the C library defines the variable 'sys_siglist'. */ 209 196 /* #undef HAVE_SYS_SIGLIST */ 210 197 211 /* Define this if the C library defines the variable `_sys_siglist'. */198 /* Define this if the C library defines the variable '_sys_siglist'. */ 212 199 /* #undef HAVE__SYS_SIGLIST */ 213 200 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>. */ 215 202 /* #undef HAVE_UNION_WAIT */ 216 203 … … 248 235 /* #undef HAVE_SETEUID */ 249 236 250 /* Define if you have the setlinebuf function. 237 /* Define if you have the setlinebuf function. */ 251 238 /* #undef HAVE_SETLINEBUF */ 252 239 … … 257 244 /* #undef HAVE_SETREUID */ 258 245 259 /* Define if you have the sigsetmask function. 246 /* Define if you have the sigsetmask function. */ 260 247 /* #undef HAVE_SIGSETMASK */ 261 248 … … 302 289 /* #undef HAVE_NDIR_H */ 303 290 304 /* Define to 1 if you have the <stdarg.h> header file. */305 #define HAVE_STDARG_H 1306 307 291 /* Define if you have the <stdlib.h> header file. */ 308 292 /* #undef HAVE_STDLIB_H */ … … 335 319 /* #undef HAVE_LIBKSTAT */ 336 320 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 337 327 /* Define if you have the sun library (-lsun). */ 338 328 /* #undef HAVE_LIBSUN */ 339 329 330 /* Output sync sypport */ 331 #define NO_OUTPUT_SYNC 332 340 333 /* Define for Case Insensitve behavior */ 341 334 #define HAVE_CASE_INSENSITIVE_FS -
vendor/gnumake/current/config.h-vms.template
r2596 r3138 1 1 /* config.h-vms. Generated by hand by Klaus Kämpf <kkaempf@rmi.de> -*-C-*- 2 2 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. 5 4 This file is part of GNU Make. 6 5 … … 18 17 19 18 /* 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 21 26 22 27 /* Define to 1 if on AIX 3. … … 36 41 /* #undef HAVE_GETTEXT */ 37 42 43 /* Embed GNU Guile support */ 44 /* #undef HAVE_GUILE */ 45 38 46 /* Define to 1 if your locale.h file contains LC_MESSAGES. */ 39 47 /* #undef HAVE_LC_MESSAGES */ … … 58 66 /* #undef DGUX */ 59 67 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. */ 61 69 /* #undef GETLOADAVG_PRIVILEGED */ 62 70 63 /* Define to `unsigned long' or `unsigned long long'71 /* Define to 'unsigned long' or 'unsigned long long' 64 72 if <inttypes.h> doesn't define. */ 65 73 #define uintmax_t unsigned long 66 74 67 /* Define to `int' if <sys/types.h> doesn't define. */75 /* Define to 'int' if <sys/types.h> doesn't define. */ 68 76 /* #undef gid_t */ 69 77 … … 74 82 /* #undef HAVE_ALLOCA_H */ 75 83 76 /* Define to 1 if you don't have vprintf but do have _doprnt. */77 /* #undef HAVE_DOPRNT */78 79 84 /* Define to 1 if you have the fdopen function. */ 80 85 #define HAVE_FDOPEN 1 … … 83 88 /* #undef HAVE_FNMATCH */ 84 89 85 /* Define to 1 if your system has its own `getloadavg' function. */90 /* Define to 1 if your system has its own 'getloadavg' function. */ 86 91 /* #undef HAVE_GETLOADAVG */ 87 92 … … 89 94 /* #undef HAVE_GETMNTENT */ 90 95 91 /* Define to 1 if the `long double' type works. */96 /* Define to 1 if the 'long double' type works. */ 92 97 /* #undef HAVE_LONG_DOUBLE */ 93 98 … … 95 100 #define HAVE_LONG_FILE_NAMES 1 96 101 97 /* Define to 1 if you have a working `mmap' system call. */102 /* Define to 1 if you have a working 'mmap' system call. */ 98 103 /* #undef HAVE_MMAP */ 99 104 … … 111 116 /* #undef HAVE_STRCOLL */ 112 117 118 /* Define to 1 if you have the strncasecmp' function. */ 119 #if __CRTL_VER >= 70000000 120 #define HAVE_STRNCASECMP 1 121 #endif 122 113 123 /* Define to 1 if your struct stat has st_rdev. */ 114 124 /* #undef HAVE_ST_RDEV */ … … 135 145 /* #undef HAVE_UTIME_NULL */ 136 146 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 1142 143 147 /* Define to 1 if you have the wait3 system call. */ 144 148 /* #undef HAVE_WAIT3 */ … … 156 160 /* #undef NO_MINUS_C_MINUS_O */ 157 161 158 /* Define to `int' if <sys/types.h> doesn't define. */162 /* Define to 'int' if <sys/types.h> doesn't define. */ 159 163 /* I assume types.h is available for all 5.0 cc/cxx compilers */ 160 164 #if __DECC_VER < 50090000 … … 180 184 direction of stack growth for your system; otherwise it will be 181 185 automatically deduced at run-time. 182 183 184 186 STACK_DIRECTION > 0 => grows toward higher addresses 187 STACK_DIRECTION < 0 => grows toward lower addresses 188 STACK_DIRECTION = 0 => direction of growth unknown 185 189 */ 186 190 /* #undef STACK_DIRECTION */ 187 191 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. */ 189 193 /* #undef STAT_MACROS_BROKEN */ 190 194 … … 195 199 /* #undef SVR4 */ 196 200 197 /* Define to 1 if `sys_siglist' is declared by <signal.h>. */201 /* Define to 1 if 'sys_siglist' is declared by <signal.h>. */ 198 202 /* #undef SYS_SIGLIST_DECLARED */ 199 203 200 /* Define to `int' if <sys/types.h> doesn't define. */204 /* Define to 'int' if <sys/types.h> doesn't define. */ 201 205 #if __DECC_VER < 50090000 202 206 #define uid_t int … … 210 214 /* #undef UMAX4_3 */ 211 215 212 /* Define vfork as fork if vfork does not work. */213 /* #undef vfork */214 215 216 /* Name of this package (needed by automake) */ 216 217 #define PACKAGE "%PACKAGE%" … … 219 220 #define VERSION "%VERSION%" 220 221 221 /* Define to the name of the SCCS `get' command. */222 /* Define to the name of the SCCS 'get' command. */ 222 223 /* #undef SCCS_GET */ 223 224 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. */ 225 226 /* #undef SCCS_GET_MINUS_G */ 226 227 … … 232 233 /* #undef ST_MTIM_NSEC */ 233 234 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'. */ 235 236 /* #undefine HAVE_SYS_SIGLIST */ 236 237 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'. */ 238 239 /* #undef HAVE__SYS_SIGLIST */ 239 240 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>. */ 241 242 /* #undef HAVE_UNION_WAIT */ 242 243 … … 255 256 /* Define to 1 if you have the gethostname function. */ 256 257 /* #undef HAVE_GETHOSTNAME */ 257 258 /* Define to 1 if you have the getloadavg function. */259 /* #undef HAVE_GETLOADAVG */260 258 261 259 /* Define to 1 if you have the memmove function. */ … … 333 331 /* #undef HAVE_NDIR_H */ 334 332 335 /* Define to 1 if your compiler conforms to the ANSI C standard. */336 #define HAVE_ANSI_COMPILER 1337 338 /* Define to 1 if you have the <stdarg.h> header file. */339 #define HAVE_STDARG_H 1340 341 333 /* Define to 1 if you have the <stdlib.h> header file. */ 342 334 #define HAVE_STDLIB_H 1 … … 370 362 /* Define to 1 if you have the sun library (-lsun). */ 371 363 /* #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 */ 372 370 373 371 /* Use high resolution file timestamps if nonzero. */ … … 387 385 /* #undef _DIRENT_HAVE_D_NAMLEN */ 388 386 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 398 390 #endif 399 391 … … 421 413 /* Define if using alloca.c. */ 422 414 /* #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 427 430 428 431 /* Build host information. */ -
vendor/gnumake/current/config.h.W32.template
r2596 r3138 1 1 /* config.h.W32 -- hand-massaged config.h file for Windows builds -*-C-*- 2 2 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. 5 4 This file is part of GNU Make. 6 5 … … 29 28 #endif 30 29 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'. */ 32 31 /* #undef CLOSEDIR_VOID */ 33 32 34 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP35 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. 36 35 */ 37 36 /* #undef CRAY_STACKSEG_END */ 38 37 39 /* Define to 1 if using `alloca.c'. */38 /* Define to 1 if using 'alloca.c'. */ 40 39 /* #undef C_ALLOCA */ 41 40 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 44 43 45 44 /* Define to 1 for DGUX with <sys/dg_sys_info.h>. */ … … 53 52 #define FILE_TIMESTAMP_HI_RES 0 54 53 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. 56 55 */ 57 56 /* #undef GETLOADAVG_PRIVILEGED */ 58 57 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. */ 60 59 #define HAVE_ALLOCA 1 61 60 … … 64 63 /* #undef HAVE_ALLOCA_H */ 65 64 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 71 67 72 68 /* Use case insensitive file names */ 73 69 /* #undef HAVE_CASE_INSENSITIVE_FS */ 74 70 75 /* Define if you have the clock_gettime function. */71 /* Define to 1 if you have the clock_gettime function. */ 76 72 /* #undef HAVE_CLOCK_GETTIME */ 77 73 74 /* Embed GNU Guile support. Windows build sets this on the 75 compilation command line. */ 76 /* #undef HAVE_GUILE */ 77 78 78 /* Define if the GNU dcgettext() function is already present or preinstalled. 79 79 */ 80 80 /* #undef HAVE_DCGETTEXT */ 81 81 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'. 83 99 */ 84 100 #define HAVE_DIRENT_H 1 … … 91 107 #endif 92 108 93 /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */94 /* #undef HAVE_DOPRNT */95 96 109 /* Use platform specific coding */ 97 110 #define HAVE_DOS_PATHS 1 98 111 99 /* Define to 1 if you have the `dup2' function. */112 /* Define to 1 if you have the 'dup2' function. */ 100 113 #define HAVE_DUP2 1 101 114 … … 103 116 #define HAVE_FCNTL_H 1 104 117 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. */ 112 127 #define HAVE_GETCWD 1 113 128 114 /* Define to 1 if you have the `getgroups' function. */129 /* Define to 1 if you have the 'getgroups' function. */ 115 130 /* #undef HAVE_GETGROUPS */ 116 131 117 /* Define to 1 if you have the `gethostbyname' function. */132 /* Define to 1 if you have the 'gethostbyname' function. */ 118 133 /* #undef HAVE_GETHOSTBYNAME */ 119 134 120 /* Define to 1 if you have the `gethostname' function. */135 /* Define to 1 if you have the 'gethostname' function. */ 121 136 /* #undef HAVE_GETHOSTNAME */ 122 137 123 /* Define to 1 if you have the `getloadavg' function. */138 /* Define to 1 if you have the 'getloadavg' function. */ 124 139 /* #undef HAVE_GETLOADAVG */ 125 140 126 /* Define to 1 if you have the `getrlimit' function. */141 /* Define to 1 if you have the 'getrlimit' function. */ 127 142 /* #undef HAVE_GETRLIMIT */ 128 143 … … 130 145 /* #undef HAVE_GETTEXT */ 131 146 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 134 151 135 152 /* Define if you have the iconv() function. */ … … 137 154 138 155 /* 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). */ 142 161 /* #undef HAVE_LIBDGC */ 143 162 144 /* Define to 1 if you have the `kstat' library (-lkstat). */163 /* Define to 1 if you have the 'kstat' library (-lkstat). */ 145 164 /* #undef HAVE_LIBKSTAT */ 146 165 … … 151 170 /*#define HAVE_LOCALE_H 1*/ 152 171 172 /* Define to 1 if you have the 'lstat' function. */ 173 /* #undef HAVE_LSTAT */ 174 153 175 /* Define to 1 if you have the <mach/mach.h> header file. */ 154 176 /* #undef HAVE_MACH_MACH_H */ 155 177 156 /* Define to 1 if you have the `memmove' function. */157 #define HAVE_MEMMOVE 1158 159 178 /* Define to 1 if you have the <memory.h> header file. */ 160 179 #define HAVE_MEMORY_H 1 161 180 162 /* Define to 1 if you have the `mkstemp' function. */181 /* Define to 1 if you have the 'mkstemp' function. */ 163 182 /* #undef HAVE_MKSTEMP */ 164 183 165 /* Define to 1 if you have the `mktemp' function. */184 /* Define to 1 if you have the 'mktemp' function. */ 166 185 #define HAVE_MKTEMP 1 167 186 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'. */ 169 188 /* #undef HAVE_NDIR_H */ 170 189 … … 172 191 /* #undef HAVE_NLIST_H */ 173 192 174 /* Define to 1 if you have the `pipe' function. */193 /* Define to 1 if you have the 'pipe' function. */ 175 194 /* #undef HAVE_PIPE */ 176 195 177 /* Define to 1 if you have the `pstat_getdynamic' function. */196 /* Define to 1 if you have the 'pstat_getdynamic' function. */ 178 197 /* #undef HAVE_PSTAT_GETDYNAMIC */ 179 198 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. */ 181 203 /* #undef HAVE_REALPATH */ 182 204 183 /* Define if <signal.h> defines the SA_RESTART constant. */205 /* Define to 1 if <signal.h> defines the SA_RESTART constant. */ 184 206 /* #undef HAVE_SA_RESTART */ 185 207 186 /* Define to 1 if you have the `setegid' function. */208 /* Define to 1 if you have the 'setegid' function. */ 187 209 /* #undef HAVE_SETEGID */ 188 210 189 /* Define to 1 if you have the `seteuid' function. */211 /* Define to 1 if you have the 'seteuid' function. */ 190 212 /* #undef HAVE_SETEUID */ 191 213 192 /* Define to 1 if you have the `setlinebuf' function. */214 /* Define to 1 if you have the 'setlinebuf' function. */ 193 215 /* #undef HAVE_SETLINEBUF */ 194 216 195 /* Define to 1 if you have the `setlocale' function. */217 /* Define to 1 if you have the 'setlocale' function. */ 196 218 /*#define HAVE_SETLOCALE 1*/ 197 219 198 /* Define to 1 if you have the `setregid' function. */220 /* Define to 1 if you have the 'setregid' function. */ 199 221 /* #undef HAVE_SETREGID */ 200 222 201 /* Define to 1 if you have the `setreuid' function. */223 /* Define to 1 if you have the 'setreuid' function. */ 202 224 /* #undef HAVE_SETREUID */ 203 225 204 /* Define to 1 if you have the `setrlimit' function. */226 /* Define to 1 if you have the 'setrlimit' function. */ 205 227 /* #undef HAVE_SETRLIMIT */ 206 228 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. */ 211 233 /* #undef HAVE_SIGACTION */ 212 234 213 /* Define to 1 if you have the `sigsetmask' function. */235 /* Define to 1 if you have the 'sigsetmask' function. */ 214 236 /* #undef HAVE_SIGSETMASK */ 215 237 216 /* Define to 1 if you have the `socket' function. */238 /* Define to 1 if you have the 'socket' function. */ 217 239 /* #undef HAVE_SOCKET */ 218 240 219 /* Define to 1 if you have the <stdarg.h> header file. */220 #define HAVE_STDARG_H 1221 222 241 /* 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 224 245 225 246 /* Define to 1 if you have the <stdlib.h> header file. */ 226 247 #define HAVE_STDLIB_H 1 227 248 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. */ 235 268 #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 1245 246 /* Define to 1 if you have the `strchr' function. */247 #define HAVE_STRCHR 1248 249 /* Define to 1 if you have the `strcoll' function and it is properly defined.250 */251 #define HAVE_STRCOLL 1252 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 1258 269 259 270 /* Define to 1 if you have the <strings.h> header file. */ … … 263 274 #define HAVE_STRING_H 1 264 275 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. */ 266 293 /* #undef HAVE_STRSIGNAL */ 267 294 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 300 char *ttyname (int); 301 302 /* Define to 1 if 'n_un.n_name' is a member of 'struct nlist'. */ 269 303 /* #undef HAVE_STRUCT_NLIST_N_UN_N_NAME */ 270 304 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'. 272 306 */ 273 307 /* #undef HAVE_SYS_DIR_H */ 274 308 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'. 276 310 */ 277 311 /* #undef HAVE_SYS_NDIR_H */ 278 312 279 313 /* 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 281 317 282 318 /* Define to 1 if you have the <sys/resource.h> header file. */ … … 284 320 285 321 /* 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 287 323 288 324 /* 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 290 326 291 327 /* 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 293 331 294 332 /* 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 296 334 297 335 /* Define to 1 if you have the <sys/wait.h> header file. */ 298 336 /* #undef HAVE_SYS_WAIT_H */ 299 337 300 /* Define t his 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>. */ 301 339 /* #undef HAVE_UNION_WAIT */ 302 340 303 341 /* 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. */ 320 347 /* #undef HAVE_WAIT3 */ 321 348 322 /* Define to 1 if you have the `waitpid' function. */349 /* Define to 1 if you have the 'waitpid' function. */ 323 350 /* #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 */330 351 331 352 /* Build host information. */ 332 353 #define MAKE_HOST "Windows32" 333 354 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 */ 339 366 /* #undef NLIST_NAME_UNION */ 340 367 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. */ 342 369 /* #undef NLIST_STRUCT */ 343 370 … … 348 375 #define PACKAGE "%PACKAGE%" 349 376 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'). */ 354 393 #define RETSIGTYPE void 355 394 … … 360 399 /* #undef SCCS_GET_MINUS_G */ 361 400 362 /* Define to 1 if the `setvbuf' function takes the buffering type as its401 /* Define to 1 if the 'setvbuf' function takes the buffering type as its 363 402 second argument and the buffer pointer as the third, as on System V before 364 403 release 3. */ … … 367 406 /* If using the C implementation of alloca, define if you know the 368 407 direction of stack growth for your system; otherwise it will be 369 automatically deduced at run -time.370 371 372 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 */ 373 412 /* #undef STACK_DIRECTION */ 374 413 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. */ 376 415 /* #undef STAT_MACROS_BROKEN */ 377 416 … … 386 425 387 426 /* 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 389 430 390 431 /* Define to 1 for Encore UMAX. */ … … 421 462 /* #undef _POSIX_1_SOURCE */ 422 463 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. */ 430 468 /* #undef const */ 431 469 432 470 #include <sys/types.h> 433 471 434 /* Define to `int' if <sys/types.h> doesn't define. */472 /* Define to 'int' if <sys/types.h> doesn't define. */ 435 473 #define gid_t int 436 474 437 /* Define to `int' if <sys/types.h> does not define. */475 /* Define to 'int' if <sys/types.h> does not define. */ 438 476 /* GCC 4.x reportedly defines pid_t. */ 439 477 #ifndef _PID_T_ … … 445 483 #endif 446 484 447 /* Define to `int' if <sys/types.h> doesn't define. */485 /* Define to 'int' if <sys/types.h> doesn't define. */ 448 486 #define uid_t int 449 487 450 488 /* Define uintmax_t if not defined in <stdint.h> or <inttypes.h>. */ 489 #if !HAVE_STDINT_H && !HAVE_INTTYPES_H 451 490 #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 470 492 471 493 /* Define if you have <sys/wait.h> that is POSIX.1 compatible. */ 472 494 /* #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 array478 tzname. */479 #undef HAVE_TZNAME480 #define HAVE_TZNAME 1481 482 /* Define if utime(file, NULL) sets file's timestamp to the present. */483 #undef HAVE_UTIME_NULL484 #define HAVE_UTIME_NULL 1485 495 486 496 /* 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 1 ar-lib 6 2 compile 3 config.guess 4 config.rpath 5 config.sub 7 6 depcomp 8 7 install-sh 8 mdate-sh 9 9 missing 10 11 Makefile Makefile.in 10 texinfo.tex 11 *.m4 12 !dospaths.m4 -
Property svn:eol-style
set to
-
vendor/gnumake/current/config/ChangeLog.1
r3137 r3138 1 2012-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 1 6 2006-03-09 Paul Smith <psmith@gnu.org> 2 7 … … 30 35 31 36 32 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software 33 Foundation, Inc. 37 Copyright (C) 2002-2016 Free Software Foundation, Inc. 34 38 This file is part of GNU Make. 35 39 -
vendor/gnumake/current/config/Makefile.am
r2596 r3138 1 1 # -*-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. 4 3 # This file is part of GNU Make. 5 4 # … … 17 16 # this program. If not, see <http://www.gnu.org/licenses/>. 18 17 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 2 2 # By Paul Smith <psmith@gnu.org>. Based on dos.m4 by Jim Meyering. 3 3 # 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. 6 5 # This file is part of GNU Make. 7 6 # … … 19 18 # this program. If not, see <http://www.gnu.org/licenses/>. 20 19 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([ 20 AC_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([[ 26 23 #if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __EMX__ && !defined __MSYS__ && !defined __CYGWIN__ 27 24 neither MSDOS nor Windows nor OS2 28 25 #endif 29 ] ,26 ]])], 30 27 [ac_cv_dos_paths=yes], 31 [ac_cv_dos_paths=no]) 32 ]) 28 [ac_cv_dos_paths=no])]) 33 29 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 1 1 /* configh.dos -- hand-massaged config.h file for MS-DOS builds -*-C-*- 2 2 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. 3 Copyright (C) 1994-2016 Free Software Foundation, Inc. 5 4 This file is part of GNU Make. 6 5 … … 26 25 #if __DJGPP__ > 2 || __DJGPP_MINOR__ > 1 27 26 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>. */ 29 28 # define SYS_SIGLIST_DECLARED 1 30 29 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'. */ 32 31 # define HAVE_DECL_SYS_SIGLIST 1 33 32 … … 42 41 #define FILE_TIMESTAMP_HI_RES 0 43 42 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. */ 45 44 #define HAVE_ALLOCA 1 46 45 … … 48 47 #define HAVE_FDOPEN 1 49 48 50 /* Define to 1 if you have the `getgroups' function. */49 /* Define to 1 if you have the 'getgroups' function. */ 51 50 #define HAVE_GETGROUPS 1 52 51 … … 57 56 #define HAVE_MKSTEMP 1 58 57 59 /* Define to 1 if you have the `mktemp' function. */58 /* Define to 1 if you have the 'mktemp' function. */ 60 59 #define HAVE_MKTEMP 1 61 60 62 /* Define to 1 if you have the `setlinebuf' function. */61 /* Define to 1 if you have the 'setlinebuf' function. */ 63 62 #define HAVE_SETLINEBUF 1 64 63 65 /* Define to 1 if you have the `setvbuf' function. */64 /* Define to 1 if you have the 'setvbuf' function. */ 66 65 #define HAVE_SETVBUF 1 67 66 68 67 #define SCCS_GET "get" 69 68 70 /* Define to `unsigned long' or `unsigned long long'69 /* Define to 'unsigned long' or 'unsigned long long' 71 70 if <inttypes.h> doesn't define. */ 72 71 #define uintmax_t unsigned long long … … 78 77 #define HAVE_SELECT 1 79 78 80 /* Define to 1 if your compiler conforms to the ANSI C standard. */81 #define HAVE_ANSI_COMPILER 182 83 /* Define to 1 if you have the <stdarg.h> header file. */84 #define HAVE_STDARG_H 185 86 /* Define to 1 if you have the vprintf library function. */87 #undef HAVE_VPRINTF88 #define HAVE_VPRINTF 189 90 79 /* Define to 1 if you have the stricmp function. */ 91 80 #define HAVE_STRICMP 1 81 82 /* Define to 1 if you have the 'strncasecmp' function. */ 83 #define HAVE_STRNCASECMP 1 92 84 93 85 /* Name of the package */ … … 109 101 #define PACKAGE_VERSION "%VERSION%" 110 102 111 /* Define to 1 if the C compiler supports function prototypes.*/112 #define PROTOTYPES 1103 /* Output sync sypport */ 104 #define NO_OUTPUT_SYNC 113 105 114 106 /* Version number of package */ -
vendor/gnumake/current/configure.bat
r2596 r3138 1 1 @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. 2 rem Copyright (C) 1994-2016 Free Software Foundation, Inc. 4 3 rem This file is part of GNU Make. 5 4 rem -
vendor/gnumake/current/debug.h
r2596 r3138 1 1 /* Debugging macros and interface. 2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 3 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 1999-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 -
vendor/gnumake/current/default.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make.h" 17 #include "makeint.h" 18 19 #include <assert.h> 20 20 21 #include "filedef.h" 21 22 #include "variable.h" … … 33 34 34 35 /* This is the default list of suffixes for suffix rules. 35 `.s' must come last, so that a `.o' file will be made from36 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. */ 37 38 38 39 static char default_suffixes[] 39 40 #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"; 43 46 #elif defined(__EMX__) 44 47 = ".out .a .ln .o .c .cc .C .cpp .p .f .F .m .r .y .l .ym .yl .s .S \ … … 53 56 static struct pspec default_pattern_rules[] = 54 57 { 58 #ifdef VMS 55 59 { "(%)", "%", 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 58 76 /* The X.out rules are only in BSD's default set because 59 BSD Make has no null-suffix rules, so `foo.out' and60 `foo' are the same thing. */77 BSD Make has no null-suffix rules, so 'foo.out' and 78 'foo' are the same thing. */ 61 79 #ifdef VMS 62 80 { "%.exe", "%", 63 "copy $< $@" }, 64 #else 81 "$(CP) $< $@" }, 82 83 #endif 65 84 { "%.out", "%", 66 67 #endif 85 "@rm -f $@ \n cp $< $@" }, 86 68 87 /* Syntax is "ctangle foo.w foo.ch foo.c". */ 69 88 { "%.c", "%.w %.ch", 70 89 "$(CTANGLE) $^ $@" }, 71 90 { "%.tex", "%.w %.ch", 72 91 "$(CWEAVE) $^ $@" }, 73 92 74 93 { 0, 0, 0 } … … 78 97 { 79 98 #ifdef VMS 99 80 100 /* RCS. */ 81 101 { "%", "%$$5lv", /* Multinet style */ 82 "if f$$search( $@) .nes. \"\" then +$(CHECKOUT,v)" },102 "if f$$search(\"$@\") .nes. \"\" then +$(CHECKOUT,v)" }, 83 103 { "%", "[.$$rcs]%$$5lv", /* Multinet style */ 84 "if f$$search( $@) .nes. \"\" then +$(CHECKOUT,v)" },104 "if f$$search(\"$@\") .nes. \"\" then +$(CHECKOUT,v)" }, 85 105 { "%", "%_v", /* Normal style */ 86 "if f$$search( $@) .nes. \"\" then +$(CHECKOUT,v)" },106 "if f$$search(\"$@\") .nes. \"\" then +$(CHECKOUT,v)" }, 87 107 { "%", "[.rcs]%_v", /* Normal style */ 88 "if f$$search( $@) .nes. \"\" then +$(CHECKOUT,v)" },108 "if f$$search(\"$@\") .nes. \"\" then +$(CHECKOUT,v)" }, 89 109 90 110 /* SCCS. */ 91 /* ain't no SCCS on vms */ 111 /* ain't no SCCS on vms */ 112 92 113 #else 93 114 /* RCS. */ 94 115 { "%", "%,v", 95 116 "$(CHECKOUT,v)" }, 96 117 { "%", "RCS/%,v", 97 118 "$(CHECKOUT,v)" }, 98 119 { "%", "RCS/%", 99 120 "$(CHECKOUT,v)" }, 100 121 101 122 /* SCCS. */ 102 123 { "%", "s.%", 103 124 "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" }, 104 125 { "%", "SCCS/s.%", 105 126 "$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" }, 106 127 #endif /* !VMS */ 107 128 { 0, 0, 0 } 108 129 }; 109 130 110 static c har *default_suffix_rules[] =131 static const char *default_suffix_rules[] = 111 132 { 112 133 #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 113 169 ".obj.exe", 114 170 "$(LINK.obj) $^ $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@", 115 171 ".mar.exe", 116 172 "$(COMPILE.mar) $^ \n $(LINK.obj) $(subst .mar,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@", 173 ".s.o", 174 "$(COMPILE.s) -o $@ $<", 117 175 ".s.exe", 118 176 "$(COMPILE.s) $^ \n $(LINK.obj) $(subst .s,.obj,$^) $(LOADLIBES) $(LDLIBS) $(CRT0) /exe=$@", … … 149 207 ".c.obj", 150 208 "$(COMPILE.c) /obj=$@ $<", 209 ".c.o", 210 "$(COMPILE.c) /obj=$@ $<", 151 211 ".cc.ii", 152 212 "$(COMPILE.cc)/prep /list=$@ $<", … … 157 217 ".cc.obj", 158 218 "$(COMPILE.cc) /obj=$@ $<", 219 ".cc.o", 220 "$(COMPILE.cc) /obj=$@ $<", 159 221 ".cxx.obj", 222 "$(COMPILE.cxx) /obj=$@ $<", 223 ".cxx.o", 160 224 "$(COMPILE.cxx) /obj=$@ $<", 161 225 ".for.obj", 162 226 "$(COMPILE.for) /obj=$@ $<", 227 ".for.o", 228 "$(COMPILE.for) /obj=$@ $<", 163 229 ".pas.obj", 230 "$(COMPILE.pas) /obj=$@ $<", 231 ".pas.o", 164 232 "$(COMPILE.pas) /obj=$@ $<", 165 233 … … 174 242 ".tex.dvi", 175 243 "$(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", 176 265 177 266 #else /* ! VMS */ … … 294 383 295 384 ".w.c", 296 "$(CTANGLE) $< - $@", /* The `-' says there is no `.ch' file. */385 "$(CTANGLE) $< - $@", /* The '-' says there is no '.ch' file. */ 297 386 298 387 ".web.p", … … 300 389 301 390 ".w.tex", 302 "$(CWEAVE) $< - $@", /* The `-' says there is no `.ch' file. */391 "$(CWEAVE) $< - $@", /* The '-' says there is no '.ch' file. */ 303 392 304 393 ".web.tex", … … 322 411 "ARCH", "VAX", 323 412 #endif 324 "AR", "library/obj", 413 "AR", "library", 414 "LIBRARY", "library", 325 415 "ARFLAGS", "/replace", 326 416 "AS", "macro", … … 332 422 #endif 333 423 "CD", "builtin_cd", 334 "MAKE", "make", 335 "ECHO", "write sys$$output \"", 424 "ECHO", "builtin_echo", 336 425 #ifdef GCC_IS_NATIVE 337 426 "C++", "gcc/plus", … … 340 429 "C++", "cxx", 341 430 "CXX", "cxx", 431 #ifndef __ia64 342 432 "CXXLD", "cxxlink", 433 "CXXLINK", "cxxlink", 434 #else 435 /* CXXLINK is not used on VMS/IA64 */ 436 "CXXLD", "link", 437 "CXXLINK", "link", 438 #endif 343 439 #endif 344 440 "CO", "co", … … 376 472 #endif 377 473 474 "LINK.o", "$(LD) $(LDFLAGS)", 378 475 "LINK.obj", "$(LD) $(LDFLAGS)", 379 476 #ifndef GCC_IS_NATIVE … … 382 479 #endif 383 480 "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)", 384 484 "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)", 385 489 "YACC.y", "$(YACC) $(YFLAGS)", 386 490 "LEX.l", "$(LEX) $(LFLAGS)", 491 "YACC.m", "$(YACC) $(YFLAGS)", 492 "LEX.m", "$(LEX) $(LFLAGS) -t", 387 493 "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)", 388 500 "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)", 389 505 "COMPILE.mar", "$(MACRO) $(MACROFLAGS)", 390 506 "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", 391 512 "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)", 392 513 393 514 "MV", "rename/new_version", 394 515 "CP", "copy", 516 ".LIBPATTERNS", "%.olb lib%.a", 395 517 396 518 #else /* !VMS */ … … 402 524 "CC", "gcc", 403 525 # ifdef __MSDOS__ 404 "CXX", "gpp", 526 "CXX", "gpp", /* g++ is an invalid name on MSDOS */ 405 527 # else 406 528 "CXX", "gcc", … … 420 542 421 543 "CPP", "$(CC) -E", 422 #ifdef 544 #ifdef CRAY 423 545 "CF77PPFLAGS", "-P", 424 546 "CF77PP", "/lib/cpp", … … 426 548 "CF", "cf77", 427 549 "FC", "$(CF)", 428 #else 429 #ifdef 550 #else /* Not CRAY. */ 551 #ifdef _IBMR2 430 552 "FC", "xlf", 431 553 #else 432 #ifdef 554 #ifdef __convex__ 433 555 "FC", "fc", 434 556 #else … … 440 562 "F77", "$(FC)", 441 563 "F77FLAGS", "$(FFLAGS)", 442 #endif 564 #endif /* Cray. */ 443 565 "GET", SCCS_GET, 444 566 "LD", "ld", … … 450 572 "LINT", "lint", 451 573 "M2C", "m2c", 452 #ifdef 574 #ifdef pyr 453 575 "PC", "pascal", 454 576 #else 455 #ifdef 577 #ifdef CRAY 456 578 "PC", "PASCAL", 457 579 "SEGLDR", "segldr", 458 580 #else 459 581 "PC", "pc", 460 #endif 461 #endif 582 #endif /* CRAY. */ 583 #endif /* pyr. */ 462 584 #ifdef GCC_IS_NATIVE 463 585 "YACC", "bison -y", 464 586 #else 465 "YACC", "yacc", 587 "YACC", "yacc", /* Or "bison -y" */ 466 588 #endif 467 589 "MAKEINFO", "makeinfo", … … 481 603 "LINK.m", "$(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)", 482 604 "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. */ 483 609 "COMPILE.C", "$(COMPILE.cc)", 610 #else 611 "COMPILE.C", "$(COMPILE.c)", 612 #endif 484 613 "COMPILE.cpp", "$(COMPILE.cc)", 485 614 "LINK.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)", 615 #ifndef HAVE_CASE_INSENSITIVE_FS 486 616 "LINK.C", "$(LINK.cc)", 617 #else 618 "LINK.C", "$(LINK.c)", 619 #endif 487 620 "LINK.cpp", "$(LINK.cc)", 488 621 "YACC.y", "$(YACC) $(YFLAGS)", … … 509 642 "LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)", 510 643 511 #ifndef 644 #ifndef NO_MINUS_C_MINUS_O 512 645 "OUTPUT_OPTION", "-o $@", 513 646 #endif 514 647 515 #ifdef 648 #ifdef SCCS_GET_MINUS_G 516 649 "SCCS_OUTPUT_OPTION", "-G$@", 517 650 #endif 518 651 519 #if def _AMIGA652 #if defined(_AMIGA) 520 653 ".LIBPATTERNS", "%.lib", 521 #else 522 #ifdef __MSDOS__ 654 #elif defined(__MSDOS__) 523 655 ".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", 524 660 #else 525 661 ".LIBPATTERNS", "lib%.so lib%.a", 526 662 #endif 527 #endif528 663 529 664 #endif /* !VMS */ 665 /* Make this assignment to avoid undefined variable warnings. */ 666 "GNUMAKEFLAGS", "", 530 667 0, 0 531 668 }; … … 538 675 { 539 676 suffix_file = enter_file (strcache_add (".SUFFIXES")); 677 suffix_file->builtin = 1; 540 678 541 679 if (no_builtin_rules_flag) … … 543 681 else 544 682 { 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 549 690 define_variable_cname ("SUFFIXES", default_suffixes, o_default, 0); 550 691 } … … 559 700 install_default_suffix_rules (void) 560 701 { 561 c har **s;702 const char **s; 562 703 563 704 if (no_builtin_rules_flag) … … 567 708 { 568 709 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; 577 718 } 578 719 } … … 607 748 define_variable (s[0], strlen (s[0]), s[1], o_default, 1); 608 749 } 750 751 void 752 undefine_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 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 /* Flag bits for the second argument to `read_makefile'.20 These flags are saved in the `changed' field of each21 `struct dep' in the chain returned by `read_all_makefiles'. */22 17 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 24 struct 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 28 38 29 39 /* 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. */ 33 42 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 35 52 36 53 struct dep 37 54 { 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); 47 56 }; 48 57 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. */ 49 61 50 /* Structure used in chains of names, for parsing and globbing. */ 51 52 struct nameseq 62 struct goaldep 53 63 { 54 struct nameseq *next; 55 const char *name; 64 DEP (struct goaldep); 65 unsigned short error; 66 floc floc; 56 67 }; 57 68 69 /* Options for parsing lists of filenames. */ 58 70 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 65 77 66 78 #define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \ 67 79 (_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) 68 82 69 83 #ifdef VMS … … 71 85 #else 72 86 void *parse_file_seq (char **stringp, unsigned int size, 73 int stop char, const char *prefix, int flags);87 int stopmap, const char *prefix, int flags); 74 88 #endif 75 89 … … 80 94 #endif 81 95 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) 83 97 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)) 99 void 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 104 SI struct nameseq *alloc_ns() { return alloc_seq_elt (struct nameseq); } 105 SI struct dep *alloc_dep() { return alloc_seq_elt (struct dep); } 106 SI struct goaldep *alloc_goaldep() { return alloc_seq_elt (struct goaldep); } 107 108 SI void free_ns(struct nameseq *n) { free (n); } 109 SI void free_dep(struct dep *d) { free_ns ((struct nameseq *)d); } 110 SI void free_goaldep(struct goaldep *g) { free_dep ((struct dep *)g); } 111 112 SI void free_dep_chain(struct dep *d) { free_ns_chain((struct nameseq *)d); } 113 SI 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 87 126 88 127 struct 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 129 struct goaldep *read_all_makefiles (const char **makefiles); 130 void eval_buffer (char *buffer, const floc *floc); 131 enum update_status update_goal_chain (struct goaldep *goals); -
vendor/gnumake/current/dir.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 #include "hash.h" 21 22 #ifdef HAVE_DIRENT_H 19 #include "filedef.h" 20 #include "dep.h" 21 22 #ifdef HAVE_DIRENT_H 23 23 # include <dirent.h> 24 24 # define NAMLEN(dirent) strlen((dirent)->d_name) … … 88 88 89 89 /* 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) 91 91 *df++ = tolower ((unsigned char)*filename++); 92 92 93 93 /* Now skip to the next dot. */ 94 while ( *filename != '\0' && *filename != '.')94 while (! STOP_SET (*filename, MAP_DOT|MAP_NUL)) 95 95 ++filename; 96 96 if (*filename != '\0') 97 97 { 98 98 *df++ = *filename++; 99 for (i = 0; *filename != '\0' && i < 3 && *filename != '.'; ++i)100 99 for (i = 0; i < 3 && ! STOP_SET (*filename, MAP_DOT|MAP_NUL); ++i) 100 *df++ = tolower ((unsigned char)*filename++); 101 101 } 102 102 103 103 /* Look for more dots. */ 104 while ( *filename != '\0' && *filename != '.')104 while (! STOP_SET (*filename, MAP_DOT|MAP_NUL)) 105 105 ++filename; 106 106 if (*filename == '.') … … 144 144 #ifdef VMS 145 145 146 static char * 147 downcase_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 146 172 static int 147 173 vms_hash (const char *name) 148 174 { 149 175 int h = 0; 150 int g;151 176 152 177 while (*name) 153 178 { 154 179 unsigned char uc = *name; 180 int g; 155 181 #ifdef HAVE_CASE_INSENSITIVE_FS 156 182 h = (h << 4) + (isupper (uc) ? tolower (uc) : uc); … … 161 187 g = h & 0xf0000000; 162 188 if (g) 163 164 165 166 189 { 190 h = h ^ (g >> 24); 191 h = h ^ g; 192 } 167 193 } 168 194 return h; … … 181 207 return -1; 182 208 closedir (dir); 183 s = strchr (name, ':'); 209 s = strchr (name, ':'); /* find device */ 184 210 if (s) 185 211 { … … 202 228 return 0; 203 229 } 230 231 # define stat(__path, __sbuf) vmsstat_dir (__path, __sbuf) 232 233 #endif /* _USE_STD_STAT */ 204 234 #endif /* VMS */ 205 235 … … 207 237 /* Hash table of directories. */ 208 238 209 #ifndef 239 #ifndef DIRECTORY_BUCKETS 210 240 #define DIRECTORY_BUCKETS 199 211 241 #endif … … 213 243 struct directory_contents 214 244 { 215 dev_t dev; 245 dev_t dev; /* Device and inode numbers of this dir. */ 216 246 #ifdef WINDOWS32 217 247 /* Inode means nothing on WINDOWS32. Even file key information is … … 221 251 * unreliable. I'm open to suggestion on a better way to emulate inode. */ 222 252 char *path_key; 223 intctime;224 intmtime; /* controls check for stale directory cache */225 int 253 time_t ctime; 254 time_t mtime; /* controls check for stale directory cache */ 255 int fs_flags; /* FS_FAT, FS_NTFS, ... */ 226 256 # define FS_FAT 0x1 227 257 # define FS_NTFS 0x2 228 258 # define FS_UNKNOWN 0x4 229 259 #else 230 # ifdef VMS 260 # ifdef VMS_INO_T 231 261 ino_t ino[3]; 232 262 # else … … 234 264 # endif 235 265 #endif /* WINDOWS32 */ 236 struct hash_table dirfiles; 237 DIR *dirstream; 266 struct hash_table dirfiles; /* Files in this directory. */ 267 DIR *dirstream; /* Stream reading this directory. */ 238 268 }; 239 269 … … 249 279 hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) key->ctime; 250 280 #else 251 # ifdef VMS 281 # ifdef VMS_INO_T 252 282 hash = (((unsigned int) key->dev << 4) 253 254 255 283 ^ ((unsigned int) key->ino[0] 284 + (unsigned int) key->ino[1] 285 + (unsigned int) key->ino[2])); 256 286 # else 257 287 hash = ((unsigned int) key->dev << 4) ^ (unsigned int) key->ino; … … 272 302 hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) ~key->ctime; 273 303 #else 274 # ifdef VMS 304 # ifdef VMS_INO_T 275 305 hash = (((unsigned int) key->dev << 4) 276 277 278 306 ^ ~((unsigned int) key->ino[0] 307 + (unsigned int) key->ino[1] 308 + (unsigned int) key->ino[2])); 279 309 # else 280 310 hash = ((unsigned int) key->dev << 4) ^ (unsigned int) ~key->ino; … … 311 341 return result; 312 342 #else 313 # ifdef VMS 343 # ifdef VMS_INO_T 314 344 result = MAKECMP(x->ino[0], y->ino[0]); 315 345 if (result) … … 336 366 struct directory 337 367 { 338 const char *name; 368 const char *name; /* Name of the directory. */ 339 369 340 370 /* The directory's contents. This data may be shared by several 341 371 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. */ 343 373 struct directory_contents *contents; 344 374 }; … … 360 390 { 361 391 return_ISTRING_COMPARE (((const struct directory *) x)->name, 362 392 ((const struct directory *) y)->name); 363 393 } 364 394 … … 377 407 struct dirfile 378 408 { 379 const char *name; 380 s hort length;381 short impossible; 409 const char *name; /* Name of the file. */ 410 size_t length; 411 short impossible; /* This file is impossible. */ 382 412 }; 383 413 … … 405 435 } 406 436 407 #ifndef 437 #ifndef DIRFILE_BUCKETS 408 438 #define DIRFILE_BUCKETS 107 409 439 #endif … … 414 444 static struct directory *find_directory (const char *name); 415 445 416 /* Find the directory named NAME and return its `struct directory'. */446 /* Find the directory named NAME and return its 'struct directory'. */ 417 447 418 448 static struct directory * 419 449 find_directory (const char *name) 420 450 { 421 const char *p;422 451 struct directory *dir; 423 452 struct directory **dir_slot; 424 453 struct directory dir_key; 425 int r;426 #ifdef WINDOWS32427 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 #endif434 #ifdef VMS435 if ((*name == '.') && (*(name+1) == 0))436 name = "[]";437 else438 name = vmsify (name,1);439 #endif440 454 441 455 dir_key.name = name; … … 445 459 if (HASH_VACANT (dir)) 446 460 { 461 /* The directory was not found. Create a new entry for it. */ 462 const char *p = name + strlen (name); 447 463 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 452 466 dir = xmalloc (sizeof (struct directory)); 453 467 #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 } 455 474 #else 456 475 dir->name = strcache_add_len (name, p - name); … … 458 477 hash_insert_at (&directories, dir, dir_slot); 459 478 /* 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) 465 482 { 466 483 char tem[MAXPATHLEN], *tstart, *tend; … … 485 502 if (r < 0) 486 503 { 487 488 setting the `contents' member to a nil pointer. */489 490 504 /* Couldn't stat the directory. Mark this by 505 setting the 'contents' member to a nil pointer. */ 506 dir->contents = 0; 507 } 491 508 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]; 508 528 # else 509 529 dc_key.ino = st.st_ino; 510 530 # endif 511 531 #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; 524 550 #ifdef WINDOWS32 525 551 dc->path_key = xstrdup (w32_path); 526 552 dc->ctime = st.st_ctime; 527 553 dc->mtime = st.st_mtime; 528 554 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. */ 534 557 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) 539 561 dc->fs_flags = FS_UNKNOWN; 540 else if (!strcmp (fs_type, "FAT"))562 else if (!strcmp (fs_type, "FAT")) 541 563 dc->fs_flags = FS_FAT; 542 else if (!strcmp (fs_type, "NTFS"))564 else if (!strcmp (fs_type, "NTFS")) 543 565 dc->fs_flags = FS_NTFS; 544 566 else 545 567 dc->fs_flags = FS_UNKNOWN; 546 568 #else 547 # ifdef VMS 548 549 550 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]; 551 573 # else 552 574 dc->ino = st.st_ino; 553 575 # endif 554 576 #endif /* WINDOWS32 */ 555 556 557 577 hash_insert_at (&directory_contents, dc, dc_slot); 578 ENULLLOOP (dc->dirstream, opendir (name)); 579 if (dc->dirstream == 0) 558 580 /* Couldn't open the directory. Mark this by setting the 559 `files' member to a nil pointer. */581 'files' member to a nil pointer. */ 560 582 dc->dirfiles.ht_vec = 0; 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 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 } 577 599 } 578 600 … … 588 610 const char *filename) 589 611 { 590 unsigned int hash;591 612 struct dirfile *df; 592 613 struct dirent *d; … … 612 633 _fnlwr (filename); /* lower case for FAT drives */ 613 634 #endif 614 615 #ifdef VMS616 filename = vmsify (filename,0);617 #endif618 619 hash = 0;620 635 if (filename != 0) 621 636 { … … 623 638 624 639 if (*filename == '\0') 625 626 627 628 640 { 641 /* Checking if the directory exists. */ 642 return 1; 643 } 629 644 dirfile_key.name = filename; 630 645 dirfile_key.length = strlen (filename); … … 646 661 */ 647 662 if (dir->path_key) 648 663 { 649 664 if ((dir->fs_flags & FS_FAT) != 0) 650 651 652 653 654 655 656 657 658 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 } 660 675 661 676 /* If it has been already read in, all done. */ 662 663 677 if (!rehash) 678 return 0; 664 679 665 680 /* make sure directory can still be opened; if not return. */ … … 667 682 if (!dir->dirstream) 668 683 return 0; 669 684 } 670 685 else 671 686 #endif 672 673 687 /* The directory has been all read in. */ 688 return 0; 674 689 } 675 690 … … 685 700 { 686 701 if (errno) 687 fatal (NILF, "INTERNAL: readdir: %s\n", strerror (errno));702 pfatal_with_name ("INTERNAL: readdir"); 688 703 break; 689 704 } 690 705 691 706 #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. */ 693 710 { 694 711 char *p = strrchr (d->d_name, ';'); … … 698 715 #endif 699 716 if (!REAL_DIR_ENTRY (d)) 700 717 continue; 701 718 702 719 len = NAMLEN (d); … … 711 728 if (! rehash || HASH_VACANT (*dirfile_slot)) 712 729 #endif 713 714 730 { 731 df = xmalloc (sizeof (struct dirfile)); 715 732 #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 } 724 742 /* Check if the name matches the one we're searching for. */ 725 743 if (filename != 0 && patheq (d->d_name, filename)) … … 745 763 dir_file_exists_p (const char *dirname, const char *filename) 746 764 { 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 747 774 return dir_contents_file_exists_p (find_directory (dirname)->contents, 748 775 filename); 749 776 } 750 777 … … 759 786 const char *slash; 760 787 761 #ifndef 788 #ifndef NO_ARCHIVES 762 789 if (ar_name (name)) 763 790 return ar_member_date (name) != (time_t) -1; 764 791 #endif 765 792 793 dirend = strrchr (name, '/'); 766 794 #ifdef VMS 767 dirend = strrchr (name, ']');768 795 if (dirend == 0) 769 dirend = strrchr (name, ':'); 796 { 797 dirend = strrchr (name, ']'); 798 dirend == NULL ? dirend : dirend++; 799 } 770 800 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 */ 774 811 #ifdef HAVE_DOS_PATHS 775 812 /* Forward and backslashes might be mixed. We need the rightmost one. */ 776 813 { 777 const char *bslash = strrchr (name, '\\');814 const char *bslash = strrchr (name, '\\'); 778 815 if (!dirend || bslash > dirend) 779 816 dirend = bslash; … … 786 823 #ifndef _AMIGA 787 824 return dir_file_exists_p (".", name); 788 #else /* ! VMS && !AMIGA */825 #else /* !AMIGA */ 789 826 return dir_file_exists_p ("", name); 790 827 #endif /* AMIGA */ 791 #endif /* VMS */792 828 793 829 slash = dirend; … … 800 836 /* d:/ and d: are *very* different... */ 801 837 if (dirend < name + 3 && name[1] == ':' && 802 803 838 (*dirend == '/' || *dirend == '\\' || *dirend == ':')) 839 dirend++; 804 840 #endif 805 841 p = alloca (dirend - name + 1); … … 808 844 dirname = p; 809 845 } 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'. 815 857 This means an attempt has been made to search for FILENAME 816 858 as an intermediate file, and it has failed. */ … … 824 866 struct dirfile *new; 825 867 868 dirend = strrchr (p, '/'); 826 869 #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 836 887 /* Forward and backslashes might be mixed. We need the rightmost one. */ 837 888 { 838 const char *bslash = strrchr (p, '\\');889 const char *bslash = strrchr (p, '\\'); 839 890 if (!dirend || bslash > dirend) 840 891 dirend = bslash; … … 843 894 dirend = p + 1; 844 895 } 845 # 896 #endif /* HAVE_DOS_PATHS */ 846 897 if (dirend == 0) 847 # 898 #ifdef _AMIGA 848 899 dir = find_directory (""); 849 # else /* !VMS &&!AMIGA */900 #else /* !AMIGA */ 850 901 dir = find_directory ("."); 851 # endif /* AMIGA */ 852 #endif /* VMS */ 902 #endif /* AMIGA */ 853 903 else 854 904 { … … 856 906 const char *slash = dirend; 857 907 if (dirend == p) 858 908 dirname = "/"; 859 909 else 860 910 { 861 911 char *cp; 862 912 #ifdef HAVE_DOS_PATHS 863 864 865 866 867 #endif 868 869 870 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'; 871 921 dirname = cp; 872 922 } 873 923 dir = find_directory (dirname); 924 #ifdef VMS 925 if (*slash == '/') 926 filename = p = slash + 1; 927 else 928 filename = p = slash; 929 #else 874 930 filename = p = slash + 1; 931 #endif 875 932 } 876 933 … … 883 940 { 884 941 hash_init (&dir->contents->dirfiles, DIRFILE_BUCKETS, 885 942 dirfile_hash_1, dirfile_hash_2, dirfile_hash_cmp); 886 943 } 887 944 … … 891 948 new->length = strlen (filename); 892 949 #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); 894 952 #else 895 953 new->name = strcache_add_len (filename, new->length); … … 906 964 { 907 965 const char *dirend; 908 const char *p = filename;909 966 struct directory_contents *dir; 910 967 struct dirfile *dirfile; 911 968 struct dirfile dirfile_key; 912 913 969 #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 918 973 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 919 985 #ifdef HAVE_DOS_PATHS 920 986 /* Forward and backslashes might be mixed. We need the rightmost one. */ 921 987 { 922 const char *bslash = strrchr (filename, '\\');988 const char *bslash = strrchr (filename, '\\'); 923 989 if (!dirend || bslash > dirend) 924 990 dirend = bslash; … … 931 997 #ifdef _AMIGA 932 998 dir = find_directory ("")->contents; 933 #else /* ! VMS && !AMIGA */999 #else /* !AMIGA */ 934 1000 dir = find_directory (".")->contents; 935 1001 #endif /* AMIGA */ 936 #endif /* VMS */937 1002 else 938 1003 { … … 940 1005 const char *slash = dirend; 941 1006 if (dirend == filename) 942 1007 dirname = "/"; 943 1008 else 944 1009 { 945 1010 char *cp; 946 1011 #ifdef HAVE_DOS_PATHS 947 948 949 950 951 #endif 952 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'; 955 1020 dirname = cp; 956 1021 } 957 1022 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 959 1031 } 960 1032 … … 964 1036 965 1037 #ifdef __MSDOS__ 966 filename = dosify ( p);1038 filename = dosify (filename); 967 1039 #endif 968 1040 #ifdef HAVE_CASE_INSENSITIVE_FS 969 filename = downcase ( p);1041 filename = downcase (filename); 970 1042 #endif 971 1043 #ifdef VMS 972 filename = vmsify (p, 1); 1044 if (want_vmsify) 1045 filename = vmsify (filename, 1); 973 1046 #endif 974 1047 … … 1013 1086 struct directory *dir = *dir_slot; 1014 1087 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); 1023 1097 #else /* WINDOWS32 */ 1024 #ifdef VMS 1025 1026 1027 1028 1029 #else 1030 1031 1032 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); 1033 1107 #endif 1034 1108 #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); 1059 1134 #else /* WINDOWS32 */ 1060 #ifdef VMS 1061 1062 1063 1064 1065 #else 1066 1067 1068 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); 1069 1144 #endif 1070 1145 #endif /* WINDOWS32 */ 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 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 } 1089 1164 } 1090 1165 … … 1105 1180 /* Hooks for globbing. */ 1106 1181 1107 #include <glob.h>1108 1109 1182 /* Structure describing state of iterating through a directory hash table. */ 1110 1183 … … 1156 1229 struct dirfile *df = *ds->dirfile_slot++; 1157 1230 if (! HASH_VACANT (df) && !df->impossible) 1158 1159 /* The glob interface wants a `struct dirent', so mock one up. */1160 1161 1231 { 1232 /* The glob interface wants a 'struct dirent', so mock one up. */ 1233 struct dirent *d; 1234 unsigned int len = df->length + 1; 1162 1235 unsigned int sz = sizeof (*d) - sizeof (d->d_name) + len; 1163 1164 1165 1166 1167 1168 1169 1170 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; 1171 1244 #ifdef __MINGW32__ 1172 1245 # if __MINGW32_MAJOR_VERSION < 3 || (__MINGW32_MAJOR_VERSION == 3 && \ 1173 1174 d->d_name = xmalloc(len);1246 __MINGW32_MINOR_VERSION == 0) 1247 d->d_name = xmalloc (len); 1175 1248 # endif 1176 1249 #endif 1177 1250 FAKE_DIR_ENTRY (d); 1178 1251 #ifdef _DIRENT_HAVE_D_NAMLEN 1179 1252 d->d_namlen = len - 1; 1180 1253 #endif 1181 1254 #ifdef _DIRENT_HAVE_D_TYPE 1182 1183 #endif 1184 1185 1186 1255 d->d_type = DT_UNKNOWN; 1256 #endif 1257 memcpy (d->d_name, df->name, len); 1258 return d; 1259 } 1187 1260 } 1188 1261 1189 1262 return 0; 1190 }1191 1192 static void1193 ansi_free (void *p)1194 {1195 if (p)1196 free(p);1197 1263 } 1198 1264 … … 1200 1266 * macro for stat64(). If stat is a macro, make a local wrapper function to 1201 1267 * invoke it. 1268 * 1269 * On MS-Windows, stat() "succeeds" for foo/bar/. where foo/bar is a 1270 * regular file; fix that here. 1202 1271 */ 1203 #if ndef stat1272 #if !defined(stat) && !defined(WINDOWS32) || defined(VMS) 1204 1273 # ifndef VMS 1274 # ifndef HAVE_SYS_STAT_H 1205 1275 int 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 1206 1282 # endif 1207 1283 # define local_stat stat … … 1211 1287 { 1212 1288 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 1213 1306 1214 1307 EINTRLOOP (e, stat (path, buf)); … … 1222 1315 gl->gl_opendir = open_dirstream; 1223 1316 gl->gl_readdir = read_dirstream; 1224 gl->gl_closedir = ansi_free;1317 gl->gl_closedir = free; 1225 1318 gl->gl_stat = local_stat; 1226 1319 /* We don't bother setting gl_lstat, since glob never calls it. … … 1232 1325 { 1233 1326 hash_init (&directories, DIRECTORY_BUCKETS, 1234 1327 directory_hash_1, directory_hash_2, directory_hash_cmp); 1235 1328 hash_init (&directory_contents, DIRECTORY_BUCKETS, 1236 1329 directory_contents_hash_1, directory_contents_hash_2, 1237 1330 directory_contents_hash_cmp); 1238 1331 } -
vendor/gnumake/current/doc/Makefile.am
r2596 r3138 1 1 # -*-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. 4 3 # This file is part of GNU Make. 5 4 # … … 24 23 25 24 CLEANFILES = make*.html 26 27 ## ----------------------------- ##28 ## Other documentation formats. ##29 ## ----------------------------- ##30 31 html: make_1.html32 33 make_1.html: $(info_TEXINFOS) $(make_TEXINFOS)34 $(TEXI2HTML) $(TEXI2HTML_FLAGS) $(srcdir)/make.texi35 36 .PHONY: html -
vendor/gnumake/current/doc/make.texi
r2596 r3138 4 4 5 5 @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 8 7 9 8 @settitle GNU @code{make} … … 28 27 Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 29 28 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 30 2008, 2009, 2010 Free Software Foundation, Inc. 29 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software 30 Foundation, Inc. 31 31 32 32 @quotation 33 33 Permission is granted to copy, distribute and/or modify this document 34 under the terms of the GNU Free Documentation License, Version 1. 2or34 under the terms of the GNU Free Documentation License, Version 1.3 or 35 35 any later version published by the Free Software Foundation; with no 36 36 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,'' … … 101 101 based on their file names. 102 102 * 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. 103 105 * Features:: Features GNU @code{make} has over other @code{make}s. 104 106 * Missing:: What GNU @code{make} lacks from other @code{make}s. … … 110 112 but nontrivial, makefile. 111 113 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. 115 117 116 118 @detailmenu … … 119 121 Overview of @code{make} 120 122 121 * Preparing:: Preparing and running make122 * 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. 124 126 125 127 An Introduction to Makefiles 126 128 127 129 * 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. 134 136 135 137 Writing Makefiles … … 144 146 * Reading Makefiles:: How makefiles are parsed. 145 147 * Secondary Expansion:: How and when secondary expansion is performed. 148 149 What Makefiles Contain 150 151 * Splitting Lines:: Splitting long lines in makefiles 146 152 147 153 Writing Rules … … 171 177 Using Wildcard Characters in File Names 172 178 173 * Wildcard Examples:: Several examples 179 * Wildcard Examples:: Several examples. 174 180 * Wildcard Pitfall:: Problems to avoid. 175 181 * Wildcard Function:: How to cause wildcard expansion where … … 207 213 Recipe Syntax 208 214 209 * Splitting Lines::Breaking long recipe lines for readability.215 * Splitting Recipe Lines:: Breaking long recipe lines for readability. 210 216 * Variables in Recipes:: Using @code{make} variables in recipes. 211 217 212 218 Recipe Execution 213 219 220 * One Shell:: One shell for all lines in a recipe. 214 221 * Choosing the Shell:: How @code{make} chooses the shell used 215 222 to run recipes. 223 224 Parallel Execution 225 226 * Parallel Output:: Handling output during parallel execution 227 * Parallel Input:: Handling input during parallel execution 216 228 217 229 Recursive Use of @code{make} … … 236 248 * Multi-Line:: An alternate way to set a variable 237 249 to a multi-line string. 250 * Undefine Directive:: How to undefine a variable so that it appears 251 as if it was never set. 238 252 * Environment:: Variable values can come from the environment. 239 253 * Target-specific:: Variable values can be defined on a per-target … … 263 277 * Conditional Functions:: Functions that implement conditions. 264 278 * Foreach Function:: Repeat some text with controlled variation. 279 * File Function:: Write text to a file. 265 280 * Call Function:: Expand a user-defined function. 266 281 * Value Function:: Return the un-expanded value of a variable. … … 268 283 * Origin Function:: Find where a variable got its value. 269 284 * Flavor Function:: Find out the flavor of a variable. 285 * Make Control Functions:: Functions that control how make runs. 270 286 * 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. 272 288 273 289 How to Run @code{make} … … 290 306 291 307 * 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 implicitrules.308 to get the recipes for updating a file. 309 * Catalogue of Rules:: A list of built-in rules. 294 310 * Implicit Variables:: How to change what predefined rules do. 295 311 * Chained Rules:: How to use a chain of implicit rules. … … 325 341 * Archive Symbols:: How to update archive symbol directories. 326 342 343 Extending GNU @code{make} 344 345 * Guile Integration:: Using Guile as an embedded scripting language. 346 * Loading Objects:: Loading dynamic objects as extensions. 347 348 GNU 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 354 Loading 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 361 Integrating GNU @code{make} 362 363 * Job Slots:: Share job slots with GNU @code{make}. 364 * Terminal Output:: Control output to terminals. 365 366 Sharing 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 327 371 @end detailmenu 328 372 @end menu … … 351 395 352 396 @menu 353 * Preparing:: Preparing and Running Make354 * Reading:: On Reading this Text355 * Bugs:: Problems and Bugs397 * Preparing:: Preparing and running @code{make}. 398 * Reading:: On reading this text. 399 * Bugs:: Problems and bugs. 356 400 @end menu 357 401 … … 487 531 @menu 488 532 * Rule Introduction:: What a rule looks like. 489 * Simple Makefile:: A Simple Makefile490 * How Make Works:: How @code{make} Processes This Makefile491 * Variables Simplify:: Variables Make Makefiles Simpler492 * make Deduces:: Letting @code{make} Deduce the Recipes493 * Combine By Prerequisite:: Another Style of Makefile494 * Cleanup:: Rules for Cleaning the Directory533 * 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. 495 539 @end menu 496 540 … … 592 636 593 637 @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. 638 We split each long line into two lines using backslash/newline; this is 639 like using one long line, but is easier to read. @xref{Splitting Lines, 640 , Splitting Long Lines}. 596 641 @cindex continuation lines 597 642 @cindex @code{\} (backslash), for continuation lines … … 1027 1072 @end itemize 1028 1073 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 1084 Makefiles use a ``line-based'' syntax in which the newline character 1085 is special and marks the end of a statement. GNU @code{make} has no 1086 limit on the length of a statement line, up to the amount of memory in 1087 your computer. 1088 1089 However, it is difficult to read lines which are too long to display 1090 without wrapping or scrolling. So, you can format your makefiles for 1091 readability by adding newlines into the middle of a statement: you do 1092 this by escaping the internal newlines with a backslash (@code{\}) 1093 character. Where we need to make a distinction we will refer to 1094 ``physical lines'' as a single line ending with a newline (regardless 1095 of whether it is escaped) and a ``logical line'' being a complete 1096 statement including all escaped newlines up to the first non-escaped 1097 newline. 1098 1099 The way in which backslash/newline combinations are handled depends on 1100 whether the statement is a recipe line or a non-recipe line. Handling 1101 of backslash/newline in a recipe line is discussed later 1102 (@pxref{Splitting Recipe Lines}). 1103 1104 Outside of recipe lines, backslash/newlines are converted into a 1105 single space character. Once that is done, all whitespace around the 1106 backslash/newline is condensed into a single space: this includes all 1107 whitespace preceding the backslash, all whitespace at the beginning of 1108 the line after the backslash/newline, and any consecutive 1109 backslash/newline combinations. 1110 1111 If the @code{.POSIX} special target is defined then backslash/newline 1112 handling is modified slightly to conform to POSIX.2: first, whitespace 1113 preceding a backslash is not removed and second, consecutive 1114 backslash/newlines are not condensed. 1115 1029 1116 @node Makefile Names, Include, Makefile Contents, Makefiles 1030 1117 @section What Name to Give Your Makefile … … 1220 1307 @node Remaking Makefiles, Overriding Makefiles, MAKEFILES Variable, Makefiles 1221 1308 @section How Makefiles Are Remade 1222 1223 1309 @cindex updating makefiles 1224 1310 @cindex remaking makefiles … … 1242 1328 you want to keep @code{make} from performing an implicit rule search 1243 1329 on them, perhaps for efficiency reasons, you can use any normal method 1244 of preventing implicit rule look up to do so. For example, you can1330 of preventing implicit rule look-up to do so. For example, you can 1245 1331 write an explicit rule with the makefile as the target, and an empty 1246 1332 recipe (@pxref{Empty Recipes, ,Using Empty Recipes}). … … 1306 1392 another makefile. You can often use the @samp{include} directive to 1307 1393 include one in the other, and add more targets or variable definitions. 1308 However, it is i llegalfor two makefiles to give different recipes for1394 However, it is invalid for two makefiles to give different recipes for 1309 1395 the same target. But there is another way. 1310 1396 … … 1380 1466 @cindex ?=, expansion 1381 1467 @cindex +=, expansion 1468 @cindex !=, expansion 1382 1469 @cindex define, expansion 1383 1470 … … 1388 1475 @var{immediate} ?= @var{deferred} 1389 1476 @var{immediate} := @var{immediate} 1477 @var{immediate} ::= @var{immediate} 1390 1478 @var{immediate} += @var{deferred} or @var{immediate} 1479 @var{immediate} != @var{immediate} 1391 1480 1392 1481 define @var{immediate} … … 1406 1495 endef 1407 1496 1497 define @var{immediate} ::= 1498 @var{immediate} 1499 endef 1500 1408 1501 define @var{immediate} += 1409 1502 @var{deferred} or @var{immediate} 1410 1503 endef 1504 1505 define @var{immediate} != 1506 @var{immediate} 1507 endef 1411 1508 @end example 1412 1509 1413 1510 For the append operator, @samp{+=}, the right-hand side is considered 1414 1511 immediate if the variable was previously set as a simple variable 1415 (@samp{:=}), and deferred otherwise. 1512 (@samp{:=} or @samp{::=}), and deferred otherwise. 1513 1514 For the shell assignment operator, @samp{!=}, the right-hand side is 1515 evaluated immediately and handed to the shell. The result is stored in the 1516 variable named on the left, and that variable becomes a simple variable 1517 (and will thus be re-evaluated on each reference). 1416 1518 1417 1519 @subheading Conditional Directives … … 1439 1541 @example 1440 1542 @var{immediate} : @var{immediate} ; @var{deferred} 1441 1543 @var{deferred} 1442 1544 @end example 1443 1545 … … 1488 1590 without being recognized as a variable reference. Now during the 1489 1591 secondary expansion the first word is expanded again but since it 1490 contains no variable or function references it remains the static1491 value @file{onefile}, while the second word is now a normal reference1492 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}.1592 contains no variable or function references it remains the value 1593 @file{onefile}, while the second word is now a normal reference to the 1594 variable @var{TWOVAR}, which is expanded to the value @file{twofile}. 1595 The final result is that there are two prerequisites, @file{onefile} 1596 and @file{twofile}. 1495 1597 1496 1598 Obviously, this is not a very interesting case since the same result … … 1634 1736 Search, ,Implicit Rule Search Algorithm}, is appended (after 1635 1737 expansion) to all the patterns in the prerequisites list. As an 1636 example: 1738 example:@refill 1637 1739 1638 1740 @example … … 1642 1744 1643 1745 %.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 1749 The prerequisite list printed, after the secondary expansion and 1750 directory prefix reconstruction, will be @file{/tmp/foo/foo.c 1751 /tmp/bar/foo.c foo.h}. If you are not interested in this 1752 reconstruction, you can use @code{$$*} instead of @code{%} in the 1753 prerequisites list. 1650 1754 1651 1755 @node Rules, Recipes, Makefiles, Top … … 1685 1789 * Directory Search:: Searching other directories for source files. 1686 1790 * Phony Targets:: Using a target that is not a real file's name. 1687 * Force Targets:: You can use a target without recipes1791 * Force Targets:: You can use a target without a recipe 1688 1792 or prerequisites to mark other targets 1689 1793 as phony. … … 1922 2026 1923 2027 @menu 1924 * Wildcard Examples:: Several examples 2028 * Wildcard Examples:: Several examples. 1925 2029 * Wildcard Pitfall:: Problems to avoid. 1926 2030 * Wildcard Function:: How to cause wildcard expansion where … … 2120 2224 for a specified class of names. 2121 2225 * Search Algorithm:: When and how search paths are applied. 2122 * Recipes/Search:: How to write recipes that work together2226 * Recipes/Search:: How to write recipes that work together 2123 2227 with search paths. 2124 2228 * Implicit/Search:: How search paths affect implicit rules. … … 2456 2560 @samp{-l@var{name}} is seen, @code{make} will replace the percent in 2457 2561 each pattern in the list with @var{name} and perform the above directory 2458 searches using each library file name.2562 searches using each library file name. 2459 2563 2460 2564 The default value for @code{.LIBPATTERNS} is @samp{lib%.so lib%.a}, … … 2493 2597 2494 2598 @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} 2599 In this example, the @file{clean} target will not work properly if a 2600 file named @file{clean} is ever created in this directory. Since it 2601 has no prerequisites, @file{clean} would always be considered up to 2602 date and its recipe would not be executed. To avoid this problem you 2603 can explicitly declare the target to be phony by making it a 2604 prerequisite of the special target @code{.PHONY} 2500 2605 (@pxref{Special Targets, ,Special Built-in Target Names}) as follows: 2501 2502 @example2503 .PHONY : clean2504 @end example2505 2506 @noindent2507 Once this is done, @samp{make clean} will run the recipe regardless of2508 whether there is a file named @file{clean}.2509 2510 Since it knows that phony targets do not name actual files that could be2511 remade from other files, @code{make} skips the implicit rule search for2512 phony targets (@pxref{Implicit Rules}). This is why declaring a target2513 phony is good for performance, even if you are not worried about the2514 actual file existing.2515 2516 Thus, you first write the line that states that @code{clean} is a2517 phony target, then you write the rule, like this:2518 2606 2519 2607 @example … … 2525 2613 @end example 2526 2614 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 2616 Once this is done, @samp{make clean} will run the recipe regardless of 2617 whether there is a file named @file{clean}. 2618 2619 Phony targets are also useful in conjunction with recursive 2620 invocations of @code{make} (@pxref{Recursion, ,Recursive Use of @code{make}}). 2621 In this situation the makefile will often contain a variable which 2622 lists a number of sub-directories to be built. A simplistic way to 2623 handle this is to define one rule with a recipe that loops over the 2624 sub-directories, like this: 2533 2625 2534 2626 @example … … 2544 2636 2545 2637 There are problems with this method, however. First, any error 2546 detected in a sub make is ignored by this rule, so it will continue2638 detected in a sub-make is ignored by this rule, so it will continue 2547 2639 to build the rest of the directories even when one fails. This can be 2548 2640 overcome by adding shell commands to note the error and exit, but then … … 2553 2645 one rule. 2554 2646 2555 By declaring the sub directories as phony targets (you must do this as2556 th e subdirectory obviously always exists; otherwise it won't be built)2557 you can remove these problems:2647 By declaring the sub-directories as @code{.PHONY} targets (you must do 2648 this as the sub-directory obviously always exists; otherwise it won't 2649 be built) you can remove these problems: 2558 2650 2559 2651 @example … … 2572 2664 @end example 2573 2665 2574 Here we've also declared that the @file{foo} sub directory cannot be2575 built until after the @file{baz} sub directory is complete; this kind of2666 Here we've also declared that the @file{foo} sub-directory cannot be 2667 built until after the @file{baz} sub-directory is complete; this kind of 2576 2668 relationship declaration is particularly important when attempting 2577 2669 parallel builds. 2670 2671 The 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 2674 about the actual file existing. 2578 2675 2579 2676 A phony target should not be a prerequisite of a real target file; if it … … 2817 2914 is up to date. Unfortunately, some hosts do not provide a way to set a 2818 2915 high resolution file time stamp, so commands like @samp{cp -p} that 2819 explicitly set a file's time stamp must discard its sub second part.2916 explicitly set a file's time stamp must discard its sub-second part. 2820 2917 If a file is created by such a command, you should list it as a 2821 2918 prerequisite of @code{.LOW_RESOLUTION_TIME} so that @command{make} … … 2831 2928 @end example 2832 2929 2833 Since @samp{cp -p} discards the sub second part of @file{src}'s time2930 Since @samp{cp -p} discards the sub-second part of @file{src}'s time 2834 2931 stamp, @file{dst} is typically slightly older than @file{src} even when 2835 2932 it is up to date. The @code{.LOW_RESOLUTION_TIME} line causes … … 3133 3230 for each target that does not. If you have a list of files, only some of 3134 3231 which will match the pattern, you can use the @code{filter} function to 3135 remove non matching file names (@pxref{Text Functions, ,Functions for String Substitution and Analysis}):3232 remove non-matching file names (@pxref{Text Functions, ,Functions for String Substitution and Analysis}): 3136 3233 3137 3234 @example … … 3287 3384 The compiler will do it for you. 3288 3385 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}. 3386 Note that such a rule constitutes mentioning @file{main.o} in a 3387 makefile, so it can never be considered an intermediate file by 3388 implicit rule search. This means that @code{make} won't ever remove 3389 the file after using it; @pxref{Chained Rules, ,Chains of Implicit 3390 Rules}. 3293 3391 3294 3392 @cindex @code{make depend} … … 3335 3433 of @samp{-M}. This omits prerequisites on system header files. 3336 3434 @xref{Preprocessor Options, , Options Controlling the Preprocessor, 3337 gcc .info, Using GNU CC}, for details.3435 gcc, Using GNU CC}, for details. 3338 3436 3339 3437 @cindex @code{sed} (shell command) … … 3464 3562 3465 3563 @menu 3466 * Splitting Lines::Breaking long recipe lines for readability.3564 * Splitting Recipe Lines:: Breaking long recipe lines for readability. 3467 3565 * Variables in Recipes:: Using @code{make} variables in recipes. 3468 3566 @end menu 3469 3567 3470 @node Splitting Lines, Variables in Recipes, Recipe Syntax, Recipe Syntax3568 @node Splitting Recipe Lines, Variables in Recipes, Recipe Syntax, Recipe Syntax 3471 3569 @subsection Splitting Recipe Lines 3472 3570 @cindex recipes, splitting … … 3487 3585 3488 3586 However, 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. 3587 makefile (@pxref{Splitting Lines, , Splitting Long Lines}), 3588 backslash/newline pairs are @emph{not} removed from the recipe. Both 3589 the backslash and the newline characters are preserved and passed to 3590 the shell. How the backslash/newline is interpreted depends on your 3591 shell. If the first character of the next line after the 3592 backslash/newline is the recipe prefix character (a tab by default; 3593 @pxref{Special Variables}), then that character (and only that 3594 character) is removed. Whitespace is never added to the recipe. 3496 3595 3497 3596 For example, the recipe for the all target in this makefile: … … 3564 3663 3565 3664 Sometimes 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.3665 you don't want the backslash/newline to appear in the quoted content. 3567 3666 This is often the case when passing scripts to languages such as Perl, 3568 3667 where extraneous backslashes inside the script can change its meaning … … 3571 3670 @code{make} variable then use the variable in the recipe. In this 3572 3671 situation the newline quoting rules for makefiles will be used, and 3573 the backslash -newline will be removed. If we rewrite our example3672 the backslash/newline will be removed. If we rewrite our example 3574 3673 above using this method: 3575 3674 … … 3597 3696 uses it. 3598 3697 3599 @node Variables in Recipes, , Splitting Lines, Recipe Syntax3698 @node Variables in Recipes, , Splitting Recipe Lines, Recipe Syntax 3600 3699 @subsection Using Variables in Recipes 3601 3700 @cindex variable references in recipes … … 3700 3799 3701 3800 When it is time to execute recipes to update a target, they are 3702 executed by invoking a new sub shell for each line of the recipe,3801 executed by invoking a new sub-shell for each line of the recipe, 3703 3802 unless the @code{.ONESHELL} special target is in effect 3704 3803 (@pxref{One Shell, ,Using One Shell}) (In practice, @code{make} may … … 3731 3830 3732 3831 @menu 3733 * One Shell:: One shell for all lines in a recipe 3832 * One Shell:: One shell for all lines in a recipe. 3734 3833 * Choosing the Shell:: How @code{make} chooses the shell used 3735 3834 to run recipes. … … 3970 4069 slots is one, which means serial execution (one thing at a time). 3971 4070 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}}. 4071 Handling recursive @code{make} invocations raises issues for parallel 4072 execution. For more information on this, see @ref{Options/Recursion, 4073 ,Communicating Options to a Sub-@code{make}}. 4001 4074 4002 4075 If 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 4076 status), and errors are not ignored for that recipe (@pxref{Errors, 4077 ,Errors in Recipes}), the remaining recipe lines to remake the same 4078 target 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 4010 4081 terminates for any reason (including a signal) with child processes 4011 4082 running, it waits for them to finish before actually exiting.@refill … … 4039 4110 4040 4111 By 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 4123 When running several recipes in parallel the output from each 4124 recipe appears as soon as it is generated, with the result that 4125 messages from different recipes may be interspersed, sometimes even 4126 appearing on the same line. This can make reading the output very 4127 difficult. 4128 4129 @cindex @code{--output-sync} 4130 @cindex @code{-O} 4131 To avoid this you can use the @samp{--output-sync} (@samp{-O}) option. 4132 This option instructs @code{make} to save the output from the commands 4133 it invokes and print it all once the commands are completed. 4134 Additionally, if there are multiple recursive @code{make} invocations 4135 running in parallel, they will communicate so that only one of them is 4136 generating output at a time. 4137 4138 If working directory printing is enabled (@pxref{-w Option, ,The 4139 @samp{--print-directory} Option}), the enter/leave messages are 4140 printed around each output grouping. If you prefer not to see these 4141 messages add the @samp{--no-print-directory} option to @code{MAKEFLAGS}. 4142 4143 There are four levels of granularity when synchronizing output, 4144 specified by giving an argument to the option (e.g., @samp{-Oline} or 4145 @samp{--output-sync=recurse}). 4146 4147 @table @code 4148 @item none 4149 This is the default: all output is sent directly as it is generated and 4150 no synchronization is performed. 4151 4152 @item line 4153 Output from each individual line of the recipe is grouped and printed 4154 as soon as that line is complete. If a recipe consists of multiple 4155 lines, they may be interspersed with lines from other recipes. 4156 4157 @item target 4158 Output from the entire recipe for each target is grouped and printed 4159 once 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 4163 Output from each recursive invocation of @code{make} is grouped and 4164 printed once the recursive invocation is complete. 4165 4166 @end table 4167 4168 Regardless of the mode chosen, the total build time will be the same. 4169 The only difference is in how the output appears. 4170 4171 The @samp{target} and @samp{recurse} modes both collect the output of 4172 the entire recipe of a target and display it uninterrupted when the 4173 recipe completes. The difference between them is in how recipes that 4174 contain recursive invocations of @code{make} are treated 4175 (@pxref{Recursion, ,Recursive Use of @code{make}}). For all recipes 4176 which have no recursive lines, the @samp{target} and @samp{recurse} 4177 modes behave identically. 4178 4179 If the @samp{recurse} mode is chosen, recipes that contain recursive 4180 @code{make} invocations are treated the same as other targets: the 4181 output from the recipe, including the output from the recursive 4182 @code{make}, is saved and printed after the entire recipe is complete. 4183 This ensures output from all the targets built by a given recursive 4184 @code{make} instance are grouped together, which may make the output 4185 easier to understand. However it also leads to long periods of time 4186 during the build where no output is seen, followed by large bursts of 4187 output. If you are not watching the build as it proceeds, but instead 4188 viewing a log of the build after the fact, this may be the best option 4189 for you. 4190 4191 If you are watching the output, the long gaps of quiet during the 4192 build can be frustrating. The @samp{target} output synchronization 4193 mode detects when @code{make} is going to be invoked recursively, 4194 using the standard methods, and it will not synchronize the output of 4195 those lines. The recursive @code{make} will perform the 4196 synchronization for its targets and the output from each will be 4197 displayed immediately when it completes. Be aware that output from 4198 recursive lines of the recipe are not synchronized (for example if 4199 the recursive line prints a message before running @code{make}, that 4200 message will not be synchronized). 4201 4202 The @samp{line} mode can be useful for front-ends that are watching 4203 the output of @code{make} to track when recipes are started and 4204 completed. 4205 4206 Some programs invoked by @code{make} may behave differently if they 4207 determine they're writing output to a terminal versus a file (often 4208 described as ``interactive'' vs. ``non-interactive'' modes). For 4209 example, many programs that can display colorized output will not do 4210 so if they determine they are not writing to a terminal. If your 4211 makefile invokes a program like this then using the output 4212 synchronization options will cause the program to believe it's running 4213 in ``non-interactive'' mode even though the output will ultimately go 4214 to 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 4222 Two processes cannot both take input from the same device at the same 4223 time. To make sure that only one recipe tries to take input from the 4224 terminal at once, @code{make} will invalidate the standard input 4225 streams of all but one running recipe. If another recipe attempts to 4226 read from standard input it will usually incur a fatal error (a 4227 @samp{Broken pipe} signal). 4228 @cindex broken pipe 4229 4230 It is unpredictable which recipe will have a valid standard input stream 4231 (which will come from the terminal, or wherever you redirect the standard 4232 input of @code{make}). The first recipe run will always get it first, and 4233 the first recipe started after that one finishes will get it next, and so 4234 on. 4235 4236 We will change how this aspect of @code{make} works if we find a better 4237 alternative. In the mean time, you should not rely on any recipe using 4238 standard input at all if you are using the parallel execution feature; but 4239 if you are not using this feature, then standard input works normally in 4240 all recipes. 4041 4241 4042 4242 @node Errors, Interrupts, Parallel, Recipes … … 4179 4379 makefile. This technique is useful when you want separate makefiles for 4180 4380 various subsystems that compose a larger system. For example, suppose you 4181 have a sub directory @file{subdir} which has its own makefile, and you would4381 have a sub-directory @file{subdir} which has its own makefile, and you would 4182 4382 like the containing directory's makefile to run @code{make} on the 4183 sub directory. You can do it by writing this:4383 sub-directory. You can do it by writing this: 4184 4384 4185 4385 @example … … 4293 4493 Variable values of the top-level @code{make} can be passed to the 4294 4494 sub-@code{make} through the environment by explicit request. These 4295 variables are defined in the sub-@code{make} as defaults, but do not4296 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}).@refill4495 variables are defined in the sub-@code{make} as defaults, but they do 4496 not override variables defined in the makefile used by 4497 the sub-@code{make} unless you use the @samp{-e} switch (@pxref{Options 4498 Summary, ,Summary of Options}).@refill 4299 4499 4300 4500 To pass down, or @dfn{export}, a variable, @code{make} adds the … … 4522 4722 4523 4723 If 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 down4526 to sub-@code{make}s ,you would get many more jobs running in parallel4724 no @samp{-j} is added to @code{MAKEFLAGS}, so that sub-@code{make}s 4725 run in non-parallel mode. If the @w{@samp{-j}} option were passed down 4726 to sub-@code{make}s you would get many more jobs running in parallel 4527 4727 than you asked for. If you give @samp{-j} with no numeric argument, 4528 4728 meaning to run as many jobs as possible in parallel, this is passed … … 4556 4756 see the error message @samp{Arg list too long}, this may be the problem. 4557 4757 @findex .POSIX 4558 @cindex POSIX .24758 @cindex POSIX 4559 4759 (For strict compliance with POSIX.2, changing @code{MAKEOVERRIDES} does 4560 4760 not affect @code{MAKEFLAGS} if the special target @samp{.POSIX} appears … … 4608 4808 put in one of these variables, could have disastrous consequences and would 4609 4809 certainly have at least surprising and probably annoying effects.@refill 4810 4811 If you'd like to run other implementations of @code{make} in addition 4812 to GNU @code{make}, and hence do not want to add GNU 4813 @code{make}-specific flags to the @code{MAKEFLAGS} variable, you can 4814 add them to the @code{GNUMAKEFLAGS} variable instead. This variable 4815 is parsed just before @code{MAKEFLAGS}, in the same way as 4816 @code{MAKEFLAGS}. When @code{make} constructs @code{MAKEFLAGS} to 4817 pass to a recursive @code{make} it will include all flags, even those 4818 taken from @code{GNUMAKEFLAGS}. As a result, after parsing 4819 @code{GNUMAKEFLAGS} GNU @code{make} sets this variable to the empty 4820 string to avoid duplicating flags during recursion. 4821 4822 It's best to use @code{GNUMAKEFLAGS} only with flags which won't 4823 materially change the behavior of your makefiles. If your makefiles 4824 require GNU make anyway then simply use @code{MAKEFLAGS}. Flags such 4825 as @samp{--no-print-directory} or @samp{--output-sync} may be 4826 appropriate for @code{GNUMAKEFLAGS}. 4610 4827 4611 4828 @node -w Option, , Options/Recursion, Recursion … … 4717 4934 In recipe execution, each line of a canned sequence is treated just as 4718 4935 if the line appeared on its own in the rule, preceded by a tab. In 4719 particular, @code{make} invokes a separate sub shell for each line. You4936 particular, @code{make} invokes a separate sub-shell for each line. You 4720 4937 can use the special prefix characters that affect command lines 4721 4938 (@samp{@@}, @samp{-}, and @samp{+}) on each line of a canned sequence. … … 4766 4983 4767 4984 @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 4985 You may be wondering why you would want to define a recipe that does 4986 nothing. One reason this is useful is to prevent a target from 4987 getting implicit recipes (from implicit rules or the @code{.DEFAULT} 4988 special target; @pxref{Implicit Rules} and @pxref{Last Resort, 4989 ,Defining Last-Resort Default Rules}).@refill 4990 4991 Empty recipes can also be used to avoid errors for targets that will 4992 be created as a side-effect of another recipe: if the target does not 4993 exist the empty recipe ensures that @code{make} won't complain that it 4994 doesn't know how to build the target, and @code{make} will assume the 4995 target is out of date. 4996 4997 You may be inclined to define empty recipes for targets that are not 4998 actual files, but only exist so that their prerequisites can be 4786 4999 remade. 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. 5000 prerequisites may not be remade properly if the target file actually 5001 does exist. @xref{Phony Targets, ,Phony Targets}, for a better way to 5002 do this. 4789 5003 4790 5004 @node Using Variables, Conditionals, Recipes, Top … … 4811 5025 write output in, or anything else you can imagine. 4812 5026 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}}). 5027 A variable name may be any sequence of characters not containing 5028 @samp{:}, @samp{#}, @samp{=}, or whitespace. However, variable names 5029 containing characters other than letters, numbers, and underscores 5030 should be considered carefully, as in some shells they cannot be 5031 passed through the environment to a sub-@code{make} 5032 (@pxref{Variables/Recursion, ,Communicating Variables to a 5033 Sub-@code{make}}). Variable names beginning with @samp{.} and an 5034 uppercase letter may be given special meaning in future versions of 5035 @code{make}. 4820 5036 4821 5037 Variable names are case-sensitive. The names @samp{foo}, @samp{FOO}, … … 4941 5157 expands to @samp{$(ugh)} which finally expands to @samp{Huh?}.@refill 4942 5158 4943 This flavor of variable is the only sort supported by other versions of4944 @code{make}. It has its advantages and its disadvantages. An advantage 4945 (most would say) is that:5159 This flavor of variable is the only sort supported by most other 5160 versions of @code{make}. It has its advantages and its disadvantages. 5161 An advantage (most would say) is that: 4946 5162 4947 5163 @example … … 4979 5195 @cindex variables, simply expanded 4980 5196 @cindex := 5197 @cindex ::= 4981 5198 @dfn{Simply expanded variables} are defined by lines using @samp{:=} 4982 (@pxref{Setting, ,Setting Variables}). 5199 or @samp{::=} (@pxref{Setting, ,Setting Variables}). Both forms are 5200 equivalent in GNU @code{make}; however only the @samp{::=} form is 5201 described by the POSIX standard (support for @samp{::=} was added to 5202 the POSIX standard in 2012, so older versions of @code{make} won't 5203 accept this form either). 5204 4983 5205 The value of a simply expanded variable is scanned 4984 5206 once and for all, expanding any references to other variables and … … 5220 5442 5221 5443 References to recursively-expanded variables within a variable name are 5222 re expanded in the usual fashion. For example:5444 re-expanded in the usual fashion. For example: 5223 5445 5224 5446 @example … … 5399 5621 @cindex = 5400 5622 @cindex := 5623 @cindex ::= 5401 5624 @cindex ?= 5625 @cindex != 5402 5626 5403 5627 To 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, 5628 variable name followed by @samp{=}, @samp{:=}, or @samp{::=}. Whatever 5629 follows the @samp{=}, @samp{:=}, or @samp{::=} on the line becomes the 5630 value. For example, 5406 5631 5407 5632 @example … … 5413 5638 name and immediately after the @samp{=} is ignored. 5414 5639 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}. 5640 Variables defined with @samp{=} are @dfn{recursively expanded} 5641 variables. Variables defined with @samp{:=} or @samp{::=} are 5642 @dfn{simply expanded} variables; these definitions can contain 5643 variable references which will be expanded before the definition is 5644 made. @xref{Flavors, ,The Two Flavors of Variables}. 5419 5645 5420 5646 The variable name may contain function and variable references, which … … 5422 5648 5423 5649 There 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. 5650 amount of memory on the computer. You can split the value of a 5651 variable into multiple physical lines for readability 5652 (@pxref{Splitting Lines, ,Splitting Long Lines}). 5429 5653 5430 5654 Most variable names are considered to have the empty string as a value if … … 5454 5678 @end example 5455 5679 5680 The shell assignment operator @samp{!=} can be used to execute a 5681 shell script and set a variable to its output. This operator first 5682 evaluates the right-hand side, then passes that result to the shell 5683 for execution. If the result of the execution ends in a newline, that 5684 one newline is removed; all other newlines are replaced by spaces. 5685 The resulting string is then placed into the named 5686 recursively-expanded variable. For example: 5687 5688 @example 5689 hash != printf '\043' 5690 file_list != find . -name '*.c' 5691 @end example 5692 5693 If the result of the execution could produce a @code{$}, and you don't 5694 intend what follows that to be interpreted as a make variable or 5695 function reference, then you must replace every @code{$} with 5696 @code{$$} as part of the execution. Alternatively, you can set a 5697 simply expanded variable to the result of running a program using the 5698 @code{shell} function call. @xref{Shell Function, , The @code{shell} 5699 Function}. For example: 5700 5701 @example 5702 hash := $(shell printf '\043') 5703 var := $(shell find . -name "*.c") 5704 @end example 5705 5706 As with the @code{shell} function, the exit status of the just-invoked 5707 shell script is stored in the @code{.SHELLSTATUS} variable. 5708 5709 5456 5710 @node Appending, Override Directive, Setting, Using Variables 5457 5711 @section Appending More Text to Variables … … 5498 5752 When you add to a variable's value with @samp{+=}, @code{make} acts 5499 5753 essentially 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,5754 definition of the variable. If you defined it first with @samp{:=} or 5755 @samp{::=}, making it a simply-expanded variable, @samp{+=} adds to 5756 that simply-expanded definition, and expands the new text before 5757 appending 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, 5506 5760 5507 5761 @example … … 5561 5815 The first line defines the @code{CFLAGS} variable with a reference to another 5562 5816 variable, @code{includes}. (@code{CFLAGS} is used by the rules for C 5563 compilation; @pxref{Catalogue of Rules, ,Catalogue of ImplicitRules}.)5817 compilation; @pxref{Catalogue of Rules, ,Catalogue of Built-In Rules}.) 5564 5818 Using @samp{=} for the definition makes @code{CFLAGS} a recursively-expanded 5565 5819 variable, meaning @w{@samp{$(includes) -O}} is @emph{not} expanded when … … 5717 5971 since two commands separated by semicolon behave much like two separate 5718 5972 shell commands. However, note that using two separate lines means 5719 @code{make} will invoke the shell twice, running an independent sub shell5973 @code{make} will invoke the shell twice, running an independent sub-shell 5720 5974 for each line. @xref{Execution, ,Recipe Execution}. 5721 5975 … … 5843 6097 5844 6098 The @var{variable-assignment} can be any valid form of assignment; 5845 recursive (@samp{=}), s tatic (@samp{:=}), appending (@samp{+=}), or5846 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).6099 recursive (@samp{=}), simple (@samp{:=} or @samp{::=}), appending 6100 (@samp{+=}), or conditional (@samp{?=}). All variables that appear 6101 within the @var{variable-assignment} are evaluated within the context 6102 of the target: thus, any previously-defined target-specific variable 6103 values will be in effect. Note that this variable is actually 6104 distinct from any ``global'' value: the two variables do not have to 6105 have the same flavor (recursive vs.@: simple). 5852 6106 5853 6107 Target-specific variables have the same priority as any other makefile … … 5974 6228 Due to the @code{private} modifier, @code{a.o} and @code{b.o} will not 5975 6229 inherit the @code{EXTRA_CFLAGS} variable assignment from the 5976 @code{prog s} target.6230 @code{prog} target. 5977 6231 5978 6232 @node Special Variables, , Suppressing Inheritance, Using Variables … … 6070 6324 6071 6325 Note that assigning more than one target name to @code{.DEFAULT_GOAL} is 6072 i llegaland will result in an error.6326 invalid and will result in an error. 6073 6327 6074 6328 @vindex MAKE_RESTARTS @r{(number of times @code{make} has restarted)} … … 6079 6333 this is not the same as recursion (counted by the @code{MAKELEVEL} 6080 6334 variable). 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 6340 When @code{make} starts it will check whether stdout and stderr will 6341 show their output on a terminal. If so, it will set 6342 @code{MAKE_TERMOUT} and @code{MAKE_TERMERR}, respectively, to the name 6343 of the terminal device (or @code{true} if this cannot be determined). 6344 If set these variables will be marked for export. These variables 6345 will not be changed by @code{make} and they will not be modified if 6346 already set. 6347 6348 These values can be used (particularly in combination with output 6349 synchronization (@pxref{Parallel Output, ,Output During Parallel 6350 Execution}) to determine whether @code{make} itself is writing to a 6351 terminal; they can be tested to decide whether to force recipe 6352 commands to generate colorized output for example. 6353 6354 If you invoke a sub-@code{make} and redirect its stdout or stderr it 6355 is your responsibility to reset or unexport these variables as well, 6356 if your makefiles rely on them. 6081 6357 6082 6358 @vindex .RECIPEPREFIX @r{(change the recipe prefix character)} … … 6121 6397 @item .FEATURES 6122 6398 Expands 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: 6124 6400 6125 6401 @table @samp 6126 6402 6127 6403 @item archives 6128 Supports @code{ar} (archive) files using special file name syntax.6404 Supports @code{ar} (archive) files using special file name syntax. 6129 6405 @xref{Archives, ,Using @code{make} to Update Archive Files}. 6130 6406 … … 6141 6417 ,Parallel Execution}. 6142 6418 6143 @item second-expansion 6144 Supports secondary expansion of prerequisite lists. 6419 @item oneshell 6420 Supports the @code{.ONESHELL} special target. @xref{One Shell, ,Using 6421 One Shell}. 6145 6422 6146 6423 @item order-only … … 6148 6425 of Prerequisites}. 6149 6426 6427 @item second-expansion 6428 Supports secondary expansion of prerequisite lists. 6429 6430 @item shortest-stem 6431 Uses the ``shortest stem'' method of choosing which pattern, of 6432 multiple applicable options, will be used. @xref{Pattern Match, ,How 6433 Patterns Match}. 6434 6150 6435 @item target-specific 6151 6436 Supports target-specific and pattern-specific variable assignments. 6152 6437 @xref{Target-specific, ,Target-specific Variable Values}. 6153 6438 6439 @item undefine 6440 Supports the @code{undefine} directive. @xref{Undefine Directive}. 6441 6442 @item guile 6443 Has GNU Guile available as an embedded extension language. 6444 @xref{Guile Integration, ,GNU Guile Integration}. 6445 6446 @item load 6447 Supports dynamically loadable objects for creating custom extensions. 6448 @xref{Loading Objects, ,Loading Dynamic Objects}. 6154 6449 @end table 6155 6450 … … 6292 6587 6293 6588 @example 6294 @var{conditional-directive }6589 @var{conditional-directive-one} 6295 6590 @var{text-if-one-is-true} 6296 else @var{conditional-directive }6297 @var{text-if-t rue}6591 else @var{conditional-directive-two} 6592 @var{text-if-two-is-true} 6298 6593 else 6299 @var{text-if- false}6594 @var{text-if-one-and-two-are-false} 6300 6595 endif 6301 6596 @end example … … 6354 6649 @item ifdef @var{variable-name} 6355 6650 The @code{ifdef} form takes the @emph{name} of a variable as its 6356 argument, not a reference to a variable. The value of that variable6357 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 t o the name of a variable. For example:6651 argument, not a reference to a variable. If the value of that 6652 variable has a non-empty value, the @var{text-if-true} is effective; 6653 otherwise, the @var{text-if-false}, if any, is effective. Variables 6654 that have never been defined have an empty value. The text 6655 @var{variable-name} is expanded, so it could be a variable or function 6656 that expands to the name of a variable. For example: 6362 6657 6363 6658 @example … … 6493 6788 * Conditional Functions:: Functions that implement conditions. 6494 6789 * Foreach Function:: Repeat some text with controlled variation. 6790 * File Function:: Write text to a file. 6495 6791 * Call Function:: Expand a user-defined function. 6496 6792 * Value Function:: Return the un-expanded value of a variable. … … 6498 6794 * Origin Function:: Find where a variable got its value. 6499 6795 * Flavor Function:: Find out the flavor of a variable. 6796 * Make Control Functions:: Functions that control how make runs. 6500 6797 * 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. 6502 6799 @end menu 6503 6800 … … 6509 6806 @cindex functions, syntax of 6510 6807 6511 A function call resembles a variable reference. It looks like this: 6808 A function call resembles a variable reference. It can appear 6809 anywhere a variable reference can appear, and it is expanded using the 6810 same rules as variable references. A function call looks like this: 6512 6811 6513 6812 @example … … 6524 6823 Here @var{function} is a function name; one of a short list of names 6525 6824 that are part of @code{make}. You can also essentially create your own 6526 functions by using the @code{call} built in function.6825 functions by using the @code{call} built-in function. 6527 6826 6528 6827 The @var{arguments} are the arguments of the function. They are … … 7141 7440 @end table 7142 7441 7143 @node Foreach Function, CallFunction, Conditional Functions, Functions7442 @node Foreach Function, File Function, Conditional Functions, Functions 7144 7443 @section The @code{foreach} Function 7145 7444 @findex foreach … … 7203 7502 Here we use the variable @code{find_files} this way. We use plain @samp{=} 7204 7503 to define a recursively-expanding variable, so that its value contains an 7205 actual function call to be re expanded under the control of @code{foreach};7504 actual function call to be re-expanded under the control of @code{foreach}; 7206 7505 a simply-expanded variable would not do, since @code{wildcard} would be 7207 7506 called only once at the time of defining @code{find_files}. … … 7221 7520 7222 7521 @smallexample 7223 files := $(foreach Esta escrito enespanol!,b c ch,$(find_files))7522 files := $(foreach Esta-escrito-en-espanol!,b c ch,$(find_files)) 7224 7523 @end smallexample 7225 7524 7226 7525 @noindent 7227 7526 might be useful if the value of @code{find_files} references the variable 7228 whose name is @samp{Esta escrito enespanol!} (es un nombre bastante largo,7527 whose name is @samp{Esta-escrito-en-espanol!} (es un nombre bastante largo, 7229 7528 no?), but it is more likely to be a mistake. 7230 7529 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 7538 The @code{file} function allows the makefile to write to or read from 7539 a file. Two modes of writing are supported: overwrite, where the text 7540 is written to the beginning of the file and any existing content is 7541 lost, and append, where the text is written to the end of the file, 7542 preserving the existing content. In both cases the file is created if 7543 it does not exist. It is a fatal error if the file cannot be opened 7544 for writing, or if the write operation fails. The @code{file} 7545 function expands to the empty string when writing to a file. 7546 7547 When reading from a file, the @code{file} function expands to the 7548 verbatim contents of the file, except that the final newline (if there 7549 is one) will be stripped. Attempting to read from a non-existent file 7550 expands to the empty string. 7551 7552 The syntax of the @code{file} function is: 7553 7554 @example 7555 $(file @var{op} @var{filename}[,@var{text}]) 7556 @end example 7557 7558 When the @code{file} function is evaluated all its arguments are 7559 expanded first, then the file indicated by @var{filename} will be 7560 opened in the mode described by @var{op}. 7561 7562 The operator @var{op} can be @code{>} to indicate the file will be 7563 overwritten with new content, @code{>>} to indicate the current 7564 contents of the file will be appended to, or @code{<} to indicate the 7565 contents of the file will be read in. The @var{filename} specifies 7566 the file to be written to or read from. There may optionally be 7567 whitespace between the operator and the file name. 7568 7569 When reading files, it is an error to provide a @var{text} value. 7570 7571 When 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 7573 written (even if @var{text} is the empty string). If the @var{text} 7574 argument is not given at all, nothing will be written. 7575 7576 For example, the @code{file} function can be useful if your build 7577 system has a limited command line size and your recipe runs a command 7578 that can accept arguments from a file as well. Many commands use the 7579 convention that an argument prefixed with an @code{@@} specifies a 7580 file containing more arguments. Then you might write your recipe in 7581 this way: 7582 7583 @example 7584 @group 7585 program: $(OBJECTS) 7586 $(file >$@@.in,$^) 7587 $(CMD) $(CMDFLAGS) @@$@@.in 7588 @@rm $@@.in 7589 @end group 7590 @end example 7591 7592 If the command required each argument to be on a separate line of the 7593 input file, you might write your recipe like this: 7594 7595 @example 7596 @group 7597 program: $(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 7232 7605 @section The @code{call} Function 7233 7606 @findex call … … 7263 7636 constant.) 7264 7637 7265 If @var{variable} is the name of a built in function, the builtin function7638 If @var{variable} is the name of a built-in function, the built-in function 7266 7639 is always invoked (even if a @code{make} variable by that name also 7267 7640 exists). … … 7269 7642 The @code{call} function expands the @var{param} arguments before 7270 7643 assigning them to temporary variables. This means that @var{variable} 7271 values containing references to built in functions that have special7644 values containing references to built-in functions that have special 7272 7645 expansion rules, like @code{foreach} or @code{if}, may not work as you 7273 7646 expect. … … 7341 7714 @end example 7342 7715 7343 Note that @var{variable} is the @emph{name} of a variable ;not a7716 Note that @var{variable} is the @emph{name} of a variable, not a 7344 7717 @emph{reference} to that variable. Therefore you would not normally 7345 7718 use a @samp{$} or parentheses when writing it. (You can, however, use … … 7452 7825 @end example 7453 7826 7454 Note that @var{variable} is the @emph{name} of a variable to inquire about ;7827 Note that @var{variable} is the @emph{name} of a variable to inquire about, 7455 7828 not a @emph{reference} to that variable. Therefore you would not normally 7456 7829 use a @samp{$} or parentheses when writing it. (You can, however, use a … … 7545 7918 @xref{Text Functions, , Functions for String Substitution and Analysis}. 7546 7919 7547 @node Flavor Function, Shell Function, Origin Function, Functions7920 @node Flavor Function, Make Control Functions, Origin Function, Functions 7548 7921 @section The @code{flavor} Function 7549 7922 @findex flavor … … 7551 7924 @cindex flavor of variable 7552 7925 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}). 7926 The @code{flavor} function, like the @code{origin} function, does not 7927 operate on the values of variables but rather it tells you something 7928 @emph{about} a variable. Specifically, it tells you the flavor of a 7929 variable (@pxref{Flavors, ,The Two Flavors of Variables}). 7558 7930 7559 7931 The syntax of the @code{flavor} function is: … … 7563 7935 @end example 7564 7936 7565 Note that @var{variable} is the @emph{name} of a variable to inquire about ;7937 Note that @var{variable} is the @emph{name} of a variable to inquire about, 7566 7938 not a @emph{reference} to that variable. Therefore you would not normally 7567 7939 use a @samp{$} or parentheses when writing it. (You can, however, use a … … 7586 7958 @end table 7587 7959 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 7638 7961 @section Functions That Control Make 7639 7962 @cindex functions, for controlling make … … 7696 8019 result of the expansion of this function is the empty string. 7697 8020 @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 8029 The @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 8032 communicates with the world outside of @code{make}. 8033 8034 The @code{shell} function performs the same function that backquotes 8035 (@samp{`}) perform in most shells: it does @dfn{command expansion}. 8036 This means that it takes as an argument a shell command and evaluates 8037 to the output of the command. The only processing @code{make} does on 8038 the result is to convert each newline (or carriage-return / newline 8039 pair) to a single space. If there is a trailing (carriage-return 8040 and) newline it will simply be removed.@refill 8041 8042 The commands run by calls to the @code{shell} function are run when the 8043 function calls are expanded (@pxref{Reading Makefiles, , How 8044 @code{make} Reads a Makefile}). Because this function involves 8045 spawning a new shell, you should carefully consider the performance 8046 implications of using the @code{shell} function within recursively 8047 expanded variables vs.@: simply expanded variables (@pxref{Flavors, ,The 8048 Two Flavors of Variables}). 8049 8050 @vindex .SHELLSTATUS 8051 After the @code{shell} function or @samp{!=} assignment operator is 8052 used, its exit status is placed in the @code{.SHELLSTATUS} variable. 8053 8054 Here are some examples of the use of the @code{shell} function: 8055 8056 @example 8057 contents := $(shell cat foo) 8058 @end example 8059 8060 @noindent 8061 sets @code{contents} to the contents of the file @file{foo}, with a space 8062 (rather than a newline) separating each line. 8063 8064 @example 8065 files := $(shell echo *.c) 8066 @end example 8067 8068 @noindent 8069 sets @code{files} to the expansion of @samp{*.c}. Unless @code{make} is 8070 using a very strange shell, this has the same result as 8071 @w{@samp{$(wildcard *.c)}} (as long as at least one @samp{.c} file 8072 exists).@refill 8073 8074 @node Guile Function, , Shell Function, Functions 8075 @section The @code{guile} Function 8076 @findex guile 8077 @cindex Guile 8078 8079 If GNU @code{make} is built with support for GNU Guile as an embedded 8080 extension language then the @code{guile} function will be available. 8081 The @code{guile} function takes one argument which is first expanded 8082 by @code{make} in the normal fashion, then passed to the GNU Guile 8083 evaluator. The result of the evaluator is converted into a string and 8084 used as the expansion of the @code{guile} function in the makefile. 8085 See @ref{Guile Integration, ,GNU Guile Integration} for details on 8086 writing extensions to @code{make} in Guile. 8087 8088 You can determine whether GNU Guile support is available by checking 8089 the @code{.FEATURES} variable for the word @var{guile}. 7698 8090 7699 8091 @node Running, Implicit Rules, Functions, Top … … 7919 8311 @cindex @code{-n} 7920 8312 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 8314 make the targets up to date, but not actually execute them. Note that 8315 some recipes are still executed, even with this flag (@pxref{MAKE 8316 Variable, ,How the @code{MAKE} Variable Works}). Also any recipes 8317 needed to update included makefiles are still executed 8318 (@pxref{Remaking Makefiles, ,How Makefiles Are Remade}). 7924 8319 7925 8320 @item -t … … 7930 8325 @cindex @code{-t} 7931 8326 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 8328 them. In other words, @code{make} pretends to update the targets but 8329 does not really change their contents; instead only their modified 8330 times are updated. 7935 8331 7936 8332 @item -q … … 7940 8336 @cindex question mode 7941 8337 7942 ``Question''. The activity is to find out silently whether the targets7943 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 8339 do not execute recipes; the exit code shows whether any updates are 8340 needed. 7945 8341 7946 8342 @item -W @var{file} … … 8116 8512 define either a recursively-expanded variable or a simply-expanded 8117 8513 variable. The examples shown above make a recursively-expanded 8118 variable; to make a simply-expanded variable, write @samp{:=} instead8119 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.8514 variable; to make a simply-expanded variable, write @samp{:=} or 8515 @samp{::=} instead of @samp{=}. But, unless you want to include a 8516 variable reference or function call in the @emph{value} that you 8517 specify, it makes no difference which kind of variable you create. 8122 8518 8123 8519 There is one way that the makefile can change a variable that you have … … 8243 8639 8244 8640 @item j (@i{jobs}) 8245 Prints messages giving details on the invocation of specific sub commands.8641 Prints messages giving details on the invocation of specific sub-commands. 8246 8642 8247 8643 @item m (@i{makefile}) … … 8250 8646 too. Note that the @samp{all} option does enable this option. This 8251 8647 option also enables @samp{basic} messages. 8648 8649 @item n (@i{none}) 8650 Disable all debugging currently enabled. If additional debugging 8651 flags are encountered after this they will still take effect. 8252 8652 @end table 8253 8653 … … 8367 8767 are ignored. @xref{Avoiding Compilation, ,Avoiding Recompilation of 8368 8768 Some 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 8776 Ensure that the complete output from each recipe is printed in one 8777 uninterrupted 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 8780 will be displayed as it is generated by the recipes.@refill 8781 8782 With no type or the type @samp{target}, output from the entire recipe 8783 of each target is grouped together. With the type @samp{line}, output 8784 from each line in the recipe is grouped together. With the type 8785 @samp{recurse}, the output from an entire recursive make is grouped 8786 together. With the type @samp{none}, no output synchronization is 8787 performed. @xref{Parallel Output, ,Output During Parallel Execution}. 8369 8788 8370 8789 @item -p … … 8380 8799 to remake any files, use @w{@samp{make -qp}}. To print the data base 8381 8800 of predefined rules and variables, use @w{@samp{make -p -f /dev/null}}. 8382 The data base output contains file name and linenumber information for8801 The data base output contains file name and line number information for 8383 8802 recipe and variable definitions, so it can be a useful debugging tool 8384 8803 in complex environments. … … 8455 8874 @code{make}. @xref{Instead of Execution, ,Instead of Executing Recipes}. 8456 8875 8876 @item --trace 8877 @cindex @code{--trace} 8878 Show tracing information for @code{make} execution. Prints the entire 8879 recipe to be executed, even for recipes that are normally silent (due 8880 to @code{.SILENT} or @samp{@@}). Also prints the makefile name and 8881 line number where the recipe was defined, and information on why the 8882 target is being rebuilt. 8883 8457 8884 @item -v 8458 8885 @cindex @code{-v} … … 8473 8900 see @ref{-w Option, ,The @samp{--print-directory} Option}.) 8474 8901 8475 @item x--no-print-directory8902 @item --no-print-directory 8476 8903 @cindex @code{--no-print-directory} 8477 8904 Disable printing of the working directory under @code{-w}. … … 8551 8978 * Using Implicit:: How to use an existing implicit rule 8552 8979 to get the recipes for updating a file. 8553 * Catalogue of Rules:: A list of built-in implicitrules.8980 * Catalogue of Rules:: A list of built-in rules. 8554 8981 * Implicit Variables:: How to change what predefined rules do. 8555 8982 * Chained Rules:: How to use a chain of implicit rules. 8556 8983 * Pattern Rules:: How to define new implicit rules. 8557 * Last Resort:: How to define recipesfor rules which8984 * Last Resort:: How to define a recipe for rules which 8558 8985 cannot find any. 8559 8986 * Suffix Rules:: The old-fashioned style of implicit rule. … … 8603 9030 want @code{make} to use, and you know it will choose that one because you 8604 9031 know which possible prerequisite files are supposed to exist. 8605 @xref{Catalogue of Rules, ,Catalogue of ImplicitRules},9032 @xref{Catalogue of Rules, ,Catalogue of Built-In Rules}, 8606 9033 for a catalogue of all the predefined implicit rules. 8607 9034 … … 8633 9060 rule to make an object file from a C source file is used instead, 8634 9061 because it appears before the Pascal rule in the list of predefined 8635 implicit rules (@pxref{Catalogue of Rules, , Catalogue of Implicit9062 implicit rules (@pxref{Catalogue of Rules, , Catalogue of Built-In 8636 9063 Rules}). 8637 9064 … … 8641 9068 8642 9069 @node Catalogue of Rules, Implicit Variables, Using Implicit, Implicit Rules 8643 @section Catalogue of ImplicitRules9070 @section Catalogue of Built-In Rules 8644 9071 @cindex implicit rule, predefined 8645 9072 @cindex rule, implicit, predefined … … 8987 9414 Here is a table of some of the more common variables used as names of 8988 9415 programs in built-in rules: 8989 makefiles.8990 9416 8991 9417 @table @code … … 9142 9568 @vindex LDFLAGS 9143 9569 Extra 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 9571 added to the @code{LDLIBS} variable instead. 9572 9573 @item LDLIBS 9574 @vindex LDLIBS 9575 @vindex LOADLIBES 9576 Library flags or names given to compilers when they are supposed to 9577 invoke the linker, @samp{ld}. @code{LOADLIBES} is a deprecated (but 9578 still supported) alternative to @code{LDLIBS}. Non-library linker 9579 flags, such as @code{-L}, should go in the @code{LDFLAGS} variable. 9145 9580 9146 9581 @item LFLAGS … … 9275 9710 * Pattern Examples:: Examples of pattern rules. 9276 9711 * Automatic Variables:: How to use automatic variables in the 9277 recipe sof implicit rules.9712 recipe of implicit rules. 9278 9713 * Pattern Match:: How patterns match. 9279 9714 * Match-Anything Rules:: Precautions you should take prior to … … 9375 9810 @noindent 9376 9811 defines a rule that can make any file @file{@var{x}} whatsoever from a 9377 corresponding file @file{@var{x},v} in the sub directory @file{RCS}. Since9812 corresponding file @file{@var{x},v} in the sub-directory @file{RCS}. Since 9378 9813 the target is @samp{%}, this rule will apply to any file whatever, provided 9379 9814 the appropriate prerequisite file exists. The double colon makes the rule … … 9748 10183 9749 10184 If you do not mark the match-anything rule as terminal, then it is 9750 non terminal. A nonterminal match-anything rule cannot apply to a file name10185 non-terminal. A non-terminal match-anything rule cannot apply to a file name 9751 10186 that indicates a specific type of data. A file name indicates a specific 9752 10187 type of data if some non-match-anything implicit rule target matches it. … … 9756 10191 rule is actually applicable (which happens only if there is a file 9757 10192 @file{foo.y}), the fact that its target matches is enough to prevent 9758 consideration of any non terminal match-anything rules for the file10193 consideration of any non-terminal match-anything rules for the file 9759 10194 @file{foo.c}. Thus, @code{make} will not even consider trying to make 9760 10195 @file{foo.c} as an executable file from @file{foo.c.o}, @file{foo.c.c}, 9761 10196 @file{foo.c.p}, etc.@refill 9762 10197 9763 The motivation for this constraint is that non terminal match-anything10198 The motivation for this constraint is that non-terminal match-anything 9764 10199 rules are used for making files containing specific types of data (such as 9765 10200 executable files) and a file name with a recognized suffix indicates some … … 9767 10202 9768 10203 Special built-in dummy pattern rules are provided solely to recognize 9769 certain file names so that non terminal match-anything rules will not be10204 certain file names so that non-terminal match-anything rules will not be 9770 10205 considered. These dummy rules have no prerequisites and no recipes, and 9771 10206 they are ignored for all other purposes. For example, the built-in … … 9987 10422 @item 9988 10423 If any rule in that list is @emph{not} a match-anything rule, then 9989 remove all non terminal match-anything rules from the list.10424 remove all non-terminal match-anything rules from the list. 9990 10425 9991 10426 @item … … 10056 10491 prerequisites. @xref{Automatic Variables}. 10057 10492 10058 @node Archives, Features, Implicit Rules, Top10493 @node Archives, Extending make, Implicit Rules, Top 10059 10494 @chapter Using @code{make} to Update Archive Files 10060 10495 @cindex archive 10061 10496 10062 @dfn{Archive files} are files containing named sub files called10497 @dfn{Archive files} are files containing named sub-files called 10063 10498 @dfn{members}; they are maintained with the program @code{ar} and their 10064 10499 main use is as subroutine libraries for linking. … … 10283 10718 @w{%.@var{x}}} and @samp{@w{%.a}: @w{%.@var{x}}}.@refill 10284 10719 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 10724 GNU @code{make} provides many advanced capabilities, including many 10725 useful functions. However, it does not contain a complete programming 10726 language and so it has limitations. Sometimes these limitations can be 10727 overcome through use of the @code{shell} function to invoke a separate 10728 program, although this can be inefficient. 10729 10730 In cases where the built-in capabilities of GNU @code{make} are 10731 insufficient to your requirements there are two options for extending 10732 @code{make}. On systems where it's provided, you can utilize GNU 10733 Guile as an embedded scripting language (@pxref{Guile Integration,,GNU 10734 Guile Integration}). On systems which support dynamically loadable 10735 objects, you can write your own extension in any language (which can 10736 be compiled into such an object) and load it to provide extended 10737 capabilities (@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 10749 GNU @code{make} may be built with support for GNU Guile as an embedded 10750 extension language. Guile implements the Scheme language. A review 10751 of GNU Guile and the Scheme language and its features is beyond the 10752 scope of this manual: see the documentation for GNU Guile and Scheme. 10753 10754 You can determine if @code{make} contains support for Guile by 10755 examining the @code{.FEATURES} variable; it will contain the word 10756 @var{guile} if Guile support is available. 10757 10758 The Guile integration provides one new @code{make} function: @code{guile}. 10759 The @code{guile} function takes one argument which is first expanded 10760 by @code{make} in the normal fashion, then passed to the GNU Guile 10761 evaluator. The result of the evaluator is converted into a string and 10762 used as the expansion of the @code{guile} function in the makefile. 10763 10764 In addition, GNU @code{make} exposes Guile procedures for use in Guile 10765 scripts. 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 10779 There is only one ``data type'' in @code{make}: a string. GNU Guile, 10780 on the other hand, provides a rich variety of different data types. 10781 An important aspect of the interface between @code{make} and GNU Guile 10782 is the conversion of Guile data types into @code{make} strings. 10783 10784 This conversion is relevant in two places: when a makefile invokes the 10785 @code{guile} function to evaluate a Guile expression, the result of 10786 that evaluation must be converted into a make string so it can be 10787 further evaluated by @code{make}. And secondly, when a Guile script 10788 invokes one of the procedures exported by @code{make} the argument 10789 provided to the procedure must be converted into a string. 10790 10791 The conversion of Guile types into @code{make} strings is as below: 10792 10793 @table @code 10794 @item #f 10795 False is converted into the empty string: in @code{make} conditionals 10796 the empty string is considered false. 10797 10798 @item #t 10799 True is converted to the string @samp{#t}: in @code{make} conditionals 10800 any non-empty string is considered true. 10801 10802 @item symbol 10803 @item number 10804 A symbol or number is converted into the string representation of that 10805 symbol or number. 10806 10807 @item character 10808 A printable character is converted to the same character. 10809 10810 @item string 10811 A string containing only printable characters is converted to the same 10812 string. 10813 10814 @item list 10815 A list is converted recursively according to the above rules. This 10816 implies that any structured list will be flattened (that is, a result 10817 of @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 10821 Any 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 10826 The translation of @samp{#f} (to the empty string) and @samp{#t} (to 10827 the non-empty string @samp{#t}) is designed to allow you to use Guile 10828 boolean results directly as @code{make} boolean conditions. For 10829 example: 10830 10831 @example 10832 $(if $(guile (access? "myfile" R_OK)),$(info myfile exists)) 10833 @end example 10834 10835 As a consequence of these conversion rules you must consider the 10836 result of your Guile script, as that result will be converted into a 10837 string and parsed by @code{make}. If there is no natural result for 10838 the script (that is, the script exists solely for its side-effects), 10839 you should add @samp{#f} as the final expression in order to avoid 10840 syntax 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 10847 In addition to the @code{guile} function available in makefiles, 10848 @code{make} exposes some procedures for use in your Guile scripts. At 10849 startup @code{make} creates a new Guile module, @code{gnu make}, and 10850 exports these procedures as public interfaces from that module: 10851 10852 @table @code 10853 @item gmk-expand 10854 @findex gmk-expand 10855 This procedure takes a single argument which is converted into a 10856 string. The string is expanded by @code{make} using normal 10857 @code{make} expansion rules. The result of the expansion is converted 10858 into a Guile string and provided as the result of the procedure. 10859 10860 @item gmk-eval 10861 @findex gmk-eval 10862 This procedure takes a single argument which is converted into a 10863 string. The string is evaluated by @code{make} as if it were a 10864 makefile. This is the same capability available via the @code{eval} 10865 function (@pxref{Eval Function}). The result of the @code{gmk-eval} 10866 procedure is always the empty string. 10867 10868 Note that @code{gmk-eval} is not quite the same as using 10869 @code{gmk-expand} with the @code{eval} function: in the latter case 10870 the 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 10880 Here is a very simple example using GNU Guile to manage writing to a 10881 file. These Guile procedures simply open a file, allow writing to the 10882 file (one string per line), and close the file. Note that because we 10883 cannot store complex values such as Guile ports in @code{make} 10884 variables, we'll keep the port as a global variable in the Guile 10885 interpreter. 10886 10887 You can create Guile functions easily using @code{define}/@code{endef} 10888 to create a Guile script, then use the @code{guile} function to 10889 internalize it: 10890 10891 @example 10892 @group 10893 define 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 10912 endef 10913 10914 # Internalize the Guile IO functions 10915 $(guile $(GUILEIO)) 10916 @end group 10917 @end example 10918 10919 If you have a significant amount of Guile support code, you might 10920 consider keeping it in a different file (e.g., @file{guileio.scm}) and 10921 then loading it in your makefile using the @code{guile} function: 10922 10923 @example 10924 $(guile (load "guileio.scm")) 10925 @end example 10926 10927 An advantage to this method is that when editing @file{guileio.scm}, 10928 your editor will understand that this file contains Scheme syntax 10929 rather than makefile syntax. 10930 10931 Now you can use these Guile functions to create files. Suppose you 10932 need to operate on a very large list, which cannot fit on the command 10933 line, but the utility you're using accepts the list as input as well: 10934 10935 @example 10936 @group 10937 prog: $(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 10945 A more comprehensive suite of file manipulation procedures is possible 10946 of course. You could, for example, maintain multiple output files at 10947 the same time by choosing a symbol for each one and using it as the 10948 key to a hash table, where the value is a port, then returning the 10949 symbol 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 10959 The @code{load} directive and extension capability is considered a 10960 ``technology preview'' in this release of GNU make. We encourage you 10961 to experiment with this feature and we appreciate any feedback on it. 10962 However we cannot guarantee to maintain backward-compatibility in the 10963 next 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 10968 Many operating systems provide a facility for dynamically loading 10969 compiled objects. If your system provides this facility, GNU 10970 @code{make} can make use of it to load dynamic objects at runtime, 10971 providing new capabilities which may then be invoked by your makefile. 10972 10973 The @code{load} directive is used to load a dynamic object. Once the 10974 object is loaded, a ``setup'' function will be invoked to allow the 10975 object to initialize itself and register new facilities with GNU 10976 @code{make}. A dynamic object might include new @code{make} functions, 10977 for 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 10992 Objects are loaded into GNU @code{make} by placing the @code{load} 10993 directive into your makefile. The syntax of the @code{load} directive 10994 is as follows: 10995 10996 @findex load 10997 @example 10998 load @var{object-file} @dots{} 10999 @end example 11000 11001 or: 11002 11003 @example 11004 load @var{object-file}(@var{symbol-name}) @dots{} 11005 @end example 11006 11007 The file @var{object-file} is dynamically loaded by GNU @code{make}. 11008 If @var{object-file} does not include a directory path then it is 11009 first looked for in the current directory. If it is not found there, 11010 or a directory path is included, then system-specific paths will be 11011 searched. If the load fails for any reason, @code{make} will print a 11012 message and exit. 11013 11014 If the load succeeds @code{make} will invoke an initializing function. 11015 11016 If @var{symbol-name} is provided, it will be used as the name of the 11017 initializing function. 11018 11019 If no @var{symbol-name} is provided, the initializing function name is 11020 created by taking the base file name of @var{object-file}, up to the 11021 first character which is not a valid symbol name character 11022 (alphanumerics and underscores are valid symbol name characters). To 11023 this prefix will be appended the suffix @code{_gmk_setup}. 11024 11025 More than one object file may be loaded with a single @code{load} 11026 directive, and both forms of @code{load} arguments may be used in the 11027 same directive. 11028 11029 The initializing function will be provided the file name and line 11030 number of the invocation of the @code{load} operation. It should 11031 return a value of type @code{int}, which must be @code{0} on failure 11032 and non-@code{0} on success. If the return value is @code{-1}, then 11033 GNU make will @emph{not} attempt to rebuild the object file 11034 (@pxref{Remaking Loaded Objects, ,How Loaded Objects Are Remade}). 11035 11036 For example: 11037 11038 @example 11039 load ../mk_funcs.so 11040 @end example 11041 11042 will load the dynamic object @file{../mk_funcs.so}. After the object 11043 is loaded, @code{make} will invoke the function (assumed to be defined 11044 by the shared object) @code{mk_funcs_gmk_setup}. 11045 11046 On the other hand: 11047 11048 @example 11049 load ../mk_funcs.so(init_mk_func) 11050 @end example 11051 11052 will load the dynamic object @file{../mk_funcs.so}. After the object 11053 is loaded, @code{make} will invoke the function @code{init_mk_func}. 11054 11055 Regardless of how many times an object file appears in a @code{load} 11056 directive, it will only be loaded (and its setup function will only 11057 be invoked) once. 11058 11059 @vindex .LOADED 11060 After an object has been successfully loaded, its file name is 11061 appended to the @code{.LOADED} variable. 11062 11063 @findex -load 11064 If you would prefer that failure to load a dynamic object not be 11065 reported as an error, you can use the @code{-load} directive instead 11066 of @code{load}. GNU @code{make} will not fail and no message will be 11067 generated if an object fails to load. The failed object is not added 11068 to the @code{.LOADED} variable, which can then be consulted to 11069 determine 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 11077 Loaded objects undergo the same re-make procedure as makefiles 11078 (@pxref{Remaking Makefiles, ,How Makefiles Are Remade}). If any 11079 loaded object is recreated, then @code{make} will start from scratch 11080 and re-read all the makefiles, and reload the object files again. It 11081 is not necessary for the loaded object to do anything special to 11082 support this.@refill 11083 11084 It's up to the makefile author to provide the rules needed for 11085 rebuilding 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 11094 For this feature to be useful your extensions will need to invoke 11095 various functions internal to GNU @code{make}. The programming 11096 interfaces provided in this release should not be considered stable: 11097 functions may be added, removed, or change calling signatures or 11098 implementations in future versions of GNU @code{make}. 11099 @end quotation 11100 @end cartouche 11101 11102 To be useful, loaded objects must be able to interact with GNU 11103 @code{make}. This interaction includes both interfaces the loaded 11104 object provides to makefiles and also interfaces @code{make} provides 11105 to the loaded object to manipulate @code{make}'s operation. 11106 11107 The interface between loaded objects and @code{make} is defined by the 11108 @file{gnumake.h} C header file. All loaded objects written in C 11109 should include this header file. Any loaded object not written in C 11110 will need to implement the interface defined in this header file. 11111 11112 Typically, a loaded object will register one or more new GNU 11113 @code{make} functions using the @code{gmk_add_function} routine from 11114 within its setup function. The implementations of these @code{make} 11115 functions may make use of the @code{gmk_expand} and @code{gmk_eval} 11116 routines to perform their tasks, then optionally return a string as 11117 the result of the function expansion. 11118 11119 @subsubheading Loaded Object Licensing 11120 @cindex loaded object licensing 11121 @cindex plugin_is_GPL_compatible 11122 11123 Every dynamic extension should define the global symbol 11124 @code{plugin_is_GPL_compatible} to assert that it has been licensed 11125 under 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 11127 extension. 11128 11129 The declared type of the symbol should be @code{int}. It does not need 11130 to be in any allocated section, though. The code merely asserts that 11131 the symbol exists in the global scope. Something like this is enough: 11132 11133 @example 11134 int plugin_is_GPL_compatible; 11135 @end example 11136 11137 @subsubheading Data Structures 11138 11139 @table @code 11140 @item gmk_floc 11141 This structure represents a filename/location pair. It is provided 11142 when defining items, so GNU @code{make} can inform the user later 11143 where the definition occurred if necessary. 11144 @end table 11145 11146 @subsubheading Registering Functions 11147 @findex gmk_add_function 11148 11149 There is currently one way for makefiles to invoke operations provided 11150 by the loaded object: through the @code{make} function call 11151 interface. A loaded object can register one or more new functions 11152 which may then be invoked from within the makefile in the same way as 11153 any other function. 11154 11155 Use @code{gmk_add_function} to create a new @code{make} function. Its 11156 arguments are as follows: 11157 11158 @table @code 11159 @item name 11160 The function name. This is what the makefile should use to invoke the 11161 function. The name must be between 1 and 255 characters long and it 11162 may only contain alphanumeric, period (@samp{.}), dash (@samp{-}), and 11163 underscore (@samp{_}) characters. It may not begin with a period. 11164 11165 @item func_ptr 11166 A pointer to a function that @code{make} will invoke when it expands 11167 the function in a makefile. This function must be defined by the 11168 loaded object. 11169 11170 @item min_args 11171 The minimum number of arguments the function will accept. Must be 11172 between 0 and 255. GNU @code{make} will check this and fail before 11173 invoking @code{func_ptr} if the function was invoked with too few 11174 arguments. 11175 11176 @item max_args 11177 The maximum number of arguments the function will accept. Must be 11178 between 0 and 255. GNU @code{make} will check this and fail before 11179 invoking @code{func_ptr} if the function was invoked with too few 11180 arguments. If the value is 0, then any number of arguments is 11181 accepted. If the value is greater than 0, then it must be greater 11182 than or equal to @code{min_args}. 11183 11184 @item flags 11185 Flags that specify how this function will operate; the desired flags 11186 should be OR'd together. If the @code{GMK_FUNC_NOEXPAND} flag is 11187 given then the function arguments will not be expanded before the 11188 function is called; otherwise they will be expanded first. 11189 @end table 11190 11191 @subsubheading Registered Function Interface 11192 @findex gmk_func_ptr 11193 11194 A 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 11197 arguments to the function), and @code{argv} (an array of pointers to 11198 arguments to the function). The last pointer (that is, 11199 @code{argv[argc]}) will be null (@code{0}). 11200 11201 The return value of the function is the result of expanding the 11202 function. If the function expands to nothing the return value may be 11203 null. Otherwise, it must be a pointer to a string created with 11204 @code{gmk_alloc}. Once the function returns, @code{make} owns this 11205 string and will free it when appropriate; it cannot be accessed by the 11206 loaded object. 11207 11208 @subsubheading GNU @code{make} Facilities 11209 11210 There are some facilities exported by GNU @code{make} for use by 11211 loaded objects. Typically these would be run from within the 11212 setup function and/or the functions registered via 11213 @code{gmk_add_function}, to retrieve or modify the data @code{make} 11214 works with. 11215 11216 @table @code 11217 @item gmk_expand 11218 @findex gmk_expand 11219 This function takes a string and expands it using @code{make} 11220 expansion rules. The result of the expansion is returned in a 11221 nil-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 11226 This function takes a buffer and evaluates it as a segment of makefile 11227 syntax. This function can be used to define new variables, new rules, 11228 etc. It is equivalent to using the @code{eval} @code{make} function. 11229 @end table 11230 11231 Note that there is a difference between @code{gmk_eval} and calling 11232 @code{gmk_expand} with a string using the @code{eval} function: in 11233 the 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 11236 read by the @code{make} parser). 11237 11238 @subsubheading Memory Management 11239 11240 Some systems allow for different memory management schemes. Thus you 11241 should never pass memory that you've allocated directly to any 11242 @code{make} function, nor should you attempt to directly free any 11243 memory returned to you by any @code{make} function. Instead, use the 11244 @code{gmk_alloc} and @code{gmk_free} functions. 11245 11246 In particular, the string returned to @code{make} by a function 11247 registered using @code{gmk_add_function} @emph{must} be allocated 11248 using @code{gmk_alloc}, and the string returned from the @code{make} 11249 @code{gmk_expand} function @emph{must} be freed (when no longer 11250 needed) using @code{gmk_free}. 11251 11252 @table @code 11253 @item gmk_alloc 11254 @findex gmk_alloc 11255 Return a pointer to a newly-allocated buffer. This function will 11256 always return a valid pointer; if not enough memory is available 11257 @code{make} will exit. 11258 11259 @item gmk_free 11260 @findex gmk_free 11261 Free 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 11270 Let's suppose we wanted to write a new GNU @code{make} function that 11271 would create a temporary file and return its name. We would like our 11272 function to take a prefix as an argument. First we can write the 11273 function 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 11286 int plugin_is_GPL_compatible; 11287 11288 char * 11289 gen_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 11314 int 11315 mk_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 11324 Next, we will write a makefile that can build this shared object, load 11325 it, and use it: 11326 11327 @example 11328 @group 11329 all: 11330 @@echo Temporary file: $(mk-temp tmpfile.) 11331 11332 load mk_temp.so 11333 11334 mk_temp.so: mk_temp.c 11335 $(CC) -shared -fPIC -o $@ $< 11336 @end group 11337 @end example 11338 11339 On MS-Windows, due to peculiarities of how shared objects are 11340 produced, the compiler needs to scan the @dfn{import library} produced 11341 when building @code{make}, typically called 11342 @file{libgnumake-@var{version}.dll.a}, where @var{version} is the 11343 version of the load object API. So the recipe to produce a shared 11344 object will look on Windows like this (assuming the API version is 1): 11345 11346 @example 11347 @group 11348 mk_temp.dll: mk_temp.c 11349 $(CC) -shared -o $@ $< -lgnumake-1 11350 @end group 11351 @end example 11352 11353 Now when you run @code{make} you'll see something like: 11354 11355 @example 11356 $ make 11357 cc -shared -fPIC -o mk_temp.so mk_temp.c 11358 Temporary 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 11365 GNU @code{make} is often one component in a larger system of tools, 11366 including integrated development environments, compiler toolchains, 11367 and others. The role of @code{make} is to start commands and 11368 determine whether they succeeded or not: no special integration is 11369 needed to accomplish that. However, sometimes it is convenient to 11370 bind @code{make} more tightly with other parts of the system, both 11371 higher-level (tools that invoke @code{make}) and lower-level (tools 11372 that @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 11384 GNU @code{make} has the ability to run multiple recipes in parallel 11385 (@pxref{Parallel, ,Parallel Execution}) and to cap the total number of 11386 parallel jobs even across recursive invocations of @code{make} 11387 (@pxref{Options/Recursion, ,Communicating Options to a 11388 Sub-@code{make}}). Tools that @code{make} invokes which are also able 11389 to run multiple operations in parallel, either using multiple threads 11390 or multiple processes, can be enhanced to participate in GNU 11391 @code{make}'s job management facility to ensure that the total number 11392 of active threads/processes running on the system does not exceed the 11393 maximum number of slots provided to GNU @code{make}. @refill 11394 11395 @cindex jobserver 11396 GNU @code{make} uses a method called the ``jobserver'' to control the 11397 number of active jobs across recursive invocations. The actual 11398 implementation of the jobserver varies across different operating 11399 systems, but some fundamental aspects are always true. 11400 11401 First, only command lines that @code{make} understands to be recursive 11402 invocations of @code{make} (@pxref{MAKE Variable, ,How the @code{MAKE} 11403 Variable Works}) will have access to the jobserver. When writing 11404 makefiles you must be sure to mark the command as recursive (most 11405 commonly by prefixing the command line with the @code{+} indicator 11406 (@pxref{Recursion, ,Recursive Use of @code{make}}). 11407 11408 Second, @code{make} will provide information necessary for accessing 11409 the jobserver through the environment to its children, in the 11410 @code{MAKEFLAGS} environment variable. Tools which want to 11411 participate in the jobserver protocol will need to parse this 11412 environment variable, as described in subsequent sections. 11413 11414 Third, every command @code{make} starts has one implicit job slot 11415 reserved for it before it starts. Any tool which wants to participate 11416 in the jobserver protocol should assume it can always run one job 11417 without having to contact the jobserver at all. 11418 11419 Finally, it's critical that tools that participate in the jobserver 11420 protocol return the exact number of slots they obtained from the 11421 jobserver back to the jobserver before they exit, even under error 11422 conditions. Remember that the implicit job slot should @strong{not} 11423 be returned to the jobserver! Returning too few slots means that 11424 those slots will be lost for the rest of the build process; returning 11425 too many slots means that extra slots will be available. The 11426 top-level @code{make} command will print an error message at the end 11427 of the build if it detects an incorrect number of slots available in 11428 the jobserver. 11429 11430 As an example, suppose you are implementing a linker which provides 11431 for multithreaded operation. You would like to enhance the linker so 11432 that if it is invoked by GNU @code{make} it can participate in the 11433 jobserver protocol to control how many threads are used during link. 11434 First you will need to modify the linker to determine if the 11435 @code{MAKEFLAGS} environment variable is set. Next you will need to 11436 parse the value of that variable to determine if the jobserver is 11437 available, and how to access it. If it is available then you can 11438 access it to obtain job slots controlling how much parallelism your 11439 tool can use. Once done your tool must return those job slots back to 11440 the 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 11451 On POSIX systems the jobserver is implemented as a simple UNIX pipe. 11452 The pipe will be pre-loaded with one single-character token for each 11453 available job. To obtain an extra slot you must read a single 11454 character from the jobserver pipe; to release a slot you must write a 11455 single character back into the jobserver pipe. 11456 11457 To access the pipe you must parse the @code{MAKEFLAGS} variable and 11458 look for the argument string @code{--jobserver-auth=R,W} where 11459 @samp{R} and @samp{W} are non-negative integers representing file 11460 descriptors: @samp{R} is the read file descriptor and @samp{W} is the 11461 write file descriptor. 11462 11463 It's important that when you release the job slot, you write back the 11464 same character you read from the pipe for that slot. Don't assume 11465 that all tokens are the same character; different characters may have 11466 different meanings to GNU @code{make}. The order is not important, 11467 since @code{make} has no idea in what order jobs will complete anyway. 11468 11469 There are various error conditions you must consider to ensure your 11470 implementation is robust: 11471 11472 @itemize @bullet 11473 @item 11474 Usually you will have a command-line argument controlling the parallel 11475 operation of your tool. Consider whether your tool should detect 11476 situations where both the jobserver and the command-line argument are 11477 specified, and how it should react. 11478 11479 @item 11480 If your tool determines that the @code{--jobserver-auth} option is 11481 available in @code{MAKEFLAGS} but that the file descriptors specified 11482 are closed, this means that the calling @code{make} process did not 11483 think that your tool was a recursive @code{make} invocation (e.g., the 11484 command line was not prefixed with a @code{+} character). You should 11485 notify your users of this situation. 11486 11487 @item 11488 Your tool should also examine the first word of the @code{MAKEFLAGS} 11489 variable and look for the character @code{n}. If this character is 11490 present then @code{make} was invoked with the @samp{-n} option and 11491 your tool should stop without performing any operations. 11492 11493 @item 11494 Your tool should be sure to write back the tokens it read, even under 11495 error conditions. This includes not only errors in your tool but also 11496 outside influences such as interrupts (@code{SIGINT}), etc. You may 11497 want 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 11504 On Windows systems the jobserver is implemented as a named semaphore. 11505 The semaphore will be set with an initial count equal to the number of 11506 available slots; to obtain a slot you must wait on the semaphore (with 11507 or without a timeout). To release a slot, release the semaphore. 11508 11509 To access the semaphore you must parse the @code{MAKEFLAGS} variable and 11510 look 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 11514 There are various error conditions you must consider to ensure your 11515 implementation is robust: 11516 11517 @itemize @bullet 11518 @item 11519 Usually you will have a command-line argument controlling the parallel 11520 operation of your tool. Consider whether your tool should detect 11521 situations where both the jobserver and the command-line argument are 11522 specified, and how it should react. 11523 11524 @item 11525 Your tool should be sure to release the semaphore for the tokens it 11526 read, even under error conditions. This includes not only errors in 11527 your tool but also outside influences such as interrupts 11528 (@code{SIGINT}), etc. You may want to install signal handlers to 11529 manage 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 11537 Normally GNU @code{make} will invoke all commands with access to the 11538 same standard and error outputs that @code{make} itself was started 11539 with. A number of tools will detect whether the output is a terminal 11540 or not-a-terminal, and use this information to change the output 11541 style. For example if the output goes to a terminal the tool may add 11542 control characters that set color, or even change the location of the 11543 cursor. If the output is not going to a terminal then these special 11544 control characters are not emitted so that they don't corrupt log 11545 files, etc. 11546 11547 The @code{--output-sync} (@pxref{Parallel Output, ,Output During 11548 Parallel Output}) option will defeat the terminal detection. When 11549 output synchronization is enabled GNU @code{make} arranges for all 11550 command output to be written to a file, so that its output can be 11551 written as a block without interference from other commands. This 11552 means that all tools invoked by @code{make} will believe that their 11553 output is not going to be displayed on a terminal, even when it will 11554 be (because @code{make} will display it there after the command is 11555 completed). 11556 11557 In order to facilitate tools which would like to determine whether or 11558 not their output will be displayed on a terminal, GNU @code{make} will 11559 set the @code{MAKE_TERMOUT} and @code{MAKE_TERMERR} environment 11560 variables before invoking any commands. Tools which would like to 11561 determine whether standard or error output (respectively) will be 11562 displayed on a terminal can check these environment variables to 11563 determine if they exist and contain a non-empty value. If so the tool 11564 can assume that the output will (eventually) be displayed on a 11565 terminal. If the variables are not set or have an empty value, then 11566 the tool should fall back to its normal methods of detecting whether 11567 output is going to a terminal or not. 11568 11569 The content of the variables can be parsed to determine the type of 11570 terminal which will be used to display the output. 11571 11572 Similarly, environments which invoke @code{make} and would like to 11573 capture the output and eventually display it on a terminal (or some 11574 display which can interpret terminal control characters) can set these 11575 variables before invoking @code{make}. GNU @code{make} will not 11576 modify these environment variables if they already exist when it 11577 starts. 11578 11579 @node Features, Missing, Integrating make, Top 10286 11580 @chapter Features of GNU @code{make} 10287 11581 @cindex features of GNU @code{make} … … 10350 11644 10351 11645 @item 10352 The arrangement of lines and backslash -newline combinations in11646 The arrangement of lines and backslash/newline combinations in 10353 11647 recipes is retained when the recipes are printed, so they appear as 10354 11648 they do in the makefile, except for the stripping of initial … … 10393 11687 10394 11688 @item 11689 A number of different build tools that support parallelism also 11690 support collecting output and displaying as a single block. 11691 @xref{Parallel Output, ,Output During Parallel Execution}. 11692 11693 @item 10395 11694 Modified variable references using pattern substitution come from 10396 11695 SunOS 4. @xref{Reference, ,Basics of Variable References}. … … 10421 11720 @code{-include} directive.) The same feature appears with the name 10422 11721 @code{sinclude} in SGI @code{make} and perhaps others. 11722 11723 @item 11724 The @code{!=} shell assignment operator exists in many BSD of 11725 @code{make} and is purposefully implemented here to behave identically 11726 to those implementations. 11727 11728 @item 11729 Various build management tools are implemented using scripting 11730 languages such as Perl or Python and thus provide a natural embedded 11731 scripting language, similar to GNU @code{make}'s integration of GNU 11732 Guile. 10423 11733 @end itemize 10424 11734 … … 10524 11834 @item 10525 11835 Various new built-in implicit rules. 10526 @xref{Catalogue of Rules, ,Catalogue of ImplicitRules}.11836 @xref{Catalogue of Rules, ,Catalogue of Built-In Rules}. 10527 11837 10528 11838 @item 10529 The built-in variable @samp{MAKE_VERSION} gives the version number of 10530 @code{make}. 10531 @vindex MAKE_VERSION 11839 Load dynamic objects which can modify the behavior of @code{make}. 11840 @xref{Loading Objects, ,Loading Dynamic Objects}. 10532 11841 @end itemize 10533 11842 … … 10550 11859 10551 11860 This feature was not put into GNU @code{make} because of the 10552 non modularity of putting knowledge into @code{make} of the internal11861 non-modularity of putting knowledge into @code{make} of the internal 10553 11862 format of archive file symbol tables. 10554 11863 @xref{Archive Symbols, ,Updating Archive Symbol Directories}. … … 10648 11957 This appendix summarizes the directives, text manipulation functions, 10649 11958 and special variables which GNU @code{make} understands. 10650 @xref{Special Targets}, @ref{Catalogue of Rules, ,Catalogue of ImplicitRules},11959 @xref{Special Targets}, @ref{Catalogue of Rules, ,Catalogue of Built-In Rules}, 10651 11960 and @ref{Options Summary, ,Summary of Options}, 10652 11961 for other summaries. … … 10658 11967 @itemx define @var{variable} = 10659 11968 @itemx define @var{variable} := 11969 @itemx define @var{variable} ::= 10660 11970 @itemx define @var{variable} += 10661 11971 @itemx define @var{variable} ?= … … 10872 12182 @xref{Eval Function, ,The @code{eval} Function}. 10873 12183 12184 @item $(file @var{op} @var{filename},@var{text}) 12185 Expand 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 10874 12189 @item $(value @var{var}) 10875 12190 Evaluates to the contents of the variable @var{var}, with no expansion … … 10971 12286 @code{MAKE} Variable Works}. 10972 12287 12288 @item MAKE_VERSION 12289 12290 The built-in variable @samp{MAKE_VERSION} expands to the version 12291 number of the GNU @code{make} program. 12292 @vindex MAKE_VERSION 12293 12294 @item MAKE_HOST 12295 12296 The built-in variable @samp{MAKE_HOST} expands to a string 12297 representing the host that GNU @code{make} was built to run on. 12298 @vindex MAKE_HOST 12299 10973 12300 @item MAKELEVEL 10974 12301 … … 10987 12314 through the environment from its parent. 10988 12315 12316 @item GNUMAKEFLAGS 12317 12318 Other flags parsed by @code{make}. You can set this in the environment or 12319 a makefile to set @code{make} command-line flags. GNU @code{make} 12320 never sets this variable itself. This variable is only needed if 12321 you'd like to set GNU @code{make}-specific flags in a POSIX-compliant 12322 makefile. This variable will be seen by GNU @code{make} and ignored 12323 by other @code{make} implementations. It's not needed if you only use 12324 GNU @code{make}; just use @code{MAKEFLAGS} directly. 12325 @xref{Options/Recursion, ,Communicating Options to a Sub-@code{make}}. 12326 10989 12327 @item MAKECMDGOALS 10990 12328 … … 10995 12333 @item CURDIR 10996 12334 10997 Set to the pathname of the current working directory (after all10998 @code{-C} options are processed, if any). Setting this variable has no 10999 effect on the operation of @code{make}.@*12335 Set to the absolute pathname of the current working directory (after 12336 all @code{-C} options are processed, if any). Setting this variable 12337 has no effect on the operation of @code{make}.@* 11000 12338 @xref{Recursion, ,Recursive Use of @code{make}}. 11001 12339 … … 11025 12363 Error messages are all either prefixed with the name of the program 11026 12364 (usually @samp{make}), or, if the error is found in a makefile, the name 11027 of the file and line number containing the problem.12365 of the file and line number containing the problem. 11028 12366 11029 12367 In the table below, these common prefixes are left off. … … 11039 12377 signal of some type). @xref{Errors, ,Errors in Recipes}. 11040 12378 11041 If no @code{***} is attached to the message, then the sub process failed12379 If no @code{***} is attached to the message, then the sub-process failed 11042 12380 but the rule in the makefile was prefixed with the @code{-} special 11043 12381 character, so @code{make} ignored the error. … … 11079 12417 If you want that file to be built, you will need to add a rule to your 11080 12418 makefile describing how that target can be built. Other possible 11081 sources of this problem are typos in the makefile (if that file name is12419 sources of this problem are typos in the makefile (if that file name is 11082 12420 wrong) or a corrupted source tree (if that file is not supposed to be 11083 12421 built, but rather only a prerequisite). … … 11113 12451 This means you've defined a normal (recursive) @code{make} variable 11114 12452 @var{xxx} that, when it's expanded, will refer to itself (@var{xxx}). 11115 This is not allowed; either use simply-expanded variables (@ code{:=}) or11116 use the append operator (@code{+=}). @xref{Using Variables, ,How to Use 11117 Variables }.12453 This is not allowed; either use simply-expanded variables (@samp{:=} 12454 or @samp{::=}) or use the append operator (@samp{+=}). @xref{Using 12455 Variables, ,How to Use Variables}. 11118 12456 11119 12457 @item Unterminated variable reference. Stop. … … 11130 12468 @itemx target pattern contains no `%'. Stop. 11131 12469 @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. 12470 These are generated for malformed static pattern rules. The first 12471 means there's no pattern in the target section of the rule; the second 12472 means there are multiple patterns in the target section; the third 12473 means the target doesn't contain a pattern character (@code{%}); and 12474 the fourth means that all three parts of the static pattern rule 12475 contain pattern characters (@code{%})--only the first two parts 12476 should. If you see these errors and you aren't trying to create a 12477 static pattern rule, check the value of any variables in your target 12478 and prerequisite lists to be sure they do not contain colons. 11138 12479 @xref{Static Usage, ,Syntax of Static Pattern Rules}. 11139 12480 … … 11168 12509 11169 12510 Here is the makefile for the GNU @code{tar} program. This is a 11170 moderately complex makefile. 12511 moderately complex makefile. The first line uses a @code{#!} setting 12512 to allow the makefile to be executed directly. 11171 12513 11172 12514 Because it is the first target, the default goal is @samp{all}. An … … 11204 12546 @example 11205 12547 @group 12548 #!/usr/bin/make -f 11206 12549 # Generated automatically from Makefile.in by configure. 11207 12550 # Un*x Makefile for GNU tar program. -
vendor/gnumake/current/dosbuild.bat
r2596 r3138 1 1 @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. 2 rem Copyright (C) 1998-2016 Free Software Foundation, Inc. 4 3 rem This file is part of GNU Make. 5 4 rem … … 22 21 @echo on 23 22 gcc -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g commands.c -o commands.o 23 gcc -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g output.c -o output.o 24 24 gcc -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g job.c -o job.o 25 25 gcc -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g dir.c -o dir.o … … 53 53 cd .. 54 54 echo commands.o > respf.$$$ 55 for %%f in (job dir file misc main read remake rule implicit default variable) do echo %%f.o >> respf.$$$55 for %%f in (job output dir file misc main read remake rule implicit default variable) do echo %%f.o >> respf.$$$ 56 56 for %%f in (expand function vpath hash strcache version ar arscan signame remote-stub getopt getopt1) do echo %%f.o >> respf.$$$ 57 57 echo glob/libglob.a >> respf.$$$ 58 rem gcc -c -I. -I./glob -DHAVE_CONFIG_H -O2 -g guile.c -o guile.o 59 rem echo guile.o >> respf.$$$ 58 60 @echo Linking... 59 61 @echo on -
vendor/gnumake/current/expand.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 21 19 #include <assert.h> … … 29 27 /* Initially, any errors reported when expanding strings will be reported 30 28 against the file where the error appears. */ 31 const structfloc **expanding_var = &reading_file;29 const floc **expanding_var = &reading_file; 32 30 33 31 /* The next two describe the variable output buffer. … … 64 62 unsigned int offset = ptr - variable_buffer; 65 63 variable_buffer_length = (newlen + 100 > 2 * variable_buffer_length 66 67 64 ? newlen + 100 65 : 2 * variable_buffer_length); 68 66 variable_buffer = xrealloc (variable_buffer, variable_buffer_length); 69 67 ptr = variable_buffer + offset; … … 100 98 { 101 99 char *value; 102 const structfloc *this_var;103 const structfloc **saved_varp;100 const floc *this_var; 101 const floc **saved_varp; 104 102 struct variable_set_list *save = 0; 105 103 int set_reading = 0; … … 125 123 if (!v->exp_count) 126 124 /* Expanding V causes infinite recursion. Lose. */ 127 fatal (*expanding_var,128 _("Recursive variable `%s' references itself (eventually)"),129 125 OS (fatal, *expanding_var, 126 _("Recursive variable '%s' references itself (eventually)"), 127 v->name); 130 128 --v->exp_count; 131 129 } … … 190 188 a null byte is found. 191 189 192 Write the results to LINE, which must point into `variable_buffer'. If190 Write the results to LINE, which must point into 'variable_buffer'. If 193 191 LINE is NULL, start at the beginning of the buffer. 194 192 Return a pointer to LINE, or to the beginning of the buffer if LINE is … … 200 198 struct variable *v; 201 199 const char *p, *p1; 202 char * abuf = NULL;200 char *save; 203 201 char *o; 204 202 unsigned int line_offset; 205 203 206 204 if (!line) 207 line = initialize_variable_output ();205 line = initialize_variable_output (); 208 206 o = line; 209 207 line_offset = line - variable_buffer; … … 215 213 } 216 214 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; 227 220 228 221 while (1) … … 230 223 /* Copy all following uninteresting chars all at once to the 231 224 variable output buffer, and skip them. Uninteresting chars end 232 225 at the next $ or the end of the input. */ 233 226 234 227 p1 = strchr (p, '$'); … … 237 230 238 231 if (p1 == 0) 239 232 break; 240 233 p = p1 + 1; 241 234 … … 243 236 244 237 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 == '(') ? ')' : '}'; 257 252 const char *begp; 258 259 253 const char *beg = p + 1; 254 char *op; 260 255 char *abeg = NULL; 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 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) 277 272 /* Unterminated variable reference. */ 278 fatal (*expanding_var, _("unterminated variable reference"));279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 such as `$($(a)'. */295 296 297 298 299 300 301 302 303 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 304 299 finished expanding this one, P will be incremented to 305 300 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); 335 328 336 329 /* If the variable is not empty, perform the 337 330 substitution. */ 338 339 340 341 331 if (v != 0 && *v->value != '\0') 332 { 333 char *pattern, *replace, *ppercent, *rpercent; 334 char *value = (v->recursive 342 335 ? recursively_expand (v) 343 336 : v->value); 344 337 345 338 /* Copy the pattern and the replacement. Add in an … … 359 352 /* Look for %. Set the percent pointers properly 360 353 based on whether we find one or not. */ 361 362 354 ppercent = find_percent (pattern); 355 if (ppercent) 363 356 { 364 357 ++ppercent; … … 367 360 ++rpercent; 368 361 } 369 362 else 370 363 { 371 364 ppercent = pattern; … … 378 371 ppercent, rpercent); 379 372 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). */ 405 394 o = reference_variable (o, p, 1); 406 395 407 408 396 break; 397 } 409 398 410 399 if (*p == '\0') 411 400 break; 412 401 413 402 ++p; 414 403 } 415 404 416 if (abuf) 417 free (abuf); 405 free (save); 418 406 419 407 variable_buffer_output (o, "", 1); … … 423 411 424 412 /* 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. 426 414 Return the address of the resulting string, which is null-terminated 427 415 and is valid only until the next time this function is called. */ … … 430 418 variable_expand (const char *line) 431 419 { 432 return variable_expand_string (NULL, line, (long)-1);420 return variable_expand_string (NULL, line, (long)-1); 433 421 } 434 422 … … 437 425 The text starting at STR and ending at END is variable-expanded 438 426 into a null-terminated string that is returned as the value. 439 This is done without clobbering `variable_buffer' or the current427 This is done without clobbering 'variable_buffer' or the current 440 428 variable-expansion that is in progress. */ 441 429 … … 447 435 448 436 if (str == end) 449 return xstrdup ("");437 return xstrdup (""); 450 438 451 439 if (!end || *end == '\0') … … 462 450 r = allocated_variable_expand (tmp); 463 451 464 if (alloc) 465 free (alloc); 452 free (alloc); 466 453 467 454 return r; … … 477 464 char *result; 478 465 struct variable_set_list *savev; 479 const structfloc *savef;466 const floc *savef; 480 467 481 468 if (file == 0) … … 506 493 static char * 507 494 variable_append (const char *name, unsigned int length, 508 const struct variable_set_list *set )495 const struct variable_set_list *set, int local) 509 496 { 510 497 const struct variable *v; 511 498 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; 512 501 513 502 /* If there's nothing left to check, return the empty buffer. */ … … 518 507 v = lookup_variable_in_set (name, length, set->set); 519 508 520 /* If there isn't one, look to see if there's one in aset 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); 523 512 524 513 /* If this variable type is append, first get any upper values. 525 514 If not, initialize the buffer. */ 526 515 if (v->append) 527 buf = variable_append (name, length, set->next );516 buf = variable_append (name, length, set->next, nextlocal); 528 517 else 529 518 buf = initialize_variable_output (); … … 555 544 variable_buffer = 0; 556 545 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); 558 548 variable_buffer_output (val, "", 1); 559 549 val = variable_buffer; -
vendor/gnumake/current/file.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 21 19 #include <assert.h> 22 20 21 #include "filedef.h" 23 22 #include "dep.h" 24 #include "filedef.h"25 23 #include "job.h" 26 24 #include "commands.h" … … 57 55 { 58 56 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 65 60 static struct hash_table files; 66 61 … … 78 73 struct file *f; 79 74 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 81 78 char *lname; 79 #endif 82 80 #endif 83 81 … … 88 86 on the command line. */ 89 87 #ifdef VMS 88 want_vmsify = (strpbrk (name, "]>:^") != NULL); 90 89 # ifndef WANT_CASE_SENSITIVE_TARGETS 91 90 if (*name != '.') … … 103 102 while (name[0] == '[' && name[1] == ']' && name[2] != '\0') 104 103 name += 2; 104 while (name[0] == '<' && name[1] == '>' && name[2] != '\0') 105 name += 2; 105 106 #endif 106 107 while (name[0] == '.' 107 108 #ifdef HAVE_DOS_PATHS 108 109 && (name[1] == '/' || name[1] == '\\') 109 110 #else 110 111 && name[1] == '/' 111 112 #endif 112 113 && name[2] != '\0') 113 114 { 114 115 name += 2; 115 116 while (*name == '/' 116 117 #ifdef HAVE_DOS_PATHS 117 118 || *name == '\\' 118 119 #endif 119 120 121 120 ) 121 /* Skip following slashes: ".//foo" is "foo", not "/foo". */ 122 ++name; 122 123 } 123 124 124 125 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 126 133 #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 = "[]"; 132 137 #endif 133 138 } 134 139 file_key.hname = name; 135 140 f = hash_find_item (&files, &file_key); … … 156 161 157 162 assert (*name != '\0'); 158 assert ( strcache_iscached (name));163 assert (! verify_flag || strcache_iscached (name)); 159 164 160 165 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS) … … 180 185 f = *file_slot; 181 186 if (! HASH_VACANT (f) && !f->double_colon) 182 return f; 187 { 188 f->builtin = 0; 189 return f; 190 } 183 191 184 192 new = xcalloc (sizeof (struct file)); 185 193 new->name = new->hname = name; 186 new->update_status = -1;194 new->update_status = us_none; 187 195 188 196 if (HASH_VACANT (f)) … … 204 212 205 213 /* 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, 207 215 and possibly merged with an existing file called NAME. */ 208 216 … … 217 225 218 226 /* If it's already that name, we're done. */ 227 from_file->builtin = 0; 219 228 file_key.hname = to_hname; 220 229 if (! file_hash_cmp (from_file, &file_key)) … … 261 270 else if (from_file->cmds != to_file->cmds) 262 271 { 272 size_t l = strlen (from_file->name); 263 273 /* We have two sets of commands. We will go with the 264 274 one given in the rule explicitly mentioning this name, … … 266 276 if (to_file->cmds->fileinfo.filenm != 0) 267 277 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,"), 269 280 from_file->name, to_file->cmds->fileinfo.filenm, 270 281 to_file->cmds->fileinfo.lineno); 271 282 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,"), 274 285 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'."), 277 289 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'."), 280 292 to_hname, from_file->name); 281 293 } … … 297 309 298 310 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 311 OSS (fatal, NILF, _("can't rename single-colon '%s' to double-colon '%s'"), 312 from_file->name, to_hname); 301 313 if (!to_file->double_colon && from_file->double_colon) 302 314 { 303 315 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); 306 319 else 307 320 to_file->double_colon = from_file->double_colon; … … 322 335 MERGE (cmd_target); 323 336 MERGE (phony); 337 MERGE (loaded); 324 338 MERGE (ignore_vpath); 325 339 #undef MERGE 326 340 341 to_file->builtin = 0; 327 342 from_file->renamed = to_file; 328 343 } 329 344 330 345 /* 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, 332 347 and possibly merged with an existing file called NAME. */ 333 348 … … 368 383 if (! HASH_VACANT (*file_slot)) 369 384 { 370 385 struct file *f = *file_slot; 371 386 /* Is this file eligible for automatic deletion? 372 387 Yes, IFF: it's marked intermediate, it's not secondary, it wasn't 373 388 given on the command line, and it's either a -include makefile or 374 389 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 } 416 432 } 417 433 … … 430 446 split_prereqs (char *p) 431 447 { 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); 433 450 434 451 if (*p) … … 439 456 440 457 ++p; 441 ood = PARSE_ FILE_SEQ (&p, struct dep, '\0', NULL, 0);458 ood = PARSE_SIMPLE_SEQ (&p, struct dep); 442 459 443 460 if (! new) … … 579 596 if (d->staticpattern) 580 597 { 581 char *o; 582 d->name = o = variable_expand (""); 598 char *o = variable_expand (""); 583 599 o = subst_expand (o, name, "%", "$*", 1, 2, 0); 584 600 *o = '\0'; 585 601 free (name); 586 d->name = name = xstrdup ( d->name);602 d->name = name = xstrdup (variable_buffer); 587 603 d->staticpattern = 0; 588 604 } … … 641 657 } 642 658 643 /* For each dependency of each file, make the `struct dep' point644 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). 645 661 646 662 Also mark the files depended on by .PRECIOUS, .PHONY, .SILENT, … … 697 713 for (d = f->deps; d != 0; d = d->next) 698 714 for (f2 = d->file; f2 != 0; f2 = f2->prev) 699 715 f2->precious = 1; 700 716 701 717 for (f = lookup_file (".LOW_RESOLUTION_TIME"); f != 0; f = f->prev) 702 718 for (d = f->deps; d != 0; d = d->next) 703 719 for (f2 = d->file; f2 != 0; f2 = f2->prev) 704 720 f2->low_resolution_time = 1; 705 721 706 722 for (f = lookup_file (".PHONY"); f != 0; f = f->prev) 707 723 for (d = f->deps; d != 0; d = d->next) 708 724 for (f2 = d->file; f2 != 0; f2 = f2->prev) 709 710 711 725 { 726 /* Mark this file as phony nonexistent target. */ 727 f2->phony = 1; 712 728 f2->is_target = 1; 713 714 715 729 f2->last_mtime = NONEXISTENT_MTIME; 730 f2->mtime_before_update = NONEXISTENT_MTIME; 731 } 716 732 717 733 for (f = lookup_file (".INTERMEDIATE"); f != 0; f = f->prev) … … 745 761 { 746 762 if (f->deps == 0) 747 763 ignore_errors_flag = 1; 748 764 else 749 750 751 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; 752 768 } 753 769 … … 756 772 { 757 773 if (f->deps == 0) 758 774 silent_flag = 1; 759 775 else 760 761 762 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; 763 779 } 764 780 … … 777 793 778 794 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. */ 780 796 781 797 void … … 794 810 795 811 FILE_TIMESTAMP 796 file_timestamp_cons (const char *fname, time_t s ,int ns)812 file_timestamp_cons (const char *fname, time_t stamp, long int ns) 797 813 { 798 814 int offset = ORDINARY_MTIME_MIN + (FILE_TIMESTAMP_HI_RES ? ns : 0); 815 FILE_TIMESTAMP s = stamp; 799 816 FILE_TIMESTAMP product = (FILE_TIMESTAMP) s << FILE_TIMESTAMP_LO_BITS; 800 817 FILE_TIMESTAMP ts = product + offset; 801 818 802 819 if (! (s <= FILE_TIMESTAMP_S (ORDINARY_MTIME_MAX) 803 820 && product <= ts && ts <= ORDINARY_MTIME_MAX)) 804 821 { 805 822 char buf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1]; 823 const char *f = fname ? fname : _("Current time"); 806 824 ts = s <= OLD_MTIME ? ORDINARY_MTIME_MIN : ORDINARY_MTIME_MAX; 807 825 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); 810 828 } 811 829 … … 832 850 if (clock_gettime (CLOCK_REALTIME, ×pec) == 0) 833 851 { 834 835 836 837 852 r = 1; 853 s = timespec.tv_sec; 854 ns = timespec.tv_nsec; 855 goto got_time; 838 856 } 839 857 } … … 844 862 if (gettimeofday (&timeval, 0) == 0) 845 863 { 846 847 848 849 864 r = 1000; 865 s = timeval.tv_sec; 866 ns = timeval.tv_usec * 1000; 867 goto got_time; 850 868 } 851 869 } … … 874 892 if (tm) 875 893 sprintf (p, "%04d-%02d-%02d %02d:%02d:%02d", 876 877 894 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, 895 tm->tm_hour, tm->tm_min, tm->tm_sec); 878 896 else if (t < 0) 879 897 sprintf (p, "%ld", (long) t); … … 927 945 const struct file *f = item; 928 946 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 929 954 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 930 968 if (!f->is_target) 931 969 puts (_("# Not a target:")); … … 941 979 if (f->dontcare) 942 980 puts (_("# A default, MAKEFILES, or -include/sinclude makefile.")); 981 if (f->builtin) 982 puts (_("# Builtin rule")); 943 983 puts (f->tried_implicit 944 984 ? _("# Implicit rule search has been done.") 945 985 : _("# Implicit rule search has not been done.")); 946 986 if (f->stem != 0) 947 printf (_("# Implicit/static pattern stem: `%s'\n"), f->stem);987 printf (_("# Implicit/static pattern stem: '%s'\n"), f->stem); 948 988 if (f->intermediate) 949 989 puts (_("# File is an intermediate prerequisite.")); … … 953 993 fputs (_("# Also makes:"), stdout); 954 994 for (d = f->also_make; d != 0; d = d->next) 955 995 printf (" %s", dep_name (d)); 956 996 putchar ('\n'); 957 997 } … … 981 1021 case cs_finished: 982 1022 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 } 1002 1037 break; 1003 1038 default: 1004 puts (_("# Invalid value in `command_state' member!"));1039 puts (_("# Invalid value in 'command_state' member!")); 1005 1040 fflush (stdout); 1006 1041 fflush (stderr); … … 1033 1068 1034 1069 #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); \ 1038 1074 }while(0) 1039 1075 -
vendor/gnumake/current/filedef.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 20 18 /* Structure that represents the info on one file 21 19 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'. */ 23 21 24 22 #include "hash.h" … … 29 27 const char *hname; /* Hashed filename */ 30 28 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 35 32 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. */ 43 37 struct file *last; /* Last entry for the same file name. */ 44 38 45 39 /* 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). */ 47 41 struct file *renamed; 48 42 … … 62 56 struct file *double_colon; 63 57 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. */ 73 77 } command_state ENUM_BITFIELD (2); 74 78 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. */ 78 84 unsigned int tried_implicit:1; /* Nonzero if have searched 79 80 81 unsigned int updating:1; 82 unsigned int updated:1; 83 unsigned int is_target:1; 84 unsigned int cmd_target:1; 85 unsigned int phony:1; 86 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. */ 87 93 unsigned int intermediate:1;/* Nonzero if this is an intermediate file. */ 88 94 unsigned int secondary:1; /* Nonzero means remove_intermediates should 89 95 not delete it. */ 90 unsigned int dontcare:1; 91 96 unsigned int dontcare:1; /* Nonzero if no complaint is to be made if 97 this target cannot be remade. */ 92 98 unsigned int ignore_vpath:1;/* Nonzero if we threw out VPATH name. */ 93 99 unsigned int pat_searched:1;/* Nonzero if we already searched for 94 100 pattern-specific variables. */ 95 unsigned int considered:1; /* equal to 'considered' if file has been96 considered on current scan of goal chain */97 101 unsigned int no_diag:1; /* True if the file failed to update and no 98 102 diagnostics has been issued (dontcare). */ … … 100 104 101 105 102 extern struct file * suffix_file, *default_file;106 extern struct file *default_file; 103 107 104 108 … … 114 118 void notice_finished_file (struct file *file); 115 119 void init_hash_files (void); 120 void verify_file_data_base (void); 116 121 char *build_target_list (char *old_list); 117 122 void print_prereqs (const struct dep *deps); 118 123 void print_file_data_base (void); 124 int try_implicit_rule (struct file *file, unsigned int depth); 125 int stemlen_compare (const void *v1, const void *v2); 119 126 120 127 #if FILE_TIMESTAMP_HI_RES 121 128 # 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) 123 130 #else 124 131 # define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \ … … 135 142 136 143 #define FILE_TIMESTAMP_S(ts) (((ts) - ORDINARY_MTIME_MIN) \ 137 144 >> FILE_TIMESTAMP_LO_BITS) 138 145 #define FILE_TIMESTAMP_NS(ts) ((int) (((ts) - ORDINARY_MTIME_MIN) \ 139 146 & ((1 << FILE_TIMESTAMP_LO_BITS) - 1))) 140 147 141 148 /* 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, 143 150 since the year might be less than -999 or greater than 9999. 144 151 … … 157 164 + 1 + 1 + 4 + 25) 158 165 159 FILE_TIMESTAMP file_timestamp_cons (char const *, time_t, int);166 FILE_TIMESTAMP file_timestamp_cons (char const *, time_t, long int); 160 167 FILE_TIMESTAMP file_timestamp_now (int *); 161 168 void file_timestamp_sprintf (char *p, FILE_TIMESTAMP ts); … … 188 195 #define ORDINARY_MTIME_MIN (OLD_MTIME + 1) 189 196 #define ORDINARY_MTIME_MAX ((FILE_TIMESTAMP_S (NEW_MTIME) \ 190 191 192 193 /* Modtime value to use for `infinitely new'. We used to get the current time194 from the system and use that whenever we wanted `new'. But that causes197 << 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 195 202 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' 197 204 targets, which need to be considered newer than anything that depends on 198 205 them, even if said dependents' modtimes are in the future. */ -
vendor/gnumake/current/function.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 #include "filedef.h" 21 19 #include "variable.h" … … 32 30 struct function_table_entry 33 31 { 32 union { 33 char *(*func_ptr) (char *output, char **argv, const char *fname); 34 gmk_func_ptr alloc_func_ptr; 35 } fptr; 34 36 const char *name; 35 37 unsigned char len; 36 38 unsigned char minimum_args; 37 39 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; 40 42 }; 41 43 … … 87 89 o = variable_buffer_output (o, t, strlen (t)); 88 90 if (rlen > 0) 89 91 o = variable_buffer_output (o, replace, rlen); 90 92 return o; 91 93 } … … 94 96 { 95 97 if (by_word && slen == 0) 96 97 98 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)); 99 101 else 100 101 102 103 104 105 106 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 } 109 111 110 112 /* Output everything before this occurrence of the string to replace. */ 111 113 if (p > t) 112 114 o = variable_buffer_output (o, t, p - t); 113 115 114 116 /* If we're substituting only by fully matched words, 115 117 or only at the ends of words, check that this case qualifies. */ 116 118 if (by_word 117 && ((p > text && ! isblank ((unsigned char)p[-1]))118 || (p[slen] != '\0' && !isblank ((unsigned char)p[slen]))))119 120 121 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); 122 124 else if (rlen > 0) 123 124 125 /* Output the replacement string. */ 126 o = variable_buffer_output (o, replace, rlen); 125 127 126 128 /* Advance T past the string to be replaced. */ … … 170 172 /* With no % in the pattern, this is just a simple substitution. */ 171 173 return subst_expand (o, text, pattern, replace, 172 174 strlen (pattern), strlen (replace), 1); 173 175 174 176 /* Record the length of PATTERN before and after the % … … 183 185 /* Is it big enough to match? */ 184 186 if (len < pattern_prepercent_len + pattern_postpercent_len) 185 187 fail = 1; 186 188 187 189 /* Does the prefix match? */ 188 190 if (!fail && pattern_prepercent_len > 0 189 190 191 192 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; 193 195 194 196 /* Does the suffix match? */ 195 197 if (!fail && pattern_postpercent_len > 0 196 197 198 199 200 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; 201 203 202 204 if (fail) 203 204 205 /* It didn't match. Output the string. */ 206 o = variable_buffer_output (o, t, len); 205 207 else 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 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 } 224 226 225 227 /* Output a space, but not if the replacement is "". */ 226 228 if (fail || replace_prepercent_len > 0 227 228 229 230 231 229 || (replace_percent != 0 && len + replace_postpercent_len > 0)) 230 { 231 o = variable_buffer_output (o, " ", 1); 232 doneany = 1; 233 } 232 234 } 233 235 if (doneany) … … 271 273 lookup_function (const char *s) 272 274 { 275 struct function_table_entry function_table_entry_key; 273 276 const char *e = s; 274 277 275 while ( *e && ( (*e >= 'a' && *e <= 'z') || *e == '-'))278 while (STOP_SET (*e, MAP_USERFUNC)) 276 279 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); 286 288 } 287 289 … … 302 304 percent = find_percent (new_chars); 303 305 if (percent == 0) 304 306 return streq (new_chars, str); 305 307 pattern = new_chars; 306 308 } … … 337 339 else if (*ptr == endparen) 338 340 { 339 340 341 341 --count; 342 if (count < 0) 343 return NULL; 342 344 } 343 345 … … 362 364 unsigned int idx; 363 365 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. 366 368 That would break examples like: 367 369 $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)). */ … … 436 438 tp = find_next_token (&list1_iterator, &len1); 437 439 if (tp != 0) 438 440 o = variable_buffer_output (o, tp, len1); 439 441 440 442 pp = find_next_token (&list2_iterator, &len2); 441 443 if (pp != 0) 442 444 o = variable_buffer_output (o, pp, len2); 443 445 444 446 if (tp != 0 || pp != 0) 445 446 447 448 447 { 448 o = variable_buffer_output (o, " ", 1); 449 doneany = 1; 450 } 449 451 } 450 452 while (tp != 0 || pp != 0); … … 469 471 default: 470 472 case o_invalid: 471 472 473 abort (); 474 break; 473 475 case o_default: 474 475 476 o = variable_buffer_output (o, "default", 7); 477 break; 476 478 case o_env: 477 478 479 o = variable_buffer_output (o, "environment", 11); 480 break; 479 481 case o_file: 480 481 482 o = variable_buffer_output (o, "file", 4); 483 break; 482 484 case o_env_override: 483 484 485 o = variable_buffer_output (o, "environment override", 20); 486 break; 485 487 case o_command: 486 487 488 o = variable_buffer_output (o, "command line", 12); 489 break; 488 490 case o_override: 489 490 491 o = variable_buffer_output (o, "override", 8); 492 break; 491 493 case o_automatic: 492 493 494 o = variable_buffer_output (o, "automatic", 9); 495 break; 494 496 } 495 497 … … 513 515 } 514 516 515 #ifdef VMS516 # define IS_PATHSEP(c) ((c) == ']')517 #else518 # ifdef HAVE_DOS_PATHS519 # define IS_PATHSEP(c) ((c) == '/' || (c) == '\\')520 # else521 # define IS_PATHSEP(c) ((c) == '/')522 # endif523 #endif524 525 517 526 518 static char * … … 533 525 unsigned int len=0; 534 526 535 int is_suffix = streq (funcname, "suffix");527 int is_suffix = funcname[0] == 's'; 536 528 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 537 546 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; 548 553 549 554 if (p >= p2) 550 551 552 553 554 555 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 } 557 562 #ifdef HAVE_DOS_PATHS 558 563 /* Handle the case of "d:foo/bar". */ 559 else if ( streq (funcname, "notdir")&& p2[0] && p2[1] == ':')560 561 562 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 } 564 569 #endif 565 570 else if (is_notdir) 566 571 o = variable_buffer_output (o, p2, len); 567 572 568 573 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 } 573 584 } 574 585 … … 587 598 const char *p3 = argv[0]; 588 599 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 595 618 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; 604 624 605 625 if (p >= p2 && (is_dir)) … … 614 634 else if (is_dir) 615 635 #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 } 617 643 #else 618 644 #ifndef _AMIGA … … 626 652 o = variable_buffer_output (o, p2, len); 627 653 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 629 661 doneany = 1; 630 662 } … … 642 674 int fixlen = strlen (argv[0]); 643 675 const char *list_iterator = argv[1]; 644 int is_addprefix = streq (funcname, "addprefix");676 int is_addprefix = funcname[3] == 'p'; 645 677 int is_addsuffix = !is_addprefix; 646 678 … … 652 684 { 653 685 if (is_addprefix) 654 686 o = variable_buffer_output (o, argv[0], fixlen); 655 687 o = variable_buffer_output (o, p, len); 656 688 if (is_addsuffix) 657 689 o = variable_buffer_output (o, argv[0], fixlen); 658 690 o = variable_buffer_output (o, " ", 1); 659 691 doneany = 1; … … 671 703 { 672 704 o = subst_expand (o, argv[2], argv[0], argv[1], strlen (argv[0]), 673 705 strlen (argv[1]), 0); 674 706 675 707 return o; … … 714 746 char buf[20]; 715 747 716 while (find_next_token (&word_iterator, (unsigned int *) 0) != 0)748 while (find_next_token (&word_iterator, NULL) != 0) 717 749 ++i; 718 750 … … 731 763 strip_whitespace (const char **begpp, const char **endpp) 732 764 { 733 while (*begpp <= *endpp && isspace ((unsigned char)**begpp))765 while (*begpp <= *endpp && ISSPACE (**begpp)) 734 766 (*begpp) ++; 735 while (*endpp >= *begpp && isspace ((unsigned char)**endpp))767 while (*endpp >= *begpp && ISSPACE (**endpp)) 736 768 (*endpp) --; 737 769 return (char *)*begpp; … … 746 778 747 779 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. */ 749 781 break; 750 782 751 783 if (s <= end || end - beg < 0) 752 fatal (*expanding_var, "%s: '%s'", msg, beg);784 OSS (fatal, *expanding_var, "%s: '%s'", msg, beg); 753 785 } 754 786 … … 763 795 764 796 /* 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")); 766 798 i = atoi (argv[0]); 767 799 768 800 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")); 771 803 772 804 end_p = argv[1]; … … 788 820 /* Check the arguments. */ 789 821 check_numeric (argv[0], 790 _("non-numeric first argument to `wordlist' function"));822 _("non-numeric first argument to 'wordlist' function")); 791 823 check_numeric (argv[1], 792 _("non-numeric second argument to `wordlist' function"));824 _("non-numeric second argument to 'wordlist' function")); 793 825 794 826 start = atoi (argv[0]); 795 827 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); 798 830 799 831 count = atoi (argv[1]) - start + 1; … … 846 878 struct variable *var; 847 879 880 /* Clean up the variable name by removing whitespace. */ 881 char *vp = next_token (varname); 882 end_of_token (vp)[0] = '\0'; 883 848 884 push_new_variable_scope (); 849 var = define_variable (v arname, strlen (varname), "", o_automatic, 0);885 var = define_variable (vp, strlen (vp), "", o_automatic, 0); 850 886 851 887 /* loop through LIST, put the value in VAR and expand BODY */ … … 904 940 return result; 905 941 return_STRING_COMPARE (((struct a_word const *) x)->str, 906 942 ((struct a_word const *) y)->str); 907 943 } 908 944 … … 913 949 char *percent; 914 950 int length; 915 int save_c;916 951 }; 917 952 … … 927 962 928 963 struct hash_table a_word_table; 929 int is_filter = streq (funcname, "filter");964 int is_filter = funcname[CSTRLEN ("filter")] == '\0'; 930 965 const char *pat_iterator = argv[0]; 931 966 const char *word_iterator = argv[1]; … … 936 971 unsigned int len; 937 972 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. */ 939 976 940 977 pattail = &pathead; … … 947 984 948 985 if (*pat_iterator != '\0') 949 986 ++pat_iterator; 950 987 951 988 pat->str = p; 952 pat->length = len;953 pat->save_c = p[len];954 989 p[len] = '\0'; 955 990 pat->percent = find_percent (p); 956 991 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); 958 996 } 959 997 *pattail = 0; … … 970 1008 971 1009 if (*word_iterator != '\0') 972 1010 ++word_iterator; 973 1011 974 1012 p[len] = '\0'; … … 988 1026 a_word_hash_cmp); 989 1027 for (wp = wordhead; wp != 0; wp = wp->next) 990 991 992 993 994 1028 { 1029 struct a_word *owp = hash_insert (&a_word_table, wp); 1030 if (owp) 1031 wp->chain = owp; 1032 } 995 1033 } 996 1034 … … 1001 1039 /* Run each pattern through the words, killing words. */ 1002 1040 for (pp = pathead; pp != 0; pp = pp->next) 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 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 } 1024 1062 1025 1063 /* Output the words that matched (or didn't, for filter-out). */ 1026 1064 for (wp = wordhead; wp != 0; wp = wp->next) 1027 1028 1029 1030 1031 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 } 1033 1071 1034 1072 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 } 1041 1076 1042 1077 if (hashing) … … 1058 1093 const char *word_start; 1059 1094 1060 while (isspace ((unsigned char)*p)) 1061 ++p; 1095 NEXT_TOKEN (p); 1062 1096 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 {} 1065 1099 if (!i) 1066 1100 break; 1067 1101 o = variable_buffer_output (o, word_start, i); 1068 1102 o = variable_buffer_output (o, " ", 1); … … 1104 1138 strcpy (p, *argvp); 1105 1139 1106 switch (*funcname) { 1140 switch (*funcname) 1141 { 1107 1142 case 'e': 1108 fatal (reading_file, "%s", msg);1143 OS (fatal, reading_file, "%s", msg); 1109 1144 1110 1145 case 'w': 1111 error (reading_file, "%s", msg);1146 OS (error, reading_file, "%s", msg); 1112 1147 break; 1113 1148 1114 1149 case 'i': 1115 printf ("%s\n", msg);1116 fflush(stdout);1150 outputs (0, msg); 1151 outputs (0, "\n"); 1117 1152 break; 1118 1153 1119 1154 default: 1120 fatal (*expanding_var, "Internal error: func_error: '%s'", funcname);1121 }1155 OS (fatal, *expanding_var, "Internal error: func_error: '%s'", funcname); 1156 } 1122 1157 1123 1158 /* The warning function expands to the empty string. */ … … 1137 1172 char *p; 1138 1173 unsigned int len; 1139 int i;1140 1174 1141 1175 /* Find the maximum number of words we'll have. */ 1142 1176 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; 1151 1181 ++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 *)); 1158 1185 1159 1186 /* Now assign pointers to each string in the array. */ … … 1169 1196 if (wordi) 1170 1197 { 1198 int i; 1199 1171 1200 /* Now sort the list of words. */ 1172 1201 qsort (words, wordi, sizeof (char *), alpha_compare); … … 1312 1341 { 1313 1342 char *expansion; 1314 int result;1315 1343 1316 1344 while (1) … … 1318 1346 const char *begp = *argv; 1319 1347 const char *endp = begp + strlen (*argv) - 1; 1348 int result; 1320 1349 1321 1350 /* An empty condition is always false. */ … … 1379 1408 install_variable_buffer (&buf, &len); 1380 1409 1381 eval_buffer (argv[0] );1410 eval_buffer (argv[0], NULL); 1382 1411 1383 1412 restore_variable_buffer (buf, len); … … 1395 1424 /* Copy its value into the output buffer without expanding it. */ 1396 1425 if (v) 1397 o = variable_buffer_output (o, v->value, strlen (v->value));1426 o = variable_buffer_output (o, v->value, strlen (v->value)); 1398 1427 1399 1428 return o; … … 1401 1430 1402 1431 /* 1403 \r 1432 \r is replaced on UNIX as well. Is this desirable? 1404 1433 */ 1405 1434 static void 1406 fold_newlines (char *buffer, unsigned int *length )1435 fold_newlines (char *buffer, unsigned int *length, int trim_newlines) 1407 1436 { 1408 1437 char *dst = buffer; 1409 1438 char *src = buffer; 1410 char *last_nonnl = buffer - 1;1439 char *last_nonnl = buffer - 1; 1411 1440 src[*length] = 0; 1412 1441 for (; *src != '\0'; ++src) 1413 1442 { 1414 1443 if (src[0] == '\r' && src[1] == '\n') 1415 1444 continue; 1416 1445 if (*src == '\n') 1417 1418 1419 1446 { 1447 *dst++ = ' '; 1448 } 1420 1449 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 1426 1459 *(++last_nonnl) = '\0'; 1427 1460 *length = last_nonnl - buffer; 1428 1461 } 1429 1462 1430 1431 1432 int shell_function_pid = 0, shell_function_completed; 1433 1463 pid_t shell_function_pid = 0; 1464 static int shell_function_completed; 1465 1466 void 1467 shell_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 } 1434 1480 1435 1481 #ifdef WINDOWS32 … … 1441 1487 1442 1488 1443 void 1444 windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp)1489 int 1490 windows32_openpipe (int *pipedes, int errfd, pid_t *pid_p, char **command_argv, char **envp) 1445 1491 { 1446 1492 SECURITY_ATTRIBUTES saAttr; 1447 HANDLE hIn ;1448 HANDLE hErr ;1493 HANDLE hIn = INVALID_HANDLE_VALUE; 1494 HANDLE hErr = INVALID_HANDLE_VALUE; 1449 1495 HANDLE hChildOutRd; 1450 1496 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; 1453 1503 1454 1504 saAttr.nLength = sizeof (SECURITY_ATTRIBUTES); … … 1456 1506 saAttr.lpSecurityDescriptor = NULL; 1457 1507 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); 1484 1568 1485 1569 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 } 1487 1574 1488 1575 /* make sure that CreateProcess() has Path it needs */ 1489 sync_Path_environment ();1490 /* `sync_Path_environment' may realloc `environ', so take note of1576 sync_Path_environment (); 1577 /* 'sync_Path_environment' may realloc 'environ', so take note of 1491 1578 the new value. */ 1492 1579 envp = environ; 1493 1580 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 } 1522 1613 } 1523 1614 #endif … … 1529 1620 { 1530 1621 FILE *fpipe=0; 1531 /* MSDOS can't fork, but it has `popen'. */1622 /* MSDOS can't fork, but it has 'popen'. */ 1532 1623 struct variable *sh = lookup_variable ("SHELL", 5); 1533 1624 int e; … … 1535 1626 1536 1627 /* Make sure not to bother processing an empty line. */ 1537 while (isblank ((unsigned char)*text)) 1538 ++text; 1628 NEXT_TOKEN (text); 1539 1629 if (*text == '\0') 1540 1630 return 0; … … 1544 1634 char buf[PATH_MAX + 7]; 1545 1635 /* This makes sure $SHELL value is used by $(shell), even 1546 1636 though the target environment is not passed to it. */ 1547 1637 sprintf (buf, "SHELL=%s", sh->value); 1548 1638 putenv (buf); … … 1563 1653 *pidp = -1; 1564 1654 if (dos_status) 1565 1655 errno = EINTR; 1566 1656 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); 1569 1661 } 1570 1662 else … … 1573 1665 *pidp = 42; /* Yes, the Meaning of Life, the Universe, and Everything! */ 1574 1666 errno = e; 1575 shell_function_completed = 1;1576 1667 } 1577 1668 return fpipe; … … 1586 1677 1587 1678 /* VMS can't do $(shell ...) */ 1679 1680 char * 1681 func_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 1588 1688 #define func_shell 0 1589 1689 1590 1690 #else 1591 1691 #ifndef _AMIGA 1592 staticchar *1593 func_shell (char *o, char **argv, const char *funcname UNUSED)1692 char * 1693 func_shell_base (char *o, char **argv, int trim_newlines) 1594 1694 { 1595 1695 char *batch_filename = NULL; 1596 1696 int errfd; 1597 1697 #ifdef __MSDOS__ 1598 1698 FILE *fpipe; … … 1605 1705 1606 1706 #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 1607 1715 /* Construct the argument list. */ 1608 1716 command_argv = construct_command_argv (argv[0], NULL, NULL, 0, 1609 1717 &batch_filename); 1610 1718 if (command_argv == 0) 1611 return o; 1719 { 1720 #ifdef WINDOWS32 1721 just_print_flag = j_p_f; 1612 1722 #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. 1620 1733 1621 1734 See Savannah bug #10593. 1622 1735 1623 envp = target_environment (N ILF);1736 envp = target_environment (NULL); 1624 1737 */ 1625 1738 … … 1630 1743 { 1631 1744 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); 1633 1747 error_prefix = p; 1634 1748 } 1635 1749 else 1636 1750 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); 1637 1757 1638 1758 #if defined(__MSDOS__) … … 1643 1763 return o; 1644 1764 } 1765 1645 1766 #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 1647 1771 if (pipedes[0] < 0) 1648 1772 { 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"); 1652 1776 return o; 1653 1777 } 1654 else 1778 1655 1779 #else 1656 1780 if (pipe (pipedes) < 0) … … 1660 1784 } 1661 1785 1662 # ifdef __EMX__ 1663 /* close some handles that are unnecessary for the child process */ 1786 /* Close handles that are unnecessary for the child process. */ 1664 1787 CLOSE_ON_EXEC(pipedes[1]); 1665 1788 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 1668 1799 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 } 1678 1804 #endif 1679 { 1680 /* We are the parent. */1681 1682 1683 1684 1685 1686 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; 1687 1813 #ifndef __MSDOS__ 1688 1689 1690 1691 1692 1693 1694 1695 1696 libraries barf when `close' is called with -1. */1697 1698 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]); 1699 1825 #endif 1700 1826 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 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. */ 1722 1848 #ifdef __MSDOS__ 1723 if (fpipe) 1724 (void) pclose (fpipe); 1849 if (fpipe) 1850 { 1851 int st = pclose (fpipe); 1852 shell_completed (st, 0); 1853 } 1725 1854 #else 1726 1855 (void) close (pipedes[0]); 1727 1856 #endif 1728 1857 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); 1739 1869 } 1740 1741 1742 /* The child_handler function will set shell_function_completed1743 to 1 when the child dies normally, or to -1 if it 1744 dies with status 127, which ismost likely an exec fail. */1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 fold_newlines (buffer, &i);1758 1759 1760 1761 1762 1763 1764 return o; 1765 } 1766 1767 #else 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 */ 1768 1898 1769 1899 /* Do the Amiga version of func_shell. */ 1770 1900 1771 staticchar *1772 func_shell (char *o, char **argv, const char *funcname)1901 char * 1902 func_shell_base (char *o, char **argv, int trim_newlines) 1773 1903 { 1774 1904 /* Amiga can't fork nor spawn, but I can start a program with … … 1800 1930 1801 1931 /* 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 special1932 Ideally we would use output_tmpfile(), but this uses a special 1803 1933 Open(), not fopen(), and I'm not familiar enough with the code to mess 1804 1934 with it. */ … … 1835 1965 { 1836 1966 if (i == maxlen) 1837 1838 1839 1840 1967 { 1968 maxlen += 512; 1969 buffer = xrealloc (buffer, maxlen + 1); 1970 } 1841 1971 1842 1972 cc = Read (child_stdout, &buffer[i], maxlen - i); 1843 1973 if (cc > 0) 1844 1974 i += cc; 1845 1975 } while (cc > 0); 1846 1976 1847 1977 Close (child_stdout); 1848 1978 1849 fold_newlines (buffer, &i );1979 fold_newlines (buffer, &i, trim_newlines); 1850 1980 o = variable_buffer_output (o, buffer, i); 1851 1981 free (buffer); … … 1853 1983 } 1854 1984 #endif /* _AMIGA */ 1985 1986 static char * 1987 func_shell (char *o, char **argv, const char *funcname UNUSED) 1988 { 1989 return func_shell_base (o, argv, 1); 1990 } 1855 1991 #endif /* !VMS */ 1856 1992 … … 1858 1994 1859 1995 /* 1860 equality. Return is string-boolean, i e, the empty string is false.1996 equality. Return is string-boolean, i.e., the empty string is false. 1861 1997 */ 1862 1998 static char * 1863 func_eq (char *o, char **argv, char *funcname )1999 func_eq (char *o, char **argv, char *funcname UNUSED) 1864 2000 { 1865 2001 int result = ! strcmp (argv[0], argv[1]); … … 1873 2009 */ 1874 2010 static char * 1875 func_not (char *o, char **argv, char *funcname )2011 func_not (char *o, char **argv, char *funcname UNUSED) 1876 2012 { 1877 2013 const char *s = argv[0]; 1878 2014 int result = 0; 1879 while (isspace ((unsigned char)*s)) 1880 s++; 2015 NEXT_TOKEN (s); 1881 2016 result = ! (*s); 1882 2017 o = variable_buffer_output (o, result ? "1" : "", result); … … 1888 2023 1889 2024 #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 1892 2031 #else 1893 2032 #define IS_ABSOLUTE(n) (n[0] == '/') … … 1895 2034 #endif 1896 2035 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 ('/'). */ 1899 2038 1900 2039 static char * … … 1914 2053 /* It is unlikely we would make it until here but just to make sure. */ 1915 2054 if (!starting_directory) 1916 2055 return NULL; 1917 2056 1918 2057 strcpy (apath, starting_directory); 1919 2058 1920 2059 #ifdef HAVE_DOS_PATHS 1921 if ( IS_PATHSEP(name[0]))1922 1923 if (IS_PATHSEP(name[1]))1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 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 } 1936 2075 #endif 1937 2076 … … 1940 2079 else 1941 2080 { 2081 #if defined(__CYGWIN__) && defined(HAVE_DOS_PATHS) 2082 if (STOP_SET (name[0], MAP_DIRSEP)) 2083 root_len = 1; 2084 #endif 1942 2085 strncpy (apath, name, root_len); 1943 2086 apath[root_len] = '\0'; … … 1946 2089 name += root_len; 1947 2090 #ifdef HAVE_DOS_PATHS 1948 if (! IS_PATHSEP(apath[2]))1949 1950 1951 1952 1953 1954 1955 1956 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 } 1958 2101 else 1959 apath[2] = '/';/* make sure it's a forward slash */2102 apath[root_len - 1] = '/'; /* make sure it's a forward slash */ 1960 2103 #endif 1961 2104 } … … 1966 2109 1967 2110 /* Skip sequence of multiple path-separators. */ 1968 while ( IS_PATHSEP(*start))1969 2111 while (STOP_SET (*start, MAP_DIRSEP)) 2112 ++start; 1970 2113 1971 2114 /* 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) 1973 2116 ; 1974 2117 … … 1976 2119 1977 2120 if (len == 0) 1978 2121 break; 1979 2122 else if (len == 1 && start[0] == '.') 1980 2123 /* nothing */; 1981 2124 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 } 1987 2131 else 1988 1989 if (!IS_PATHSEP(dest[-1]))2132 { 2133 if (! STOP_SET (dest[-1], MAP_DIRSEP)) 1990 2134 *dest++ = '/'; 1991 2135 1992 2136 if (dest + len >= apath_limit) 1993 2137 return NULL; 1994 2138 1995 2139 dest = memcpy (dest, start, len); 1996 2140 dest += len; 1997 1998 2141 *dest = '\0'; 2142 } 1999 2143 } 2000 2144 2001 2145 /* 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)) 2003 2147 --dest; 2004 2148 … … 2017 2161 int doneany = 0; 2018 2162 unsigned int len = 0; 2019 #ifndef HAVE_REALPATH2020 struct stat st;2021 #endif2022 PATH_VAR (in);2023 PATH_VAR (out);2024 2163 2025 2164 while ((path = find_next_token (&p, &len)) != 0) … … 2027 2166 if (len < GET_PATH_MAX) 2028 2167 { 2168 char *rp; 2169 struct stat st; 2170 PATH_VAR (in); 2171 PATH_VAR (out); 2172 2029 2173 strncpy (in, path, len); 2030 2174 in[len] = '\0'; 2031 2175 2032 if (2033 2176 #ifdef HAVE_REALPATH 2034 realpath (in, out)2177 ENULLLOOP (rp, realpath (in, out)); 2035 2178 #else 2036 abspath (in, out) && stat (out, &st) == 02179 rp = abspath (in, out); 2037 2180 #endif 2038 ) 2181 2182 if (rp) 2039 2183 { 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 } 2043 2192 } 2044 2193 } … … 2048 2197 if (doneany) 2049 2198 --o; 2199 2200 return o; 2201 } 2202 2203 static char * 2204 func_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); 2050 2284 2051 2285 return o; … … 2060 2294 int doneany = 0; 2061 2295 unsigned int len = 0; 2062 PATH_VAR (in);2063 PATH_VAR (out);2064 2296 2065 2297 while ((path = find_next_token (&p, &len)) != 0) … … 2067 2299 if (len < GET_PATH_MAX) 2068 2300 { 2301 PATH_VAR (in); 2302 PATH_VAR (out); 2303 2069 2304 strncpy (in, path, len); 2070 2305 in[len] = '\0'; … … 2100 2335 static char *func_call (char *o, char **argv, const char *funcname); 2101 2336 2337 #define FT_ENTRY(_name, _min, _max, _exp, _func) \ 2338 { { (_func) }, STRING_SIZE_TUPLE(_name), (_min), (_max), (_exp), 0 } 2102 2339 2103 2340 static struct function_table_entry function_table_init[] = 2104 2341 { 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), 2141 2379 #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), 2144 2382 #endif 2145 2383 }; … … 2155 2393 const struct function_table_entry *entry_p) 2156 2394 { 2395 char *p; 2396 2157 2397 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'"), 2160 2400 argc, entry_p->name); 2161 2401 2162 /* I suppose technically some function could do something with no 2163 arguments, but so far nonedo, so just test it for all functions here2402 /* 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 2164 2404 rather than in each one. We can change it later if necessary. */ 2165 2405 2166 if (!argc )2406 if (!argc && !entry_p->alloc_fn) 2167 2407 return o; 2168 2408 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; 2174 2427 } 2175 2428 … … 2202 2455 whitespace after the name). */ 2203 2456 2204 beg = next_token (beg + entry_p->len); 2457 beg += entry_p->len; 2458 NEXT_TOKEN (beg); 2205 2459 2206 2460 /* Find the end of the function invocation, counting nested use of … … 2218 2472 2219 2473 if (count >= 0) 2220 fatal (*expanding_var, 2221 _("unterminated call to function `%s': missing `%c'"),2222 2474 fatal (*expanding_var, strlen (entry_p->name), 2475 _("unterminated call to function '%s': missing '%c'"), 2476 entry_p->name, closeparen); 2223 2477 2224 2478 *stringp = end; … … 2286 2540 for (argvp=argv; *argvp != 0; ++argvp) 2287 2541 free (*argvp); 2288 if (abeg)2542 else 2289 2543 free (abeg); 2290 2544 … … 2303 2557 static int max_args = 0; 2304 2558 char *fname; 2305 char *cp;2306 2559 char *body; 2307 2560 int flen; … … 2311 2564 struct variable *v; 2312 2565 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'; 2323 2569 2324 2570 /* Calling nothing is a no-op */ … … 2399 2645 2400 2646 void 2647 define_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 2684 void 2401 2685 hash_init_function_table (void) 2402 2686 { 2403 2687 hash_init (&function_table, FUNCTION_TABLE_ENTRIES * 2, 2404 2405 2688 function_table_entry_hash_1, function_table_entry_hash_2, 2689 function_table_entry_hash_cmp); 2406 2690 hash_load (&function_table, function_table_init, 2407 2408 } 2691 FUNCTION_TABLE_ENTRIES, sizeof (struct function_table_entry)); 2692 } -
vendor/gnumake/current/getloadavg.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1985-2016 Free Software Foundation, Inc. 5 3 6 4 GNU Make is free software; you can redistribute it and/or modify it under the … … 87 85 88 86 /* 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 program87 if the system has its own 'getloadavg' function. 88 89 The declaration of 'errno' is needed by the test program 92 90 as well as the function itself, so it comes first. */ 93 91 … … 748 746 /* This call can return -1 for an error, but with good args 749 747 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 *'. */ 751 749 dg_sys_info ((long int *) &load_info, 752 750 DG_SYS_INFO_LOAD_INFO_TYPE, … … 991 989 992 990 #ifdef TEST 993 #include "make .h"991 #include "makeint.h" 994 992 995 993 int -
vendor/gnumake/current/getopt.c
r2596 r3138 4 4 before changing it! 5 5 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. 6 Copyright (C) 1987-2016 Free Software Foundation, Inc. 9 7 10 8 NOTE: The canonical source of this file is maintained with the GNU C Library. … … 84 82 85 83 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' 87 85 but it behaves differently for the user, since it allows the user 88 86 to intersperse the options with the other arguments. … … 662 660 { 663 661 if (opterr) 664 fprintf (stderr, _("%s: option `%s' is ambiguous\n"),662 fprintf (stderr, _("%s: option '%s' is ambiguous\n"), 665 663 argv[0], argv[optind]); 666 664 nextchar += strlen (nextchar); … … 686 684 /* --option */ 687 685 fprintf (stderr, 688 _("%s: option `--%s' doesn't allow an argument\n"),686 _("%s: option '--%s' doesn't allow an argument\n"), 689 687 argv[0], pfound->name); 690 688 else 691 689 /* +option or -option */ 692 690 fprintf (stderr, 693 _("%s: option `%c%s' doesn't allow an argument\n"),691 _("%s: option '%c%s' doesn't allow an argument\n"), 694 692 argv[0], argv[optind - 1][0], pfound->name); 695 693 … … 708 706 if (opterr) 709 707 fprintf (stderr, 710 _("%s: option `%s' requires an argument\n"),708 _("%s: option '%s' requires an argument\n"), 711 709 argv[0], argv[optind - 1]); 712 710 nextchar += strlen (nextchar); … … 737 735 if (argv[optind][1] == '-') 738 736 /* --option */ 739 fprintf (stderr, _("%s: unrecognized option `--%s'\n"),737 fprintf (stderr, _("%s: unrecognized option '--%s'\n"), 740 738 argv[0], nextchar); 741 739 else 742 740 /* +option or -option */ 743 fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),741 fprintf (stderr, _("%s: unrecognized option '%c%s'\n"), 744 742 argv[0], argv[optind][0], nextchar); 745 743 } … … 847 845 { 848 846 if (opterr) 849 fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),847 fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), 850 848 argv[0], argv[optind]); 851 849 nextchar += strlen (nextchar); … … 866 864 if (opterr) 867 865 fprintf (stderr, _("\ 868 %s: option `-W %s' doesn't allow an argument\n"),866 %s: option '-W %s' doesn't allow an argument\n"), 869 867 argv[0], pfound->name); 870 868 … … 881 879 if (opterr) 882 880 fprintf (stderr, 883 _("%s: option `%s' requires an argument\n"),881 _("%s: option '%s' requires an argument\n"), 884 882 argv[0], argv[optind - 1]); 885 883 nextchar += strlen (nextchar); … … 1008 1006 1009 1007 case 'c': 1010 printf ("option c with value `%s'\n", optarg);1008 printf ("option c with value '%s'\n", optarg); 1011 1009 break; 1012 1010 -
vendor/gnumake/current/getopt.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1989-2016 Free Software Foundation, Inc. 5 3 6 4 NOTE: The canonical source of this file is maintained with the GNU C Library. -
vendor/gnumake/current/getopt1.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1987-1994, 1996-2016 Free Software Foundation, Inc. 5 3 6 4 NOTE: The canonical source of this file is maintained with the GNU C Library. … … 152 150 153 151 case 'c': 154 printf ("option c with value `%s'\n", optarg);152 printf ("option c with value '%s'\n", optarg); 155 153 break; 156 154 157 155 case 'd': 158 printf ("option d with value `%s'\n", optarg);156 printf ("option d with value '%s'\n", optarg); 159 157 break; 160 158 -
vendor/gnumake/current/gettext.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1995-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 -
vendor/gnumake/current/glob/ChangeLog
r2596 r3138 1 2013-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 1 7 2008-09-28 Juan Manuel Guerrero <juan.guerrero@gmx.de> 2 8 -
vendor/gnumake/current/glob/glob.c
r2596 r3138 378 378 return -1; 379 379 } 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; 380 385 381 386 if (flags & GLOB_BRACE) -
vendor/gnumake/current/glob/glob.h
r1989 r3138 57 57 /* This is a guess. */ 58 58 /*hb 59 * Conflicts with DECCs a ready defined type __size_t.59 * Conflicts with DECCs already defined type __size_t. 60 60 * Defining an own type with a name beginning with '__' is no good. 61 61 * Anyway if DECC is used and __SIZE_T is defined then __size_t is -
vendor/gnumake/current/hash.c
r2596 r3138 15 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 16 16 17 #include "make .h"17 #include "makeint.h" 18 18 #include "hash.h" 19 19 20 #define CALLOC(t, n) ((t *) calloc (sizeof (t),(n)))20 #define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n))) 21 21 #define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n))) 22 22 #define REALLOC(o, t, n) ((t *) xrealloc ((o), sizeof (t) * (n))) … … 27 27 28 28 /* Implement double hashing with open addressing. The table size is 29 always a power of two. The secondary ( `increment') hash function29 always a power of two. The secondary ('increment') hash function 30 30 is forced to return an odd-value, in order to be relatively prime 31 31 to the table size. This guarantees that the increment can … … 49 49 fprintf (stderr, _("can't allocate %lu bytes for hash table: memory exhausted"), 50 50 ht->ht_size * (unsigned long) sizeof (struct token *)); 51 exit ( 1);51 exit (MAKE_TROUBLE); 52 52 } 53 53 … … 62 62 } 63 63 64 /* Load an array of items into `ht'. */64 /* Load an array of items into 'ht'. */ 65 65 66 66 void … … 76 76 } 77 77 78 /* Returns the address of the table slot matching `key'. If `key' is78 /* Returns the address of the table slot matching 'key'. If 'key' is 79 79 not found, return the address of an empty slot suitable for 80 inserting `key'. The caller is responsible for incrementing80 inserting 'key'. The caller is responsible for incrementing 81 81 ht_fill on insertion. */ 82 82 -
vendor/gnumake/current/hash.h
r2596 r3138 29 29 # undef __P 30 30 # define __P(protos) () 31 /* We can get away without defining `const' here only because in this file32 it is used only inside the prototype for `fnmatch', which is elided in33 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. */ 34 34 #endif /* C++ or ANSI C. */ 35 35 … … 42 42 { 43 43 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 */ 44 47 unsigned long ht_size; /* total number of slots (power of 2) */ 45 48 unsigned long ht_capacity; /* usable slots, limited by loading-factor */ … … 49 52 unsigned long ht_lookups; /* # of queries */ 50 53 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 */54 54 }; 55 55 -
vendor/gnumake/current/implicit.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 #include "filedef.h" 21 19 #include "rule.h" … … 39 37 try_implicit_rule (struct file *file, unsigned int depth) 40 38 { 41 DBF (DB_IMPLICIT, _("Looking for an implicit rule for `%s'.\n"));39 DBF (DB_IMPLICIT, _("Looking for an implicit rule for '%s'.\n")); 42 40 43 41 /* The order of these searches was previously reversed. My logic now is … … 55 53 { 56 54 DBF (DB_IMPLICIT, 57 _("Looking for archive-member implicit rule for `%s'.\n"));55 _("Looking for archive-member implicit rule for '%s'.\n")); 58 56 if (pattern_search (file, 1, depth, 0)) 59 57 return 1; … … 77 75 78 76 /* Skip any leading whitespace. */ 79 while (isblank ((unsigned char)*p)) 80 ++p; 77 NEXT_TOKEN (p); 81 78 82 79 beg = p; … … 222 219 223 220 /* List of dependencies found recursively. */ 224 struct patdeps *deplist225 = 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)); 226 223 struct patdeps *pat = deplist; 227 228 /* All the prerequisites actually found for a rule, after expansion. */229 struct dep *deps;230 224 231 225 /* Names of possible dependencies are constructed in this buffer. */ … … 254 248 255 249 /* Nonzero if we have matched a pattern-rule target 256 that is not just `%'. */250 that is not just '%'. */ 257 251 int specific_rule_matched = 0; 258 259 struct dep dep_simple;260 252 261 253 unsigned int ri; /* uninit checks OK */ … … 276 268 but not counting any slash at the end. (foo/bar/ counts as 277 269 bar/ in directory foo/, not empty in directory foo/bar/.) */ 270 lastslash = strrchr (filename, '/'); 278 271 #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) 281 277 lastslash = strrchr (filename, ':'); 282 #else 283 lastslash = strrchr (filename, '/'); 278 #endif 284 279 #ifdef HAVE_DOS_PATHS 285 280 /* Handle backslashes (possibly mixed with forward slashes) … … 293 288 } 294 289 #endif 295 #endif296 290 if (lastslash != 0 && lastslash[1] == '\0') 297 291 lastslash = 0; … … 325 319 const char *target = rule->targets[ti]; 326 320 const char *suffix = rule->suffixes[ti]; 327 intcheck_lastslash;321 char check_lastslash; 328 322 329 323 /* Rules that can match any filename and are not terminal … … 349 343 { 350 344 #ifdef VMS 351 check_lastslash = (strchr (target, ']') == 0 352 && strchr (target, ':') == 0); 345 check_lastslash = strpbrk (target, "/]>:") == NULL; 353 346 #else 354 347 check_lastslash = strchr (target, '/') == 0; 348 #endif 355 349 #ifdef HAVE_DOS_PATHS 356 350 /* Didn't find it yet: check for DOS-type directories. */ … … 360 354 check_lastslash = !(b || (target[0] && target[1] == ':')); 361 355 } 362 #endif363 356 #endif 364 357 } … … 405 398 that rule will be in TRYRULES more than once. */ 406 399 tryrules[nrules].rule = rule; 407 400 tryrules[nrules].matches = ti; 408 401 tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0); 409 402 tryrules[nrules].order = nrules; 410 403 tryrules[nrules].checked_lastslash = check_lastslash; 411 404 ++nrules; 412 405 } … … 447 440 { 448 441 struct dep *dep; 449 intcheck_lastslash;442 char check_lastslash; 450 443 unsigned int failed = 0; 451 444 int file_variables_set = 0; … … 491 484 } 492 485 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"), 494 494 (int) stemlen, stem)); 495 495 … … 533 533 if (! dep->need_2nd_expansion) 534 534 { 535 dep_simple = *dep;536 dep_simple.next = 0;537 535 p = strchr (nptr, '%'); 538 536 if (p == 0) 539 dep_simple.name = nptr;537 strcpy (depname, nptr); 540 538 else 541 539 { … … 551 549 o += stemlen; 552 550 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 } 556 561 557 562 /* We've used up this dep, so next time get a new one. */ 558 563 nptr = 0; 559 ++deps_found;560 564 } 561 565 … … 573 577 int add_dir = 0; 574 578 unsigned int len; 579 struct dep **dptr; 575 580 576 581 nptr = get_next_word (nptr, &len); … … 615 620 } 616 621 622 /* Set up for the next word. */ 623 nptr += len; 624 617 625 /* Initialize and set file variables if we haven't already 618 626 done so. */ … … 633 641 /* Perform the 2nd expansion. */ 634 642 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'); 649 670 } 650 671 … … 652 673 2nd expansion), reset it and realloc the arrays. */ 653 674 654 if (deps_found > max_ pattern_deps)675 if (deps_found > max_deps) 655 676 { 656 677 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; 657 681 deplist = xrealloc (deplist, 658 deps_found* sizeof (struct patdeps));682 max_deps * sizeof (struct patdeps)); 659 683 pat = deplist + l; 660 max_pattern_deps = deps_found;661 684 } 662 685 … … 674 697 DBS (DB_IMPLICIT, 675 698 (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"), 678 701 d->name)); 679 702 tryrules[ri].rule = 0; … … 688 711 DBS (DB_IMPLICIT, 689 712 (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)); 692 715 693 716 /* If this prereq is also explicitly mentioned for FILE, … … 728 751 { 729 752 DBS (DB_IMPLICIT, 730 (_("Found prerequisite `%s' as VPATH `%s'\n"),753 (_("Found prerequisite '%s' as VPATH '%s'\n"), 731 754 d->name, vname)); 732 755 (pat++)->name = d->name; … … 742 765 { 743 766 DBS (DB_IMPLICIT, 744 (_("Looking for a rule with intermediate file `%s'.\n"),767 (_("Looking for a rule with intermediate file '%s'.\n"), 745 768 d->name)); 746 769 … … 758 781 int_file->name = d->name; 759 782 pat->file = int_file; 783 int_file = 0; 760 784 (pat++)->name = d->name; 761 int_file = 0;762 785 continue; 763 786 } … … 780 803 781 804 /* Free the ns chain. */ 782 if (dl != &dep_simple) 783 free_dep_chain (dl); 805 free_dep_chain (dl); 784 806 785 807 if (failed) … … 791 813 file->stem = 0; 792 814 793 /* This rule is no longer `in use' for recursive searches. */815 /* This rule is no longer 'in use' for recursive searches. */ 794 816 rule->in_use = 0; 795 817 … … 798 820 break; 799 821 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. */ 804 823 } 805 824 … … 847 866 /* We don't want to delete an intermediate file that happened 848 867 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. */ 850 870 if (f != 0) 851 f-> precious= 1;871 f->secondary = 1; 852 872 else 853 873 f = enter_file (imf->name); … … 893 913 the rule that found it was a terminal one, then we want to mark 894 914 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, we896 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. */ 897 917 if (dep->file == 0) 898 918 dep->changed = 1; … … 938 958 939 959 /* If this rule builds other targets, too, put the others into FILE's 940 `also_make' member. */960 'also_make' member. */ 941 961 942 962 if (rule->num > 1) -
vendor/gnumake/current/job.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 21 19 #include <assert.h> … … 26 24 #include "commands.h" 27 25 #include "variable.h" 28 #include " debug.h"26 #include "os.h" 29 27 30 28 #include <string.h> … … 34 32 #include <windows.h> 35 33 36 c har *default_shell = "sh.exe";34 const char *default_shell = "sh.exe"; 37 35 int no_default_sh_exe = 1; 38 36 int batch_mode_shell = 1; … … 41 39 #elif defined (_AMIGA) 42 40 43 c har default_shell[]= "";41 const char *default_shell = ""; 44 42 extern int MyExecute (char **); 45 43 int batch_mode_shell = 0; … … 51 49 to search the $PATH for it (since MSDOS doesn't have standard 52 50 directories we could trust). */ 53 c har *default_shell = "command.com";51 const char *default_shell = "command.com"; 54 52 int batch_mode_shell = 0; 55 53 56 54 #elif defined (__EMX__) 57 55 58 c har *default_shell = "/bin/sh";56 const char *default_shell = "/bin/sh"; 59 57 int batch_mode_shell = 0; 60 58 … … 62 60 63 61 # include <descrip.h> 64 char default_shell[] = ""; 62 # include <stsdef.h> 63 const char *default_shell = ""; 65 64 int batch_mode_shell = 0; 66 65 67 #elif defined (__riscos__) 68 69 char default_shell[] = ""; 70 int batch_mode_shell = 0; 66 #define strsignal vms_strsignal 67 char * 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 71 75 72 76 #else 73 77 74 c har default_shell[]= "/bin/sh";78 const char *default_shell = "/bin/sh"; 75 79 int batch_mode_shell = 0; 76 80 … … 109 113 # include "w32err.h" 110 114 # include "pathstuff.h" 115 # define WAIT_NOHANG 1 111 116 #endif /* WINDOWS32 */ 112 117 … … 120 125 121 126 #ifdef HAVE_WAITPID 122 # define WAIT_NOHANG(status) 123 #else 127 # define WAIT_NOHANG(status) waitpid (-1, (status), WNOHANG) 128 #else /* Don't have waitpid. */ 124 129 # ifdef HAVE_WAIT3 125 130 # ifndef wait3 126 131 extern int wait3 (); 127 132 # endif 128 # define WAIT_NOHANG(status) 133 # define WAIT_NOHANG(status) wait3 ((status), WNOHANG, (struct rusage *) 0) 129 134 # endif /* Have wait3. */ 130 135 #endif /* Have waitpid. */ … … 134 139 #endif 135 140 136 #ifndef 141 #ifndef HAVE_UNION_WAIT 137 142 138 143 # define WAIT_T int … … 154 159 # endif 155 160 156 #else /* Have `union wait'. */161 #else /* Have 'union wait'. */ 157 162 158 163 # define WAIT_T union wait … … 173 178 # endif 174 179 175 #endif /* Don't have `union wait'. */180 #endif /* Don't have 'union wait'. */ 176 181 177 182 #if !defined(HAVE_UNISTD_H) && !defined(WINDOWS32) … … 203 208 } 204 209 210 #ifndef HAVE_GETLOADAVG 205 211 int 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 213 214 static void free_child (struct child *); 214 215 static void start_job_command (struct child *child); … … 226 227 unsigned int job_slots_used = 0; 227 228 228 /* Nonzero if the `good' standard input is in use. */229 /* Nonzero if the 'good' standard input is in use. */ 229 230 230 231 static int good_stdin_used = 0; … … 245 246 246 247 unsigned int jobserver_tokens = 0; 248 247 249 248 250 249 251 #ifdef WINDOWS32 250 252 /* 251 * The macro which references this function is defined in make .h.253 * The macro which references this function is defined in makeint.h. 252 254 */ 253 255 int 254 w32_kill (pid_t pid, int sig)256 w32_kill (pid_t pid, int sig) 255 257 { 256 return ((process_kill ((HANDLE)pid, sig) == TRUE) ? 0 : -1);258 return ((process_kill ((HANDLE)pid, sig) == TRUE) ? 0 : -1); 257 259 } 258 260 … … 267 269 const char *error_string = NULL; 268 270 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); 270 272 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; 272 283 const unsigned sizemax = strlen (base) + strlen (ext) + 10; 273 284 … … 278 289 } 279 290 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 } 280 301 while (path_size > 0 && 281 302 path_size + sizemax < sizeof temp_path && 282 uniq < 0x10000)303 !(uniq >= 0x10000 && second_loop)) 283 304 { 284 305 unsigned size = sprintf (temp_path + path_size, … … 297 318 if (h == INVALID_HANDLE_VALUE) 298 319 { 299 const DWORD er = GetLastError ();320 const DWORD er = GetLastError (); 300 321 301 322 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 } 303 331 304 332 /* the temporary path is not guaranteed to exist */ … … 336 364 if (error_string == NULL) 337 365 error_string = _("Cannot create a temporary file\n"); 338 fatal (NILF, error_string);366 O (fatal, NILF, error_string); 339 367 340 368 /* not reached */ … … 376 404 377 405 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 } 383 412 384 413 /* in doubt assume a unix like shell */ … … 391 420 is_bourne_compatible_shell (const char *path) 392 421 { 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[] = { 395 424 "sh", 396 425 "bash", … … 402 431 NULL 403 432 }; 404 unsigned i, len;433 const char **s; 405 434 406 435 /* find the rightmost '/' or '\\' */ … … 415 444 name = path; 416 445 417 if (*name == '/' || *name == '\\') name++; 446 if (*name == '/' || *name == '\\') 447 ++name; 418 448 419 449 /* 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 { 422 452 #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) 425 456 #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 } 431 461 432 462 /* if not on the list, assume it's not a Bourne-like shell */ … … 441 471 442 472 static void 443 child_error ( const char *target_name,473 child_error (struct child *child, 444 474 int exit_code, int exit_sig, int coredump, int ignored) 445 475 { 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 446 484 if (ignored && silent_flag) 447 485 return; 448 486 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 456 511 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); 460 514 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 (); 465 522 } 466 523 … … 469 526 /* Handle a dead child. This handler may or may not ever be installed. 470 527 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. 475 533 476 534 If we don't have either waitpid or wait3, then make is unreliable, but we … … 484 542 ++dead_children; 485 543 486 if (job_rfd >= 0) 487 { 488 close (job_rfd); 489 job_rfd = -1; 490 } 544 jobserver_signal (); 491 545 492 546 #ifdef __EMX__ … … 494 548 signal (SIGCHLD, SIG_DFL); 495 549 #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 */500 550 } 501 551 502 extern int shell_function_pid, shell_function_completed;552 extern pid_t shell_function_pid; 503 553 504 554 /* 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 the555 state ('cs_finished') in the 'file' member of the 'struct child' for the 506 556 dead child, and removing the child from the chain. In addition, if BLOCK 507 557 nonzero, we block in this function until we've reaped at least one … … 514 564 #ifndef WINDOWS32 515 565 WAIT_T status; 566 #endif 516 567 /* Initially, assume we have some. */ 517 568 int reap_more = 1; 518 #endif519 569 520 570 #ifdef WAIT_NOHANG … … 535 585 && (block || REAP_MORE)) 536 586 { 537 int remote = 0;587 unsigned int remote = 0; 538 588 pid_t pid; 539 589 int exit_code, exit_sig, coredump; 540 registerstruct child *lastc, *c;590 struct child *lastc, *c; 541 591 int child_failed; 542 592 int any_remote, any_local; … … 544 594 545 595 if (err && block) 546 596 { 547 597 static int printed = 0; 548 598 549 599 /* We might block for a while, so let the user know why. 550 600 Only print this message once no matter how many jobs are left. */ 551 601 fflush (stdout); 552 602 if (!printed) 553 error (NILF, _("*** Waiting for unfinished jobs...."));603 O (error, NILF, _("*** Waiting for unfinished jobs....")); 554 604 printed = 1; 555 605 } 556 606 557 607 /* We have one less dead child to reap. As noted in 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 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. */ 573 623 574 624 if (dead_children > 0) 575 625 --dead_children; 576 626 577 627 any_remote = 0; 578 628 any_local = shell_function_pid != 0; 579 629 for (c = children; c != 0; c = c->next) 580 581 582 583 630 { 631 any_remote |= c->remote; 632 any_local |= ! c->remote; 633 DB (DB_JOBS, (_("Live child %p (%s) PID %s %s\n"), 584 634 c, c->file->name, pid2str (c->pid), 585 635 c->remote ? _(" (remote)") : "")); 586 636 #ifdef VMS 587 588 #endif 589 637 break; 638 #endif 639 } 590 640 591 641 /* First, check for remote children. */ 592 642 if (any_remote) 593 643 pid = remote_status (&exit_code, &exit_sig, &coredump, 0); 594 644 else 595 645 pid = 0; 596 646 597 647 if (pid > 0) 598 599 648 /* We got a remote child. */ 649 remote = 1; 600 650 else if (pid < 0) 601 651 { 602 652 /* A remote status command failed miserably. Punt. */ 603 604 605 653 remote_status_lose: 654 pfatal_with_name ("remote_status"); 655 } 606 656 else 607 608 657 { 658 /* No remote children. Check for local children. */ 609 659 #if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32) 610 611 660 if (any_local) 661 { 612 662 #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; 615 674 #else 616 675 #ifdef WAIT_NOHANG 617 618 619 620 #endif 621 EINTRLOOP(pid, wait (&status));676 if (!block) 677 pid = WAIT_NOHANG (&status); 678 else 679 #endif 680 EINTRLOOP (pid, wait (&status)); 622 681 #endif /* !VMS */ 623 624 625 626 627 628 682 } 683 else 684 pid = 0; 685 686 if (pid < 0) 687 { 629 688 /* The wait*() failed miserably. Punt. */ 630 631 632 633 634 635 636 637 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); 638 697 639 698 /* If we have started jobs in this second, remove one. */ 640 699 if (job_counter) 641 700 --job_counter; 642 643 644 645 701 } 702 else 703 { 704 /* No local children are dead. */ 646 705 reap_more = 0; 647 706 648 707 if (!block || !any_remote) 649 708 break; 650 709 … … 659 718 /* We got a remote child. */ 660 719 remote = 1; 661 720 } 662 721 #endif /* !__MSDOS__, !Amiga, !WINDOWS32. */ 663 722 664 723 #ifdef __MSDOS__ 665 666 667 668 669 670 671 672 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; 673 732 #endif /* __MSDOS__ */ 674 733 #ifdef _AMIGA 675 676 677 678 679 680 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; 681 740 #endif /* _AMIGA */ 682 741 #ifdef WINDOWS32 683 742 { 684 743 HANDLE hPID; 685 int werr;686 744 HANDLE hcTID, hcPID; 745 DWORD dwWaitStatus = 0; 687 746 exit_code = 0; 688 747 exit_sig = 0; … … 701 760 fprintf (stderr, 702 761 "Determine main thread ID (Error %ld: %s)\n", 703 e, map_windows32_error_to_string (e));762 e, map_windows32_error_to_string (e)); 704 763 } 705 764 else … … 708 767 709 768 /* wait for anything to finish */ 710 hPID = process_wait_for_any ();769 hPID = process_wait_for_any (block, &dwWaitStatus); 711 770 if (hPID) 712 771 { 713 714 772 /* was an error found on this process? */ 715 werr = process_last_err(hPID);773 int werr = process_last_err (hPID); 716 774 717 775 /* get exit data */ 718 exit_code = process_exit_code (hPID);776 exit_code = process_exit_code (hPID); 719 777 720 778 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)); 723 781 724 782 /* signal */ 725 exit_sig = process_signal (hPID);783 exit_sig = process_signal (hPID); 726 784 727 785 /* cleanup process */ 728 process_cleanup (hPID);786 process_cleanup (hPID); 729 787 730 788 coredump = 0; 731 789 } 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 732 802 pid = (pid_t) hPID; 733 803 } 734 804 #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. */ 738 808 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 } 749 813 750 814 /* Search for a child matching the deceased one. */ 751 815 lastc = 0; 752 816 for (c = children; c != 0; lastc = c, c = c->next) 753 if (c->remote == remote && c->pid == pid)754 817 if (c->pid == pid && c->remote == remote) 818 break; 755 819 756 820 if (c == 0) … … 759 823 continue; 760 824 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 761 834 DB (DB_JOBS, (child_failed 762 835 ? _("Reaping losing child %p PID %s %s\n") … … 764 837 c, pid2str (c->pid), c->remote ? _(" (remote)") : "")); 765 838 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 } 777 856 778 857 /* If this child had the good stdin, say it is now free. */ … … 788 867 static int delete_on_error = -1; 789 868 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; 794 873 if (delete_on_error == -1) 795 874 { … … 805 884 { 806 885 /* 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); 809 887 child_failed = 0; 810 888 } … … 819 897 the target was not completely remade. So we treat 820 898 this as if a command had failed. */ 821 c->file->update_status = 2;899 c->file->update_status = us_failed; 822 900 } 823 901 else 824 902 { 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 825 909 /* Check again whether to start remotely. 826 910 Whether or not we want to changes over time. … … 840 924 } 841 925 842 if (c->file->update_status != 0)926 if (c->file->update_status != us_success) 843 927 /* We failed to start the commands. */ 844 928 delete_child_targets (c); … … 848 932 without an unignored error. Now the target has been 849 933 successfully updated. */ 850 c->file->update_status = 0;934 c->file->update_status = us_success; 851 935 } 852 936 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 856 946 ran; notice_finish_file looks for cs_running to tell it that 857 947 it's interesting to check the file's modtime again now. */ … … 892 982 /* fatal_error_signal will die with the right signal. */ 893 983 !handling_fatal_signal) 894 die ( 2);984 die (child_failed); 895 985 896 986 /* Only block for one child. */ … … 907 997 free_child (struct child *child) 908 998 { 999 output_close (&child->output); 1000 909 1001 if (!jobserver_tokens) 910 fatal (NILF, "INTERNAL: Freeing child %p (%s) but no tokens left!\n",911 1002 ONS (fatal, NILF, "INTERNAL: Freeing child %p (%s) but no tokens left!\n", 1003 child, child->file->name); 912 1004 913 1005 /* If we're using the jobserver and this child is not the only outstanding 914 1006 job, put a token back into the pipe for it. */ 915 1007 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); 927 1011 DB (DB_JOBS, (_("Released token for child %p (%s).\n"), 928 1012 child, child->file->name)); … … 938 1022 register unsigned int i; 939 1023 for (i = 0; i < child->file->cmds->ncommand_lines; ++i) 940 1024 free (child->command_lines[i]); 941 1025 free (child->command_lines); 942 1026 } … … 946 1030 register char **ep = child->environment; 947 1031 while (*ep != 0) 948 1032 free (*ep++); 949 1033 free (child->environment); 950 1034 } … … 980 1064 #endif 981 1065 982 #ifdef MAKE_JOBSERVER983 RETSIGTYPE984 job_noop (int sig UNUSED)985 {986 }987 /* Set the child handler action flags to FLAGS. */988 static void989 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 #endif997 998 memset (&sa, '\0', sizeof sa);999 sa.sa_handler = child_handler;1000 sa.sa_flags = set_handler ? 0 : SA_RESTART;1001 #if defined SIGCHLD1002 sigaction (SIGCHLD, &sa, NULL);1003 #endif1004 #if defined SIGCLD && SIGCLD != SIGCHLD1005 sigaction (SIGCLD, &sa, NULL);1006 #endif1007 #if defined SIGALRM1008 if (set_alarm)1009 {1010 /* If we're about to enter the read(), set an alarm to wake up in a1011 second so we can check if the load has dropped and we can start more1012 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 #endif1019 }1020 #endif1021 1022 1066 1023 1067 /* Start a job to run the commands specified in CHILD. … … 1025 1069 1026 1070 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 so1071 for calling 'unblock_sigs', once the new child is safely on the chain so 1028 1072 it can be cleaned up in the event of a fatal signal. */ 1029 1073 … … 1031 1075 start_job_command (struct child *child) 1032 1076 { 1033 #if !defined(_AMIGA) && !defined(WINDOWS32) 1034 static int bad_stdin = -1; 1035 #endif 1077 int flags; 1036 1078 char *p; 1037 /* Must be volatile to silence bogus GCC warning about longjmp/vfork. */1038 volatile int flags;1039 1079 #ifdef VMS 1040 1080 char *argv; … … 1050 1090 the flags specified globally for this target. */ 1051 1091 flags = (child->file->command_flags 1052 1092 | child->file->cmds->lines_flags[child->command_line - 1]); 1053 1093 1054 1094 p = child->command_ptr; … … 1058 1098 { 1059 1099 if (*p == '@') 1060 1100 flags |= COMMANDS_SILENT; 1061 1101 else if (*p == '+') 1062 1102 flags |= COMMANDS_RECURSE; 1063 1103 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; 1067 1108 ++p; 1068 1109 } 1110 1111 child->recursive = ((flags & COMMANDS_RECURSE) != 0); 1069 1112 1070 1113 /* Update the file's command flags with any new ones we found. We only … … 1074 1117 order to really fix this, we'll have to keep a lines_flags for every 1075 1118 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 } 1078 1136 1079 1137 /* Figure out an argument list from this command line. */ 1080 1081 1138 { 1082 1139 char *end = 0; 1083 1140 #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 1084 1154 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 } 1085 1179 #else 1086 1180 argv = construct_command_argv (p, &end, child->file, 1087 1088 1181 child->file->cmds->lines_flags[child->command_line - 1], 1182 &child->sh_batch_file); 1089 1183 #endif 1090 1184 if (end == NULL) … … 1092 1186 else 1093 1187 { 1094 1095 1188 *end++ = '\0'; 1189 child->command_ptr = end; 1096 1190 } 1097 1191 } 1098 1192 1099 /* If -q was given, say that updating `failed' if there was any text on the1100 command line, or `succeeded' otherwise. The exit status of 1 tells the1101 user that -q is saying `something to do'; the exit status for a random1193 /* 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 1102 1196 error is 2. */ 1103 1197 if (argv != 0 && question_flag && !(flags & COMMANDS_RECURSE)) … … 1107 1201 free (argv); 1108 1202 #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 1112 1214 } 1113 1215 … … 1115 1217 { 1116 1218 /* Go on to the next command. It might be the recursive one. 1117 1219 We construct ARGV only to find the end of the command line. */ 1118 1220 #ifndef VMS 1119 1221 if (argv) … … 1134 1236 /* This line has no commands. Go to the next. */ 1135 1237 if (job_next_command (child)) 1136 1238 start_job_command (child); 1137 1239 else 1138 1139 1240 { 1241 /* No more commands. Make sure we're "running"; we might not be if 1140 1242 (e.g.) all commands were skipped due to -n. */ 1141 1243 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(); 1145 1249 return; 1146 1250 } 1147 1251 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); 1154 1271 1155 1272 /* Tell update_goal_chain that a command has been started on behalf of … … 1171 1288 if ( 1172 1289 #if defined __MSDOS__ || defined (__EMX__) 1173 unixy_shell 1290 unixy_shell /* the test is complicated and we already did it */ 1174 1291 #else 1175 (argv[0] && is_bourne_compatible_shell (argv[0]))1292 (argv[0] && is_bourne_compatible_shell (argv[0])) 1176 1293 #endif 1177 1294 && (argv[1] && argv[1][0] == '-' 1178 1179 1180 1181 1295 && 1296 ((argv[1][1] == 'c' && argv[1][2] == '\0') 1297 || 1298 (argv[1][1] == 'e' && argv[1][2] == 'c' && argv[1][3] == '\0'))) 1182 1299 && (argv[2] && argv[2][0] == ':' && argv[2][1] == '\0') 1183 1300 && argv[3] == NULL) … … 1200 1317 } 1201 1318 1319 /* We're sure we're going to invoke a command: set up the output. */ 1320 output_start (); 1321 1202 1322 /* Flush the output streams so they won't have things written twice. */ 1203 1323 … … 1205 1325 fflush (stderr); 1206 1326 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 1235 1329 that points to the read side of a broken pipe. */ 1236 1330 … … 1238 1332 if (child->good_stdin) 1239 1333 good_stdin_used = 1; 1240 1241 #endif /* !VMS */1242 1334 1243 1335 child->deleted = 0; … … 1257 1349 int is_remote, id, used_stdin; 1258 1350 if (start_remote_job (argv, child->environment, 1259 child->good_stdin ? 0 : bad_stdin,1260 1351 child->good_stdin ? 0 : get_bad_stdin (), 1352 &is_remote, &id, &used_stdin)) 1261 1353 /* Don't give up; remote execution may fail for various reasons. If 1262 1354 so, simply run the job locally. */ 1263 1355 goto run_local; 1264 1356 else 1265 1266 1267 1268 1269 1270 1271 1272 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 } 1274 1366 } 1275 1367 else … … 1286 1378 1287 1379 #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 } 1293 1386 1294 1387 #else … … 1296 1389 parent_environ = environ; 1297 1390 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 1312 1398 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 } 1365 1405 #endif /* !VMS */ 1366 1406 } 1367 1407 1368 #else 1408 #else /* __MSDOS__ or Amiga or WINDOWS32 */ 1369 1409 #ifdef __MSDOS__ 1370 1410 { … … 1374 1414 dos_status = 0; 1375 1415 1376 /* We call `system' to do the job of the SHELL, since stock DOS1377 shell is too dumb. Our `system' knows how to handle long1416 /* 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 1378 1418 command lines even if pipes/redirection is needed; it will only 1379 1419 call COMMAND.COM when its internal commands are used. */ 1380 1420 if (execute_by_shell) 1381 1421 { 1382 1383 /* We don't have a way to pass environment to `system',1384 1385 1386 1387 1388 1389 /* If we have a *real* shell, tell `system' to call1390 1391 1392 1393 1394 command lines the DJGPP way, so we must use `system'. */1395 cmdline = argv[2];/* get past "shell -c" */1396 1397 1398 1399 1400 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 */ 1402 1442 } 1403 1443 else 1404 1444 { 1405 1406 1445 dos_command_running = 1; 1446 proc_return = spawnvpe (P_WAIT, argv[0], argv, child->environment); 1407 1447 } 1408 1448 … … 1433 1473 DeleteFile (amiga_bname); /* Ignore errors. */ 1434 1474 } 1435 #endif 1475 #endif /* Amiga */ 1436 1476 #ifdef WINDOWS32 1437 1477 { 1438 1478 HANDLE hPID; 1439 1479 char* arg0; 1480 int outfd = FD_STDOUT; 1481 int errfd = FD_STDERR; 1440 1482 1441 1483 /* make UNC paths safe for CreateProcess -- backslash format */ … … 1447 1489 1448 1490 /* 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); 1452 1506 1453 1507 if (hPID != INVALID_HANDLE_VALUE) 1454 1508 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 } 1466 1521 } 1467 1522 #endif /* WINDOWS32 */ 1468 #endif 1523 #endif /* __MSDOS__ or Amiga or WINDOWS32 */ 1469 1524 1470 1525 /* Bump the number of jobs started in this second. */ … … 1482 1537 #endif 1483 1538 1539 OUTPUT_UNSET(); 1484 1540 return; 1485 1541 1486 1542 error: 1487 child->file->update_status = 2;1543 child->file->update_status = us_failed; 1488 1544 notice_finished_file (child->file); 1489 return;1545 OUTPUT_UNSET(); 1490 1546 } 1491 1547 1492 1548 /* Try to start a child running. 1493 1549 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. */ 1495 1551 1496 1552 static int … … 1510 1566 && ((job_slots_used > 0 && load_too_high ()) 1511 1567 #ifdef WINDOWS32 1512 1513 #endif 1514 1568 || (process_used_slots () >= MAXIMUM_WAIT_OBJECTS) 1569 #endif 1570 )) 1515 1571 { 1516 1572 /* Put this child on the chain of children waiting for the load average … … 1540 1596 case cs_not_started: 1541 1597 /* All the command lines turned out to be empty. */ 1542 f->update_status = 0;1598 f->update_status = us_success; 1543 1599 /* FALLTHROUGH */ 1544 1600 … … 1556 1612 } 1557 1613 1558 /* Create a `struct child' for FILE and start its commands running. */1614 /* Create a 'struct child' for FILE and start its commands running. */ 1559 1615 1560 1616 void … … 1576 1632 chop_commands (cmds); 1577 1633 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 1578 1650 /* Expand the command lines and store the results in LINES. */ 1579 1651 lines = xmalloc (cmds->ncommand_lines * sizeof (char *)); … … 1581 1653 { 1582 1654 /* Collapse backslash-newline combinations that are inside variable 1583 1584 1585 1586 1587 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. */ 1588 1660 1589 1661 char *in, *out, *ref; 1590 1662 1591 1663 /* IN points to where in the line we are scanning. 1592 1593 1594 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. */ 1595 1667 1596 1668 in = out = cmds->command_lines[i]; 1597 1669 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 } 1669 1742 1670 1743 /* There are no more references in this line to worry about. 1671 1744 Copy the remaining uninteresting text to the output. */ 1672 1745 if (out != in) 1673 1746 memmove (out, in, strlen (in) + 1); 1674 1747 1675 1748 /* Finally, expand the line. */ 1749 cmds->fileinfo.offset = i; 1676 1750 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; 1685 1755 c->command_lines = lines; 1686 c->sh_batch_file = NULL;1687 1688 /* Cache dontcare flag because file->dontcare can be changed once we1689 return. Check dontcare inheritance mechanism for details. */1690 c->dontcare = file->dontcare;1691 1756 1692 1757 /* Fetch the first command line to be run. */ … … 1713 1778 this is where the old parallel job code waits, so... */ 1714 1779 1715 else if (job _fds[0] >= 0)1780 else if (jobserver_enabled ()) 1716 1781 while (1) 1717 1782 { 1718 char token; 1719 int got_token; 1720 int saved_errno; 1783 int got_token; 1721 1784 1722 1785 DB (DB_JOBS, ("Need a job token; we %shave children\n", … … 1727 1790 break; 1728 1791 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 (); 1757 1794 1758 1795 /* Reap anything that's currently waiting. */ … … 1760 1797 1761 1798 /* Kick off any jobs we have waiting for an opportunity that 1762 can run now (i ewaiting for load). */1799 can run now (i.e., waiting for load). */ 1763 1800 start_waiting_jobs (); 1764 1801 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. */ 1767 1803 if (!jobserver_tokens) 1768 1804 break; … … 1771 1807 waiting for a token. */ 1772 1808 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); 1780 1813 1781 1814 /* If we got one, we're done here. */ 1782 1815 if (got_token == 1) 1783 1816 { 1784 1817 DB (DB_JOBS, (_("Obtained token for child %p (%s).\n"), … … 1786 1819 break; 1787 1820 } 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"));1796 1821 } 1797 1822 #endif 1798 1823 1799 1824 ++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 } 1800 1851 1801 1852 /* The job is now primed. Start it running. 1802 1853 (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 else1808 DB (DB_BASIC, (_("Invoking builtin recipe to update target `%s'.\n"),1809 c->file->name));1810 1811 1812 1854 start_waiting_job (c); 1813 1855 1814 1856 if (job_slots == 1 || not_parallel) 1815 1857 /* 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'. */ 1817 1859 while (file->command_state == cs_running) 1818 1860 reap_children (1, 0); 1819 1861 1862 OUTPUT_UNSET (); 1820 1863 return; 1821 1864 } … … 1832 1875 /* There are no more lines in the expansion of this line. */ 1833 1876 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 } 1839 1883 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; 1843 1889 return 1; 1844 1890 } … … 1911 1957 /* Complain only once for the same error. */ 1912 1958 if (lossage == -1 || errno != lossage) 1913 1914 1915 1916 error (NILF,1917 1918 1919 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 } 1921 1967 lossage = errno; 1922 1968 load = 0; … … 1968 2014 1969 2015 /* Try to start that job. We break out of the loop as soon 1970 2016 as start_waiting_job puts one back on the waiting list. */ 1971 2017 } 1972 2018 while (start_waiting_job (job) && waiting_jobs != 0); … … 1981 2027 # if defined __EMX__ 1982 2028 int 1983 child_execute_job ( int stdin_fd, int stdout_fd, char **argv, char **envp)2029 child_execute_job (struct output *out, int good_stdin, char **argv, char **envp) 1984 2030 { 1985 2031 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 } 2015 2089 2016 2090 /* Run the command. */ 2017 2091 pid = exec_command (argv, envp); 2018 2092 2019 /* Restore stdout/stdin of the parent and close temporary FDs. */2020 if (s tdin_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")); 2024 2098 else 2025 close (save_ stdin);2026 } 2027 2028 if (s tdout_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")); 2032 2106 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); 2034 2116 } 2035 2117 … … 2039 2121 #elif !defined (_AMIGA) && !defined (__MSDOS__) && !defined (VMS) 2040 2122 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. */ 2126 int 2127 child_execute_job (struct output *out, int good_stdin, char **argv, char **envp) 2047 2128 { 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)); 2056 2165 2057 2166 /* Run the command. */ … … 2087 2196 HANDLE hPID; 2088 2197 HANDLE hWaitPID; 2089 int err = 0;2090 2198 int exit_code = EXIT_FAILURE; 2091 2199 2092 2200 /* make sure CreateProcess() has Path it needs */ 2093 sync_Path_environment ();2201 sync_Path_environment (); 2094 2202 2095 2203 /* launch command */ 2096 hPID = process_easy (argv, envp);2204 hPID = process_easy (argv, envp, -1, -1); 2097 2205 2098 2206 /* make sure launch ok */ … … 2100 2208 { 2101 2209 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)); 2105 2212 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); 2109 2216 } 2110 2217 2111 2218 /* wait and reap last child */ 2112 hWaitPID = process_wait_for_any ();2219 hWaitPID = process_wait_for_any (1, 0); 2113 2220 while (hWaitPID) 2114 2221 { 2115 2222 /* was an error found on this process? */ 2116 err = process_last_err(hWaitPID);2223 int err = process_last_err (hWaitPID); 2117 2224 2118 2225 /* get exit data */ 2119 exit_code = process_exit_code (hWaitPID);2226 exit_code = process_exit_code (hWaitPID); 2120 2227 2121 2228 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)); 2124 2231 2125 2232 /* cleanup process */ 2126 process_cleanup (hWaitPID);2233 process_cleanup (hWaitPID); 2127 2234 2128 2235 /* expect to find only last pid, warn about other pids reaped */ … … 2130 2237 break; 2131 2238 else 2132 2133 2134 2135 fprintf (stderr,2136 _("make reaped child pid %s, still waiting for pid %s\n"),2137 2138 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 } 2140 2247 } 2141 2248 2142 2249 /* return child's exit code as our exit code */ 2143 exit (exit_code);2250 exit (exit_code); 2144 2251 2145 2252 #else /* !WINDOWS32 */ … … 2153 2260 2154 2261 # ifdef __EMX__ 2155 2156 2262 /* Run the program. */ 2157 2263 pid = spawnvpe (P_NOWAIT, argv[0], argv, envp); 2158 2159 2264 if (pid >= 0) 2160 2265 return pid; … … 2165 2270 2166 2271 # else 2167 2168 2272 /* Run the program. */ 2169 2273 environ = envp; … … 2175 2279 { 2176 2280 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]); 2178 2288 break; 2179 2289 case ENOEXEC: 2180 2290 { 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; 2186 2295 int i=1; 2187 2296 2188 2297 # ifdef __EMX__ 2189 2298 /* Do not use $SHELL from the environment */ 2190 2191 2192 2299 struct variable *p = lookup_variable ("SHELL", 5); 2300 if (p) 2301 shell = p->value; 2193 2302 else 2194 2303 shell = 0; 2195 2304 # else 2196 2305 shell = getenv ("SHELL"); 2197 2306 # endif 2198 2199 2200 2201 2202 2203 2307 if (shell == 0) 2308 shell = default_shell; 2309 2310 argc = 1; 2311 while (argv[argc] != 0) 2312 ++argc; 2204 2313 2205 2314 # ifdef __EMX__ … … 2208 2317 # endif 2209 2318 2210 2211 new_argv[0] =shell;2319 new_argv = alloca ((1 + argc + 1) * sizeof (char *)); 2320 new_argv[0] = (char *)shell; 2212 2321 2213 2322 # ifdef __EMX__ … … 2221 2330 2222 2331 new_argv[i] = argv[0]; 2223 2224 2225 2226 2227 2332 while (argc > 0) 2333 { 2334 new_argv[i + argc] = argv[argc]; 2335 --argc; 2336 } 2228 2337 2229 2338 # ifdef __EMX__ 2230 2231 2339 pid = spawnvpe (P_NOWAIT, shell, new_argv, envp); 2340 if (pid >= 0) 2232 2341 break; 2233 2342 # else 2234 2343 execvp (shell, new_argv); 2235 2344 # endif 2236 2237 error (NILF, _("%s: Shell program not found"), shell);2238 2239 2240 2345 if (errno == ENOENT) 2346 OS (error, NILF, _("%s: Shell program not found"), shell); 2347 else 2348 perror_with_name ("execvp: ", shell); 2349 break; 2241 2350 } 2242 2351 … … 2244 2353 case EINVAL: 2245 2354 /* 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")); 2247 2356 /* FALLTHROUGH */ 2248 2357 # endif … … 2262 2371 } 2263 2372 #else /* On Amiga */ 2264 void exec_command (char **argv) 2373 void 2374 exec_command (char **argv) 2265 2375 { 2266 2376 MyExecute (argv); … … 2278 2388 /* Figure out the argument list necessary to run LINE as a command. Try to 2279 2389 avoid using a shell. This routine handles only ' quoting, and " quoting 2280 when no backslash, $ or `characters are seen in the quotes. Starting2390 when no backslash, $ or ' characters are seen in the quotes. Starting 2281 2391 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 2283 2393 is the first word of a line, the shell is used. 2284 2394 … … 2295 2405 2296 2406 static char ** 2297 construct_command_argv_internal (char *line, char **restp, c har *shell,2298 c har *shellflags, char *ifs, int flags,2299 char **batch_filename_ptr)2407 construct_command_argv_internal (char *line, char **restp, const char *shell, 2408 const char *shellflags, const char *ifs, 2409 int flags, char **batch_filename UNUSED) 2300 2410 { 2301 2411 #ifdef __MSDOS__ 2302 2412 /* 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, 2304 2414 because DOS shells are too dumb. When $SHELL points to a real 2305 (unix-style) shell, `system' just calls it to do everything. When2306 $SHELL points to a DOS shell, `system' does most of the work2415 (unix-style) shell, 'system' just calls it to do everything. When 2416 $SHELL points to a DOS shell, 'system' does most of the work 2307 2417 internally, calling the shell only for its internal commands. 2308 2418 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 are2419 external command named 'mkdir'. 2420 2421 Since we call 'system', certain characters and commands below are 2312 2422 actually not specific to COMMAND.COM, but to the DJGPP implementation 2313 of `system'. In particular:2423 of 'system'. In particular: 2314 2424 2315 2425 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 run2426 not be expanded if we call the child via 'spawnXX'. 2427 2428 The ';' is in DOS_CHARS, because our 'system' knows how to run 2319 2429 multiple commands on a single line. 2320 2430 … … 2322 2432 won't have to tell one from another and have one more set of 2323 2433 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 2343 2452 #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; 2371 2478 2372 2479 #elif defined (_AMIGA) 2373 static c har sh_chars[]= "#;\"|<>()?*$`";2374 static c har *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 2379 2486 #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", 2396 2508 #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; 2402 2515 #elif defined(__riscos__) 2403 static c har sh_chars[]= "";2404 static c har *sh_cmds[] = { 0 };2516 static const char *sh_chars = ""; 2517 static const char *sh_cmds[] = { 0 }; 2405 2518 #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 2412 2526 # ifdef HAVE_DOS_PATHS 2413 2527 /* This is required if the MSYS/Cygwin ports (which do not define 2414 2528 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 */ 2418 2533 #endif 2419 2534 int i; 2420 2535 char *p; 2536 #ifndef NDEBUG 2537 char *end; 2538 #endif 2421 2539 char *ap; 2422 char *end; 2540 const char *cap; 2541 const char *cp; 2423 2542 int instring, word_has_equals, seen_nonequals, last_argument_was_empty; 2424 2543 char **new_argv = 0; … … 2427 2546 int slow_flag = 0; 2428 2547 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 } 2436 2558 #endif /* WINDOWS32 */ 2437 2559 … … 2439 2561 *restp = NULL; 2440 2562 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)) 2443 2565 ++line; 2444 2566 if (*line == '\0') 2445 2567 return 0; 2568 2569 if (shellflags == 0) 2570 shellflags = posix_pedantic ? "-ec" : "-c"; 2446 2571 2447 2572 /* See if it is safe to parse commands internally. */ … … 2456 2581 slow_flag = strcmp ((s1 ? s1 : ""), (s2 ? s2 : "")); 2457 2582 2458 if (s1) 2459 free (s1); 2460 if (s2) 2461 free (s2); 2583 free (s1); 2584 free (s2); 2462 2585 } 2463 2586 if (slow_flag) … … 2469 2592 extern int _is_unixy_shell (const char *_path); 2470 2593 2471 DB (DB_BASIC, (_("$SHELL changed (was `%s', now `%s')\n"),2594 DB (DB_BASIC, (_("$SHELL changed (was '%s', now '%s')\n"), 2472 2595 default_shell, shell)); 2473 2596 unixy_shell = _is_unixy_shell (shell); … … 2499 2622 #endif /* not WINDOWS32 */ 2500 2623 2501 if (ifs != 0)2502 for ( ap = ifs; *ap != '\0'; ++ap)2503 if (* ap != ' ' && *ap != '\t' && *ap != '\n')2504 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) 2507 2630 if (shellflags[0] != '-' 2508 2631 || ((shellflags[1] != 'c' || shellflags[2] != '\0') … … 2517 2640 /* All the args can fit in a buffer as big as LINE is. */ 2518 2641 ap = new_argv[0] = argstr = xmalloc (i); 2642 #ifndef NDEBUG 2519 2643 end = ap + i; 2644 #endif 2520 2645 2521 2646 /* I is how many complete arguments have been found. */ … … 2527 2652 2528 2653 if (instring) 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 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') 2539 2664 { 2540 2665 /* Backslash-newline is handled differently depending on what 2541 2666 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. */ 2546 2670 if (instring == '"' 2547 2671 #if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32) 2548 2549 #endif 2550 2672 || !unixy_shell 2673 #endif 2674 ) 2551 2675 ++p; 2552 2676 else … … 2556 2680 } 2557 2681 } 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 } 2573 2705 else if (strchr (sh_chars, *p) != 0) 2574 2575 2706 /* Not inside a string, but it's a special char. */ 2707 goto slow; 2576 2708 else if (one_shell && *p == '\n') 2577 2578 2709 /* In .ONESHELL mode \n is a separator like ; or && */ 2710 goto slow; 2579 2711 #ifdef __MSDOS__ 2580 2712 else if (*p == '.' && p[1] == '.' && p[2] == '.' && p[3] != '.') 2581 /* `...' is a wildcard in DJGPP. */2582 2713 /* '...' is a wildcard in DJGPP. */ 2714 goto slow; 2583 2715 #endif 2584 2716 else 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 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. 2601 2733 We're in the fastpath, so emulate what the shell would do. */ 2602 2603 2604 2734 if (p[1] == '\n') 2735 { 2736 /* Throw out the backslash and newline. */ 2605 2737 ++p; 2606 2738 2607 /* If there's nothing in this argument yet, skip any2608 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. */ 2609 2741 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') 2613 2755 { 2614 2756 #ifdef HAVE_DOS_PATHS … … 2631 2773 #endif 2632 2774 if (p[1] != '\\' && p[1] != '\'' 2633 && ! isspace ((unsigned char)p[1])2775 && !ISSPACE (p[1]) 2634 2776 && strchr (sh_chars_sh, p[1]) == 0) 2635 2777 /* back up one notch, to copy the backslash */ … … 2640 2782 *ap++ = *++p; 2641 2783 } 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 heretofore has contained an `='. */2671 2672 2673 /* An `=' in a word before the first2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 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) 2685 2827 { 2686 2828 if (streq (sh_cmds[j], new_argv[0])) 2687 2829 goto slow; 2688 # ifdef __EMX__2830 #if defined(__EMX__) || defined(WINDOWS32) 2689 2831 /* Non-Unix shells are case insensitive. */ 2690 2832 if (!unixy_shell 2691 2833 && strcasecmp (sh_cmds[j], new_argv[0]) == 0) 2692 2834 goto slow; 2693 # 2835 #endif 2694 2836 } 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 } 2705 2848 } 2706 2849 end_of_line: … … 2721 2864 register int j; 2722 2865 for (j = 0; sh_cmds[j] != 0; ++j) 2723 2724 2866 if (streq (sh_cmds[j], new_argv[0])) 2867 goto slow; 2725 2868 } 2726 2869 … … 2746 2889 2747 2890 #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 */ 2749 2892 #endif 2750 2893 … … 2761 2904 { 2762 2905 if (*ptr == '\\' && ptr[1] == '\n') 2763 2906 ptr += 2; 2764 2907 else if (*ptr == '@') /* Kludge: multiline commands */ 2765 2908 { 2766 2767 2909 ptr += 2; 2910 *dptr++ = '\n'; 2768 2911 } 2769 2912 else 2770 2913 *dptr++ = *ptr++; 2771 2914 } 2772 2915 *dptr = 0; … … 2776 2919 new_argv[1] = 0; 2777 2920 } 2778 #else 2921 #else /* Not Amiga */ 2779 2922 #ifdef WINDOWS32 2780 2923 /* … … 2789 2932 2790 2933 /* Make sure not to bother processing an empty line. */ 2791 while (isspace ((unsigned char)*line)) 2792 ++line; 2934 NEXT_TOKEN (line); 2793 2935 if (*line == '\0') 2794 2936 return 0; … … 2801 2943 argument list. */ 2802 2944 2945 char *new_line; 2803 2946 unsigned int shell_len = strlen (shell); 2804 2947 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 2806 2950 char *command_ptr = NULL; /* used for batch_mode_shell mode */ 2807 char *new_line; 2951 #endif 2808 2952 2809 2953 # ifdef __EMX__ /* is this necessary? */ 2810 if (!unixy_shell )2954 if (!unixy_shell && shellflags) 2811 2955 shellflags[0] = '/'; /* "/c" */ 2812 2956 # endif 2813 2957 2814 2958 /* In .ONESHELL mode we are allowed to throw the entire current 2815 2816 2817 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. */ 2818 2962 if (one_shell) 2819 2963 { 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 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. */ 2830 2974 #if defined __MSDOS__ || defined (__EMX__) 2831 2975 if (unixy_shell) /* the test is complicated and we already did it */ 2832 2976 #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 ) 2834 2983 #endif 2835 2984 { … … 2843 2992 int esc = 0; 2844 2993 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 == '+') 2848 2997 ++f; 2849 2998 … … 2867 3016 *t = '\0'; 2868 3017 } 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; 2876 3115 } 2877 3116 2878 new_line = alloca (shell_len+ 1 + sflags_len + 12879 3117 new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1 3118 + (line_len*2) + 1); 2880 3119 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 } 2883 3130 *(ap++) = ' '; 2884 memcpy (ap, shellflags, sflags_len); 3131 if (shellflags) 3132 memcpy (ap, shellflags, sflags_len); 2885 3133 ap += sflags_len; 2886 3134 *(ap++) = ' '; 3135 #ifdef WINDOWS32 2887 3136 command_ptr = ap; 3137 #endif 2888 3138 for (p = line; *p != '\0'; ++p) 2889 3139 { 2890 2891 2892 2893 2894 2895 2896 2897 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 2898 3148 POSIX shell on DOS/Windows/OS2, mimic the pre-POSIX behavior 2899 3149 and remove the backslash/newline. */ … … 2903 3153 # define PRESERVE_BSNL 1 2904 3154 #endif 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 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 } 2918 3168 2919 3169 /* DOS shells don't know about backslash-escaping. */ 2920 3170 if (unixy_shell && !batch_mode_shell && 2921 3171 (*p == '\\' || *p == '\'' || *p == '"' 2922 || isspace ((unsigned char)*p)3172 || ISSPACE (*p) 2923 3173 || strchr (sh_chars, *p) != 0)) 2924 3174 *ap++ = '\\'; 2925 3175 #ifdef __MSDOS__ 2926 3176 else if (unixy_shell && strneq (p, "...", 3)) 2927 3177 { 2928 /* The case of `...' wildcard again. */3178 /* The case of '...' wildcard again. */ 2929 3179 strcpy (ap, "\\.\\.\\"); 2930 3180 ap += 5; … … 2932 3182 } 2933 3183 #endif 2934 3184 *ap++ = *p; 2935 3185 } 2936 3186 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 } 2939 3192 *ap = '\0'; 2940 3193 … … 2943 3196 command line (e.g. Cygnus GNUWIN32 sh.exe on WIN32 systems). In these 2944 3197 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 (""); 2983 3204 new_argv[1] = NULL; 2984 3205 } 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 2987 3247 #endif /* WINDOWS32 */ 2988 3248 2989 3249 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); 2991 3252 2992 3253 #ifdef __EMX__ 2993 3254 else if (!unixy_shell) 2994 3255 { 2995 3256 /* new_line is local, must not be freed therefore 2996 3257 We use line here instead of new_line because we run the shell 2997 3258 manually. */ … … 3073 3334 #else 3074 3335 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"), 3076 3338 __FILE__, __LINE__); 3077 3339 #endif 3340 3341 free (new_line); 3078 3342 } 3079 #endif 3343 #endif /* ! AMIGA */ 3080 3344 3081 3345 return new_argv; … … 3085 3349 /* Figure out the argument list necessary to run LINE as a command. Try to 3086 3350 avoid using a shell. This routine handles only ' quoting, and " quoting 3087 when no backslash, $ or `characters are seen in the quotes. Starting3351 when no backslash, $ or ' characters are seen in the quotes. Starting 3088 3352 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 3090 3354 is the first word of a line, the shell is used. 3091 3355 … … 3098 3362 char ** 3099 3363 construct_command_argv (char *line, char **restp, struct file *file, 3100 int cmd_flags, char **batch_filename _ptr)3364 int cmd_flags, char **batch_filename) 3101 3365 { 3102 3366 char *shell, *ifs, *shellflags; … … 3111 3375 for (;;) 3112 3376 { 3113 while ((*cptr != 0) 3114 && (isspace ((unsigned char)*cptr))) 3115 cptr++; 3377 while ((*cptr != 0) && (ISSPACE (*cptr))) 3378 cptr++; 3116 3379 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++; 3121 3383 argc++; 3122 3384 } … … 3130 3392 for (;;) 3131 3393 { 3132 while ((*cptr != 0) 3133 && (isspace ((unsigned char)*cptr))) 3134 cptr++; 3394 while ((*cptr != 0) && (ISSPACE (*cptr))) 3395 cptr++; 3135 3396 if (*cptr == 0) 3136 3397 break; 3137 3398 DB (DB_JOBS, ("argv[%d] = [%s]\n", argc, cptr)); 3138 3399 argv[argc++] = cptr; 3139 while ((*cptr != 0) 3140 && (!isspace((unsigned char)*cptr))) 3141 cptr++; 3400 while ((*cptr != 0) && (!ISSPACE (*cptr))) 3401 cptr++; 3142 3402 if (*cptr != 0) 3143 3403 *cptr++ = 0; 3144 3404 } 3145 3405 #else … … 3155 3415 * is not confused. 3156 3416 */ 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 } 3161 3422 #endif 3162 3423 #ifdef __EMX__ … … 3166 3427 static int init = 0; 3167 3428 if (init == 0) 3168 3169 3170 3171 3172 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 } 3174 3435 3175 3436 /* if we have an unixroot drive and if shell is not default_shell … … 3179 3440 "$UNIXROOT/bin/sh" instead. */ 3180 3441 if (unixroot && shell && strcmp (shell, last_shell) != 0 3181 3182 3183 3184 3185 3186 3187 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' */ 3188 3449 if (access (shell, F_OK) != 0 && access (buf, F_OK) != 0) 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 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 3202 3463 free (buf); 3203 3464 } 3204 3465 } 3205 3466 #endif /* __EMX__ */ … … 3212 3473 3213 3474 argv = construct_command_argv_internal (line, restp, shell, shellflags, ifs, 3214 cmd_flags, batch_filename _ptr);3475 cmd_flags, batch_filename); 3215 3476 3216 3477 free (shell); … … 3229 3490 3230 3491 (void) close (new); 3231 fd = dup (old);3492 EINTRLOOP (fd, dup (old)); 3232 3493 if (fd != new) 3233 3494 { -
vendor/gnumake/current/job.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1992-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #ifndef SEEN_JOB_H 20 #define SEEN_JOB_H 17 #include "output.h" 21 18 22 19 #ifdef HAVE_FCNTL_H … … 28 25 /* How to set close-on-exec for a file descriptor. */ 29 26 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 32 33 #else 33 34 # ifndef FD_CLOEXEC … … 37 38 #endif 38 39 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 55 struct 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. */ 66 typedef intptr_t sync_handle_t; 67 68 /* Public functions emulated/provided in posixfcn.c. */ 69 int fcntl (intptr_t fd, int cmd, ...); 70 intptr_t create_mutex (void); 71 int same_stream (FILE *f1, FILE *f2); 72 73 # define RECORD_SYNC_MUTEX(m) record_sync_mutex(m) 74 void record_sync_mutex (const char *str); 75 void prepare_mutex_handle_string (intptr_t hdl); 76 # else /* !WINDOWS32 */ 77 78 typedef int sync_handle_t; /* file descriptor */ 79 80 # define RECORD_SYNC_MUTEX(m) (void)(m) 81 82 # endif 83 #endif /* !NO_OUTPUT_SYNC */ 84 39 85 /* Structure describing a running or dead child process. */ 40 86 41 87 struct child 42 88 { 43 struct child *next; 89 struct child *next; /* Link in the chain. */ 44 90 45 struct file *file; 91 struct file *file; /* File being remade. */ 46 92 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]. */ 48 97 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 52 104 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. */ 67 114 }; 68 115 69 116 extern struct child *children; 70 117 118 /* A signal handler for SIGCHLD, if needed. */ 119 RETSIGTYPE child_handler (int sig); 71 120 int is_bourne_compatible_shell(const char *path); 72 121 void new_job (struct file *file); … … 76 125 char **construct_command_argv (char *line, char **restp, struct file *file, 77 126 int cmd_flags, char** batch_file); 127 78 128 #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); 129 int child_execute_job (struct child *child, char *argv); 82 130 #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)) 134 int child_execute_job (struct output *out, int good_stdin, char **argv, char **envp); 84 135 #endif 136 85 137 #ifdef _AMIGA 86 void exec_command (char **argv) ;138 void exec_command (char **argv) __attribute__ ((noreturn)); 87 139 #elif defined(__EMX__) 88 140 int exec_command (char **argv, char **envp); 89 141 #else 90 void exec_command (char **argv, char **envp) ;142 void exec_command (char **argv, char **envp) __attribute__ ((noreturn)); 91 143 #endif 92 144 … … 97 149 void unblock_sigs (void); 98 150 #else 99 #ifdef 151 #ifdef HAVE_SIGSETMASK 100 152 extern int fatal_signal_mask; 101 #define unblock_sigs()sigsetmask (0)153 #define unblock_sigs() sigsetmask (0) 102 154 #else 103 #define 155 #define unblock_sigs() 104 156 #endif 105 157 #endif 106 158 107 159 extern unsigned int jobserver_tokens; 108 109 #endif /* SEEN_JOB_H */ -
vendor/gnumake/current/main.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make.h" 17 #include "makeint.h" 18 #include "os.h" 19 #include "filedef.h" 20 20 #include "dep.h" 21 #include "filedef.h"22 21 #include "variable.h" 23 22 #include "job.h" … … 33 32 #endif 34 33 #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" 38 39 #endif 39 40 #ifdef __EMX__ … … 48 49 int __stack = 20000; /* Make sure we have 20K of stack space */ 49 50 #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 52 int vms_use_mcr_command = 0; 53 int vms_always_use_cmd_file = 0; 54 int vms_gnv_shell = 0; 55 int vms_legacy_behavior = 0; 56 int vms_comma_separator = 0; 57 int vms_unix_simulation = 0; 58 int vms_report_unix_paths = 0; 59 60 /* Evaluates if a VMS environment option is set, only look at first character */ 61 static int 62 get_vms_env_flag (const char *name, int default_value) 63 { 64 char * value; 65 char 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 62 86 63 87 #if defined HAVE_WAITPID || defined HAVE_WAIT3 … … 65 89 #endif 66 90 67 #ifndef 91 #ifndef HAVE_UNISTD_H 68 92 int chdir (); 69 93 #endif 70 #ifndef 71 # ifndef sun 94 #ifndef STDC_HEADERS 95 # ifndef sun /* Sun has an incorrect decl in a header. */ 72 96 void exit (int) __attribute__ ((noreturn)); 73 97 # endif … … 78 102 static void print_data_base (void); 79 103 static void print_version (void); 80 static void decode_switches (int argc, c har **argv, int env);81 static void decode_env_switches (c har *envar, unsigned int len);82 static const char*define_makeflags (int all, int makefile);104 static void decode_switches (int argc, const char **argv, int env); 105 static void decode_env_switches (const char *envar, unsigned int len); 106 static struct variable *define_makeflags (int all, int makefile); 83 107 static char *quote_for_env (char *out, const char *in); 84 108 static void initialize_global_hash_tables (void); … … 90 114 struct command_switch 91 115 { 92 int c; 93 94 enum 116 int c; /* The switch character. */ 117 118 enum /* Type of the value. */ 95 119 { 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. */ 103 128 } type; 104 129 105 void *value_ptr; 106 107 unsigned int env:1; 108 unsigned int toenv:1; 109 unsigned int no_makefile:1; 110 111 const void *noarg_value; 112 const void *default_value; 113 114 c har *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. */ 115 140 }; 116 141 … … 120 145 121 146 /* The structure used to hold the list of strings given 122 in command switches of a type that takes str ingarguments. */147 in command switches of a type that takes strlist arguments. */ 123 148 124 149 struct stringlist 125 150 { 126 const char **list; 127 unsigned int idx; 128 unsigned int max; 151 const char **list; /* Nil-terminated list of strings. */ 152 unsigned int idx; /* Index into above. */ 153 unsigned int max; /* Number of pointers allocated. */ 129 154 }; 130 155 131 156 132 157 /* The recognized command switches. */ 158 159 /* Nonzero means do extra verification (that may slow things down). */ 160 161 int verify_flag; 133 162 134 163 /* Nonzero means do not print commands to be executed (-s). */ … … 148 177 /* Print debugging info (--debug). */ 149 178 150 static struct stringlist *db_flags ;179 static struct stringlist *db_flags = 0; 151 180 static int debug_flag = 0; 152 181 153 182 int db_level = 0; 154 183 155 /* Output level (--verbosity). */156 157 static struct stringlist *verbosity_flags;184 /* Synchronize output (--output-sync). */ 185 186 char *output_sync_option = 0; 158 187 159 188 #ifdef WINDOWS32 … … 220 249 221 250 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 253 unsigned int job_slots; 254 255 #define INVALID_JOB_SLOTS (-1) 226 256 static unsigned int master_job_slots = 0; 257 static int arg_job_slots = INVALID_JOB_SLOTS; 258 259 static const int default_job_slots = INVALID_JOB_SLOTS; 227 260 228 261 /* Value of job_slots that means no limit. */ 229 262 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; 263 static const int inf_jobs = 0; 264 265 /* Authorization for the jobserver. */ 266 267 static char *jobserver_auth = NULL; 268 269 /* Handle for the mutex used on Windows to synchronize output of our 270 children under -O. */ 271 272 char *sync_mutex = NULL; 238 273 239 274 /* Maximum load average at which multiple jobs will be run. … … 346 381 Consider FILE to be very old and don't remake it.\n"), 347 382 N_("\ 383 -O[TYPE], --output-sync[=TYPE]\n\ 384 Synchronize output of parallel jobs by TYPE.\n"), 385 N_("\ 348 386 -p, --print-data-base Print make's internal database.\n"), 349 387 N_("\ … … 361 399 -t, --touch Touch targets instead of remaking them.\n"), 362 400 N_("\ 401 --trace Print tracing information.\n"), 402 N_("\ 363 403 -v, --version Print the version number of make and exit.\n"), 364 404 N_("\ … … 374 414 }; 375 415 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. */ 377 419 378 420 static const struct command_switch switches[] = … … 380 422 { 'b', ignore, 0, 0, 0, 0, 0, 0, 0 }, 381 423 { 'B', flag, &always_make_set, 1, 1, 0, 0, 0, "always-make" }, 382 { 'C', filename, &directories, 0, 0, 0, 0, 0, "directory" },383 424 { 'd', flag, &debug_flag, 1, 1, 0, 0, 0, 0 }, 384 { CHAR_MAX+1, string, &db_flags, 1, 1, 0, "basic", 0, "debug" },385 425 #ifdef WINDOWS32 386 426 { 'D', flag, &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" }, 387 427 #endif 388 428 { 'e', flag, &env_overrides, 1, 1, 0, 0, 0, "environment-overrides", }, 389 { 'f', filename, &makefiles, 0, 0, 0, 0, 0, "file" },390 429 { 'h', flag, &print_usage_flag, 0, 0, 0, 0, 0, "help" }, 391 430 { '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" },397 431 { 'k', flag, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag, 398 432 "keep-going" }, 399 #ifndef NO_FLOAT400 { 'l', floating, &max_load_average, 1, 1, 0, &default_load_average,401 &default_load_average, "load-average" },402 #else403 { 'l', positive_int, &max_load_average, 1, 1, 0, &default_load_average,404 &default_load_average, "load-average" },405 #endif406 433 { 'L', flag, &check_symlink_flag, 1, 1, 0, 0, 0, "check-symlink-times" }, 407 434 { 'm', ignore, 0, 0, 0, 0, 0, 0, 0 }, 408 435 { 'n', flag, &just_print_flag, 1, 1, 1, 0, 0, "just-print" }, 409 { 'o', filename, &old_files, 0, 0, 0, 0, 0, "old-file" },410 436 { 'p', flag, &print_data_base_flag, 1, 1, 0, 0, 0, "print-data-base" }, 411 437 { 'q', flag, &question_flag, 1, 1, 1, 0, 0, "question" }, … … 418 444 { 't', flag, &touch_flag, 1, 1, 1, 0, 0, "touch" }, 419 445 { '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" },422 446 { '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" }, 423 470 { CHAR_MAX+4, flag, &inhibit_print_directory_flag, 1, 1, 0, 0, 0, 424 471 "no-print-directory" }, 425 { 'W', filename, &new_files, 0, 0, 0, 0, 0, "what-if" },426 472 { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0, 427 473 "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" }, 429 476 { 0, 0, 0, 0, 0, 0, 0, 0, 0 } 430 477 }; … … 434 481 static struct option long_option_aliases[] = 435 482 { 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' }, 445 492 }; 446 493 447 494 /* List of goal targets. */ 448 495 449 static struct dep *goals, *lastgoal;496 static struct goaldep *goals, *lastgoal; 450 497 451 498 /* List of variables which were defined on the command line … … 462 509 /* The name we were invoked with. */ 463 510 511 #ifdef WINDOWS32 512 /* On MS-Windows, we chop off the .exe suffix in 'main', so this 513 cannot be 'const'. */ 464 514 char *program; 515 #else 516 const char *program; 517 #endif 465 518 466 519 /* Our current directory before processing any -C options. */ … … 490 543 struct file *default_file; 491 544 492 /* Nonzero if we have seen the magic `.POSIX' target.545 /* Nonzero if we have seen the magic '.POSIX' target. 493 546 This turns on pedantic compliance with POSIX.2. */ 494 547 … … 506 559 int one_shell; 507 560 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 565 int output_sync = OUTPUT_SYNC_NONE; 566 567 /* Nonzero if the "--trace" option was given. */ 568 569 int trace_flag = 0; 570 571 /* Nonzero if we have seen the '.NOTPARALLEL' target. 509 572 This turns off parallel builds for this invocation of make. */ 510 573 … … 517 580 int clock_skew_detected; 518 581 582 /* Map of possible stop characters for searching strings. */ 583 #ifndef UCHAR_MAX 584 # define UCHAR_MAX 255 585 #endif 586 unsigned 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 591 struct output make_sync; 592 593 519 594 520 595 /* Mask of signals that are being caught with fatal_error_signal. */ 521 596 522 #ifdef 597 #ifdef POSIX 523 598 sigset_t fatal_signal_set; 524 599 #else 525 # ifdef 600 # ifdef HAVE_SIGSETMASK 526 601 int fatal_signal_mask; 527 602 # endif … … 559 634 } 560 635 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 639 static void 640 initialize_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 561 680 static const char * 562 expand_command_line_file (c har *name)681 expand_command_line_file (const char *name) 563 682 { 564 683 const char *cp; … … 566 685 567 686 if (name[0] == '\0') 568 fatal (NILF, _("empty string invalid as file name"));687 O (fatal, NILF, _("empty string invalid as file name")); 569 688 570 689 if (name[0] == '~') 571 690 { 572 691 expanded = tilde_expand (name); 573 if (expanded != 0)574 692 if (expanded && expanded[0] != '\0') 693 name = expanded; 575 694 } 576 695 … … 578 697 for names read from makefiles. It is here for names passed 579 698 on the command line. */ 580 while (name[0] == '.' && name[1] == '/' && name[2] != '\0')699 while (name[0] == '.' && name[1] == '/') 581 700 { 582 701 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 = "./"; 596 711 } 597 712 598 713 cp = strcache_add (name); 599 714 600 if (expanded) 601 free (expanded); 715 free (expanded); 602 716 603 717 return cp; … … 622 736 db_level = DB_ALL; 623 737 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') 637 781 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; 667 790 } 668 791 792 static void 793 decode_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 669 818 #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. */ 826 void 827 prepare_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 670 841 /* 671 842 * HANDLE runtime exceptions by avoiding a requestor on the GUI. Capture … … 678 849 */ 679 850 LONG WINAPI 680 handle_runtime_exceptions ( struct _EXCEPTION_POINTERS *exinfo)851 handle_runtime_exceptions (struct _EXCEPTION_POINTERS *exinfo) 681 852 { 682 853 PEXCEPTION_RECORD exrec = exinfo->ExceptionRecord; 683 LPSTR cmdline = GetCommandLine ();684 LPSTR prg = strtok (cmdline, " ");854 LPSTR cmdline = GetCommandLine (); 855 LPSTR prg = strtok (cmdline, " "); 685 856 CHAR errmsg[1024]; 686 857 #ifdef USE_EVENT_LOG … … 691 862 if (! ISDB (DB_VERBOSE)) 692 863 { 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); 704 875 705 876 if (exrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION 706 877 && 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]); 712 883 713 884 /* turn this on if we want to put stuff in the event log too */ 714 885 #ifdef USE_EVENT_LOG 715 hEventSource = RegisterEventSource (NULL, "GNU Make");886 hEventSource = RegisterEventSource (NULL, "GNU Make"); 716 887 lpszStrings[0] = errmsg; 717 888 718 889 if (hEventSource != NULL) 719 890 { 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); 731 902 } 732 903 #endif 733 904 734 905 /* Write the error to stderr too */ 735 fprintf (stderr, errmsg);906 fprintf (stderr, errmsg); 736 907 737 908 #ifdef DEBUG 738 909 return EXCEPTION_CONTINUE_SEARCH; 739 910 #else 740 exit (255);911 exit (255); 741 912 return (255); /* not reached */ 742 913 #endif … … 746 917 * On WIN32 systems we don't have the luxury of a /bin directory that 747 918 * 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 prop ogate /bin/sh919 * be invoked from any drive, and we don't want to propagate /bin/sh 749 920 * to every single drive. Allow ourselves a chance to search for 750 921 * a value for default shell here (if the default path does not exist). … … 756 927 int sh_found = 0; 757 928 char *atoken = 0; 758 c har *search_token;759 c har *tokend;929 const char *search_token; 930 const char *tokend; 760 931 PATH_VAR(sh_path); 761 extern c har *default_shell;932 extern const char *default_shell; 762 933 763 934 if (!token) 764 935 search_token = default_shell; 765 936 else 766 atoken = search_token = xstrdup (token);937 search_token = atoken = xstrdup (token); 767 938 768 939 /* If the user explicitly requests the DOS cmd shell, obey that request. … … 778 949 || (tokend - 4 > search_token 779 950 && (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)); 824 1027 } 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 } 842 1029 843 1030 /* 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 } 849 1037 850 1038 #ifdef BATCH_MODE_ONLY_SHELL … … 852 1040 #endif 853 1041 854 if (atoken) 855 free (atoken); 1042 free (atoken); 856 1043 857 1044 return (sh_found); … … 868 1055 #endif /* __MSDOS__ */ 869 1056 870 char *mktemp (char *template); 871 int mkstemp (char *template); 872 873 FILE * 874 open_tmpfile(char **name, const char *template) 1057 static void 1058 reset_jobserver (void) 875 1059 { 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; 912 1063 } 913 914 1064 915 1065 #ifdef _AMIGA … … 923 1073 static char *stdin_nm = 0; 924 1074 int makefile_status = MAKE_SUCCESS; 925 struct dep *read_makefiles;1075 struct goaldep *read_files; 926 1076 PATH_VAR (current_directory); 927 1077 unsigned int restarts = 0; 1078 unsigned int syncing = 0; 1079 int argv_slots; 928 1080 #ifdef WINDOWS32 929 c har *unix_path = NULL;930 c har *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); 933 1085 934 1086 /* start off assuming we have no shell */ … … 936 1088 no_default_sh_exe = 1; 937 1089 #endif 1090 1091 output_init (&make_sync); 1092 1093 initialize_stopchar_map(); 938 1094 939 1095 #ifdef SET_STACK_SIZE … … 955 1111 #endif 956 1112 957 #ifdef HAVE_ATEXIT958 atexit (close_stdout);959 #endif960 961 1113 /* 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 965 1120 966 1121 #if defined (__MSDOS__) && !defined (_POSIX_SOURCE) 967 /* Request the most powerful version of `system', to1122 /* Request the most powerful version of 'system', to 968 1123 make up for the dumb default shell. */ 969 1124 __system_flags = (__system_redirect 970 971 972 973 974 1125 | __system_use_shell 1126 | __system_allow_multiple_cmds 1127 | __system_allow_long_cmds 1128 | __system_handle_null_commands 1129 | __system_emulate_chdir); 975 1130 976 1131 #endif … … 983 1138 (void)textdomain (PACKAGE); 984 1139 985 #ifdef 1140 #ifdef POSIX 986 1141 sigemptyset (&fatal_signal_set); 987 #define ADD_SIG(sig)sigaddset (&fatal_signal_set, sig)1142 #define ADD_SIG(sig) sigaddset (&fatal_signal_set, sig) 988 1143 #else 989 #ifdef 1144 #ifdef HAVE_SIGSETMASK 990 1145 fatal_signal_mask = 0; 991 #define ADD_SIG(sig)fatal_signal_mask |= sigmask (sig)1146 #define ADD_SIG(sig) fatal_signal_mask |= sigmask (sig) 992 1147 #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 \ 1001 1156 ADD_SIG (sig); 1002 1157 … … 1017 1172 #endif 1018 1173 1019 #ifdef 1174 #ifdef SIGDANGER 1020 1175 FATAL_SIG (SIGDANGER); 1021 1176 #endif … … 1027 1182 #endif 1028 1183 1029 #undef 1184 #undef FATAL_SIG 1030 1185 1031 1186 /* Do not ignore the child-death signal. This must be done before … … 1043 1198 #endif 1044 1199 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); 1057 1201 1058 1202 /* Figure out where this program lives. */ 1059 1203 1060 1204 if (argv[0] == 0) 1061 argv[0] = "";1205 argv[0] = (char *)""; 1062 1206 if (argv[0][0] == '\0') 1063 1207 program = "make"; 1064 1208 else 1065 1209 { 1066 #ifdef VMS1067 program = strrchr (argv[0], ']');1068 #else1069 1210 program = strrchr (argv[0], '/'); 1070 #endif1071 1211 #if defined(__MSDOS__) || defined(__EMX__) 1072 1212 if (program == 0) 1073 1213 program = strrchr (argv[0], '\\'); 1074 1214 else 1075 1076 1077 1078 1079 1080 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 } 1082 1222 if (program == 0 && argv[0][1] == ':') 1083 1223 program = argv[0] + 1; 1084 1224 #endif 1085 1225 #ifdef WINDOWS32 … … 1087 1227 { 1088 1228 /* Extract program from full path */ 1089 int argv0_len;1090 1229 program = strrchr (argv[0], '\\'); 1091 1230 if (program) 1092 1231 { 1093 argv0_len = strlen(program);1232 int argv0_len = strlen (program); 1094 1233 if (argv0_len > 4 && streq (&program[argv0_len - 4], ".exe")) 1095 1234 /* Remove .exe extension */ … … 1098 1237 } 1099 1238 #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 1100 1286 if (program == 0) 1101 1287 program = argv[0]; 1102 1288 else 1103 ++program; 1289 ++program; 1290 #endif 1104 1291 } 1105 1292 … … 1117 1304 #endif 1118 1305 { 1119 #ifdef 1306 #ifdef HAVE_GETCWD 1120 1307 perror_with_name ("getcwd", ""); 1121 1308 #else 1122 error (NILF, "getwd: %s", current_directory);1309 OS (error, NILF, "getwd: %s", current_directory); 1123 1310 #endif 1124 1311 current_directory[0] = '\0'; … … 1127 1314 else 1128 1315 directory_before_chdir = xstrdup (current_directory); 1316 1129 1317 #ifdef __MSDOS__ 1130 1318 /* Make sure we will return to the initial directory, come what may. */ … … 1137 1325 define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1; 1138 1326 define_variable_cname (".SHELLFLAGS", "-c", o_default, 0); 1327 define_variable_cname (".LOADED", "", o_default, 0); 1139 1328 1140 1329 /* Set up .FEATURES 1141 We must do this in multiple calls because define_variable_cname() is1142 a macro andsome 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. */ 1143 1332 { 1144 1333 const char *features = "target-specific order-only second-expansion" 1145 " else-if shortest-stem undefine "1334 " else-if shortest-stem undefine oneshell" 1146 1335 #ifndef NO_ARCHIVES 1147 1336 " archives" … … 1150 1339 " jobserver" 1151 1340 #endif 1341 #ifndef NO_OUTPUT_SYNC 1342 " output-sync" 1343 #endif 1152 1344 #ifdef MAKE_SYMLINKS 1153 1345 " check-symlink" 1154 1346 #endif 1347 #ifdef HAVE_GUILE 1348 " guile" 1349 #endif 1350 #ifdef MAKE_LOAD 1351 " load" 1352 #endif 1155 1353 ; 1156 1354 1157 1355 define_variable_cname (".FEATURES", features, o_default, 0); 1158 1356 } 1357 1358 /* Configure GNU Guile support */ 1359 guile_gmake_setup (NILF); 1159 1360 1160 1361 /* Read in variables from the environment. It is important that this be … … 1168 1369 for (i = 0; envp[i] != 0; ++i) 1169 1370 { 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)) 1174 1378 ++ep; 1379 1380 /* If there's no equals sign it's a malformed environment. Ignore. */ 1381 if (*ep == '\0') 1382 continue; 1383 1175 1384 #ifdef WINDOWS32 1176 if (!unix_path && strneq (envp[i], "PATH=", 5))1385 if (!unix_path && strneq (envp[i], "PATH=", 5)) 1177 1386 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)) 1188 1388 { 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 == '-') 1205 1404 { 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 { 1206 1418 #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); 1220 1424 } 1425 1426 v->export = export; 1221 1427 } 1222 1428 } 1223 1429 #ifdef WINDOWS32 1224 1430 /* If we didn't find a correctly spelled PATH we define PATH as 1225 * either the first mis pelled value or an empty string1431 * either the first misspelled value or an empty string 1226 1432 */ 1227 1433 if (!unix_path) … … 1231 1437 #else /* For Amiga, read the ENV: device, ignoring all dirs */ 1232 1438 { 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 } 1259 1464 } 1260 1465 #endif 1261 1466 1262 1467 /* 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); 1263 1472 1264 1473 decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS")); 1474 1265 1475 #if 0 1266 1476 /* People write things like: … … 1270 1480 #endif 1271 1481 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 } 1273 1537 1274 1538 #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 1284 1547 1285 1548 /* Set always_make_flag if -B was given and we've not restarted already. */ 1286 1549 always_make_flag = always_make_set && (restarts == 0); 1287 1550 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) 1290 1553 { 1291 1554 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 (); 1297 1560 1298 1561 #ifndef VMS … … 1309 1572 * CreateProcess(). 1310 1573 */ 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)); 1315 1577 #else /* WINDOWS32 */ 1316 1578 #if defined (__MSDOS__) || defined (__EMX__) … … 1321 1583 argv[0] = xstrdup (argv[0]); 1322 1584 for (p = argv[0]; *p; p++) 1323 1324 1585 if (*p == '\\') 1586 *p = '/'; 1325 1587 } 1326 1588 /* If argv[0] is not in absolute form, prepend the current … … 1349 1611 #endif 1350 1612 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 1351 1654 /* The extra indirection through $(MAKE_COMMAND) is done 1352 1655 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 1353 1663 define_variable_cname ("MAKE_COMMAND", argv[0], o_default, 0); 1664 #endif 1354 1665 define_variable_cname ("MAKE", "$(MAKE_COMMAND)", o_default, 1); 1355 1666 … … 1362 1673 1363 1674 /* Figure out how much space will be taken up by the command-line 1364 1675 variable definitions. */ 1365 1676 for (cv = command_variables; cv != 0; cv = cv->next) 1366 1367 1368 1369 1370 1371 1372 1373 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 } 1375 1686 1376 1687 /* Now allocate a buffer big enough and fill it. */ 1377 1688 p = value = alloca (len); 1378 1689 for (cv = command_variables; cv != 0; cv = cv->next) 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 p[-1] = '\0'; 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. */ 1389 1700 1390 1701 /* Define an unchangeable variable with a name that no POSIX.2 1391 1702 makefile could validly use for its own variable. */ 1392 1703 define_variable_cname ("-*-command-variables-*-", value, o_automatic, 0); 1393 1704 … … 1400 1711 define_variable_cname ("MAKEOVERRIDES", "${-*-command-variables-*-}", 1401 1712 o_env, 1); 1713 #ifdef VMS 1714 vms_export_dcl_symbol ("MAKEOVERRIDES", "${-*-command-variables-*-}"); 1715 #endif 1402 1716 } 1403 1717 … … 1434 1748 * at the wrong place when it was first evaluated. 1435 1749 */ 1436 no_default_sh_exe = !find_and_set_default_shell(NULL); 1437 1750 no_default_sh_exe = !find_and_set_default_shell (NULL); 1438 1751 #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 else1445 makelevel = 0;1446 }1447 1752 1448 1753 /* Except under -s, always do -w in sub-makes and under -C. */ … … 1463 1768 ? 0 : include_directories->list); 1464 1769 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) 1470 1772 { 1471 1773 #ifdef WINDOWS32 … … 1474 1776 if (getcwd (current_directory, GET_PATH_MAX) == 0) 1475 1777 #endif 1476 1477 #ifdef 1478 1778 { 1779 #ifdef HAVE_GETCWD 1780 perror_with_name ("getcwd", ""); 1479 1781 #else 1480 error (NILF, "getwd: %s", current_directory);1481 #endif 1482 1483 1782 OS (error, NILF, "getwd: %s", current_directory); 1783 #endif 1784 starting_directory = 0; 1785 } 1484 1786 else 1485 1787 starting_directory = current_directory; 1486 1788 } 1487 1789 … … 1494 1796 unsigned int i; 1495 1797 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; 1503 1806 1504 1807 if (stdin_nm) 1505 fatal (NILF, _("Makefile from standard input specified twice.")); 1808 O (fatal, NILF, 1809 _("Makefile from standard input specified twice.")); 1506 1810 1507 1811 #ifdef VMS 1508 # define DEFAULT_TMPDIR " sys$scratch:"1812 # define DEFAULT_TMPDIR "/sys$scratch/" 1509 1813 #else 1510 1814 # ifdef P_tmpdir … … 1516 1820 #define DEFAULT_TMPFILE "GmXXXXXX" 1517 1821 1518 1822 if (((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0') 1519 1823 #if defined (__MSDOS__) || defined (WINDOWS32) || defined (__EMX__) 1520 1824 /* These are also used commonly on these platforms. */ … … 1523 1827 #endif 1524 1828 ) 1525 1526 1527 template = alloca (strlen (tmpdir) + sizeof (DEFAULT_TMPFILE) + 1);1528 1829 tmpdir = DEFAULT_TMPDIR; 1830 1831 template = alloca (strlen (tmpdir) + CSTRLEN (DEFAULT_TMPFILE) + 2); 1832 strcpy (template, tmpdir); 1529 1833 1530 1834 #ifdef HAVE_DOS_PATHS 1531 1532 1835 if (strchr ("/\\", template[strlen (template) - 1]) == NULL) 1836 strcat (template, "/"); 1533 1837 #else 1534 1838 # ifndef VMS 1535 1536 1839 if (template[strlen (template) - 1] != '/') 1840 strcat (template, "/"); 1537 1841 # endif /* !VMS */ 1538 1842 #endif /* !HAVE_DOS_PATHS */ 1539 1843 1540 1541 outfile = open_tmpfile (&stdin_nm, template);1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 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. */ 1555 1859 makefiles->list[i] = strcache_add (stdin_nm); 1556 1860 1557 1861 /* Make sure the temporary file will not be remade. */ 1558 1862 { 1559 1863 struct file *f = enter_file (strcache_add (stdin_nm)); 1560 1864 f->updated = 1; 1561 f->update_status = 0;1865 f->update_status = us_success; 1562 1866 f->command_state = cs_finished; 1563 1867 /* Can't be intermediate, or it'll be removed too early for … … 1566 1870 f->dontcare = 0; 1567 1871 } 1568 1872 } 1569 1873 } 1570 1874 1571 1875 #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) 1573 1877 /* 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. 1575 1879 1576 1880 If we don't have a hanging wait we have to fall back to old, broken … … 1578 1882 children. 1579 1883 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 the1582 jobserver pipe in job.c ifwe'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. 1583 1887 1584 1888 If none of these are true, we don't need a signal handler at all. */ 1585 1889 { 1586 RETSIGTYPE child_handler (int sig);1587 1890 # if defined SIGCHLD 1588 1891 bsd_signal (SIGCHLD, child_handler); … … 1592 1895 # endif 1593 1896 } 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 1594 1909 #endif 1595 1910 #endif … … 1601 1916 1602 1917 /* Define the initial list of suffixes for old-style rules. */ 1603 1604 1918 set_default_suffixes (); 1605 1919 … … 1609 1923 makefiles, it results in the built-in pattern rules taking precedence 1610 1924 over makefile-specified suffix rules, which is wrong. */ 1611 1612 1925 install_default_suffix_rules (); 1613 1926 1614 1927 /* Define some internal and special variables. */ 1615 1616 1928 define_automatic_variables (); 1617 1929 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; 1622 1933 1623 1934 /* Define the default variables. */ … … 1635 1946 char *p, *value; 1636 1947 unsigned int i; 1637 unsigned int len = sizeof ("--eval=") * eval_strings->idx;1948 unsigned int len = (CSTRLEN ("--eval=") + 1) * eval_strings->idx; 1638 1949 1639 1950 for (i = 0; i < eval_strings->idx; ++i) … … 1641 1952 p = xstrdup (eval_strings->list[i]); 1642 1953 len += 2 * strlen (p); 1643 eval_buffer (p );1954 eval_buffer (p, NULL); 1644 1955 free (p); 1645 1956 } … … 1649 1960 { 1650 1961 strcpy (p, "--eval="); 1651 p += strlen (p);1962 p += CSTRLEN ("--eval="); 1652 1963 p = quote_for_env (p, eval_strings->list[i]); 1653 1964 *(p++) = ' '; … … 1660 1971 /* Read all the makefiles. */ 1661 1972 1662 read_makefiles 1663 = read_all_makefiles (makefiles == 0 ? 0 : makefiles->list); 1973 read_files = read_all_makefiles (makefiles == 0 ? 0 : makefiles->list); 1664 1974 1665 1975 #ifdef WINDOWS32 1666 1976 /* look one last time after reading all Makefiles */ 1667 1977 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); 1669 1979 #endif /* WINDOWS32 */ 1670 1980 1671 #if defined (__MSDOS__) || defined (__EMX__) 1981 #if defined (__MSDOS__) || defined (__EMX__) || defined (VMS) 1672 1982 /* We need to know what kind of shell we will be using. */ 1673 1983 { … … 1675 1985 struct variable *shv = lookup_variable (STRING_SIZE_TUPLE ("SHELL")); 1676 1986 extern int unixy_shell; 1677 extern c har *default_shell;1987 extern const char *default_shell; 1678 1988 1679 1989 if (shv && *shv->value) 1680 1990 { 1681 char *shell_path = recursively_expand(shv);1682 1683 1684 1685 1686 1687 1688 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; 1689 1999 } 1690 2000 } 1691 2001 #endif /* __MSDOS__ || __EMX__ */ 1692 2002 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")); 1695 2014 #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 1701 2046 # ifdef __EMX__ 1702 2047 && _osmode != OS2_MODE /* turn off -j if we are in DOS mode */ … … 1704 2049 ) 1705 2050 { 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) 1752 2071 { 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; 1759 2075 } 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 } 1812 2088 1813 2089 #ifndef MAKE_SYMLINKS 1814 2090 if (check_symlink_flag) 1815 2091 { 1816 error (NILF, _("Symbolic links not supported: disabling -L."));2092 O (error, NILF, _("Symbolic links not supported: disabling -L.")); 1817 2093 check_symlink_flag = 0; 1818 2094 } … … 1823 2099 define_makeflags (1, 0); 1824 2100 1825 /* Make each `struct dep' point at the `struct file' for the file2101 /* Make each 'struct goaldep' point at the 'struct file' for the file 1826 2102 depended on. Also do magic for special targets. */ 1827 2103 … … 1862 2138 f->last_mtime = f->mtime_before_update = OLD_MTIME; 1863 2139 f->updated = 1; 1864 f->update_status = 0;2140 f->update_status = us_success; 1865 2141 f->command_state = cs_finished; 1866 2142 } … … 1871 2147 const char **p; 1872 2148 for (p = new_files->list; *p != 0; ++p) 1873 1874 1875 1876 2149 { 2150 struct file *f = enter_file (*p); 2151 f->last_mtime = f->mtime_before_update = NEW_MTIME; 2152 } 1877 2153 } 1878 2154 … … 1880 2156 remote_setup (); 1881 2157 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) 1883 2164 { 1884 2165 /* Update any makefiles if necessary. */ … … 1886 2167 FILE_TIMESTAMP *makefile_mtimes = 0; 1887 2168 unsigned int mm_idx = 0; 1888 char **nargv; 2169 char **aargv = NULL; 2170 const char **nargv; 1889 2171 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; 1895 2173 1896 2174 DB (DB_BASIC, (_("Updating makefiles....\n"))); 1897 2175 1898 2176 /* Remove any makefiles we don't want to try to update. 1899 2177 Also record the current modtimes so we can compare them later. */ 1900 2178 { 1901 register structdep *d, *last;1902 1903 d = read_makefiles;1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 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"), 1922 2200 f->name)); 1923 2201 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 { 1939 2218 makefile_mtimes = xrealloc (makefile_mtimes, 1940 2219 (mm_idx+1) 1941 2220 * sizeof (FILE_TIMESTAMP)); 1942 1943 1944 1945 1946 2221 makefile_mtimes[mm_idx++] = file_mtime_no_search (d->file); 2222 last = d; 2223 d = d->next; 2224 } 2225 } 1947 2226 } 1948 2227 1949 /* Set up `MAKEFLAGS' specially while remaking makefiles. */2228 /* Set up 'MAKEFLAGS' specially while remaking makefiles. */ 1950 2229 define_makeflags (1, 1); 1951 2230 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 } 1955 2243 1956 2244 switch (status) 1957 1958 case 1:2245 { 2246 case us_question: 1959 2247 /* 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) 1981 2268 { 1982 /* Reset the considered flag; we may need to look at the file1983 again to print an error. */1984 d->file->considered = 0;1985 1986 2269 if (d->file->updated) 1987 2270 { 1988 2271 /* This makefile was updated. */ 1989 if (d->file->update_status == 0)2272 if (d->file->update_status == us_success) 1990 2273 { 1991 2274 /* It was successfully updated. */ … … 1993 2276 != makefile_mtimes[i]); 1994 2277 } 1995 else if (! (d-> changed& RM_DONTCARE))2278 else if (! (d->flags & RM_DONTCARE)) 1996 2279 { 1997 2280 FILE_TIMESTAMP mtime; 1998 2281 /* The update failed and this makefile was not 1999 2282 from the MAKEFILES variable, so we care. */ 2000 error (NILF, _("Failed to remake makefile `%s'."),2001 2283 OS (error, NILF, _("Failed to remake makefile '%s'."), 2284 d->file->name); 2002 2285 mtime = file_mtime_no_search (d->file); 2003 2286 any_remade |= (mtime != NONEXISTENT_MTIME … … 2008 2291 else 2009 2292 /* This makefile was not found at all. */ 2010 if (! (d-> changed& RM_DONTCARE))2293 if (! (d->flags & RM_DONTCARE)) 2011 2294 { 2295 const char *dnm = dep_name (d); 2296 size_t l = strlen (dnm); 2297 2012 2298 /* 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); 2019 2304 else 2020 2305 { 2021 2306 /* 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); 2024 2309 any_failed = 1; 2025 2310 } … … 2027 2312 } 2028 2313 /* Reset this to empty so we get the right error message below. */ 2029 read_ makefiles = 0;2030 2031 2032 2033 2034 die (2);2314 read_files = 0; 2315 2316 if (any_remade) 2317 goto re_exec; 2318 if (any_failed) 2319 die (MAKE_FAILURE); 2035 2320 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 (); 2048 2331 2049 2332 clean_jobserver (0); 2050 2333 2051 2052 2053 2054 2055 2056 2057 2058 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') 2059 2342 /* This cast is OK since we never modify argv. */ 2060 2061 2062 2063 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 } 2066 2349 2067 2350 /* Add -o option for the stdin temporary file, if necessary. */ … … 2069 2352 if (stdin_nm) 2070 2353 { 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; 2075 2360 } 2076 2361 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 } 2092 2378 2093 2379 ++restarts; 2094 2380 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 } 2111 2390 2112 2391 #ifndef _AMIGA … … 2115 2394 for (p = environ; *p != 0; ++p) 2116 2395 { 2117 if (strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH) 2118 && (*p)[MAKELEVEL_LENGTH] == '=') 2396 if (strneq (*p, MAKELEVEL_NAME "=", MAKELEVEL_LENGTH+1)) 2119 2397 { 2120 2398 *p = alloca (40); 2121 2399 sprintf (*p, "%s=%u", MAKELEVEL_NAME, makelevel); 2400 #ifdef VMS 2401 vms_putenv_symbol (*p); 2402 #endif 2122 2403 } 2123 if (strneq (*p, "MAKE_RESTARTS=", 14))2404 else if (strneq (*p, "MAKE_RESTARTS=", CSTRLEN ("MAKE_RESTARTS="))) 2124 2405 { 2125 2406 *p = alloca (40); 2126 sprintf (*p, "MAKE_RESTARTS=%u", restarts); 2407 sprintf (*p, "MAKE_RESTARTS=%s%u", 2408 OUTPUT_IS_TRACED () ? "-" : "", restarts); 2127 2409 restarts = 0; 2128 2410 } … … 2130 2412 } 2131 2413 #else /* AMIGA */ 2132 2133 2414 { 2415 char buffer[256]; 2134 2416 2135 2417 sprintf (buffer, "%u", makelevel); 2136 2418 SetVar (MAKELEVEL_NAME, buffer, -1, GVF_GLOBAL_ONLY); 2137 2419 2138 sprintf (buffer, "% u", restarts);2420 sprintf (buffer, "%s%u", OUTPUT_IS_TRACED () ? "-" : "", restarts); 2139 2421 SetVar ("MAKE_RESTARTS", buffer, -1, GVF_GLOBAL_ONLY); 2140 2422 restarts = 0; 2141 2423 } 2142 2424 #endif 2143 2425 … … 2146 2428 { 2147 2429 char *b = alloca (40); 2148 sprintf (b, "MAKE_RESTARTS=%u", restarts); 2430 sprintf (b, "MAKE_RESTARTS=%s%u", 2431 OUTPUT_IS_TRACED () ? "-" : "", restarts); 2149 2432 putenv (b); 2150 2433 } 2151 2434 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); 2158 2437 2159 2438 #ifdef _AMIGA 2160 2161 2439 exec_command (nargv); 2440 exit (0); 2162 2441 #elif defined (__EMX__) 2163 2164 2165 2166 2167 2168 2169 2170 2171 int status;2172 pid = child_execute_job (0, 1, nargv, environ);2173 2174 2175 2176 pid = wait (&status);2177 2178 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 } 2181 2460 #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. */ 2200 2477 define_makeflags (1, 0); 2201 2478 … … 2208 2485 const char **p; 2209 2486 for (p = new_files->list; *p != 0; ++p) 2210 2211 2212 2213 2487 { 2488 struct file *f = enter_file (*p); 2489 f->last_mtime = f->mtime_before_update = NEW_MTIME; 2490 } 2214 2491 } 2215 2492 … … 2244 2521 struct nameseq *ns; 2245 2522 2246 ns = PARSE_ FILE_SEQ (&p, struct nameseq, '\0', NULL, 0);2523 ns = PARSE_SIMPLE_SEQ (&p, struct nameseq); 2247 2524 if (ns) 2248 2525 { 2249 2526 /* .DEFAULT_GOAL should contain one target. */ 2250 2527 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")); 2252 2530 2253 2531 f = enter_file (strcache_add (ns->name)); … … 2260 2538 if (f) 2261 2539 { 2262 goals = alloc_ dep ();2540 goals = alloc_goaldep (); 2263 2541 goals->file = f; 2264 2542 } … … 2271 2549 if (!goals) 2272 2550 { 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")); 2277 2555 } 2278 2556 … … 2282 2560 2283 2561 { 2284 int status;2285 2286 2562 switch (update_goal_chain (goals)) 2287 2563 { 2288 case -1:2564 case us_none: 2289 2565 /* Nothing happened. */ 2290 case 0:2291 /* Updated successfully. */2292 status = makefile_status;2566 /* FALLTHROUGH */ 2567 case us_success: 2568 /* Keep the previous result. */ 2293 2569 break; 2294 case 1:2570 case us_question: 2295 2571 /* We are under -q and would run some commands. */ 2296 status = MAKE_TROUBLE;2572 makefile_status = MAKE_TROUBLE; 2297 2573 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; 2302 2577 break; 2303 default:2304 abort ();2305 2578 } 2306 2579 2307 2580 /* If we detected some clock skew, generate one last warning */ 2308 2581 if (clock_skew_detected) 2309 error (NILF,2310 2582 O (error, NILF, 2583 _("warning: Clock skew detected. Your build may be incomplete.")); 2311 2584 2312 2585 /* Exit. */ 2313 die ( status);2586 die (makefile_status); 2314 2587 } 2315 2588 2316 2589 /* NOTREACHED */ 2317 return 0;2590 exit (MAKE_SUCCESS); 2318 2591 } 2319 2592 … … 2323 2596 static char options[1 + sizeof (switches) / sizeof (switches[0]) * 3]; 2324 2597 static struct option long_options[(sizeof (switches) / sizeof (switches[0])) + 2325 2326 2598 (sizeof (long_option_aliases) / 2599 sizeof (long_option_aliases[0]))]; 2327 2600 2328 2601 /* Fill in the string and vector for getopt. */ … … 2347 2620 { 2348 2621 long_options[i].name = (switches[i].long_name == 0 ? "" : 2349 2622 switches[i].long_name); 2350 2623 long_options[i].flag = 0; 2351 2624 long_options[i].val = switches[i].c; 2352 2625 if (short_option (switches[i].c)) 2353 2626 *p++ = switches[i].c; 2354 2627 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: 2363 2637 case filename: 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 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 } 2378 2652 } 2379 2653 *p = '\0'; 2380 2654 for (c = 0; c < (sizeof (long_option_aliases) / 2381 2655 sizeof (long_option_aliases[0])); 2382 2656 ++c) 2383 2657 long_options[i++] = long_option_aliases[c]; … … 2385 2659 } 2386 2660 2661 2662 /* Non-option argument. It might be a variable definition. */ 2387 2663 static void 2388 handle_non_switch_argument (c har *arg, int env)2664 handle_non_switch_argument (const char *arg, int env) 2389 2665 { 2390 /* Non-option argument. It might be a variable definition. */2391 2666 struct variable *v; 2667 2392 2668 if (arg[0] == '-' && arg[1] == '\0') 2393 /* Ignore plain `-' for compatibility. */2669 /* Ignore plain '-' for compatibility. */ 2394 2670 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 2395 2697 v = try_variable_definition (0, arg, o_command, 0); 2396 2698 if (v != 0) 2397 2699 { 2398 2700 /* It is indeed a variable definition. If we don't already have this 2399 2400 2701 one, record a pointer to the variable for later use in 2702 define_makeflags. */ 2401 2703 struct command_variable *cv; 2402 2704 … … 2405 2707 break; 2406 2708 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 } 2413 2716 } 2414 2717 else if (! env) 2415 2718 { 2416 2719 /* Not an option or variable definition; it must be a goal 2417 2418 2720 target! Enter it as a file and add it to the dep chain of 2721 goals. */ 2419 2722 struct file *f = enter_file (strcache_add (expand_command_line_file (arg))); 2420 2723 f->cmd_target = 1; 2421 2724 2422 2725 if (goals == 0) 2423 2424 goals = alloc_dep ();2425 2426 2726 { 2727 goals = alloc_goaldep (); 2728 lastgoal = goals; 2729 } 2427 2730 else 2428 2429 lastgoal->next = alloc_dep ();2430 2431 2731 { 2732 lastgoal->next = alloc_goaldep (); 2733 lastgoal = lastgoal->next; 2734 } 2432 2735 2433 2736 lastgoal->file = f; … … 2491 2794 2492 2795 static void 2493 decode_switches (int argc, c har **argv, int env)2796 decode_switches (int argc, const char **argv, int env) 2494 2797 { 2495 2798 int bad = 0; … … 2511 2814 while (optind < argc) 2512 2815 { 2816 const char *coptarg; 2817 2513 2818 /* 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; 2515 2821 if (c == EOF) 2516 2517 2822 /* End of arguments, or "--" marker seen. */ 2823 break; 2518 2824 else if (c == 1) 2519 2520 handle_non_switch_argument (optarg, env);2825 /* An argument not starting with a dash. */ 2826 handle_non_switch_argument (coptarg, env); 2521 2827 else if (c == '?') 2522 2523 2524 2525 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; 2526 2832 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') 2558 2865 { 2559 2866 char opt[2] = "c"; … … 2565 2872 op = cs->long_name; 2566 2873 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"), 2568 2876 short_option (cs->c) ? "-" : "--", op); 2569 2877 bad = 1; 2878 break; 2570 2879 } 2571 2880 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; 2585 2901 /* MSVC erroneously warns without a cast here. */ 2586 2902 sl->list = xrealloc ((void *)sl->list, 2587 2903 sl->max * sizeof (char *)); 2588 2904 } 2589 2905 if (cs->type == filename) 2590 sl->list[sl->idx++] = expand_command_line_file ( optarg);2906 sl->list[sl->idx++] = expand_command_line_file (coptarg); 2591 2907 else 2592 sl->list[sl->idx++] = optarg;2593 2594 2595 2596 2908 sl->list[sl->idx++] = xstrdup (coptarg); 2909 sl->list[sl->idx] = 0; 2910 break; 2911 2912 case positive_int: 2597 2913 /* See if we have an option argument; if we do require that 2598 2914 it's all digits, not something like "10foo". */ 2599 if (optarg == 0 && argc > optind)2915 if (coptarg == 0 && argc > optind) 2600 2916 { 2601 2917 const char *cp; … … 2603 2919 ; 2604 2920 if (cp[0] == '\0') 2605 optarg = argv[optind++];2921 coptarg = argv[optind++]; 2606 2922 } 2607 2923 2608 2609 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); 2614 2930 const char *cp; 2615 2931 2616 2932 /* 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) 2618 2934 ; 2619 2935 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"), 2623 2940 cs->c); 2624 2625 2626 2627 2628 2629 2630 2631 2632 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; 2633 2950 2634 2951 #ifndef NO_FLOAT 2635 2636 if (optarg == 0 && optind < argc2637 2638 2639 2640 2641 2642 = (optarg != 0 ? atof (optarg)2643 2644 2645 2646 #endif 2647 2648 2649 2650 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 } 2652 2969 } 2653 2970 … … 2659 2976 handle_non_switch_argument (argv[optind++], env); 2660 2977 2661 2662 2978 if (!env && (bad || print_usage_flag)) 2663 2979 { 2664 2980 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 (); 2667 2987 } 2668 2988 … … 2673 2993 2674 2994 static void 2675 decode_env_switches (c har *envar, unsigned int len)2995 decode_env_switches (const char *envar, unsigned int len) 2676 2996 { 2677 2997 char *varref = alloca (2 + len + 2); 2678 char *value, *p ;2998 char *value, *p, *buf; 2679 2999 int argc; 2680 c har **argv;3000 const char **argv; 2681 3001 2682 3002 /* Get the variable's value. */ … … 2689 3009 2690 3010 /* Skip whitespace, and check for an empty value. */ 2691 value = next_token(value);3011 NEXT_TOKEN (value); 2692 3012 len = strlen (value); 2693 3013 if (len == 0) … … 2696 3016 /* Allocate a vector that is definitely big enough. */ 2697 3017 argv = alloca ((1 + len + 1) * sizeof (char *)); 2698 2699 /* Allocate a buffer to copy the value into while we split it into words2700 and unquote it. We must use permanent storage for this because2701 decode_switches may store pointers into the passed argument words. */2702 p = xmalloc (2 * len);2703 3018 2704 3019 /* getopt will look at the arguments starting at ARGV[1]. … … 2706 3021 argv[0] = 0; 2707 3022 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; 2708 3029 argv[argc] = p; 2709 3030 while (*value != '\0') 2710 3031 { 2711 3032 if (*value == '\\' && value[1] != '\0') 2712 ++value;/* Skip the backslash. */2713 else if ( isblank ((unsigned char)*value))2714 2715 2716 2717 2718 2719 2720 while (isblank ((unsigned char)*value));2721 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 } 2723 3044 *p++ = *value++; 2724 3045 } 2725 3046 *p = '\0'; 2726 3047 argv[++argc] = 0; 3048 assert (p < buf + len + 2); 2727 3049 2728 3050 if (argv[1][0] != '-' && strchr (argv[1], '=') == 0) 2729 3051 /* 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; 2734 3054 2735 3055 /* Parse those words. */ … … 2750 3070 { 2751 3071 if (*in == '$') 2752 2753 else if ( isblank ((unsigned char)*in) || *in == '\\')3072 *out++ = '$'; 3073 else if (ISBLANK (*in) || *in == '\\') 2754 3074 *out++ = '\\'; 2755 3075 *out++ = *in++; … … 2761 3081 /* Define the MAKEFLAGS and MFLAGS variables to reflect the settings of the 2762 3082 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 3085 static struct variable * 2766 3086 define_makeflags (int all, int makefile) 2767 3087 { … … 2771 3091 const struct command_switch *cs; 2772 3092 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 2778 3096 all the flags which need to go in MAKEFLAGS. Then, once we 2779 3097 know how many there are and their lengths, we can put them all … … 2787 3105 }; 2788 3106 struct flag *flags = 0; 3107 struct flag *last = 0; 2789 3108 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)) \ 2803 3127 /* 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); \ 2805 3129 } while (0) 2806 3130 … … 2808 3132 if (cs->toenv && (!makefile || !cs->no_makefile)) 2809 3133 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; 2844 3165 2845 3166 #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; 2892 3219 2893 3220 /* Construct the value in FLAGSTRING. … … 2896 3223 memset (flagstring, '\0', 1 + flagslen + 1); 2897 3224 p = flagstring; 2898 words = 1; 3225 3226 /* Start with a dash, for MFLAGS. */ 2899 3227 *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 2902 3242 /* Add the flag letter or name to the string. */ 2903 3243 if (short_option (flags->cs->c)) 2904 3244 *p++ = flags->cs->c; 2905 3245 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 } 2941 3260 flags = flags->next; 2942 3261 } 2943 3262 2944 /* Define MFLAGS before appending variable definitions. */ 2945 3263 /* If no flags at all, get rid of the initial dash. */ 2946 3264 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 2960 3272 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); 2962 3276 2963 3277 /* Write a reference to -*-eval-flags-*-, which contains all the --eval … … 2965 3279 if (eval_strings) 2966 3280 { 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; 2997 3294 2998 3295 /* Copy in the string. */ 2999 3296 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 } 3004 3301 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] == '-') 3024 3310 ++flagstring; 3025 3311 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); 3042 3320 } 3043 3321 … … 3050 3328 static int printed_version = 0; 3051 3329 3052 c har *precede = print_data_base_flag ? "# " : "";3330 const char *precede = print_data_base_flag ? "# " : ""; 3053 3331 3054 3332 if (printed_version) … … 3067 3345 (C) to the copyright symbol, but this string is going to change every 3068 3346 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); 3072 3351 3073 3352 printf (_("%sLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ … … 3079 3358 3080 3359 /* 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. */ 3082 3361 fflush (stdout); 3083 3362 } … … 3086 3365 3087 3366 static void 3088 print_data_base ( )3367 print_data_base (void) 3089 3368 { 3090 time_t when; 3091 3092 when = time ((time_t *) 0); 3369 time_t when = time ((time_t *) 0); 3370 3371 print_version (); 3372 3093 3373 printf (_("\n# Make data base, printed on %s"), ctime (&when)); 3094 3374 … … 3107 3387 clean_jobserver (int status) 3108 3388 { 3109 char token = '+';3110 3111 3389 /* Sanity: have we written all our jobserver tokens back? If our 3112 3390 exit status is 2 that means some kind of syntax error; we might not … … 3114 3392 after any other error code, that's bad. */ 3115 3393 3116 if (job _fds[0] != -1&& jobserver_tokens)3394 if (jobserver_enabled() && jobserver_tokens) 3117 3395 { 3118 3396 if (status != 2) 3119 error (NILF,3120 3121 3397 ON (error, NILF, 3398 "INTERNAL: Exiting with %u jobserver tokens (should be 0)!", 3399 jobserver_tokens); 3122 3400 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); 3131 3404 } 3132 3405 … … 3137 3410 { 3138 3411 /* 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 (); 3165 3420 } 3166 3421 } … … 3181 3436 3182 3437 if (print_version_flag) 3183 3438 print_version (); 3184 3439 3185 3440 /* Wait for children to die. */ 3186 3441 err = (status != 0); 3187 3442 while (job_slots_used > 0) 3188 3443 reap_children (1, err); 3189 3444 3190 3445 /* Let the remote job module clean up its state. */ … … 3195 3450 3196 3451 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 (); 3200 3456 3201 3457 clean_jobserver (status); 3202 3458 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 3203 3473 /* Try to move back to the original directory. This is essential on 3204 3205 3206 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 3207 3477 of relative pathnames fail. */ 3208 3478 if (directory_before_chdir != 0) 3209 3479 { 3210 3480 /* If it fails we don't care: shut up GCC. */ 3211 int _x ;3481 int _x UNUSED; 3212 3482 _x = chdir (directory_before_chdir); 3213 3483 } 3214 3215 log_working_directory (0);3216 3484 } 3217 3485 3218 3486 exit (status); 3219 3487 } 3220 3221 3222 /* Write a message indicating that we've just entered or3223 left (according to ENTERING) the current directory. */3224 3225 void3226 log_working_directory (int entering)3227 {3228 static int entered = 0;3229 3230 /* Print nothing without the flag. Don't print the entering message3231 again if we already have. Don't print the leaving message if we3232 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 else3248 printf (_("%s: Leaving an unknown directory\n"), program);3249 else3250 if (entering)3251 printf (_("%s: Entering directory `%s'\n"),3252 program, starting_directory);3253 else3254 printf (_("%s: Leaving directory `%s'\n"),3255 program, starting_directory);3256 else3257 if (starting_directory == 0)3258 if (entering)3259 printf (_("%s[%u]: Entering an unknown directory\n"),3260 program, makelevel);3261 else3262 printf (_("%s[%u]: Leaving an unknown directory\n"),3263 program, makelevel);3264 else3265 if (entering)3266 printf (_("%s[%u]: Entering directory `%s'\n"),3267 program, makelevel, starting_directory);3268 else3269 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 1 1 # 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 CVS2 # only if you have the full copy of the GNU make sources from the Git 3 3 # tree, not a dist copy. 4 4 5 BUGLIST := bug-make@gnu.org 6 7 # These are related to my personal setup. 8 GPG_FINGERPRINT := 6338B6D4 9 10 # SRCROOTDIR is just a handy location to keep source files in 11 SRCROOTDIR ?= $(HOME)/src 12 13 # Where the gnulib project has been locally cloned 14 GNULIBDIR ?= $(SRCROOTDIR)/gnulib 15 16 # Where to put the CVS checkout of the GNU web repository 17 GNUWEBDIR ?= $(SRCROOTDIR)/gnu-www 18 19 # Where to put the CVS checkout of the GNU make web repository 20 MAKEWEBDIR ?= $(SRCROOTDIR)/make/make-web 21 5 22 # We like mondo-warnings! 6 AM_CFLAGS += -Wall -Wextra -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast 23 AM_CFLAGS += -Wall -Wwrite-strings -Wextra -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast 24 25 MAKE_MAINTAINER_MODE := -DMAKE_MAINTAINER_MODE 26 AM_CPPFLAGS += $(MAKE_MAINTAINER_MODE) 7 27 8 28 # I want this one but I have to wait for the const cleanup! … … 19 39 # These are built as a side-effect of the dist rule 20 40 #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 $@ $< 21 45 22 46 # General rule for turning a .template into a regular file. … … 81 105 done) > $@ 82 106 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 109 GIT := 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 115 git-clean: 116 -$(GIT) clean -fdX 117 git-very-clean: git-clean 118 -$(GIT) clean -fd 119 120 121 122 ## ---------------------- ## 123 ## Generating ChangeLog. ## 124 ## ---------------------- ## 125 126 gl2cl-date := 2013-10-10 127 gl2cl := $(GNULIBDIR)/build-aux/gitlog-to-changelog 128 129 # Rebuild the changelog whenever a new commit is added 130 ChangeLog: .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" > '$@' 114 142 115 143 … … 117 145 ## Updating files. ## 118 146 ## ---------------- ## 119 120 WGET = wget --passive-ftp -n v147 RSYNC = rsync -Lrtvz 148 WGET = wget --passive-ftp -np -nv 121 149 ftp-gnu = ftp://ftp.gnu.org/gnu 122 150 … … 124 152 echo $(target) is unchanged; rm -f $(target).t; \ 125 153 else \ 126 mv $(target).t $(target); \154 mv -f $(target).t $(target); \ 127 155 fi 128 156 … … 136 164 # ftp://tiger.informatik.hu-berlin.de/pub/po/maint/ 137 165 166 po_wget_flags = --recursive --level=1 --no-directories --no-check-certificate 138 167 po_repo = http://translationproject.org/latest/$(PACKAGE) 168 po_sync = translationproject.org::tp/latest/$(PACKAGE)/ 169 139 170 .PHONY: do-po-update po-update 140 171 do-po-update: … … 142 173 && rm -rf "$$tmppo" \ 143 174 && 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" 147 178 cd po && $(MAKE) update-po 148 179 $(MAKE) po-check … … 193 224 194 225 226 # ---------------------------------- # 227 # Alternative configuration checks. # 228 # ---------------------------------- # 229 230 .PHONY: check-alt-config 231 check-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. 239 NR_MAKE = $(MAKE) 240 241 # Check builds both with build.sh and with make 242 checkcfg.%: 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 195 259 ## --------------- ## 196 260 ## Sanity checks. ## 197 261 ## --------------- ## 198 262 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 200 269 # previous test may reveal problems requiring new ChangeLog entries. 201 270 local-check: po-check changelog-check … … 212 281 213 282 # Verify that all source files using _() are listed in po/POTFILES.in. 214 # Ignore make .h; it defines _().283 # Ignore makeint.h; it defines _(). 215 284 po-check: 216 285 if test -f po/POTFILES.in; then \ 217 286 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; \ 219 288 diff -u $@-1 $@-2 || exit 1; \ 220 289 rm -f $@-1 $@-2; \ 221 290 fi 222 291 292 293 ## --------------- ## 294 ## Generate docs. ## 295 ## --------------- ## 296 297 .PHONY: update-makeweb gendocs 298 299 CVS = cvs 300 301 makeweb-repo = $(USER)@cvs.sv.gnu.org:/web/make 302 gnuweb-repo = :pserver:anonymous@cvs.sv.gnu.org:/web/www 303 gnuweb-dir = www/server/standards 304 305 # Get the GNU make web page boilerplate etc. 306 update-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. 314 update-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 320 gendocs: 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 340 tag-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 223 347 ## ------------------------- ## 224 348 ## GNU FTP upload artifacts. ## … … 230 354 231 355 GPG = gpg 232 GPGFLAGS = -u 6338B6D4356 GPGFLAGS = -u $(GPG_FINGERPRINT) 233 357 234 358 DIST_ARCHIVES_SIG = $(addsuffix .sig,$(DIST_ARCHIVES)) … … 267 391 268 392 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. 394 Makefile.in: maintMakefile 395 396 # Copyright (C) 1997-2016 Free Software Foundation, Inc. 271 397 # This file is part of GNU Make. 272 398 # -
vendor/gnumake/current/make.1
r2596 r3138 1 .TH MAKE 1 "2 2 August 1989" "GNU" "LOCAL USER COMMANDS"1 .TH MAKE 1 "28 February 2016" "GNU" "User Commands" 2 2 .SH NAME 3 3 make \- GNU make utility to maintain groups of programs 4 4 .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]... 18 7 .SH DESCRIPTION 19 8 .LP 20 The purpose of the9 The 21 10 .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. 11 utility will determine automatically which pieces of a large program need to 12 be recompiled, and issue the commands to recompile them. The manual describes 13 the GNU implementation of 14 .BR make , 15 which was written by Richard Stallman and Roland McGrath, and is currently 16 maintained by Paul Smith. Our examples show C programs, since they are very 17 common, but you can use 18 .B make 19 with any programming language whose compiler can be run with a shell command. 33 20 In 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 22 is not limited to programs. You can use it to describe any task where some 23 files must be updated automatically from others whenever the others change. 38 24 .LP 39 25 To prepare to use 40 . IR make ,26 .BR make , 41 27 you must write a file called the 42 28 .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.29 that describes the relationships among files in your program, and the states 30 the commands for updating each file. In a program, typically the executable 31 file is updated from object files, which are in turn made by compiling source 32 files. 47 33 .LP 48 34 Once a suitable makefile exists, each time you change some source files, … … 55 41 suffices to perform all necessary recompilations. 56 42 The 57 . Imake58 program uses the makefile d ata base and the last-modification times59 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 . Imake43 .B make 44 program uses the makefile description and the last-modification times of the 45 files to decide which of the files need to be updated. For each of those 46 files, it issues the commands recorded in the makefile. 47 .LP 48 .B make 63 49 executes commands in the 64 50 .I makefile 65 to update 66 one or more target 51 to update one or more target 67 52 .IR names , 68 53 where … … 72 57 .B \-f 73 58 option is present, 74 . Imake59 .B make 75 60 will look for the makefiles 76 61 .IR GNUmakefile , … … 91 76 The first name checked, 92 77 .IR GNUmakefile , 93 is not recommended for most makefiles. 94 You should use this name if you have amakefile that is specific to GNU95 . IR make ,78 is not recommended for most makefiles. You should use this name if you have a 79 makefile that is specific to GNU 80 .BR make , 96 81 and will not be understood by other versions of 97 . IR make .82 .BR make . 98 83 If 99 84 .I makefile 100 is `\-', the standard input is read.101 .LP 102 . Imake85 is '\-', the standard input is read. 86 .LP 87 .B make 103 88 updates a target if it depends on prerequisite files 104 89 that have been modified since the target was last modified, … … 107 92 .sp 1 108 93 .TP 0.5i 109 .BR \-b , " \-m" 94 \fB\-b\fR, \fB\-m\fR 110 95 These 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 114 99 Unconditionally make all targets. 115 100 .TP 0.5i … … 127 112 .BR "\-C " /etc. 128 113 This is typically used with recursive invocations of 129 . IR make .114 .BR make . 130 115 .TP 0.5i 131 116 .B \-d … … 135 120 which files actually need to be remade, which implicit rules are 136 121 considered and which are applied---everything interesting about how 137 . Imake122 .B make 138 123 decides what to do. 139 124 .TP 0.5i … … 159 144 for details on invocation of commands, and 160 145 .I m 161 for debugging while remaking makefiles. 162 .TP 0.5i 163 .BR \-e , " \-\-environment\-overrides" 146 for debugging while remaking makefiles. Use 147 .I n 148 to disable all previous debugging flags. 149 .TP 0.5i 150 \fB\-e\fR, \fB\-\-environment\-overrides\fR 164 151 Give variables taken from the environment precedence 165 152 over variables from makefiles. … … 170 157 as a makefile. 171 158 .TP 0.5i 172 .BR \-i , " \-\-ignore\-errors" 159 \fB\-i\fR, \fB\-\-ignore\-errors\fR 173 160 Ignore all errors in commands executed to remake files. 174 161 .TP 0.5i … … 182 169 searched in the order specified. 183 170 Unlike the arguments to other flags of 184 . IR make ,171 .BR make , 185 172 directories given with 186 173 .B \-I … … 188 175 .BI \-I dir 189 176 is allowed, as well as 190 .BI "\-I " dir. 177 .B \-I 178 .IR dir . 191 179 This syntax is allowed for compatibility with the C 192 180 preprocessor's … … 204 192 .B \-j 205 193 option is given without an argument, 206 . IR make194 .BR make 207 195 will not limit the number of jobs that can run simultaneously. 208 196 .TP 0.5i 209 .BR \-k , " \-\-keep\-going" 197 \fB\-k\fR, \fB\-\-keep\-going\fR 210 198 Continue as much as possible after an error. 211 199 While the target that failed, and those that depend on it, cannot … … 220 208 With no argument, removes a previous load limit. 221 209 .TP 0.5i 222 .BR \-L , " \-\-check\-symlink\-times" 210 \fB\-L\fR, \fB\-\-check\-symlink\-times\fR 223 211 Use the latest mtime between symlinks and target. 224 212 .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 226 214 Print the commands that would be executed, but do not execute them (except in 227 215 certain circumstances). … … 235 223 Essentially the file is treated as very old and its rules are ignored. 236 224 .TP 0.5i 237 .BR \-p , " \-\-print\-data\-base" 225 \fB\-O\fR[\fItype\fR], \fB\-\-output\-sync\fR[=\fItype\fR] 226 When running multiple jobs in parallel with \fB-j\fR, ensure the output of 227 each job is collected together rather than interspersed with output from 228 other jobs. If 229 .I type 230 is not specified or is 231 .B target 232 the output from the entire recipe for each target is grouped together. If 233 .I type 234 is 235 .B line 236 the output from each command line within a recipe is grouped together. 237 If 238 .I type 239 is 240 .B recurse 241 output from an entire recursive make is grouped together. If 242 .I type 243 is 244 .B none 245 output synchronization is disabled. 246 .TP 0.5i 247 \fB\-p\fR, \fB\-\-print\-data\-base\fR 238 248 Print the data base (rules and variable values) that results from 239 249 reading the makefiles; then execute as usual or as otherwise … … 243 253 switch (see below). 244 254 To 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 250 258 ``Question mode''. 251 259 Do not run any commands, or print anything; just return an exit status … … 253 261 otherwise. 254 262 .TP 0.5i 255 .BR \-r , " \-\-no\-builtin\-rules" 263 \fB\-r\fR, \fB\-\-no\-builtin\-rules\fR 256 264 Eliminate use of the built\-in implicit rules. 257 265 Also clear out the default list of suffixes for suffix rules. 258 266 .TP 0.5i 259 .BR \-R , " \-\-no\-builtin\-variables" 267 \fB\-R\fR, \fB\-\-no\-builtin\-variables\fR 260 268 Don't define any built\-in variables. 261 269 .TP 0.5i 262 .BR \-s , " \-\-silent" , " \-\-quiet" 270 \fB\-s\fR, \fB\-\-silent\fR, \fB\-\-quiet\fR 263 271 Silent operation; do not print the commands as they are executed. 264 272 .TP 0.5i 265 .BR \-S , " \-\-no\-keep\-going" , " \-\-stop" 273 \fB\-S\fR, \fB\-\-no\-keep\-going\fR, \fB\-\-stop\fR 266 274 Cancel the effect of the 267 275 .B \-k 268 276 option. 269 277 This is never necessary except in a recursive 270 . Imake278 .B make 271 279 where 272 280 .B \-k 273 281 might be inherited from the top-level 274 . Imake282 .B make 275 283 via MAKEFLAGS or if you set 276 284 .B \-k 277 285 in MAKEFLAGS in your environment. 278 286 .TP 0.5i 279 .BR \-t , " \-\-touch" 287 \fB\-t\fR, \fB\-\-touch\fR 280 288 Touch files (mark them up to date without really changing them) 281 289 instead of running their commands. 282 290 This is used to pretend that the commands were done, in order to fool 283 291 future invocations of 284 .IR make . 285 .TP 0.5i 286 .BR \-v , " \-\-version" 292 .BR make . 293 .TP 0.5i 294 .B \-\-trace 295 Information about the disposition of each target is printed (why the target is 296 being rebuilt and what commands are run to rebuild it). 297 .TP 0.5i 298 \fB\-v\fR, \fB\-\-version\fR 287 299 Print the version of the 288 . Imake300 .B make 289 301 program plus a copyright, a list of authors and a notice that there 290 302 is no warranty. 291 303 .TP 0.5i 292 .BR \-w , " \-\-print\-directory" 304 \fB\-w\fR, \fB\-\-print\-directory\fR 293 305 Print a message containing the working directory 294 306 before and after other processing. 295 307 This may be useful for tracking down errors from complicated nests of 296 308 recursive 297 . Imake309 .B make 298 310 commands. 299 311 .TP 0.5i … … 315 327 .I touch 316 328 command on the given file before running 317 . IR make ,329 .BR make , 318 330 except that the modification time is changed only in the imagination of 319 . IR make .331 .BR make . 320 332 .TP 0.5i 321 333 .B \-\-warn\-undefined\-variables … … 323 335 .SH "EXIT STATUS" 324 336 GNU 325 . Imake337 .B make 326 338 exits with a status of zero if all makefiles were successfully parsed 327 339 and no targets that were built failed. A status of one will be returned … … 329 341 .B \-q 330 342 flag was used and 331 . Imake343 .B make 332 344 determines that a target needs to be rebuilt. A status of two will be 333 345 returned if any errors were encountered. 334 346 .SH "SEE ALSO" 335 .I "The GNU Make Manual" 347 The full documentation for 348 .B make 349 is maintained as a Texinfo manual. If the 350 .B info 351 and 352 .B make 353 programs are properly installed at your site, the command 354 .IP 355 .B info make 356 .PP 357 should give you access to the complete manual. 336 358 .SH BUGS 337 See the chapter ` Problems and Bugs' in359 See the chapter ``Problems and Bugs'' in 338 360 .IR "The GNU Make Manual" . 339 361 .SH AUTHOR 340 362 This manual page contributed by Dennis Morse of Stanford University. 341 It has been reworked by Roland McGrath. Further updates contributed by 342 M ike Frysinger.363 Further updates contributed by Mike Frysinger. It has been reworked by Roland 364 McGrath. Maintained by Paul Smith. 343 365 .SH "COPYRIGHT" 344 Copyright (C) 1992, 1993, 1996, 1999, 2007Free Software Foundation, Inc.345 This file is part of GNU346 .IR make.366 Copyright \(co 1992-1993, 1996-2016 Free Software Foundation, Inc. 367 This file is part of 368 .IR "GNU make" . 347 369 .LP 348 370 GNU 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" 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"+"output.o" 2 2 TO "make.new" 3 3 LIB glob/glob.lib LIB:sc.lib LIB:amiga.lib -
vendor/gnumake/current/make_msvc_net2003.vcproj
r501 r3138 155 155 RelativePath=".\getopt1.c"> 156 156 </File> 157 158 <File 159 RelativePath=".\guile.c"> 160 </File> 161 157 162 <File 158 163 RelativePath=".\hash.c"> … … 166 171 <File 167 172 RelativePath=".\job.c"> 173 </File> 174 <File 175 RelativePath=".\load.c"> 176 </File> 177 <File 178 RelativePath=".\output.c"> 168 179 </File> 169 180 <File … … 202 213 <File 203 214 RelativePath=".\w32\compat\dirent.c"> 215 </File> 216 <File 217 RelativePath=".\w32\compat\posixfcn.c"> 204 218 </File> 205 219 <File … … 222 236 </File> 223 237 <File 238 RelativePath=".\w32\w32os.c"> 239 </File> 240 <File 224 241 RelativePath=".\w32\subproc\sub_proc.c"> 225 242 </File> … … 265 282 </File> 266 283 <File 284 RelativePath=".\gmk-default.h"> 285 </File> 286 <File 267 287 RelativePath=".\hash.h"> 268 288 </File> … … 271 291 </File> 272 292 <File 273 RelativePath=".\make.h"> 293 RelativePath=".\output.h"> 294 </File> 295 <File 296 RelativePath=".\makeint.h"> 274 297 </File> 275 298 <File -
vendor/gnumake/current/makefile.com
r2596 r3138 2 2 $! Makefile.com - builds GNU Make for VMS 3 3 $! 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. 6 5 $! P2 = DEBUG will build an image with debug information 7 6 $! P3 = WALL will enable all warning messages (some are suppressed since … … 51 50 $ endif 52 51 $! 52 $! 53 $ if (p1 .eqs. "LIST") 54 $ then 55 $ ccopt = ccopt + "/list/show=(expan,inclu)" 56 $ endif 57 $! 53 58 $! Should we build a debug image 54 59 $! … … 68 73 $ endif 69 74 $ 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 $! 73 81 $ copy config.h-vms config.h 74 82 $ n=0 … … 78 86 $ if cfile .eqs. " " then goto linkit 79 87 $ write sys$output "Compiling ''cfile'..." 80 $ call compileit 'cfile' 'p1'88 $ call compileit 'cfile' 81 89 $ n = n + 1 82 90 $ goto loop 83 91 $ linkit: 84 92 $ close optf 85 $ if p1 .nes. "" then goto link_using_library86 93 $ link/exe=make make.opt/opt'lopt 87 94 $ goto cleanup 88 $89 $ link_using_library:90 $ link/exe=make make.opt/opt,sys$library:vaxcrtl/lib'lopt91 95 $ 92 96 $ cleanup: … … 129 133 $ compileit : subroutine 130 134 $ 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") - 136 147 'p1' 137 148 $ exit … … 139 150 $! 140 151 $!----------------------------------------------------------------------------- 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. 143 153 $!This file is part of GNU Make. 144 154 $! -
vendor/gnumake/current/makefile.vms
r2596 r3138 1 1 # -*-Makefile-*- to build GNU make on VMS 2 2 # 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. 5 4 # This file is part of GNU Make. 6 5 # … … 22 21 # Modified for version 3.78.1 by Hartmut.Becker@compaq.com. 23 22 # Modified for version 3.80 by zinser@decus.de 24 # Modified for version 3.81by Hartmut Becker23 # Modified for versions 3.81, 3.99.90 by Hartmut Becker 25 24 26 25 CC = cc … … 34 33 35 34 ifeq ($(CC),cc) 36 CFLAGS = $(defines) /include=([],[.glob])/prefix=(all,except=(glob,globfree))/standard=relaxed/warn=(disable=questcompare) 35 cinclude = /nested=none/include=([],[.glob]) 36 cprefix = /prefix=(all,except=(glob,globfree)) 37 cwarn = /standard=relaxed/warn=(disable=questcompare) 38 CFLAGS = $(defines) $(cinclude)$(cprefix)$(cwarn) 37 39 else 38 CFLAGS = $(defines) /include=([],[.glob])40 CFLAGS = $(defines) $(cinclude) 39 41 endif 40 42 #LDFLAGS = /deb … … 83 85 glob = ,[.glob]glob.obj,[.glob]fnmatch.obj 84 86 getopt = ,getopt.obj,getopt1.obj 85 # Directory to install `make' in.87 # Directory to install 'make' in. 86 88 bindir = [] 87 89 # Directory to install the man page in. … … 90 92 manext = 1 91 93 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,\ 94 guile = ,guile.obj 95 96 objs = 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,\ 94 98 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 102 srcs = 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 \ 98 104 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 101 108 102 109 … … 112 119 .PHONY: clean realclean 113 120 clean: 114 $$purge [...]121 -purge [...] 115 122 -$(RM) make.exe;,*.obj; 116 123 -$(RM) [.glob]*.obj; 117 124 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 125 ar.obj: ar.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h dep.h \ 126 [.glob]fnmatch.h 127 arscan.obj: arscan.c makeint.h config.h gnumake.h gettext.h 128 commands.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 130 default.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 132 dir.obj: dir.c makeint.h config.h gnumake.h gettext.h hash.h filedef.h \ 133 dep.h [.glob]glob.h 134 expand.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 136 file.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 139 function.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 141 getopt.obj: getopt.c config.h gettext.h getopt.h 142 getopt1.obj: getopt1.c config.h getopt.h 143 [.glob]glob.obj: [.glob]glob.c config.h [.glob]fnmatch.h [.glob]glob.h 144 guile.obj: guile.c makeint.h config.h gnumake.h gettext.h 145 hash.obj: hash.c makeint.h config.h gnumake.h gettext.h hash.h 146 implicit.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 148 job.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 150 load.obj: load.c makeint.h config.h gnumake.h gettext.h 151 main.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 153 misc.obj: misc.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h \ 154 dep.h debug.h 155 output.obj: output.c makeint.h config.h gnumake.h gettext.h job.h output.h 156 read.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 159 remake.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 161 remote-stub.obj: remote-stub.c makeint.h config.h gnumake.h gettext.h \ 162 filedef.h hash.h job.h output.h commands.h 163 rule.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 165 signame.obj: signame.c makeint.h config.h gnumake.h gettext.h 166 strcache.obj: strcache.c makeint.h config.h gnumake.h gettext.h hash.h 167 variable.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 136 169 version.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 170 vmsfunctions.obj: vmsfunctions.c makeint.h config.h gnumake.h gettext.h \ 171 debug.h job.h output.h vmsdir.h 172 vmsify.obj: vmsify.c 173 vpath.obj: vpath.c makeint.h config.h gnumake.h gettext.h filedef.h hash.h \ 174 variable.h 175 vms_progname.obj: vms_progname.c 176 vms_exit.obj: vms_exit.c 177 vms_export_symbol.obj: vms_export_symbol.c 147 178 148 179 config.h: config.h-vms -
vendor/gnumake/current/makeint.h
r3137 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 19 17 /* We use <config.h> instead of "config.h" so that a compilation 20 18 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). */ 22 20 #include <config.h> 23 21 #undef HAVE_CONFIG_H … … 44 42 #endif 45 43 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" 46 58 47 59 #ifdef CRAY … … 61 73 #include <stdio.h> 62 74 #include <ctype.h> 75 63 76 #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. */ 67 79 # include <sys/timeb.h> 68 80 #endif 69 70 81 #if TIME_WITH_SYS_TIME 71 82 # include <sys/time.h> … … 85 96 #endif 86 97 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 89 105 #endif 90 106 … … 92 108 # include <unistd.h> 93 109 /* 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! */ 95 111 # if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS) 96 112 # define POSIX 1 … … 117 133 #ifndef HAVE_SA_RESTART 118 134 # define SA_RESTART 0 135 #endif 136 137 #ifdef HAVE_VFORK_H 138 # include <vfork.h> 119 139 #endif 120 140 … … 149 169 #endif 150 170 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) 153 178 154 179 /* The minimum and maximum values for the integer type T. … … 179 204 180 205 #ifdef VMS 206 # include <fcntl.h> 181 207 # include <types.h> 182 208 # include <unixlib.h> … … 185 211 /* Needed to use alloca on VMS. */ 186 212 # include <builtins.h> 213 214 extern int vms_use_mcr_command; 215 extern int vms_always_use_cmd_file; 216 extern int vms_gnv_shell; 217 extern int vms_comma_separator; 218 extern int vms_legacy_behavior; 219 extern int vms_unix_simulation; 187 220 #endif 188 221 … … 192 225 # define __attribute__(x) 193 226 # endif 194 /* The __-protected variants of `format' and `printf' attributes227 /* The __-protected variants of 'format' and 'printf' attributes 195 228 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ 196 229 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) … … 250 283 # include <inttypes.h> 251 284 #endif 285 #if HAVE_STDINT_H 286 # include <stdint.h> 287 #endif 252 288 #define FILE_TIMESTAMP uintmax_t 253 289 … … 263 299 POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that 264 300 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 the301 it's important to use the locale's definition of 'digit' even when the 266 302 host does not conform to POSIX. */ 267 303 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9) … … 306 342 #define S_(msg1,msg2,num) ngettext (msg1,msg2,num) 307 343 308 /* Handle other OSs. */309 #ifndef PATH_SEPARATOR_CHAR310 # if defined(HAVE_DOS_PATHS)311 # define PATH_SEPARATOR_CHAR ';'312 # elif defined(VMS)313 # define PATH_SEPARATOR_CHAR ','314 # else315 # define PATH_SEPARATOR_CHAR ':'316 # endif317 #endif318 319 344 /* This is needed for getcwd() and chdir(), on some W32 systems. */ 320 345 #if defined(HAVE_DIRECT_H) … … 327 352 # define pipe(_p) _pipe((_p), 512, O_BINARY) 328 353 # 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 329 362 330 363 void sync_Path_environment (void); 331 364 int w32_kill (pid_t pid, int sig); 332 char *end_of_token_w32 (const char *s, char stopchar);333 365 int find_and_set_default_shell (const char *token); 334 366 … … 338 370 /* is default_shell unixy? */ 339 371 extern 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 340 380 #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) 341 444 342 445 #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) … … 345 448 #ifdef SET_STACK_SIZE 346 449 # include <sys/resource.h> 347 struct rlimit stack_limit; 348 #endif 349 350 struct floc 450 extern 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. */ 474 typedef struct 351 475 { 352 476 const char *filenm; 353 477 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 371 481 const 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 482 void message (int prefix, size_t length, const char *fmt, ...) 483 __attribute__ ((__format__ (__printf__, 3, 4))); 484 void error (const floc *flocp, size_t length, const char *fmt, ...) 485 __attribute__ ((__format__ (__printf__, 3, 4))); 486 void 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")) 384 504 385 505 void die (int) __attribute__ ((noreturn)); 386 void log_working_directory (int);387 506 void pfatal_with_name (const char *) __attribute__ ((noreturn)); 388 507 void perror_with_name (const char *, const char *); 508 #define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s)) 389 509 void *xmalloc (unsigned int); 390 510 void *xcalloc (unsigned int); … … 401 521 char *find_percent (char *); 402 522 const char *find_percent_cached (const char **); 403 FILE *open_tmpfile (char **, const char *);404 523 405 524 #ifndef NO_ARCHIVES … … 410 529 411 530 typedef 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); 415 535 416 536 long int ar_scan (const char *archive, ar_member_func_t function, const void *arg); … … 426 546 void file_impossible (const char *); 427 547 const char *dir_name (const char *); 548 void print_dir_data_base (void); 549 void dir_setup_glob (glob_t *); 428 550 void hash_init_directories (void); 429 551 430 552 void define_default_variables (void); 553 void undefine_default_variables (void); 431 554 void set_default_suffixes (void); 432 555 void install_default_suffix_rules (void); … … 445 568 void child_access (void); 446 569 447 void close_stdout (void);448 449 570 char *strip_whitespace (const char **begpp, const char **endpp); 571 572 void show_goal_error (void); 450 573 451 574 /* String caching */ … … 454 577 int strcache_iscached (const char *str); 455 578 const 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 579 const char *strcache_add_len (const char *str, unsigned int len); 580 581 /* Guile support */ 582 int guile_gmake_setup (const floc *flocp); 583 584 /* Loadable object support. Sets to the strcached name of the loaded file. */ 585 typedef int (*load_func_t)(const floc *flocp); 586 int load_file (const floc *flocp, const char **filename, int noerror); 587 void unload_file (const char *name); 462 588 463 589 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION, … … 471 597 # endif 472 598 599 # ifdef HAVE_GETCWD 600 # if !defined(VMS) && !defined(__DECC) 601 char *getcwd (); 602 # endif 603 # else 604 char *getwd (); 605 # define getcwd(buf, len) getwd (buf) 606 # endif 607 473 608 #endif /* Not GNU C library or POSIX. */ 474 475 #ifdef HAVE_GETCWD476 # if !defined(VMS) && !defined(__DECC)477 char *getcwd ();478 # endif479 #else480 char *getwd ();481 # define getcwd(buf, len) getwd (buf)482 #endif483 609 484 610 #if !HAVE_STRCASECMP … … 504 630 #endif 505 631 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. */ 509 638 extern char **environ; 639 640 extern const floc *reading_file; 641 extern const floc **expanding_var; 642 643 extern unsigned short stopchar_map[]; 510 644 511 645 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag; … … 513 647 extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag; 514 648 extern 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; 649 extern int warn_undefined_variables_flag, trace_flag, posix_pedantic; 650 extern int not_parallel, second_expansion, clock_skew_detected; 651 extern int rebuilding_makefiles, one_shell, output_sync, verify_flag; 652 653 extern const char *default_shell; 518 654 519 655 /* can we run commands via 'sh -c xxx' or must we use batch files? */ … … 526 662 527 663 extern unsigned int job_slots; 528 extern int job_fds[2];529 extern int job_rfd;530 664 #ifndef NO_FLOAT 531 665 extern double max_load_average; … … 534 668 #endif 535 669 670 #ifdef WINDOWS32 536 671 extern char *program; 672 #else 673 extern const char *program; 674 #endif 675 676 #ifdef VMS 677 const char *vms_command (const char *argv0); 678 const char *vms_progname (const char *argv0); 679 680 void vms_exit (int); 681 # define _exit(foo) vms_exit(foo) 682 # define exit(foo) vms_exit(foo) 683 684 extern char *program_name; 685 686 void 687 set_program_name (const char *arv0); 688 689 int 690 need_vms_symbol (void); 691 692 int 693 create_foreign_command (const char *command, const char *image); 694 695 int 696 vms_export_dcl_symbol (const char *name, const char *value); 697 698 int 699 vms_putenv_symbol (const char *string); 700 701 void 702 vms_restore_symbol (const char *string); 703 704 #endif 705 706 void remote_setup (void); 707 void remote_cleanup (void); 708 int start_remote_job_p (int); 709 int start_remote_job (char **, char **, int, int *, int *, int *); 710 int remote_status (int *, int *, int *, int); 711 void block_remote_children (void); 712 void unblock_remote_children (void); 713 int remote_kill (int id, int sig); 714 void print_variable_data_base (void); 715 void print_vpath_data_base (void); 716 537 717 extern char *starting_directory; 538 718 extern unsigned int makelevel; … … 551 731 #endif 552 732 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 562 737 563 738 /* Set up heap debugging library dmalloc. */ -
vendor/gnumake/current/misc.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make.h" 17 #include "makeint.h" 18 #include "filedef.h" 20 19 #include "dep.h" 21 20 #include "debug.h" 22 21 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 54 31 55 32 /* Compare strings *S1 and *S2. … … 76 53 collapse_continuations (char *line) 77 54 { 78 register char *in, *out, *p; 79 register int backslash; 80 register unsigned int bs_write; 55 char *in, *out, *p; 81 56 82 57 in = strchr (line, '\n'); … … 91 66 { 92 67 /* BS_WRITE gets the number of quoted backslashes at 93 94 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; 97 72 for (p = in - 1; p >= line && *p == '\\'; --p) 98 99 100 101 102 103 104 105 106 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 } 108 83 109 84 /* Output the appropriate number of backslashes. */ 110 85 while (bs_write-- > 0) 111 86 *out++ = '\\'; 112 87 113 88 /* Skip the newline. */ 114 89 ++in; 115 90 116 /* If the newline is escaped, discard following whitespace leaving just117 one space. POSIX requires that each backslash/newline/following118 whitespace sequence be reduced to a single space. */119 91 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 } 127 105 else 128 129 106 /* If the newline isn't quoted, put it in the output. */ 107 *out++ = '\n'; 130 108 131 109 /* Now copy the following line to the output. 132 110 Stop when we find backslashes followed by a newline. */ 133 111 while (*in != '\0') 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 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++; 149 127 } 150 128 … … 168 146 169 147 const char * 170 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H171 148 concat (unsigned int num, ...) 172 #else173 concat (num, va_alist)174 unsigned int num;175 va_dcl176 #endif177 149 { 178 150 static unsigned int rlen = 0; 179 151 static char *result = NULL; 180 int ri = 0; 181 182 #if USE_VARIADIC 152 unsigned int ri = 0; 183 153 va_list args; 184 #endif 185 186 VA_START (args, num); 154 155 va_start (args, num); 187 156 188 157 while (num-- > 0) 189 158 { 190 159 const char *s = va_arg (args, const char *); 191 unsigned int l = s ? strlen (s) : 0;160 unsigned int l = xstrlen (s); 192 161 193 162 if (l == 0) … … 204 173 } 205 174 206 VA_END(args);175 va_end (args); 207 176 208 177 /* Get some more memory if we don't have enough space for the … … 220 189 221 190 222 /* Print a message on stdout. */223 224 void225 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H226 message (int prefix, const char *fmt, ...)227 #else228 message (prefix, fmt, va_alist)229 int prefix;230 const char *fmt;231 va_dcl232 #endif233 {234 #if USE_VARIADIC235 va_list args;236 #endif237 238 log_working_directory (1);239 240 if (fmt != 0)241 {242 if (prefix)243 {244 if (makelevel == 0)245 printf ("%s: ", program);246 else247 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 void261 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H262 error (const struct floc *flocp, const char *fmt, ...)263 #else264 error (flocp, fmt, va_alist)265 const struct floc *flocp;266 const char *fmt;267 va_dcl268 #endif269 {270 #if USE_VARIADIC271 va_list args;272 #endif273 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 else281 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 void294 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H295 fatal (const struct floc *flocp, const char *fmt, ...)296 #else297 fatal (flocp, fmt, va_alist)298 const struct floc *flocp;299 const char *fmt;300 va_dcl301 #endif302 {303 #if USE_VARIADIC304 va_list args;305 #endif306 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 else314 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 }324 191 325 192 #ifndef HAVE_STRERROR 326 327 #undef strerror 328 193 #undef strerror 329 194 char * 330 195 strerror (int errnum) … … 343 208 } 344 209 #endif 345 346 /* Print an error message from errno. */347 348 void349 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 void357 pfatal_with_name (const char *name)358 {359 fatal (NILF, _("%s: %s"), name, strerror (errno));360 361 /* NOTREACHED */362 }363 210 364 211 … … 379 226 void *result = malloc (size ? size : 1); 380 227 if (result == 0) 381 fatal (NILF, _("virtual memory exhausted"));228 OUT_OF_MEM(); 382 229 return result; 383 230 } … … 390 237 void *result = calloc (size ? size : 1, 1); 391 238 if (result == 0) 392 fatal (NILF, _("virtual memory exhausted"));239 OUT_OF_MEM(); 393 240 return result; 394 241 } … … 405 252 result = ptr ? realloc (ptr, size) : malloc (size); 406 253 if (result == 0) 407 fatal (NILF, _("virtual memory exhausted"));254 OUT_OF_MEM(); 408 255 return result; 409 256 } … … 422 269 423 270 if (result == 0) 424 fatal (NILF, _("virtual memory exhausted"));271 OUT_OF_MEM(); 425 272 426 273 #ifdef HAVE_STRDUP … … 441 288 result = strndup (str, length); 442 289 if (result == 0) 443 fatal (NILF, _("virtual memory exhausted"));290 OUT_OF_MEM(); 444 291 #else 445 292 result = xmalloc (length + 1); … … 476 323 end_of_token (const char *s) 477 324 { 478 while (*s != '\0' && !isblank ((unsigned char)*s)) 479 ++s; 325 END_OF_TOKEN (s); 480 326 return (char *)s; 481 327 } 482 483 #ifdef WINDOWS32484 /*485 * Same as end_of_token, but take into account a stop character486 */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 != stopchar494 && (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 else506 backslash = 0;507 }508 509 return (char *)p;510 }511 #endif512 328 513 329 /* Return the address of the first nonwhitespace or null in the string S. */ … … 516 332 next_token (const char *s) 517 333 { 518 while (isblank ((unsigned char)*s)) 519 ++s; 334 NEXT_TOKEN (s); 520 335 return (char *)s; 521 336 } … … 542 357 543 358 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. */ 545 360 546 361 struct dep * … … 560 375 c->next = 0; 561 376 if (firstnew == 0) 562 377 firstnew = lastnew = c; 563 378 else 564 379 lastnew = lastnew->next = c; 565 380 566 381 d = d->next; … … 568 383 569 384 return firstnew; 570 }571 572 /* Free a chain of 'struct dep'. */573 574 void575 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 }583 385 } 584 386 … … 593 395 struct nameseq *t = ns; 594 396 ns = ns->next; 595 free (t);397 free_ns (t); 596 398 } 597 399 } … … 600 402 601 403 #if !HAVE_STRCASECMP && !HAVE_STRICMP && !HAVE_STRCMPI 602 603 404 /* If we don't have strcasecmp() (from POSIX), or anything that can substitute 604 405 for it, define our own version. */ … … 626 427 627 428 #if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI 628 629 429 /* If we don't have strncasecmp() (from POSIX), or anything that can 630 430 substitute for it, define our own version. */ … … 654 454 655 455 656 #ifdef 456 #ifdef GETLOADAVG_PRIVILEGED 657 457 658 458 #ifdef POSIX … … 667 467 #undef HAVE_SETREGID 668 468 669 #else 469 #else /* Not POSIX. */ 670 470 671 471 /* Some POSIX.1 systems have the seteuid and setegid functions. In a … … 677 477 #undef HAVE_SETEGID 678 478 679 #endif 680 681 #ifndef 479 #endif /* POSIX. */ 480 481 #ifndef HAVE_UNISTD_H 682 482 extern int getuid (), getgid (), geteuid (), getegid (); 683 483 extern int setuid (), setgid (); … … 685 485 extern int seteuid (); 686 486 #else 687 #ifdef 487 #ifdef HAVE_SETREUID 688 488 extern int setreuid (); 689 #endif 690 #endif 489 #endif /* Have setreuid. */ 490 #endif /* Have seteuid. */ 691 491 #ifdef HAVE_SETEGID 692 492 extern int setegid (); 693 493 #else 694 #ifdef 494 #ifdef HAVE_SETREGID 695 495 extern int setregid (); 696 #endif 697 #endif 698 #endif 496 #endif /* Have setregid. */ 497 #endif /* Have setegid. */ 498 #endif /* No <unistd.h>. */ 699 499 700 500 /* Keep track of the user and group IDs for user- and make- access. */ 701 501 static 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) 703 503 static enum { make, user } current_access; 704 504 … … 717 517 718 518 fprintf (stderr, _("%s: user %lu (real %lu), group %lu (real %lu)\n"), 719 519 flavor, (unsigned long) geteuid (), (unsigned long) getuid (), 720 520 (unsigned long) getegid (), (unsigned long) getgid ()); 721 521 fflush (stderr); … … 743 543 } 744 544 745 #endif 545 #endif /* GETLOADAVG_PRIVILEGED */ 746 546 747 547 /* Give the process appropriate permissions for access to … … 750 550 user_access (void) 751 551 { 752 #ifdef 552 #ifdef GETLOADAVG_PRIVILEGED 753 553 754 554 if (!access_inited) … … 763 563 which are the IDs of the process that exec'd make. */ 764 564 765 #ifdef 565 #ifdef HAVE_SETEUID 766 566 767 567 /* Modern systems have the seteuid/setegid calls which set only the … … 771 571 pfatal_with_name ("user_access: seteuid"); 772 572 773 #else 774 775 #ifndef 573 #else /* Not HAVE_SETEUID. */ 574 575 #ifndef HAVE_SETREUID 776 576 777 577 /* System V has only the setuid/setgid calls to set user/group IDs. … … 786 586 pfatal_with_name ("user_access: setuid"); 787 587 788 #else 588 #else /* HAVE_SETREUID. */ 789 589 790 590 /* In 4BSD, the setreuid/setregid calls set both the real and effective IDs. … … 798 598 pfatal_with_name ("user_access: setreuid"); 799 599 800 #endif 801 #endif 802 803 #ifdef 600 #endif /* Not HAVE_SETREUID. */ 601 #endif /* HAVE_SETEUID. */ 602 603 #ifdef HAVE_SETEGID 804 604 if (setegid (user_gid) < 0) 805 605 pfatal_with_name ("user_access: setegid"); 806 606 #else 807 #ifndef 607 #ifndef HAVE_SETREGID 808 608 if (setgid (user_gid) < 0) 809 609 pfatal_with_name ("user_access: setgid"); … … 818 618 log_access (_("User access")); 819 619 820 #endif 620 #endif /* GETLOADAVG_PRIVILEGED */ 821 621 } 822 622 … … 826 626 make_access (void) 827 627 { 828 #ifdef 628 #ifdef GETLOADAVG_PRIVILEGED 829 629 830 630 if (!access_inited) … … 836 636 /* See comments in user_access, above. */ 837 637 838 #ifdef 638 #ifdef HAVE_SETEUID 839 639 if (seteuid (make_uid) < 0) 840 640 pfatal_with_name ("make_access: seteuid"); 841 641 #else 842 #ifndef 642 #ifndef HAVE_SETREUID 843 643 if (setuid (make_uid) < 0) 844 644 pfatal_with_name ("make_access: setuid"); … … 849 649 #endif 850 650 851 #ifdef 651 #ifdef HAVE_SETEGID 852 652 if (setegid (make_gid) < 0) 853 653 pfatal_with_name ("make_access: setegid"); 854 654 #else 855 #ifndef 655 #ifndef HAVE_SETREGID 856 656 if (setgid (make_gid) < 0) 857 657 pfatal_with_name ("make_access: setgid"); … … 866 666 log_access (_("Make access")); 867 667 868 #endif 668 #endif /* GETLOADAVG_PRIVILEGED */ 869 669 } 870 670 … … 874 674 child_access (void) 875 675 { 876 #ifdef 676 #ifdef GETLOADAVG_PRIVILEGED 877 677 878 678 if (!access_inited) … … 882 682 They cannot be changed back to make's. */ 883 683 884 #ifndef 684 #ifndef HAVE_SETREUID 885 685 if (setuid (user_uid) < 0) 886 686 pfatal_with_name ("child_access: setuid"); … … 890 690 #endif 891 691 892 #ifndef 692 #ifndef HAVE_SETREGID 893 693 if (setgid (user_gid) < 0) 894 694 pfatal_with_name ("child_access: setgid"); … … 900 700 log_access (_("Child access")); 901 701 902 #endif /* GETLOADAVG_PRIVILEGED */ 903 } 904 702 #endif /* GETLOADAVG_PRIVILEGED */ 703 } 905 704 906 705 #ifdef NEED_GET_PATH_MAX … … 914 713 long int x = pathconf ("/", _PC_PATH_MAX); 915 714 if (x > 0) 916 715 value = x; 917 716 else 918 717 return MAXPATHLEN; 919 718 } 920 719 … … 922 721 } 923 722 #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 can929 remove this (and perhaps other parts of GNU make!) and migrate to using930 gnulib directly.931 932 This is called only through atexit(), which means die() has already been933 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 close938 stdout and make sure that it succeeds before exiting. Otherwise,939 suppose that you go to the extreme of checking the return status940 of every function that does an explicit write to stdout. The last941 printf can succeed in writing to the internal stream buffer, and yet942 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 be944 left with an incomplete output file and the offending program would945 exit successfully. Even calling fflush is not always sufficient,946 since some file systems (NFS and CODA) buffer written/flushed data947 until an actual close call.948 949 Besides, it's wasteful to check the return value from every call950 that writes to stdout -- just let the internal stream state record951 the failure. That's what the ferror test is checking below.952 953 It's important to detect such failures and exit nonzero because many954 tools (most notably `make' and other build-management systems) depend955 on being able to detect failure in other tools via their exit status. */956 957 void958 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 else968 error (NILF, _("write error"));969 exit (EXIT_FAILURE);970 }971 } -
vendor/gnumake/current/po/LINGUAS
r2596 r3138 1 # Set of available languages: 2 4languages1 # Set of available languages: 25 languages 2 2 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_CN3 be 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 4 4 5 5 # Can't seem to get en@quot and en@boldquot to build properly? -
vendor/gnumake/current/po/Makevars
r2596 r3138 1 1 # 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. 4 3 # This file is part of GNU Make. 5 4 # -
vendor/gnumake/current/po/POTFILES.in
r2596 r3138 1 1 # 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. 4 3 # This file is part of GNU Make. 5 4 # … … 25 24 function.c 26 25 getopt.c 26 guile.c 27 27 hash.c 28 28 implicit.c 29 29 job.c 30 job.h 31 load.c 30 32 main.c 31 33 misc.c 34 output.c 35 posixos.c 32 36 read.c 33 37 remake.c … … 41 45 vmsjobs.c 42 46 vpath.c 47 w32/w32os.c -
vendor/gnumake/current/prepare_w32.bat
r1991 r3138 1 1 @echo off 2 @echo Windows32 CVSbuild preparation of config.h.W32 and NMakefile.2 @echo Windows32 SCM build preparation of config.h.W32 and NMakefile. 3 3 if not exist config.h.W32 copy config.h.W32.template config.h.W32 4 4 if not exist config.h copy config.h.W32 config.h -
vendor/gnumake/current/read.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 21 19 #include <assert.h> 22 20 23 #include <glob.h> 24 21 #include "filedef.h" 25 22 #include "dep.h" 26 #include "filedef.h"27 23 #include "job.h" 28 24 #include "commands.h" … … 33 29 34 30 35 #ifndef WINDOWS32 31 #ifdef WINDOWS32 32 #include <windows.h> 33 #include "sub_proc.h" 34 #else /* !WINDOWS32 */ 36 35 #ifndef _AMIGA 37 36 #ifndef VMS … … 54 53 unsigned int size; /* Malloc'd size of buffer. */ 55 54 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). */ 57 56 }; 58 57 … … 77 76 78 77 79 /* A `struct conditionals' contains the information describing78 /* A 'struct conditionals' contains the information describing 80 79 all the active conditionals in a makefile. 81 80 82 The global variable `conditionals' contains the conditionals81 The global variable 'conditionals' contains the conditionals 83 82 information for the current makefile. It is initialized from 84 the static structure `toplevel_conditionals' and is later changed83 the static structure 'toplevel_conditionals' and is later changed 85 84 to new structures for included makefiles. */ 86 85 87 86 struct conditionals 88 87 { 89 unsigned int if_cmds; 90 unsigned int allocated; 91 char *ignoring; 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? 92 91 0=interpreting, 1=not yet interpreted, 93 92 2=already interpreted */ 94 char *seen_else; /* Have we already seen an `else'? */93 char *seen_else; /* Have we already seen an 'else'? */ 95 94 }; 96 95 … … 128 127 makefile currently being read in. */ 129 128 130 const structfloc *reading_file = 0;131 132 /* The chain of makefiles read by read_makefile. */133 134 static struct dep *read_makefiles = 0;135 136 static inteval_makefile (const char *filename, int flags);129 const floc *reading_file = 0; 130 131 /* The chain of files read by read_all_makefiles. */ 132 133 static struct goaldep *read_files = 0; 134 135 static struct goaldep *eval_makefile (const char *filename, int flags); 137 136 static void eval (struct ebuffer *buffer, int flags); 138 137 … … 142 141 static struct variable *do_define (char *name, enum variable_origin origin, 143 142 struct ebuffer *ebuf); 144 static int conditional_line (char *line, int len, const structfloc *flocp);143 static int conditional_line (char *line, int len, const floc *flocp); 145 144 static void record_files (struct nameseq *filenames, const char *pattern, 146 145 const char *pattern_percent, char *depstr, 147 146 unsigned int cmds_started, char *commands, 148 147 unsigned int commands_idx, int two_colon, 149 c onst struct floc *flocp);148 char prefix, const floc *flocp); 150 149 static void record_target_var (struct nameseq *filenames, char *defn, 151 150 enum variable_origin origin, 152 151 struct vmodifiers *vmod, 153 const structfloc *flocp);152 const floc *flocp); 154 153 static enum make_word_type get_next_mword (char *buffer, char *delim, 155 154 char **startp, unsigned int *length); 156 155 static void remove_comments (char *line); 157 static char *find_char_unquote (char *string, int stop1, int stop2,158 int blank, int ignorevars);156 static char *find_char_unquote (char *string, int map); 157 static char *unescape_char (char *string, int c); 159 158 160 159 … … 162 161 P must point to the word to be tested, and WLEN must be the length. 163 162 */ 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 169 struct goaldep * 171 170 read_all_makefiles (const char **makefiles) 172 171 { … … 205 204 while ((name = find_next_token ((const char **)&p, &length)) != 0) 206 205 { 207 208 209 206 if (*p != '\0') 207 *p++ = '\0'; 208 eval_makefile (name, RM_NO_DEFAULT_GOAL|RM_INCLUDED|RM_DONTCARE); 210 209 } 211 210 … … 218 217 while (*makefiles != 0) 219 218 { 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; 235 228 } 236 229 … … 239 232 if (num_makefiles == 0) 240 233 { 241 static c har *default_makefiles[] =234 static const char *default_makefiles[] = 242 235 #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 }; 245 239 #else 246 240 #ifdef _AMIGA 247 241 { "GNUmakefile", "Makefile", "SMakefile", 0 }; 248 242 #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 */ 250 248 #endif /* AMIGA */ 251 249 #endif /* VMS */ 252 registerchar **p = default_makefiles;250 const char **p = default_makefiles; 253 251 while (*p != 0 && !file_exists_p (*p)) 254 252 ++p; 255 253 256 254 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 } 261 260 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; 289 287 } 290 288 … … 309 307 { 310 308 /* 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); 315 311 316 312 /* Restore state. */ … … 319 315 320 316 321 static int317 static struct goaldep * 322 318 eval_makefile (const char *filename, int flags) 323 319 { 324 struct dep *deps;320 struct goaldep *deps; 325 321 struct ebuffer ebuf; 326 const structfloc *curfile;322 const floc *curfile; 327 323 char *expanded = 0; 328 324 int makefile_errno; 329 325 330 filename = strcache_add (filename); 331 ebuf.floc.filenm = filename; 326 ebuf.floc.filenm = filename; /* Use the original file name. */ 332 327 ebuf.floc.lineno = 1; 328 ebuf.floc.offset = 0; 333 329 334 330 if (ISDB (DB_VERBOSE)) 335 331 { 336 printf (_("Reading makefile `%s'"), filename);332 printf (_("Reading makefile '%s'"), filename); 337 333 if (flags & RM_NO_DEFAULT_GOAL) 338 334 printf (_(" (no default goal)")); 339 335 if (flags & RM_INCLUDED) 340 336 printf (_(" (search path)")); 341 337 if (flags & RM_DONTCARE) 342 338 printf (_(" (don't care)")); 343 339 if (flags & RM_NO_TILDE) 344 340 printf (_(" (no ~ expansion)")); 345 341 puts ("..."); 346 342 } … … 348 344 /* First, get a stream to read. */ 349 345 350 /* Expand ~ in FILENAME unless it came from `include',346 /* Expand ~ in FILENAME unless it came from 'include', 351 347 in which case it was already done. */ 352 348 if (!(flags & RM_NO_TILDE) && filename[0] == '~') … … 354 350 expanded = tilde_expand (filename); 355 351 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 360 357 /* Save the error code so we print the right message later. */ 361 358 makefile_errno = errno; 362 359 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 363 376 /* 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, 365 378 search the included makefile search path for this makefile. */ 366 379 if (ebuf.fp == 0 && (flags & RM_INCLUDED) && *filename != '/') … … 368 381 unsigned int i; 369 382 for (i = 0; include_directories[i] != 0; ++i) 370 371 383 { 384 const char *included = concat (3, include_directories[i], 372 385 "/", 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); 381 398 382 399 /* 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; 386 403 deps->file = lookup_file (filename); 387 404 if (deps->file == 0) 388 405 deps->file = enter_file (filename); 389 406 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); 396 410 397 411 /* If the makefile can't be found at all, give up entirely. */ … … 400 414 { 401 415 /* If we did some searching, errno has the error from the last 402 attempt, rather from FILENAME itself. Restore it in case the403 416 attempt, rather from FILENAME itself. Store it in case the 417 caller wants to use it in a message. */ 404 418 errno = makefile_errno; 405 return 0;419 return deps; 406 420 } 407 421 … … 433 447 alloca (0); 434 448 435 return 1; 449 errno = 0; 450 return deps; 436 451 } 437 452 438 453 void 439 eval_buffer (char *buffer )454 eval_buffer (char *buffer, const floc *flocp) 440 455 { 441 456 struct ebuffer ebuf; 442 457 struct conditionals *saved; 443 458 struct conditionals new; 444 const structfloc *curfile;459 const floc *curfile; 445 460 446 461 /* Evaluate the buffer */ … … 450 465 ebuf.fp = NULL; 451 466 452 if (reading_file) 467 if (flocp) 468 ebuf.floc = *flocp; 469 else if (reading_file) 453 470 ebuf.floc = *reading_file; 454 471 else 455 ebuf.floc.filenm = NULL; 472 { 473 ebuf.floc.filenm = NULL; 474 ebuf.floc.lineno = 1; 475 ebuf.floc.offset = 0; 476 } 456 477 457 478 curfile = reading_file; … … 488 509 489 510 /* Find the start of the next token. If there isn't one we're done. */ 490 line = next_token(line);511 NEXT_TOKEN (line); 491 512 if (*line == '\0') 492 513 return (char *)line; … … 497 518 int wlen; 498 519 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); 502 523 503 524 /* If this is a variable assignment, we're done. */ … … 560 581 unsigned int cmds_started, tgts_started; 561 582 int ignoring = 0, in_ignored_define = 0; 562 int no_targets = 0; 583 int no_targets = 0; /* Set when reading a rule without targets. */ 563 584 struct nameseq *filenames = 0; 564 585 char *depstr = 0; 565 586 long nlines = 0; 566 587 int two_colon = 0; 588 char prefix = cmd_prefix; 567 589 const char *pattern = 0; 568 590 const char *pattern_percent; 569 structfloc *fstart;570 structfloc 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) \ 576 598 { \ 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, \ 579 602 cmds_started, commands, commands_idx, two_colon, \ 580 &fi);\581 filenames = 0; 603 prefix, &fi); \ 604 filenames = 0; \ 582 605 } \ 583 commands_idx = 0; 606 commands_idx = 0; \ 584 607 no_targets = 0; \ 585 608 pattern = 0; \ … … 598 621 599 622 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. */ 603 625 604 626 commands = xmalloc (200); … … 622 644 break; 623 645 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 624 663 /* If this line is empty, skip it. */ 625 line = ebuf->buffer;626 664 if (line[0] == '\0') 627 665 continue; … … 630 668 631 669 /* Check for a shell command line first. 632 If it is not one, we can stop treating tabspecially. */670 If it is not one, we can stop treating cmd_prefix specially. */ 633 671 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) 662 693 { 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); 671 696 } 672 *p = '\n';673 ++commands_idx;674 675 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 } 678 703 679 704 /* This line is not a shell command line. Don't worry about whitespace. … … 682 707 683 708 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); 688 712 /* Don't need xrealloc: we don't need to preserve the content. */ 689 690 713 collapsed = xmalloc (collapsed_length); 714 } 691 715 strcpy (collapsed, line); 692 716 /* Collapse continuation lines. */ … … 696 720 /* Get rid if starting space (including formfeed, vtab, etc.) */ 697 721 p = collapsed; 698 while (isspace ((unsigned char)*p)) 699 ++p; 722 NEXT_TOKEN (p); 700 723 701 724 /* See if this is a variable assignment. We need to do this early, to 702 725 allow variables with names like 'ifdef', 'export', 'private', etc. */ 703 p = parse_var_assignment (p, &vmod);726 p = parse_var_assignment (p, &vmod); 704 727 if (vmod.assign_v) 705 728 { … … 708 731 709 732 /* If we're ignoring then we're done now. */ 710 733 if (ignoring) 711 734 { 712 735 if (vmod.define_v) … … 715 738 } 716 739 740 /* Variable assignment ends the previous rule. */ 741 record_waiting_files (); 742 717 743 if (vmod.undefine_v) 718 744 { 719 745 do_undefine (p, origin, ebuf); 720 721 /* This line has been dealt with. */ 722 goto rule_complete; 746 continue; 723 747 } 724 748 else if (vmod.define_v) … … 735 759 736 760 /* This line has been dealt with. */ 737 goto rule_complete;761 continue; 738 762 } 739 763 740 764 /* If this line is completely empty, ignore it. */ 741 765 if (*p == '\0') 742 766 continue; 743 767 744 768 p2 = end_of_token (p); 745 769 wlen = p2 - p; 746 p2 = next_token(p2);770 NEXT_TOKEN (p2); 747 771 748 772 /* If we're in an ignored define, skip this line (but maybe get out). */ 749 773 if (in_ignored_define) 750 774 { 751 775 /* 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)) 753 777 in_ignored_define = 0; 754 778 755 756 779 continue; 780 } 757 781 758 782 /* Check for conditional state changes. */ … … 762 786 { 763 787 if (i == -1) 764 fatal (fstart, _("invalid syntax in conditional"));788 O (fatal, fstart, _("invalid syntax in conditional")); 765 789 766 790 ignoring = i; … … 771 795 /* Nothing to see here... move along. */ 772 796 if (ignoring) 773 797 continue; 774 798 775 799 /* Manage the "export" keyword used outside of variable assignment 776 800 as well as "unexport". */ 777 801 if (word1eq ("export") || word1eq ("unexport")) 778 802 { 779 803 int exporting = *p == 'u' ? 0 : 1; 780 804 805 /* Export/unexport ends the previous rule. */ 806 record_waiting_files (); 807 781 808 /* (un)export by itself causes everything to be (un)exported. */ 782 809 if (*p2 == '\0') 783 810 export_all_variables = exporting; 784 811 else … … 797 824 struct variable *v = lookup_variable (p, l); 798 825 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); 800 827 v->export = exporting ? v_export : v_noexport; 801 828 } … … 803 830 free (ap); 804 831 } 805 goto rule_complete;806 832 continue; 833 } 807 834 808 835 /* Handle the special syntax for vpath. */ 809 836 if (word1eq ("vpath")) 810 837 { 811 838 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 } 832 862 833 863 /* Handle include and variants. */ 834 864 if (word1eq ("include") || word1eq ("-include") || word1eq ("sinclude")) 835 836 /* We have found an `include' line specifying a nested837 838 865 { 866 /* We have found an 'include' line specifying a nested 867 makefile to be read at this point. */ 868 struct conditionals *save; 839 869 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); 846 879 847 880 /* If no filenames, it's a no-op. */ 848 881 if (*p == '\0') 849 882 { 850 883 free (p); … … 852 885 } 853 886 854 855 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, 857 890 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; 873 959 int r; 874 960 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 } 891 985 892 986 /* This line starts with a tab but was not caught above because there … … 894 988 variable definition. But now we know it is definitely lossage. */ 895 989 if (line[0] == cmd_prefix) 896 fatal(fstart, _("recipe commences before first target"));990 O (fatal, fstart, _("recipe commences before first target")); 897 991 898 992 /* This line describes some target files. This is complicated by 899 993 the existence of target-specific variables, because we can't 900 994 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 ':', 902 996 then check to see if it's a target-specific variable. 903 997 904 In this algorithm, `lb_next' will point to the beginning of the905 unexpanded parts of the input buffer, while `p2' points to the998 In this algorithm, 'lb_next' will point to the beginning of the 999 unexpanded parts of the input buffer, while 'p2' points to the 906 1000 parts of the expanded buffer we haven't searched yet. */ 907 1001 … … 920 1014 /* Search the line for an unquoted ; that is not after an 921 1015 unquoted #. */ 922 cmdleft = find_char_unquote (line, ';', '#', 0, 1);1016 cmdleft = find_char_unquote (line, MAP_SEMI|MAP_COMMENT|MAP_VARIABLE); 923 1017 if (cmdleft != 0 && *cmdleft == '#') 924 1018 { … … 938 1032 beginning, expanding as we go, and looking for "interesting" 939 1033 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); 941 1035 switch (wtype) 942 1036 { 943 1037 case w_eol: 944 1038 if (cmdleft != 0) 945 fatal(fstart, _("missing rule before recipe"));1039 O (fatal, fstart, _("missing rule before recipe")); 946 1040 /* This line contained something but turned out to be nothing 947 1041 but whitespace (a comment?). */ … … 959 1053 } 960 1054 961 p2 = variable_expand_string (NULL, lb_next, wlen);1055 p2 = variable_expand_string (NULL, lb_next, wlen); 962 1056 963 1057 while (1) … … 967 1061 { 968 1062 /* 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); 970 1064 971 1065 if (cmdleft != 0) … … 973 1067 unsigned long p2_off = p2 - variable_buffer; 974 1068 unsigned long cmd_off = cmdleft - variable_buffer; 975 char *pend = p2 + strlen (p2);1069 char *pend = p2 + strlen (p2); 976 1070 977 1071 /* Append any remnants of lb, then cut the line short … … 983 1077 and into a command script. However, the old parser 984 1078 expanded the whole line, so we continue that for 985 backwards-compatib lity. Also, it wouldn't be1079 backwards-compatibility. Also, it wouldn't be 986 1080 entirely consistent, since we do an unconditional 987 1081 expand below once we know we don't have a 988 1082 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); 991 1085 p2 = variable_buffer + p2_off; 992 1086 cmdleft = variable_buffer + cmd_off + 1; … … 994 1088 } 995 1089 996 colonp = find_char_unquote (p2, ':', 0, 0, 0);1090 colonp = find_char_unquote (p2, MAP_COLON); 997 1091 #ifdef HAVE_DOS_PATHS 998 1092 /* The drive spec brain-damage strikes again... */ … … 1003 1097 colonp > p2 && isalpha ((unsigned char)colonp[-1]) && 1004 1098 (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); 1006 1100 #endif 1007 1101 if (colonp != 0) 1008 1102 break; 1009 1103 1010 wtype = get_next_mword (lb_next, NULL, &lb_next, &wlen);1104 wtype = get_next_mword (lb_next, NULL, &lb_next, &wlen); 1011 1105 if (wtype == w_eol) 1012 1106 break; 1013 1107 1014 p2 += strlen (p2);1108 p2 += strlen (p2); 1015 1109 *(p2++) = ' '; 1016 p2 = variable_expand_string (p2, lb_next, wlen);1110 p2 = variable_expand_string (p2, lb_next, wlen); 1017 1111 /* We don't need to worry about cmdleft here, because if it was 1018 1112 found in the variable_buffer the entire buffer has already … … 1027 1121 if (wtype == w_eol) 1028 1122 { 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")); 1036 1132 } 1037 1133 1038 1134 /* 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. */ 1040 1136 *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; 1043 1140 1044 1141 if (!filenames) … … 1077 1174 if (semip) 1078 1175 { 1079 unsigned int l = p - variable_buffer;1176 unsigned int l = p2 - variable_buffer; 1080 1177 *(--semip) = ';'; 1081 1178 collapse_continuations (semip); 1082 1179 variable_buffer_output (p2 + strlen (p2), 1083 1180 semip, strlen (semip)+1); 1084 p = variable_buffer + l;1181 p2 = variable_buffer + l; 1085 1182 } 1086 1183 record_target_var (filenames, p2, … … 1093 1190 /* This is a normal target, _not_ a target-specific variable. 1094 1191 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; 1096 1196 1097 1197 /* We have some targets, so don't ignore the following commands. */ … … 1108 1208 if (cmdleft == 0) 1109 1209 { 1110 cmdleft = find_char_unquote (p2, ';', 0, 0, 0);1210 cmdleft = find_char_unquote (p2, MAP_SEMI); 1111 1211 if (cmdleft != 0) 1112 1212 *(cmdleft++) = '\0'; … … 1114 1214 } 1115 1215 1116 /* Is this a static pattern rule: `target: %targ: %dep; ...'? */1216 /* Is this a static pattern rule: 'target: %targ: %dep; ...'? */ 1117 1217 p = strchr (p2, ':'); 1118 1218 while (p != 0 && p[-1] == '\\') … … 1140 1240 OR a space around the :. 1141 1241 */ 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]))) 1144 1243 p = 0; 1145 1244 #endif … … 1162 1261 { 1163 1262 struct nameseq *target; 1164 target = PARSE_FILE_SEQ (&p2, struct nameseq, ':', NULL,1263 target = PARSE_FILE_SEQ (&p2, struct nameseq, MAP_COLON, NULL, 1165 1264 PARSEFS_NOGLOB); 1166 1265 ++p2; 1167 1266 if (target == 0) 1168 fatal (fstart, _("missing target pattern"));1267 O (fatal, fstart, _("missing target pattern")); 1169 1268 else if (target->next != 0) 1170 fatal (fstart, _("multiple target patterns"));1269 O (fatal, fstart, _("multiple target patterns")); 1171 1270 pattern_percent = find_percent_cached (&target->name); 1172 1271 pattern = target->name; 1173 1272 if (pattern_percent == 0) 1174 fatal (fstart, _("target pattern contains no `%%'"));1273 O (fatal, fstart, _("target pattern contains no '%%'")); 1175 1274 free_ns (target); 1176 1275 } … … 1225 1324 if (set_default && default_goal_var->value[0] == '\0') 1226 1325 { 1227 const char *name;1228 1326 struct dep *d; 1229 1327 struct nameseq *t = filenames; … … 1232 1330 { 1233 1331 int reject = 0; 1234 name = t->name;1332 const char *name = t->name; 1235 1333 1236 1334 /* We have nothing to do if this is an implicit rule. */ … … 1238 1336 break; 1239 1337 1240 /* See if this target's name does not start with a `.',1338 /* See if this target's name does not start with a '.', 1241 1339 unless it contains a slash. */ 1242 1340 if (*name == '.' && strchr (name, '/') == 0 … … 1287 1385 1288 1386 /* 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. */ 1292 1389 record_waiting_files (); 1293 1390 } 1294 1391 1295 #undef 1392 #undef word1eq 1296 1393 1297 1394 if (conditionals->if_cmds) 1298 fatal (fstart, _("missing `endif'"));1395 O (fatal, fstart, _("missing 'endif'")); 1299 1396 1300 1397 /* At eof, record the last rule. */ 1301 1398 record_waiting_files (); 1302 1399 1303 if (collapsed) 1304 free (collapsed); 1400 free (collapsed); 1305 1401 free (commands); 1306 1402 } … … 1316 1412 char *comment; 1317 1413 1318 comment = find_char_unquote (line, '#', 0, 0, 0);1414 comment = find_char_unquote (line, MAP_COMMENT); 1319 1415 1320 1416 if (comment != 0) … … 1323 1419 } 1324 1420 1325 /* Execute a `undefine' directive.1421 /* Execute a 'undefine' directive. 1326 1422 The undefine line has already been read, and NAME is the name of 1327 1423 the variable to be undefined. */ … … 1336 1432 name = next_token (var); 1337 1433 if (*name == '\0') 1338 fatal (&ebuf->floc, _("empty variable name"));1434 O (fatal, &ebuf->floc, _("empty variable name")); 1339 1435 p = name + strlen (name) - 1; 1340 while (p > name && isblank ((unsigned char)*p))1436 while (p > name && ISBLANK (*p)) 1341 1437 --p; 1342 1438 p[1] = '\0'; … … 1346 1442 } 1347 1443 1348 /* Execute a `define' directive.1444 /* Execute a 'define' directive. 1349 1445 The first line has already been read, and NAME is the name of 1350 1446 the variable to be defined. The following lines remain to be read. */ … … 1354 1450 { 1355 1451 struct variable *v; 1356 enum variable_flavor flavor;1357 structfloc defstart;1452 struct variable var; 1453 floc defstart; 1358 1454 int nlevels = 1; 1359 1455 unsigned int length = 100; 1360 1456 char *definition = xmalloc (length); 1361 1457 unsigned int idx = 0; 1362 char *p, * var;1458 char *p, *n; 1363 1459 1364 1460 defstart = ebuf->floc; 1365 1461 1366 p = parse_variable_definition (name, & flavor);1462 p = parse_variable_definition (name, &var); 1367 1463 if (p == NULL) 1368 1464 /* No assignment token, so assume recursive. */ 1369 flavor = f_recursive;1465 var.flavor = f_recursive; 1370 1466 else 1371 1467 { 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")); 1374 1470 1375 1471 /* 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'; 1377 1473 } 1378 1474 1379 1475 /* 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")); 1384 1480 p = name + strlen (name) - 1; 1385 while (p > name && isblank ((unsigned char)*p))1481 while (p > name && ISBLANK (*p)) 1386 1482 --p; 1387 1483 p[1] = '\0'; … … 1396 1492 /* If there is nothing left to be eval'd, there's no 'endef'!! */ 1397 1493 if (nlines < 0) 1398 fatal (&defstart, _("missing `endef', unterminated `define'"));1494 O (fatal, &defstart, _("missing 'endef', unterminated 'define'")); 1399 1495 1400 1496 ebuf->floc.lineno += nlines; … … 1411 1507 1412 1508 /* 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]))) 1414 1510 && strneq (p, "define", 6)) 1415 1511 ++nlevels; … … 1417 1513 /* If this is an 'endef', decrement the count. If it's now 0, 1418 1514 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]))) 1420 1516 && strneq (p, "endef", 5)) 1421 1517 { … … 1423 1519 remove_comments (p); 1424 1520 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")); 1427 1523 1428 1524 if (--nlevels == 0) … … 1451 1547 definition[idx - 1] = '\0'; 1452 1548 1453 v = do_variable_definition (&defstart, name, definition, origin, flavor, 0); 1549 v = do_variable_definition (&defstart, name, 1550 definition, origin, var.flavor, 0); 1454 1551 free (definition); 1455 free ( var);1552 free (n); 1456 1553 return (v); 1457 1554 } … … 1471 1568 1472 1569 static int 1473 conditional_line (char *line, int len, const structfloc *flocp)1570 conditional_line (char *line, int len, const floc *flocp) 1474 1571 { 1475 c har *cmdname;1572 const char *cmdname; 1476 1573 enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype; 1477 1574 unsigned int i; … … 1479 1576 1480 1577 /* Compare a word, both length and contents. */ 1481 #define word1eq(s) (len == sizeof(s)-1 && strneq (s, line, sizeof(s)-1))1482 #define 1578 #define word1eq(s) (len == CSTRLEN (s) && strneq (s, line, CSTRLEN (s))) 1579 #define chkword(s, t) if (word1eq (s)) { cmdtype = (t); cmdname = (s); } 1483 1580 1484 1581 /* Make sure this line is a conditional. */ … … 1493 1590 1494 1591 /* 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) 1498 1597 1499 1598 /* An 'endif' cannot contain extra text, and reduces the if-depth by 1 */ … … 1501 1600 { 1502 1601 if (*line != '\0') 1503 EXTRANEOUS();1602 EXTRATEXT (); 1504 1603 1505 1604 if (!conditionals->if_cmds) 1506 fatal (flocp, _("extraneous `%s'"), cmdname);1605 EXTRACMD (); 1507 1606 1508 1607 --conditionals->if_cmds; … … 1518 1617 1519 1618 if (!conditionals->if_cmds) 1520 fatal (flocp, _("extraneous `%s'"), cmdname);1619 EXTRACMD (); 1521 1620 1522 1621 o = conditionals->if_cmds - 1; 1523 1622 1524 1623 if (conditionals->seen_else[o]) 1525 fatal (flocp, _("only one `else' per conditional"));1624 O (fatal, flocp, _("only one 'else' per conditional")); 1526 1625 1527 1626 /* Change the state of ignorance. */ … … 1549 1648 1550 1649 /* 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) 1552 1651 ; 1553 1652 len = p - line; 1554 1653 1555 1654 /* If it's 'else' or 'endif' or an illegal conditional, fail. */ 1556 if (word1eq ("else") || word1eq("endif")1655 if (word1eq ("else") || word1eq ("endif") 1557 1656 || conditional_line (line, len, flocp) < 0) 1558 EXTRANEOUS();1657 EXTRATEXT (); 1559 1658 else 1560 1659 { … … 1586 1685 } 1587 1686 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. */ 1589 1688 conditionals->seen_else[o] = 0; 1590 1689 … … 1593 1692 if (conditionals->ignoring[i]) 1594 1693 { 1595 1596 1597 1598 1599 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; 1600 1699 } 1601 1700 … … 1613 1712 p = end_of_token (var); 1614 1713 i = p - var; 1615 p = next_token(p);1714 NEXT_TOKEN (p); 1616 1715 if (*p != '\0') 1617 1716 return -1; 1618 1717 1619 1718 var[i] = '\0'; … … 1633 1732 1634 1733 if (termin != ',' && termin != '"' && termin != '\'') 1635 1734 return -1; 1636 1735 1637 1736 s1 = ++line; 1638 1737 /* Find the end of the first string. */ 1639 1738 if (termin == ',') 1640 1641 1642 1643 1644 1645 1646 1647 1648 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 } 1650 1749 else 1651 1652 1750 while (*line != '\0' && *line != termin) 1751 ++line; 1653 1752 1654 1753 if (*line == '\0') 1655 1754 return -1; 1656 1755 1657 1756 if (termin == ',') 1658 1659 1660 1661 while (isblank ((unsigned char)p[-1]))1662 1663 1664 1757 { 1758 /* Strip blanks after the first string. */ 1759 char *p = line++; 1760 while (ISBLANK (p[-1])) 1761 --p; 1762 *p = '\0'; 1763 } 1665 1764 else 1666 1765 *line++ = '\0'; 1667 1766 1668 1767 s2 = variable_expand (s1); 1669 1768 /* We must allocate a new copy of the expanded string because 1670 1769 variable_expand re-uses the same buffer. */ 1671 1770 l = strlen (s2); 1672 1771 s1 = alloca (l + 1); … … 1674 1773 1675 1774 if (termin != ',') 1676 1677 line = next_token(line);1775 /* Find the start of the second string. */ 1776 NEXT_TOKEN (line); 1678 1777 1679 1778 termin = termin == ',' ? ')' : *line; 1680 1779 if (termin != ')' && termin != '"' && termin != '\'') 1681 1780 return -1; 1682 1781 1683 1782 /* Find the end of the second string. */ 1684 1783 if (termin == ')') 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 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 } 1701 1800 else 1702 1703 1704 1705 1706 1707 1801 { 1802 ++line; 1803 s2 = line; 1804 while (*line != '\0' && *line != termin) 1805 ++line; 1806 } 1708 1807 1709 1808 if (*line == '\0') 1710 1711 1712 * line= '\0';1713 line = next_token (++line);1809 return -1; 1810 1811 *(line++) = '\0'; 1812 NEXT_TOKEN (line); 1714 1813 if (*line != '\0') 1715 EXTRANEOUS();1814 EXTRATEXT (); 1716 1815 1717 1816 s2 = variable_expand (s2); … … 1741 1840 record_target_var (struct nameseq *filenames, char *defn, 1742 1841 enum variable_origin origin, struct vmodifiers *vmod, 1743 const structfloc *flocp)1842 const floc *flocp) 1744 1843 { 1745 1844 struct nameseq *nextf; … … 1755 1854 struct variable *v; 1756 1855 const char *name = filenames->name; 1757 const char *fname;1758 1856 const char *percent; 1759 1857 struct pattern_var *p; … … 1780 1878 else 1781 1879 v->value = xstrdup (v->value); 1782 1783 fname = p->target;1784 1880 } 1785 1881 else … … 1798 1894 1799 1895 initialize_file_variables (f, 1); 1800 fname = f->name;1801 1896 1802 1897 current_variable_set_list = f->variables; 1803 1898 v = try_variable_definition (flocp, defn, origin, 1); 1804 1899 if (!v) 1805 fatal (flocp, _("Malformed target-specific variable definition"));1900 O (fatal, flocp, _("Malformed target-specific variable definition")); 1806 1901 current_variable_set_list = global; 1807 1902 } … … 1817 1912 { 1818 1913 struct variable *gv; 1819 int len = strlen (v->name);1914 int len = strlen (v->name); 1820 1915 1821 1916 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)) 1823 1919 { 1824 if (v->value != 0) 1825 free (v->value); 1920 free (v->value); 1826 1921 v->value = xstrdup (gv->value); 1827 1922 v->origin = gv->origin; … … 1838 1933 by COMMANDS and COMMANDS_IDX, coming from FILENAME:COMMANDS_STARTED. 1839 1934 TWO_COLON is nonzero if a double colon was used. 1840 If not nil, PATTERN is the `%' pattern to make this1935 If not nil, PATTERN is the '%' pattern to make this 1841 1936 a static pattern rule, and PATTERN_PERCENT is a pointer 1842 to the `%' within it.1937 to the '%' within it. 1843 1938 1844 1939 The links of FILENAMES are freed, and so are any names in it … … 1850 1945 unsigned int cmds_started, char *commands, 1851 1946 unsigned int commands_idx, int two_colon, 1852 c onst struct floc *flocp)1947 char prefix, const floc *flocp) 1853 1948 { 1854 1949 struct commands *cmds; … … 1862 1957 See Savannah bug # 12124. */ 1863 1958 if (snapped_deps) 1864 fatal (flocp, _("prerequisites cannot be defined in recipes"));1959 O (fatal, flocp, _("prerequisites cannot be defined in recipes")); 1865 1960 1866 1961 /* Determine if this is a pattern rule or not. */ … … 1874 1969 cmds->fileinfo.filenm = flocp->filenm; 1875 1970 cmds->fileinfo.lineno = cmds_started; 1971 cmds->fileinfo.offset = 0; 1876 1972 cmds->commands = xstrndup (commands, commands_idx); 1877 1973 cmds->command_lines = 0; 1974 cmds->recipe_prefix = prefix; 1878 1975 } 1879 1976 else … … 1884 1981 if (depstr == 0) 1885 1982 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 }1893 1983 else 1894 1984 { 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 } 1904 2005 } 1905 2006 … … 1915 2016 1916 2017 if (pattern != 0) 1917 fatal (flocp, _("mixed implicit and static pattern rules"));2018 O (fatal, flocp, _("mixed implicit and static pattern rules")); 1918 2019 1919 2020 /* Count the targets to create an array of target names. … … 1938 2039 1939 2040 if (implicit_percent == 0) 1940 fatal (flocp, _("mixed implicit and normal rules"));1941 1942 1943 2041 O (fatal, flocp, _("mixed implicit and normal rules")); 2042 2043 targets[c] = name; 2044 target_pats[c] = implicit_percent; 1944 2045 ++c; 1945 2046 … … 1971 2072 posix_pedantic = 1; 1972 2073 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); 1973 2081 } 1974 2082 else if (streq (name, ".SECONDEXPANSION")) 1975 2083 second_expansion = 1; 1976 #if !defined (WINDOWS32) && !defined(__MSDOS__) && !defined (__EMX__)2084 #if !defined (__MSDOS__) && !defined (__EMX__) 1977 2085 else if (streq (name, ".ONESHELL")) 1978 2086 one_shell = 1; … … 1980 2088 1981 2089 /* If this is a static pattern rule: 1982 `targets: target%pattern: prereq%pattern; recipe',2090 'targets: target%pattern: prereq%pattern; recipe', 1983 2091 make sure the pattern matches this target name. */ 1984 2092 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); 1986 2095 else if (deps) 1987 2096 /* If there are multiple targets, copy the chain DEPS for all but the … … 1992 2101 /* Find or create an entry in the file database for this target. */ 1993 2102 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'"), 2016 2126 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'"), 2019 2129 f->name); 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 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 { 2032 2142 free_dep_chain (f->deps); 2033 2034 2035 2143 f->deps = 0; 2144 } 2145 } 2036 2146 else 2037 2038 2039 2040 2041 2042 2043 2044 fatal (flocp,2045 _("target file `%s' has both : and :: entries"), f->name);2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 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 } 2059 2169 2060 2170 f->is_target = 1; 2061 2171 2062 2172 /* 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 the2173 name that matched the '%' in the pattern, so you can use $* in the 2064 2174 commands. If we didn't do it before, enter the prereqs now. */ 2065 2175 if (pattern) … … 2119 2229 name = filenames->name; 2120 2230 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")); 2122 2233 } 2123 2234 } … … 2134 2245 2135 2246 static char * 2136 find_char_unquote (char *string, int stop1, int stop2, int blank, 2137 int ignorevars) 2247 find_char_unquote (char *string, int map) 2138 2248 { 2139 2249 unsigned int string_len = 0; 2140 2250 char *p = string; 2141 2251 2142 if (ignorevars)2143 ignorevars = '$';2252 /* Always stop on NUL. */ 2253 map |= MAP_NUL; 2144 2254 2145 2255 while (1) 2146 2256 { 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; 2161 2259 2162 2260 if (*p == '\0') 2163 2261 break; 2164 2262 2165 2263 /* If we stopped due to a variable reference, skip over its contents. */ 2166 if ( *p == ignorevars)2264 if (STOP_SET (*p, MAP_VARIABLE)) 2167 2265 { 2168 2266 char openparen = p[1]; 2267 2268 /* Check if '$' is the last character in the string. */ 2269 if (openparen == '\0') 2270 break; 2169 2271 2170 2272 p += 2; … … 2195 2297 2196 2298 if (p > string && p[-1] == '\\') 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 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 } 2217 2319 else 2218 2219 2320 /* No backslash in sight. */ 2321 return p; 2220 2322 } 2221 2323 … … 2224 2326 } 2225 2327 2328 /* Unescape a character in a string. The string is compressed onto itself. */ 2329 2330 static char * 2331 unescape_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 2226 2376 /* Search PATTERN for an unquoted % and handle quoting. */ 2227 2377 … … 2229 2379 find_percent (char *pattern) 2230 2380 { 2231 return find_char_unquote (pattern, '%', 0, 0, 0);2381 return find_char_unquote (pattern, MAP_PERCENT); 2232 2382 } 2233 2383 … … 2252 2402 while (1) 2253 2403 { 2254 while ( *p != '\0' && *p != '%')2404 while (! STOP_SET (*p, MAP_PERCENT|MAP_NUL)) 2255 2405 ++p; 2256 2406 … … 2322 2472 */ 2323 2473 2324 static unsignedlong2474 static long 2325 2475 readstring (struct ebuffer *ebuf) 2326 2476 { … … 2394 2544 len = strlen (p); 2395 2545 if (len == 0) 2396 2397 2398 2399 2400 2401 2402 error (&ebuf->floc,2403 2404 2405 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 } 2407 2557 2408 2558 /* Jump past the text we just read. */ … … 2423 2573 { 2424 2574 --p; 2425 p[-1] = '\n';2575 memmove (p-1, p, strlen (p) + 1); 2426 2576 } 2427 2577 #endif … … 2429 2579 backslash = 0; 2430 2580 for (p2 = p - 2; p2 >= start; --p2) 2431 2432 2433 2581 { 2582 if (*p2 != '\\') 2583 break; 2434 2584 backslash = !backslash; 2435 2585 } 2436 2586 2437 2587 if (!backslash) 2438 2439 2440 2441 2588 { 2589 p[-1] = '\0'; 2590 break; 2591 } 2442 2592 2443 2593 /* It was a backslash/newline combo. If we have more space, read … … 2483 2633 w_dcolon A double-colon 2484 2634 w_semicolon A semicolon 2485 w_varassign A variable assignment operator (=, :=, +=, or ?=)2635 w_varassign A variable assignment operator (=, :=, ::=, +=, ?=, or !=) 2486 2636 2487 2637 Note that this function is only used when reading certain parts of the … … 2497 2647 2498 2648 /* Skip any leading whitespace. */ 2499 while ( isblank ((unsigned char)*p))2649 while (ISBLANK (*p)) 2500 2650 ++p; 2501 2651 … … 2522 2672 case ':': 2523 2673 ++p; 2524 wtype = w_dcolon; 2674 if (p[1] != '=') 2675 wtype = w_dcolon; 2676 else 2677 { 2678 wtype = w_varassign; 2679 ++p; 2680 } 2525 2681 break; 2526 2682 … … 2534 2690 case '+': 2535 2691 case '?': 2692 case '!': 2536 2693 if (*p == '=') 2537 2694 { … … 2553 2710 /* This is some non-operator word. A word consists of the longest 2554 2711 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. */ 2556 2713 2557 2714 /* We start out assuming a static word; if we see a variable we'll … … 2575 2732 case ':': 2576 2733 #ifdef HAVE_DOS_PATHS 2577 2578 2579 2580 2581 2582 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] == '('))) 2583 2740 #endif 2584 2741 goto done_word; 2585 2742 2586 2743 case '$': … … 2588 2745 if (c == '$') 2589 2746 break; 2747 if (c == '\0') 2748 goto done_word; 2590 2749 2591 2750 /* This is a variable reference, so note that it's expandable. … … 2657 2816 construct_include_path (const char **arg_dirs) 2658 2817 { 2659 #ifdef VAXC 2818 #ifdef VAXC /* just don't ask ... */ 2660 2819 stat_t stbuf; 2661 2820 #else … … 2688 2847 while (*arg_dirs != 0) 2689 2848 { 2690 2849 const char *dir = *(arg_dirs++); 2691 2850 char *expanded = 0; 2692 2851 int e; 2693 2852 2694 2695 2696 2697 2698 2699 2853 if (dir[0] == '~') 2854 { 2855 expanded = tilde_expand (dir); 2856 if (expanded != 0) 2857 dir = expanded; 2858 } 2700 2859 2701 2860 EINTRLOOP (e, stat (dir, &stbuf)); 2702 2861 if (e == 0 && S_ISDIR (stbuf.st_mode)) 2703 2862 { 2704 2863 unsigned int len = strlen (dir); … … 2711 2870 } 2712 2871 2713 if (expanded) 2714 free (expanded); 2872 free (expanded); 2715 2873 } 2716 2874 … … 2726 2884 { 2727 2885 unsigned int len = strlen (djdir->value) + 8; 2728 2729 2730 2731 2886 char *defdir = alloca (len + 1); 2887 2888 strcat (strcpy (defdir, djdir->value), "/include"); 2889 dirs[idx++] = strcache_add (defdir); 2732 2890 2733 2891 if (len > max_incl_len) … … 2775 2933 if (name[1] == '/' || name[1] == '\0') 2776 2934 { 2777 extern char *getenv ();2778 2935 char *home_dir; 2779 2936 int is_variable; 2780 2937 2781 2938 { 2782 2783 2784 2785 2786 2787 2788 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; 2789 2946 } 2790 2947 2791 2948 is_variable = home_dir[0] != '\0'; 2792 2949 if (!is_variable) 2793 2794 2795 2796 2950 { 2951 free (home_dir); 2952 home_dir = getenv ("HOME"); 2953 } 2797 2954 # if !defined(_AMIGA) && !defined(WINDOWS32) 2798 2955 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 } 2810 2966 # endif /* !AMIGA && !WINDOWS32 */ 2811 2967 if (home_dir != 0) 2812 2813 2814 2815 2816 2817 2968 { 2969 char *new = xstrdup (concat (2, home_dir, name + 1)); 2970 if (is_variable) 2971 free (home_dir); 2972 return new; 2973 } 2818 2974 } 2819 2975 # if !defined(_AMIGA) && !defined(WINDOWS32) … … 2823 2979 char *userend = strchr (name + 1, '/'); 2824 2980 if (userend != 0) 2825 2981 *userend = '\0'; 2826 2982 pwent = getpwnam (name + 1); 2827 2983 if (pwent != 0) 2828 2829 2830 2831 2832 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 } 2834 2990 else if (userend != 0) 2835 2991 *userend = '/'; 2836 2992 } 2837 2993 # endif /* !AMIGA && !WINDOWS32 */ … … 2865 3021 2866 3022 void * 2867 parse_file_seq (char **stringp, unsigned int size, int stop char,3023 parse_file_seq (char **stringp, unsigned int size, int stopmap, 2868 3024 const char *prefix, int flags) 2869 3025 { 2870 extern void dir_setup_glob (glob_t *glob);2871 2872 3026 /* tmp points to tmpbuf after the prefix, if any. 2873 3027 tp is the end of the buffer. */ 2874 3028 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); 2878 3031 2879 3032 struct nameseq *new = 0; … … 2890 3043 char *tp; 2891 3044 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; 2897 3047 2898 3048 if (size < sizeof (struct nameseq)) 2899 3049 size = sizeof (struct nameseq); 2900 3050 2901 if ( ! (flags &PARSEFS_NOGLOB))3051 if (NONE_SET (flags, PARSEFS_NOGLOB)) 2902 3052 dir_setup_glob (&gl); 2903 3053 2904 3054 /* Get enough temporary space to construct the largest possible target. */ 2905 3055 { 3056 static int tmpbuf_len = 0; 2906 3057 int l = strlen (*stringp) + 1; 2907 3058 if (l > tmpbuf_len) … … 2920 3071 const char **nlist = 0; 2921 3072 char *tildep = 0; 3073 int globme = 1; 2922 3074 #ifndef NO_ARCHIVES 2923 3075 char *arname = 0; … … 2929 3081 2930 3082 /* 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 3083 NEXT_TOKEN (p); 3084 if (STOP_SET (*p, stopmap)) 3085 break; 2934 3086 2935 3087 /* There are names left, so find the end of the next name. 2936 3088 Throughout this iteration S points to the start. */ 2937 3089 s = p; 2938 p = find_char_unquote (p, stop char, VMS_COMMA, 1, 0);3090 p = find_char_unquote (p, stopmap|MAP_VMSCOMMA|MAP_BLANK); 2939 3091 #ifdef VMS 2940 3092 /* convert comma separated list to space separated */ 2941 3093 if (p && *p == ',') 2942 3094 *p =' '; 2943 3095 #endif 2944 3096 #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); 2949 3100 #endif 2950 3101 #ifdef HAVE_DOS_PATHS … … 2953 3104 Note that tokens separated by spaces should be treated as separate 2954 3105 tokens since make doesn't allow path names with spaces */ 2955 if (stop char == ':')2956 while (p != 0 && ! isspace ((unsigned char)*p) &&3106 if (stopmap | MAP_COLON) 3107 while (p != 0 && !ISSPACE (*p) && 2957 3108 (p[1] == '\\' || p[1] == '/') && isalpha ((unsigned char)p[-1])) 2958 p = find_char_unquote (p + 1, stop char, VMS_COMMA, 1, 0);3109 p = find_char_unquote (p + 1, stopmap|MAP_VMSCOMMA|MAP_BLANK); 2959 3110 #endif 2960 3111 if (p == 0) 2961 3112 p = s + strlen (s); 2962 3113 2963 3114 /* Strip leading "this directory" references. */ 2964 if ( ! (flags &PARSEFS_NOSTRIP))3115 if (NONE_SET (flags, PARSEFS_NOSTRIP)) 2965 3116 #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; 2971 3123 #endif 2972 { 3124 /* Skip leading './'s. */ 3125 while (p - s > 2 && s[0] == '.' && s[1] == '/') 3126 { 2973 3127 /* Skip "./" and all following slashes. */ 2974 2975 2976 2977 3128 s += 2; 3129 while (*s == '/') 3130 ++s; 3131 } 2978 3132 2979 3133 /* Extract the filename just found, and skip it. … … 2982 3136 if (s == p) 2983 3137 { 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) 2988 3140 /* PDS-- This cannot be right!! */ 2989 3141 tp[0] = '\0'; … … 2997 3149 } 2998 3150 else 2999 3151 { 3000 3152 #ifdef VMS 3001 3153 /* VMS filenames can have a ':' in them but they have to be '\'ed but we need … … 3003 3155 * xstrdup called because S may be read-only string constant. 3004 3156 */ 3005 3006 3007 3008 3157 char *n = tp; 3158 while (s < p) 3159 { 3160 if (s[0] == '\\' && s[1] == ':') 3009 3161 ++s; 3010 3011 3162 *(n++) = *(s++); 3163 } 3012 3164 n[0] = '\0'; 3013 3165 nlen = strlen (tp); … … 3028 3180 3029 3181 TP == TMP means we're not already in an archive group. Ignore 3030 something starting with `(', as that cannot actually be an3182 something starting with '(', as that cannot actually be an 3031 3183 archive-member reference (and treating it as such results in an empty 3032 3184 file name, which causes much lossage). Also if it ends in ")" then … … 3036 3188 character, so ensure there's some word ending like that before 3037 3189 considering this an archive group. */ 3038 if ( ! (flags &PARSEFS_NOAR)3190 if (NONE_SET (flags, PARSEFS_NOAR) 3039 3191 && tp == tmpbuf && tp[0] != '(' && tp[nlen-1] != ')') 3040 3192 { … … 3044 3196 /* This looks like the first element in an open archive group. 3045 3197 A valid group MUST have ')' as the last character. */ 3046 const char *e = p + nlen;3198 const char *e = p; 3047 3199 do 3048 3200 { 3049 e = next_token (e); 3201 const char *o = e; 3202 NEXT_TOKEN (e); 3050 3203 /* Find the end of this word. We don't want to unquote and 3051 3204 we don't care about quoting since we're looking for the 3052 3205 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)) 3055 3207 ++e; 3208 /* If we didn't move, we're done now. */ 3209 if (e == o) 3210 break; 3056 3211 if (e[-1] == ')') 3057 3212 { … … 3062 3217 tp = n + 1; 3063 3218 3064 /* If we have just "lib(", part of something like3065 "lib( a b)", go to the next item. */3066 if (! nlen)3067 continue;3068 3069 3219 /* We can stop looking now. */ 3070 3220 break; … … 3072 3222 } 3073 3223 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; 3074 3229 } 3075 3230 } … … 3098 3253 /* If we're not globbing we're done: add it to the end of the chain. 3099 3254 Go to the next item in the string. */ 3100 if ( flags & PARSEFS_NOGLOB)3101 { 3102 NEWELT (concat (2, prefix, t p));3255 if (ANY_SET (flags, PARSEFS_NOGLOB)) 3256 { 3257 NEWELT (concat (2, prefix, tmpbuf)); 3103 3258 continue; 3104 3259 } … … 3107 3262 TP is a string in tmpbuf. NLEN is no longer used. 3108 3263 We may need to do more work: after this NAME will be set. */ 3109 name = t p;3264 name = tmpbuf; 3110 3265 3111 3266 /* Expand tilde if applicable. */ 3112 if (t p[0] == '~')3113 3114 tildep = tilde_expand (tp);3115 3267 if (tmpbuf[0] == '~') 3268 { 3269 tildep = tilde_expand (tmpbuf); 3270 if (tildep != 0) 3116 3271 name = tildep; 3117 3272 } 3118 3273 3119 3274 #ifndef NO_ARCHIVES … … 3121 3276 file name, and save the member name in MEMNAME. We will glob on the 3122 3277 archive name and then reattach MEMNAME later. */ 3123 if ( ! (flags &PARSEFS_NOAR) && ar_name (name))3124 3125 3126 3127 3278 if (NONE_SET (flags, PARSEFS_NOAR) && ar_name (name)) 3279 { 3280 ar_parse_name (name, &arname, &memname); 3281 name = arname; 3282 } 3128 3283 #endif /* !NO_ARCHIVES */ 3129 3284 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; 3152 3289 i = 1; 3153 3290 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 } 3156 3319 3157 3320 /* For each matched element, add it to the list. */ … … 3168 3331 { 3169 3332 /* We got a chain of items. Attach them. */ 3170 (*newp)->next = found; 3333 if (*newp) 3334 (*newp)->next = found; 3335 else 3336 *newp = found; 3171 3337 3172 3338 /* Find and set the new end. Massage names if necessary. */ … … 3190 3356 NEWELT (concat (2, prefix, nlist[i])); 3191 3357 3192 globfree (&gl); 3358 if (globme) 3359 globfree (&gl); 3193 3360 3194 3361 #ifndef NO_ARCHIVES 3195 if (arname) 3196 free (arname); 3362 free (arname); 3197 3363 #endif 3198 3364 3199 if (tildep) 3200 free (tildep); 3365 free (tildep); 3201 3366 } 3202 3367 -
vendor/gnumake/current/remake.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 #include "filedef.h" 21 19 #include "job.h" … … 40 38 #endif 41 39 42 extern int try_implicit_rule (struct file *file, unsigned int depth);43 44 40 45 41 /* The test for circular dependencies is based on the 'updating' bit in 46 `struct file'. However, double colon targets have seperate `struct42 'struct file'. However, double colon targets have separate 'struct 47 43 file's; make sure we always use the base of the double colon chain. */ 48 44 … … 58 54 unsigned int commands_started = 0; 59 55 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. */ 57 static struct goaldep *goal_list; 58 static struct dep *goal_dep; 59 60 /* Current value for pruning the scan of the goal chain. 61 All files start with considered == 0. */ 62 static unsigned int considered = 0; 63 64 static enum update_status update_file (struct file *file, unsigned int depth); 65 static enum update_status update_file_1 (struct file *file, unsigned int depth); 66 static enum update_status check_dep (struct file *file, unsigned int depth, 67 FILE_TIMESTAMP this_mtime, int *must_make); 68 static enum update_status touch_file (struct file *file); 68 69 static void remake_file (struct file *file); 69 70 static FILE_TIMESTAMP name_mtime (const char *name); … … 72 73 73 74 74 /* Remake all the goals in the `struct dep' chain GOALS. Return -1 if nothing75 /* Remake all the goals in the 'struct dep' chain GOALS. Return -1 if nothing 75 76 was done, 0 if all goals were updated successfully, or 1 if a goal failed. 76 77 … … 78 79 and -n should be disabled for them unless they were also command-line 79 80 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 83 enum update_status 84 update_goal_chain (struct goaldep *goaldeps) 84 85 { 85 86 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; 90 88 91 89 /* Duplicate the chain so we can remove things from it. */ 92 90 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; 108 100 109 101 /* Update all the goals until they are all finished. */ … … 124 116 g = goals; 125 117 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. */ 164 158 if (commands_started > ocommands_started) 165 159 g->changed = 1; 166 160 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) 173 163 { 174 if (file->update_status != 0) 164 /* We updated this goal. Update STATUS and decide whether 165 to stop. */ 166 if (file->update_status) 175 167 { 176 168 /* Updating failed, or -q triggered. The STATUS value … … 199 191 if (!rebuilding_makefiles 200 192 || (!just_print_flag && !question_flag)) 201 status = 0;193 status = us_success; 202 194 if (rebuilding_makefiles && file->dontcare) 203 195 /* This is a default makefile; stop remaking. */ … … 207 199 } 208 200 209 201 /* Keep track if any double-colon entry is not finished. 210 202 When they are all finished, the goal is finished. */ 211 203 any_not_updated |= !file->updated; 212 204 213 205 file->dontcare = 0; 214 206 215 216 217 218 219 220 221 222 223 224 225 226 227 228 /* If the update_status is zero, we updated successfully229 230 231 && file->update_status == 0&& !g->changed232 233 234 message (1, ((file->phony || file->cmds == 0)235 ? _("Nothing to be done for `%s'.")236 : _("`%s' is up to date.")),237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 /* If we reached the end of the dependency graph toggle the considered261 f lag 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. */ 262 254 if (g == 0) 263 considered = !considered;255 ++considered; 264 256 } 265 257 … … 275 267 276 268 269 /* If we're rebuilding an included makefile that failed, and we care 270 about errors, show an error message the first time. */ 271 272 void 273 show_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 277 294 /* If FILE is not up to date, execute the commands for it. 278 Return 0 if successful, 1if 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. 280 297 281 298 DEPTH is the depth in recursions of this function. … … 287 304 each is considered in turn. */ 288 305 289 static int306 static enum update_status 290 307 update_file (struct file *file, unsigned int depth) 291 308 { 292 register int status = 0;293 registerstruct file *f;309 enum update_status status = us_success; 310 struct file *f; 294 311 295 312 f = file->double_colon ? file->double_colon : file; … … 302 319 { 303 320 /* Check for the case where a target has been tried and failed but 304 the diagnostics ha sn't been issued. If we need the diagnostics321 the diagnostics haven't been issued. If we need the diagnostics 305 322 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; 310 328 } 311 329 } … … 315 333 for (; f != 0; f = f->prev) 316 334 { 335 enum update_status new; 336 317 337 f->considered = considered; 318 338 319 status |= update_file_1 (f, depth);339 new = update_file_1 (f, depth); 320 340 check_renamed (f); 321 341 … … 324 344 325 345 /* 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; 328 348 329 349 if (f->command_state == cs_running 330 350 || 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; 337 357 } 338 358 … … 347 367 348 368 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 } 350 374 } 351 375 … … 359 383 complain (struct file *file) 360 384 { 361 const char *msg_noparent362 = _("%sNo rule to make target `%s'%s");363 const char *msg_parent364 = _("%sNo rule to make target `%s', needed by `%s'%s");365 366 385 /* If this file has no_diag set then it means we tried to update it 367 386 before in the dontcare mode and failed. The target that actually … … 374 393 for (d = file->deps; d != 0; d = d->next) 375 394 { 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) 377 396 { 378 397 complain (d->file); … … 383 402 if (d == 0) 384 403 { 404 show_goal_error (); 405 385 406 /* 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 } 396 417 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 } 398 427 399 428 file->no_diag = 0; … … 401 430 } 402 431 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 435 static enum update_status 406 436 update_file_1 (struct file *file, unsigned int depth) 407 437 { 438 enum update_status dep_status = us_success; 408 439 FILE_TIMESTAMP this_mtime; 409 440 int noexist, must_make, deps_changed; 410 int dep_status = 0;411 441 struct file *ofile; 412 442 struct dep *d, *ad; … … 414 444 int running = 0; 415 445 416 DBF (DB_VERBOSE, _("Considering target file `%s'.\n"));446 DBF (DB_VERBOSE, _("Considering target file '%s'.\n")); 417 447 418 448 if (file->updated) 419 449 { 420 if (file->update_status > 0)421 422 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")); 424 454 425 455 /* If the file we tried to make is marked no_diag then no message … … 430 460 complain (file); 431 461 432 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")); 436 466 return 0; 437 467 } … … 443 473 break; 444 474 case cs_running: 445 DBF (DB_VERBOSE, _("Still updating file `%s'.\n"));475 DBF (DB_VERBOSE, _("Still updating file '%s'.\n")); 446 476 return 0; 447 477 case cs_finished: 448 DBF (DB_VERBOSE, _("Finished updating file `%s'.\n"));478 DBF (DB_VERBOSE, _("Finished updating file '%s'.\n")); 449 479 return file->update_status; 450 480 default: … … 475 505 noexist = this_mtime == NONEXISTENT_MTIME; 476 506 if (noexist) 477 DBF (DB_BASIC, _("File `%s' does not exist.\n"));507 DBF (DB_BASIC, _("File '%s' does not exist.\n")); 478 508 else if (ORDINARY_MTIME_MIN <= this_mtime && this_mtime <= ORDINARY_MTIME_MAX 479 509 && file->low_resolution_time) 480 510 { 481 511 /* Avoid spurious rebuilds due to low resolution time stamps. */ 482 512 int ns = FILE_TIMESTAMP_NS (this_mtime); 483 513 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); 486 517 this_mtime += FILE_TIMESTAMPS_PER_S - 1 - ns; 487 518 } … … 495 526 { 496 527 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")); 498 529 else 499 DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));530 DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n")); 500 531 file->tried_implicit = 1; 501 532 } … … 503 534 && default_file != 0 && default_file->cmds != 0) 504 535 { 505 DBF (DB_IMPLICIT, _("Using default recipe for `%s'.\n"));536 DBF (DB_IMPLICIT, _("Using default recipe for '%s'.\n")); 506 537 file->cmds = default_file->cmds; 507 538 } … … 525 556 while (d) 526 557 { 558 enum update_status new; 527 559 FILE_TIMESTAMP mtime; 528 560 int maybe_make; … … 536 568 if (is_updating (d->file)) 537 569 { 538 error (NILF, _("Circular %s <- %s dependency dropped."),539 570 OSS (error, NILF, _("Circular %s <- %s dependency dropped."), 571 file->name, d->file->name); 540 572 /* We cannot free D here because our the caller will still have 541 573 a reference to it when we were called recursively via … … 559 591 } 560 592 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; 562 596 563 597 /* Restore original dontcare flag. */ … … 583 617 } 584 618 585 if (dep_status != 0&& !keep_going_flag)619 if (dep_status && !keep_going_flag) 586 620 break; 587 621 588 622 if (!running) 589 /* The prereq is considered changed if the timestamp has changed while590 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. */ 591 625 d->changed = ((file_mtime (d->file) != mtime) 592 626 || (mtime == NONEXISTENT_MTIME)); … … 603 637 { 604 638 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; 607 642 int dontcare = 0; 608 643 609 610 611 644 FILE_TIMESTAMP mtime = file_mtime (d->file); 645 check_renamed (d->file); 646 d->file->parent = file; 612 647 613 648 /* Inherit dontcare flag from our parent. */ … … 618 653 } 619 654 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; 622 663 623 664 /* Restore original dontcare flag. */ … … 625 666 d->file->dontcare = dontcare; 626 667 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 if (dep_status != 0&& !keep_going_flag)643 644 645 646 647 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 } 649 690 } 650 691 … … 652 693 finish_updating (ofile); 653 694 654 DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));695 DBF (DB_VERBOSE, _("Finished prerequisites of target file '%s'.\n")); 655 696 656 697 if (running) … … 658 699 set_command_state (file, cs_deps_running); 659 700 --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")); 661 702 return 0; 662 703 } … … 664 705 /* If any dependency failed, give up now. */ 665 706 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; 669 711 notice_finished_file (file); 670 712 671 713 --depth; 672 714 673 DBF (DB_VERBOSE, _("Giving up on target file `%s'.\n"));715 DBF (DB_VERBOSE, _("Giving up on target file '%s'.\n")); 674 716 675 717 if (depth == 0 && keep_going_flag 676 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); 679 721 680 722 return dep_status; … … 705 747 #if 1 706 748 /* %%% In version 4, remove this code completely to 707 708 749 implement not remaking deps if their deps are newer 750 than their parents. */ 709 751 if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate) 710 752 /* We must remake if this dep does not … … 718 760 719 761 /* Set D->changed if either this dep actually changed, 720 762 or its dependent, FILE, is older or does not exist. */ 721 763 d->changed |= noexist || d_mtime > this_mtime; 722 764 723 765 if (!noexist && ISDB (DB_BASIC|DB_VERBOSE)) 724 766 { 725 767 const char *fmt = 0; 726 768 … … 728 770 { 729 771 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"); 731 773 } 732 774 else if (d_mtime == NONEXISTENT_MTIME) 733 775 { 734 776 if (ISDB (DB_BASIC)) 735 fmt = _("Prerequisite `%s' of target `%s' does not exist.\n");736 } 737 777 fmt = _("Prerequisite '%s' of target '%s' does not exist.\n"); 778 } 779 else if (d->changed) 738 780 { 739 781 if (ISDB (DB_BASIC)) 740 fmt = _("Prerequisite `%s' is newer than target `%s'.\n");782 fmt = _("Prerequisite '%s' is newer than target '%s'.\n"); 741 783 } 742 784 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"); 744 786 745 787 if (fmt) … … 749 791 fflush (stdout); 750 792 } 751 793 } 752 794 } 753 795 … … 759 801 must_make = 1; 760 802 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")); 762 804 } 763 805 else if (!noexist && file->is_target && !deps_changed && file->cmds == 0 … … 766 808 must_make = 0; 767 809 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")); 769 811 } 770 812 else if (!must_make && file->cmds != 0 && always_make_flag) 771 813 { 772 814 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")); 774 816 } 775 817 … … 779 821 { 780 822 print_spaces (depth); 781 printf (_("No need to remake target `%s'"), file->name);823 printf (_("No need to remake target '%s'"), file->name); 782 824 if (!streq (file->name, file->hname)) 783 printf (_("; using VPATH name `%s'"), file->hname);825 printf (_("; using VPATH name '%s'"), file->hname); 784 826 puts ("."); 785 827 fflush (stdout); … … 801 843 } 802 844 803 DBF (DB_BASIC, _("Must remake target `%s'.\n"));845 DBF (DB_BASIC, _("Must remake target '%s'.\n")); 804 846 805 847 /* It needs to be remade. If it's VPATH and not reset via GPATH, toss the 806 848 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)); 810 852 file->ignore_vpath = 1; 811 853 } … … 816 858 if (file->command_state != cs_finished) 817 859 { 818 DBF (DB_VERBOSE, _("Recipe of `%s' is being run.\n"));860 DBF (DB_VERBOSE, _("Recipe of '%s' is being run.\n")); 819 861 return 0; 820 862 } … … 822 864 switch (file->update_status) 823 865 { 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")); 826 868 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")); 829 871 break; 830 case 1:831 DBF (DB_BASIC, _("Target file `%s' needsremade under -q.\n"));872 case us_question: 873 DBF (DB_BASIC, _("Target file '%s' needs to be remade under -q.\n")); 832 874 break; 833 default: 834 assert (file->update_status >= 0 && file->update_status <= 2); 875 case us_none: 835 876 break; 836 877 } … … 841 882 842 883 843 /* Set FILE's `updated' flag and re-check its mtime and the mtime's of all844 files listed in its `also_make' member. Under -t, this function also884 /* 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 845 886 touches FILE. 846 887 847 On return, FILE->update_status will no longer be -1if it was. */888 On return, FILE->update_status will no longer be us_none if it was. */ 848 889 849 890 void … … 859 900 if (touch_flag 860 901 /* 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 1if some commands were run and lost.864 865 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) 867 908 { 868 909 if (file->cmds != 0 && file->cmds->any_recurse) 869 870 871 872 873 874 875 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 } 877 918 else 878 879 880 881 file->update_status = 0;919 { 920 have_nonrecursing: 921 if (file->phony) 922 file->update_status = us_success; 882 923 /* According to POSIX, -t doesn't affect targets with no cmds. */ 883 924 else if (file->cmds != 0) 884 925 { 885 926 /* Should set file's modification date and do nothing else. */ … … 887 928 888 929 /* Pretend we ran a real touch command, to suppress the 889 " `foo' is up to date" message. */930 "'foo' is up to date" message. */ 890 931 commands_started++; 891 932 … … 896 937 touched = 1; 897 938 } 898 939 } 899 940 } 900 941 … … 920 961 921 962 else if (file->is_target && file->cmds == 0) 922 963 i = 1; 923 964 924 965 file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME; … … 953 994 } 954 995 955 if (ran && file->update_status != -1)996 if (ran && file->update_status != us_none) 956 997 /* We actually tried to update FILE, which has 957 998 updated its also_make's as well (if it worked). … … 960 1001 for (d = file->also_make; d != 0; d = d->next) 961 1002 { 962 963 964 965 966 967 968 969 970 971 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); 972 1013 } 973 else if (file->update_status == -1)1014 else if (file->update_status == us_none) 974 1015 /* Nothing was done for FILE, but it needed nothing done. 975 1016 So mark it now as "succeeded". */ 976 file->update_status = 0;1017 file->update_status = us_success; 977 1018 } 978 1019 … … 984 1025 failed. */ 985 1026 986 static int1027 static enum update_status 987 1028 check_dep (struct file *file, unsigned int depth, 988 1029 FILE_TIMESTAMP this_mtime, int *must_make_ptr) … … 990 1031 struct file *ofile; 991 1032 struct dep *d; 992 int dep_status = 0;1033 enum update_status dep_status = us_success; 993 1034 994 1035 ++depth; … … 1009 1050 check_renamed (file); 1010 1051 if (mtime == NONEXISTENT_MTIME || mtime > this_mtime) 1011 1052 *must_make_ptr = 1; 1012 1053 } 1013 1054 else … … 1017 1058 1018 1059 if (!file->phony && file->cmds == 0 && !file->tried_implicit) 1019 1020 1021 DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));1022 1023 DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));1024 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 } 1026 1067 if (file->cmds == 0 && !file->is_target 1027 1028 1029 DBF (DB_IMPLICIT, _("Using default commands for `%s'.\n"));1030 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 } 1032 1073 1033 1074 check_renamed (file); … … 1037 1078 /* If the intermediate file actually exists and is newer, then we 1038 1079 should remake from it. */ 1039 1080 *must_make_ptr = 1; 1040 1081 else 1041 1082 { 1042 1083 /* Otherwise, update all non-intermediate files we depend on, if 1043 1084 necessary, and see whether any of them is more recent than the 1044 1085 file on whose behalf we are checking. */ 1045 1086 struct dep *ld; 1046 1087 int deps_running = 0; 1047 1088 … … 1050 1091 prerequisite and so wasn't rebuilt then, but should be now. */ 1051 1092 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; 1058 1107 int maybe_make; 1059 1108 1060 1061 1062 error (NILF, _("Circular %s <- %s dependency dropped."),1063 1064 1065 1066 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; 1067 1116 free_dep (d); 1068 1069 1070 1071 1072 1117 d = file->deps; 1118 } 1119 else 1120 { 1121 ld->next = d->next; 1073 1122 free_dep (d); 1074 1075 1076 1077 1078 1079 1123 d = ld->next; 1124 } 1125 continue; 1126 } 1127 1128 d->file->parent = file; 1080 1129 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 1083 1134 if (! d->ignore_mtime) 1084 1135 *must_make_ptr = maybe_make; 1085 1086 if (dep_status != 0&& !keep_going_flag)1087 1088 1089 1090 1091 1092 1093 1094 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 } 1096 1147 1097 1148 if (deps_running) … … 1100 1151 commands are finished. */ 1101 1152 set_command_state (file, cs_deps_running); 1102 1153 } 1103 1154 } 1104 1155 … … 1110 1161 1111 1162 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 1168 static enum update_status 1117 1169 touch_file (struct file *file) 1118 1170 { 1119 1171 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 1123 1179 if (ar_name (file->name)) 1124 return ar_touch (file->name) ;1180 return ar_touch (file->name) ? us_failed : us_success; 1125 1181 else 1126 1182 #endif 1127 1183 { 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)); 1130 1187 if (fd < 0) 1131 1188 TOUCH_ERROR ("touch: open: "); 1132 1189 else 1133 1134 1135 1190 { 1191 struct stat statbuf; 1192 char buf = 'x'; 1136 1193 int e; 1137 1194 1138 1195 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; 1162 1225 } 1163 1226 … … 1173 1236 { 1174 1237 if (file->phony) 1175 1176 file->update_status = 0;1238 /* Phony target. Pretend it succeeded. */ 1239 file->update_status = us_success; 1177 1240 else if (file->is_target) 1178 1179 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; 1181 1244 else 1182 1245 { … … 1184 1247 if (!rebuilding_makefiles || !file->dontcare) 1185 1248 complain (file); 1186 file->update_status = 2;1249 file->update_status = us_failed; 1187 1250 } 1188 1251 } … … 1193 1256 /* The normal case: start some commands. */ 1194 1257 if (!touch_flag || file->cmds->any_recurse) 1195 1196 1197 1198 1258 { 1259 execute_file_commands (file); 1260 return; 1261 } 1199 1262 1200 1263 /* This tells notice_finished_file it is ok to touch the file. */ 1201 file->update_status = 0;1264 file->update_status = us_success; 1202 1265 } 1203 1266 … … 1207 1270 1208 1271 1209 /* Return the mtime of a file, given a `struct file'.1272 /* Return the mtime of a file, given a 'struct file'. 1210 1273 Caches the time in the struct file to avoid excess stat calls. 1211 1274 … … 1219 1282 { 1220 1283 FILE_TIMESTAMP mtime; 1284 int propagate_timestamp; 1221 1285 1222 1286 /* File's mtime is not known; must get it from the system. */ 1223 1287 1224 #ifndef 1288 #ifndef NO_ARCHIVES 1225 1289 if (ar_name (file->name)) 1226 1290 { … … 1235 1299 1236 1300 /* Find the modification time of the archive itself. 1237 1301 Also allow for its name to be changed via VPATH search. */ 1238 1302 arfile = lookup_file (arname); 1239 1303 if (arfile == 0) … … 1242 1306 check_renamed (arfile); 1243 1307 if (search && strcmp (arfile->hname, arname)) 1244 1245 1246 1308 { 1309 /* The archive's name has changed. 1310 Change the archive-member reference accordingly. */ 1247 1311 1248 1312 char *name; 1249 1250 1251 1252 1253 1254 name = xmalloc(arlen + 1 + memlen + 2);1255 1256 1257 1258 1259 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'; 1260 1324 1261 1325 /* If the archive was found with GPATH, make the change permanent; 1262 1326 otherwise defer it until later. */ 1263 1327 if (arfile->name == arfile->hname) 1264 rename_file (file, name);1328 rename_file (file, strcache_add (name)); 1265 1329 else 1266 rehash_file (file, name);1330 rehash_file (file, strcache_add (name)); 1267 1331 check_renamed (file); 1268 1332 } 1269 1333 1270 1334 free (arname); … … 1273 1337 1274 1338 if (mtime == NONEXISTENT_MTIME) 1275 1276 1339 /* The archive doesn't exist, so its members don't exist either. */ 1340 return NONEXISTENT_MTIME; 1277 1341 1278 1342 member_date = ar_member_date (file->hname); … … 1287 1351 1288 1352 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; 1301 1367 1302 1368 /* If we found it in VPATH, see if it's in GPATH too; if so, 1303 1369 change the name right now; if not, defer until after the 1304 1370 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)) 1306 1379 { 1307 1380 rename_file (file, name); … … 1310 1383 } 1311 1384 1312 1313 1385 rehash_file (file, name); 1386 check_renamed (file); 1314 1387 /* If the result of a vpath search is -o or -W, preserve it. 1315 1388 Otherwise, find the mtime of the resulting file. */ 1316 1389 if (mtime != OLD_MTIME && mtime != NEW_MTIME) 1317 1390 mtime = name_mtime (name); 1318 1319 1391 } 1392 } 1320 1393 } 1321 1394 … … 1363 1436 { 1364 1437 #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); 1367 1441 #else 1368 1442 double from_now = … … 1376 1450 else 1377 1451 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); 1380 1455 #endif 1381 1456 clock_skew_detected = 1; … … 1384 1459 } 1385 1460 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. */ 1387 1464 if (file->double_colon) 1388 1465 file = file->double_colon; 1389 1466 1467 propagate_timestamp = file->updated; 1390 1468 do 1391 1469 { 1392 1470 /* If this file is not implicit but it is intermediate then it was 1393 1394 1395 1396 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. */ 1397 1475 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; 1403 1481 file = file->prev; 1404 1482 } … … 1515 1593 library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr) 1516 1594 { 1517 static c har *dirs[] =1595 static const char *dirs[] = 1518 1596 { 1519 1597 #ifndef _AMIGA … … 1528 1606 #define LIBDIR "." 1529 1607 #endif 1530 LIBDIR, 1608 LIBDIR, /* Defined by configuration. */ 1531 1609 0 1532 1610 }; … … 1543 1621 1544 1622 /* 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; 1549 1626 1550 1627 libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)")); … … 1563 1640 static unsigned int buflen = 0; 1564 1641 static int libdir_maxlen = -1; 1642 static unsigned int std_dirs = 0; 1565 1643 char *libbuf = variable_expand (""); 1566 1644 1567 1645 /* Expand the pattern using LIB as a replacement. */ 1568 1646 { 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); 1578 1657 p[len] = c; 1579 1580 1581 1582 1583 1584 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; 1585 1664 } 1586 1665 1587 /* Look first for `libNAME.a' in the current directory. */1666 /* Look first for 'libNAME.a' in the current directory. */ 1588 1667 mtime = name_mtime (libbuf); 1589 1668 if (mtime != NONEXISTENT_MTIME) 1590 1591 1592 1593 1669 { 1670 if (mtime_ptr != 0) 1671 *mtime_ptr = mtime; 1672 file = strcache_add (libbuf); 1594 1673 /* This by definition will have the best index, so stop now. */ 1595 1674 break; 1596 1675 } 1597 1676 1598 1677 /* Now try VPATH search on that. */ … … 1631 1710 } 1632 1711 buflen = strlen (libbuf); 1633 buf = xmalloc (libdir_maxlen + buflen + 2);1712 buf = xmalloc (libdir_maxlen + buflen + 2); 1634 1713 } 1635 1714 else if (buflen < strlen (libbuf)) … … 1645 1724 1646 1725 for (dp = dirs; *dp != 0; ++dp) 1647 1726 { 1648 1727 sprintf (buf, "%s/%s", *dp, libbuf); 1649 1728 mtime = name_mtime (buf); 1650 1729 if (mtime != NONEXISTENT_MTIME) 1651 1730 { 1652 1731 if (file == 0 || vpath_index < best_vpath) 1653 1732 { -
vendor/gnumake/current/remote-cstms.c
r2596 r3138 4 4 the Make maintainers. 5 5 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. 6 Copyright (C) 1988-2016 Free Software Foundation, Inc. 9 7 This file is part of GNU Make. 10 8 … … 21 19 this program. If not, see <http://www.gnu.org/licenses/>. */ 22 20 23 #include "make.h" 24 #include "job.h" 21 #include "makeint.h" 25 22 #include "filedef.h" 26 23 #include "commands.h" … … 35 32 char *remote_description = "Customs"; 36 33 37 /* File name of the Customs `export' client command.34 /* File name of the Customs 'export' client command. 38 35 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" 40 37 41 38 /* ExportPermit gotten by start_remote_job_p, and used by start_remote_job. */ … … 80 77 81 78 /* For secure Customs, make is installed setuid root and 82 79 Customs requires a privileged source port be used. */ 83 80 make_access (); 84 81 85 82 if (ISDB (DB_JOBS)) 86 Rpc_Debug (1);83 Rpc_Debug (1); 87 84 88 85 /* Ping the daemon once to see if it is there. */ … … 93 90 94 91 if (starting_directory == 0) 95 96 92 /* main couldn't figure it out. */ 93 inited = -1; 97 94 else 98 99 100 101 102 103 104 105 106 107 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 } 109 106 } 110 107 … … 114 111 njobs = job_slots_used; 115 112 if (!first_p) 116 njobs -= 1; 113 njobs -= 1; /* correction for being called from reap_children() */ 117 114 118 115 /* the first job should run locally, or, if the -l flag is given, we use … … 157 154 if (retsock < 0) 158 155 { 159 error (NILF, "exporting: Couldn't create return socket.");156 O (error, NILF, "exporting: Couldn't create return socket."); 160 157 return 1; 161 158 } … … 176 173 /* Create a WayBill to give to the server. */ 177 174 len = Customs_MakeWayBill (&permit, normalized_cwd, argv[0], argv, 178 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 ()'. */ 181 178 { 182 179 WayBill *wb = (WayBill *) waybill; … … 192 189 sin.sin_addr = permit.addr; 193 190 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 } 227 226 228 227 pid = vfork (); … … 230 229 { 231 230 /* The fork failed! */ 232 perror_with_name (" vfork", "");231 perror_with_name ("fork", ""); 233 232 return 1; 234 233 } 235 234 else if (pid == 0) 236 235 { 237 /* Child side. Run `export' to handle the connection. */236 /* Child side. Run 'export' to handle the connection. */ 238 237 static char sock_buf[20], retsock_buf[20], id_buf[20]; 239 238 static char *new_argv[6] = 240 239 { EXPORT_COMMAND, "-id", sock_buf, retsock_buf, id_buf, 0 }; 241 240 242 241 /* Set up the arguments. */ … … 247 246 /* Get the right stdin. */ 248 247 if (stdin_fd != 0) 249 248 (void) dup2 (stdin_fd, 0); 250 249 251 250 /* Unblock signals in the child. */ … … 256 255 } 257 256 258 /* Parent side. Return the `export' process's ID. */257 /* Parent side. Return the 'export' process's ID. */ 259 258 (void) close (retsock); 260 259 (void) close (sock); -
vendor/gnumake/current/remote-stub.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 #include "filedef.h" 21 19 #include "job.h" -
vendor/gnumake/current/rule.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 21 19 #include <assert.h> 22 20 21 #include "filedef.h" 23 22 #include "dep.h" 24 #include "filedef.h"25 23 #include "job.h" 26 24 #include "commands.h" … … 75 73 char *name; 76 74 int namelen; 77 struct rule *rule , *lastrule;75 struct rule *rule; 78 76 79 77 num_pattern_rules = max_pattern_targets = max_pattern_deps = 0; … … 83 81 namelen = 0; 84 82 rule = pattern_rules; 85 lastrule = 0;86 83 while (rule != 0) 87 84 { … … 93 90 94 91 if (rule->num > max_pattern_targets) 95 92 max_pattern_targets = rule->num; 96 93 97 94 for (dep = rule->deps; dep != 0; dep = dep->next) 98 95 { 99 96 const char *dname = dep_name (dep); 100 97 unsigned int len = strlen (dname); … … 112 109 ndeps++; 113 110 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 /* In the deps of an implicit rule the `changed' flag132 133 134 135 136 137 138 139 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 } 141 138 142 139 if (ndeps > max_pattern_deps) 143 max_pattern_deps = ndeps; 144 145 lastrule = rule; 140 max_pattern_deps = ndeps; 141 146 142 rule = next; 147 143 } 148 144 149 if (name != 0) 150 free (name); 145 free (name); 151 146 } 152 147 … … 155 150 TARGET is the target suffix; SOURCE is the source suffix. 156 151 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)'. 158 153 If SOURCE is nil, it means there should be no deps. */ 159 154 … … 170 165 if (target == 0) 171 166 { 172 /* Special case: TARGET being nil means we are defining a `.X.a' suffix173 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)'. */ 174 169 #ifdef VMS 175 170 *names = strcache_add_len ("(%.obj)", 7); … … 225 220 unsigned int l = strlen (dep_name (d)); 226 221 if (l > maxsuffix) 227 222 maxsuffix = l; 228 223 } 229 224 … … 236 231 237 232 /* Make a rule that is just the suffix, with no deps or commands. 238 233 This rule exists solely to disqualify match-anything rules. */ 239 234 convert_suffix_rule (dep_name (d), 0, 0); 240 235 241 236 if (d->file->cmds != 0) 242 243 237 /* Record a pattern for this suffix's null-suffix rule. */ 238 convert_suffix_rule ("", dep_name (d), d->file->cmds); 244 239 245 240 /* Add every other suffix to this one and see if it exists as a … … 249 244 250 245 for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next) 251 246 { 252 247 struct file *f; 253 248 unsigned int s2len; 254 249 255 250 s2len = strlen (dep_name (d2)); 256 251 257 252 /* Can't build something from itself. */ 258 259 260 261 262 263 264 265 266 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 271 272 273 /* The suffix rule `.X.Y:' is converted274 to the pattern rule `%.Y: %.X'. */275 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 } 277 272 } 278 273 } … … 302 297 for (i = 0; i < rule->num; ++i) 303 298 { 304 305 306 299 for (j = 0; j < r->num; ++j) 300 if (!streq (rule->targets[i], r->targets[j])) 301 break; 307 302 /* If all the targets matched... */ 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 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 } 340 335 } 341 336 … … 346 341 /* There was no rule to replace. */ 347 342 if (pattern_rules == 0) 348 343 pattern_rules = rule; 349 344 else 350 345 last_pattern_rule->next = rule; 351 346 last_pattern_rule = rule; 352 347 } … … 359 354 in the structure P points to. These strings come from one of 360 355 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. */ 362 357 363 358 void … … 365 360 { 366 361 struct rule *r; 367 c har *ptr;362 const char *ptr; 368 363 369 364 r = xmalloc (sizeof (struct rule)); … … 381 376 382 377 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); 384 379 385 380 if (new_pattern_rule (r, 0)) … … 389 384 r->cmds->fileinfo.filenm = 0; 390 385 r->cmds->fileinfo.lineno = 0; 386 r->cmds->fileinfo.offset = 0; 391 387 /* These will all be string literals, but we malloc space for them 392 388 anyway because somebody might want to free them later. */ 393 389 r->cmds->commands = xstrdup (p->commands); 394 390 r->cmds->command_lines = 0; 391 r->cmds->recipe_prefix = RECIPEPREFIX_DEFAULT; 395 392 } 396 393 } … … 416 413 are ways that they could be in more than one place: 417 414 * 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 given415 the 'struct file's for other suffix rules or plain targets given 419 416 on the same makefile line. 420 417 * If two suffixes that together make a two-suffix rule were each 421 418 given twice in the .SUFFIXES list, and in the proper order, two 422 419 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. */ 425 422 426 423 free (rule); … … 477 474 /* Print the data base of rules. */ 478 475 479 static void 476 static void /* Useful to call from gdb. */ 480 477 print_rule (struct rule *r) 481 478 { … … 513 510 514 511 if (r->terminal) 515 512 ++terminal; 516 513 } 517 514 … … 521 518 { 522 519 printf (_("\n# %u implicit rules, %u"), rules, terminal); 523 #ifndef 520 #ifndef NO_FLOAT 524 521 printf (" (%.1f%%)", (double) terminal / (double) rules * 100.0); 525 522 #else 526 523 { 527 528 524 int f = (terminal * 1000 + 5) / rules; 525 printf (" (%d.%d%%)", f/10, f%10); 529 526 } 530 527 #endif … … 537 534 makefiles and thus count_implicit_rule_limits wasn't called yet. */ 538 535 if (num_pattern_rules != 0) 539 fatal (NILF, _("BUG: num_pattern_rules is wrong! %u != %u"),540 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 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 23 21 { 24 22 struct rule *next; 25 const char **targets; 26 unsigned int *lens; 27 const char **suffixes; /* Suffixes (after `%') of each target. */28 struct dep *deps; 29 struct commands *cmds; 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. */ 30 28 unsigned short num; /* Number of targets. */ 31 char terminal; 32 char in_use; 29 char terminal; /* If terminal (double-colon). */ 30 char in_use; /* If in use by a parent pattern_search. */ 33 31 }; 34 32 … … 36 34 struct pspec 37 35 { 38 c har *target, *dep, *commands;36 const char *target, *dep, *commands; 39 37 }; 40 38 … … 58 56 unsigned int num, int terminal, struct dep *deps, 59 57 struct commands *commands, int override); 58 void print_rule_data_base (void); -
vendor/gnumake/current/signame.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1990-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 21 19 /* If the system provides strsignal, we don't need it. */ … … 30 28 31 29 /* Some systems do not define NSIG in <signal.h>. */ 32 #ifndef 33 #ifdef 34 #define NSIG_NSIG30 #ifndef NSIG 31 #ifdef _NSIG 32 #define NSIG _NSIG 35 33 #else 36 #define NSIG3234 #define NSIG 32 37 35 #endif 38 36 #endif … … 195 193 #endif 196 194 #if defined (SIGIO) 197 /* "I/O pending" has also been suggested. A disadvantage is 198 that signal only happens when the process has199 asked for it, not everytime I/O is pending. Another disadvantage200 is the confusion from giving it adifferent 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. */ 201 199 init_sig (SIGIO, "IO", _("I/O possible")); 202 200 #endif … … 247 245 #endif 248 246 249 if (sig > 0 ||sig < NSIG)247 if (sig > 0 && sig < NSIG) 250 248 return (char *) sys_siglist[sig]; 251 249 -
vendor/gnumake/current/strcache.c
r2596 r3138 1 1 /* Constant string caching for GNU Make. 2 Copyright (C) 2006 , 2007, 2008, 2009, 2010Free Software Foundation, Inc.2 Copyright (C) 2006-2016 Free Software Foundation, Inc. 3 3 This file is part of GNU Make. 4 4 … … 15 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 16 16 17 #include "make.h" 18 17 #include "makeint.h" 18 19 #include <stddef.h> 19 20 #include <assert.h> 20 21 21 22 #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 27 23 28 24 /* A string cached here will never be freed, so we don't need to worry about … … 30 26 hash so it can be looked up again. */ 31 27 28 typedef unsigned short int sc_buflen_t; 29 32 30 struct strcache { 33 struct strcache *next; /* The next block of strings. */34 char *end; /* Pointer to the beginning of thefree 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). */ 37 35 char buffer[1]; /* The buffer comes after this. */ 38 36 }; 39 37 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 41 47 static struct strcache *strcache = NULL; 48 static struct strcache *fullcache = NULL; 49 50 static unsigned long total_buffers = 0; 51 static unsigned long total_strings = 0; 52 static unsigned long total_size = 0; 42 53 43 54 /* Add a new buffer to the cache. Add it at the front to reduce search time. … … 47 58 */ 48 59 static struct strcache * 49 new_cache() 50 { 51 struct strcache *new; 52 new = xmalloc (sizeof (*new) + bufsize); 53 new->end = new->buffer; 60 new_cache (struct strcache **head, sc_buflen_t buflen) 61 { 62 struct strcache *new = xmalloc (buflen + CACHE_BUFFER_OFFSET); 63 new->end = 0; 54 64 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; 60 71 return new; 61 72 } 62 73 63 74 static const char * 64 add_string(const char *str, int len) 65 { 66 struct strcache *best = NULL; 75 copy_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 89 static const char * 90 add_string (const char *str, unsigned int len) 91 { 92 const char *res; 67 93 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; 69 100 70 101 /* 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 } 96 133 97 134 return res; 98 135 } 99 136 137 /* For strings too large for the strcache, we just save them in a list. */ 138 struct hugestring { 139 struct hugestring *next; /* The next string. */ 140 char buffer[1]; /* The string. */ 141 }; 142 143 static struct hugestring *hugestrings = NULL; 144 145 static const char * 146 add_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 } 100 157 101 158 /* Hash table of strings in the cache. */ … … 123 180 124 181 static const char * 125 add_hash (const char *str, int len) 126 { 182 add_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 127 192 /* 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 add s 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. */ 132 197 ++total_adds; 133 198 … … 148 213 149 214 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) 151 216 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 } 152 227 153 228 return 0; … … 164 239 165 240 const char * 166 strcache_add_len (const char *str, int len)241 strcache_add_len (const char *str, unsigned int len) 167 242 { 168 243 /* If we're not given a nul-terminated string we have to create one, because … … 179 254 } 180 255 181 int182 strcache_setbufsize(int size)183 {184 if (size > bufsize)185 bufsize = size;186 return bufsize;187 }188 189 256 void 190 257 strcache_init (void) … … 199 266 strcache_print_stats (const char *prefix) 200 267 { 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); 245 329 hash_print_stats (&strings, stdout); 246 330 } -
vendor/gnumake/current/subproc.bat
r2596 r3138 1 1 @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. 2 rem Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 rem This file is part of GNU Make. 5 4 rem … … 22 21 if x%2 == x set MAKE=nmake 23 22 %MAKE% /f %MAKEFILE% 23 if ERRORLEVEL 1 exit /B 24 24 cd ..\.. -
vendor/gnumake/current/tests/ChangeLog.1
r3137 r3138 1 2013-10-09 Paul Smith <psmith@gnu.org> 2 3 * scripts/features/patspecific_vars: Typo fixes. 4 5 2013-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 16 2013-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 25 2013-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 31 2013-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 51 2013-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 80 2013-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 95 2013-09-14 Paul Smith <psmith@gnu.org> 96 97 * scripts/features/output-sync: Verify -Orecurse properly. 98 99 2013-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 106 2013-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 111 2013-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 116 2013-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 123 2013-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 129 2013-05-14 Paul Smith <psmith@gnu.org> 130 131 * scripts/features/loadapi: Add plugin_is_GPL_compatible symbol. 132 * scripts/features/load: Ditto. 133 134 2013-05-13 Paul Smith <psmith@gnu.org> 135 136 * scripts/features/output-sync (output_sync_set): Update for new 137 --trace behavior. 138 139 2013-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 146 2013-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 153 2013-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 158 2013-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 164 2013-04-15 Paul Smith <psmith@gnu.org> 165 166 * scripts/features/output-sync (output_sync_set): New arg syntax. 167 168 2013-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 180 2013-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 189 2013-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 195 2013-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 203 2013-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 208 2012-10-29 Paul Smith <psmith@gnu.org> 209 210 * scripts/features/load: New test suite for the "load" directive. 211 212 2012-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 226 2012-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 237 2012-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 254 2012-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 261 2012-01-12 Paul Smith <psmith@gnu.org> 262 263 * scripts/functions/guile: New regression tests for Guile support. 264 265 2011-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 270 2011-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 275 2011-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 284 2011-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 289 2011-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 294 2011-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 299 2011-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 305 2011-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 313 2011-05-02 Paul Smith <psmith@gnu.org> 314 315 * scripts/functions/sort: Add a test for Savannah bug #33125. 316 317 2011-04-17 David A. Wheeler <dwheeler@dwheeler.com> 318 319 * scripts/features/shell_assignment: Regression for "!=" feature 320 321 2010-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 329 2010-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 339 2010-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 347 2010-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 1 352 2010-07-28 Paul Smith <psmith@gnu.org> 2 353 … … 300 651 beginning with "."). 301 652 302 * scripts/functions/andor: Tests for $(and .. ) and $(or ...)653 * scripts/functions/andor: Tests for $(and ...) and $(or ...) 303 654 functions. 304 655 … … 387 738 2005-08-13 Boris Kolpackov <boris@kolpackov.net> 388 739 389 * scripts/functions/wildcard: Wrap calls to $(wildcard 740 * scripts/functions/wildcard: Wrap calls to $(wildcard) with 390 741 $(sort) so that the resulting order is no longer filesystem- 391 depend ant.742 dependent. 392 743 393 744 2005-08-10 Boris Kolpackov <boris@kolpackov.net> … … 460 811 2005-06-09 Paul D. Smith <psmith@gnu.org> 461 812 462 813 * scripts/functions/foreach: Add a test for Savannah bug #11913. 463 814 464 815 2005-05-31 Boris Kolpackov <boris@kolpackov.net> … … 480 831 481 832 * scripts/features/parallelism: Add a test for exporting recursive 482 variables containing $(shell 833 variables containing $(shell) calls. Rewrite this script to use 483 834 run_make_test() everywhere. 484 835 … … 1064 1415 1065 1416 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. 1417 Copyright (C) 1992-2016 Free Software Foundation, Inc. 1068 1418 This file is part of GNU Make. 1069 1419 -
vendor/gnumake/current/tests/NEWS
r2596 r3138 73 73 Also, some tests and stuff still haven't made it in because I 74 74 haven't had time to write the test scripts for them. But they, 75 too, will get in eventually. Contributions of scripts (i e, tests75 too, will get in eventually. Contributions of scripts (i.e., tests 76 76 that I can just drop in) are particularly welcome and will be 77 77 incorporated immediately. … … 164 164 165 165 ------------------------------------------------------------------------------- 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. 166 Copyright (C) 1992-2016 Free Software Foundation, Inc. 168 167 This file is part of GNU Make. 169 168 -
vendor/gnumake/current/tests/README
r2596 r3138 8 8 9 9 ----------------------------------------------------------------------------- 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. 12 11 This file is part of GNU Make. 13 12 … … 40 39 41 40 By 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 (i e,41 that it finds in your path. You may use the -make_path option (i.e., 43 42 "perl run_make_tests -make_path /usr/local/src/make-3.78/make") if 44 43 you want to run a particular copy. This now works correctly with … … 60 59 make to be setgid sys or kmem for this; if you don't want to install 61 60 make just to test it, make it setgid to kmem or whatever group /dev/kmem 62 is (i e, "chgrp kmem make;chmod g+s make" as root). In any case, the61 is (i.e., "chgrp kmem make;chmod g+s make" as root). In any case, the 63 62 options/dash-l test should no longer *fail* because make can't read 64 63 /dev/kmem. -
vendor/gnumake/current/tests/mkshadow
r2596 r3138 4 4 # Typically you'd put the shadow in /tmp or another local disk 5 5 # 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. 9 7 # This file is part of GNU Make. 10 8 # … … 29 27 30 28 if [ ! -d "$dest" ]; then 31 echo "Destination directory \`$dest' must exist!"29 echo "Destination directory '$dest' must exist!" 32 30 exit 1 33 31 fi … … 56 54 rm -rf work 57 55 58 echo "Shadow test suite created in \`$dest/$name'."56 echo "Shadow test suite created in '$dest/$name'." 59 57 exit 0 -
vendor/gnumake/current/tests/run_make_tests.pl
r2596 r3138 12 12 # (and others) 13 13 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. 17 15 # This file is part of GNU Make. 18 16 # … … 30 28 # this program. If not, see <http://www.gnu.org/licenses/>. 31 29 30 %FEATURES = (); 32 31 33 32 $valgrind = 0; # invoke make with valgrind 34 33 $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'; 36 35 $massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup'; 37 36 $pure_log = undef; 38 37 38 # The location of the GNU make source directory 39 $srcdir = ''; 40 39 41 $command_string = ''; 40 42 41 43 $all_tests = 0; 42 44 45 # rmdir broken in some Perls on VMS. 46 if ($^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 43 61 require "test_driver.pl"; 62 require "config-flags.pm"; 44 63 45 64 # Some target systems might not have the POSIX module... … … 61 80 } 62 81 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 63 91 if ($option =~ /^-all([-_]?tests)?$/i) { 64 92 $all_tests = 1; … … 99 127 $old_makefile = undef; 100 128 129 sub 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 101 140 sub run_make_test 102 141 { 103 142 local ($makestring, $options, $answer, $err_code, $timeout) = @_; 143 my @call = caller; 104 144 105 145 # If the user specified a makefile string, create a new makefile to contain … … 116 156 } 117 157 118 # Make sure it ends in a newline .158 # Make sure it ends in a newline and substitute any special tokens. 119 159 $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); 128 161 129 162 # Populate the makefile! … … 134 167 135 168 # 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 } 143 173 144 174 run_make_with_options($makefile, $options, &get_logfile(0), 145 $err_code, $timeout );175 $err_code, $timeout, @call); 146 176 &compare_output($answer, &get_logfile(1)); 147 177 … … 152 182 # The old-fashioned way... 153 183 sub 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; 155 186 local($code); 156 187 local($command) = $make_path; … … 166 197 167 198 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 } 168 233 $command .= " $options"; 169 234 } 170 235 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"; 172 241 173 242 if ($valgrind) { … … 184 253 185 254 $code = &run_command_with_output($logname,$command); 186 187 255 $test_timeout = $old_timeout; 188 256 } … … 229 297 { 230 298 &print_standard_usage ("run_make_tests", 231 "[-make _path make_pathname] [-memcheck] [-massif]",);299 "[-make MAKE_PATHNAME] [-srcdir SRCDIR] [-memcheck] [-massif]",); 232 300 } 233 301 … … 235 303 { 236 304 &print_standard_help ( 237 "-make _path",305 "-make", 238 306 "\tYou may specify the pathname of the copy of make to run.", 307 "-srcdir", 308 "\tSpecify the make source directory.", 239 309 "-valgrind", 240 310 "-memcheck", … … 296 366 $port_type = 'OS/2'; 297 367 } 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 } 298 374 # Everything else, right now, is UNIX. Note that we should integrate 299 375 # the VOS support into this as well and get rid of $vos; we'll do … … 313 389 # Find the full pathname of Make. For DOS systems this is more 314 390 # 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 318 399 '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`; 323 407 324 408 $string =~ /^(GNU Make [^,\n]*)/; 325 409 $testee_version = "$1\n"; 326 410 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"`; 328 414 if ($string =~ /(.*): \*\*\* No targets\. Stop\./) { 329 415 $make_name = $1; 330 416 } 331 417 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; 338 420 } 339 421 … … 349 431 { 350 432 $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; 351 451 } 352 452 … … 360 460 } 361 461 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"`; 363 463 if ($string =~ /not supported/) { 364 464 $parallel_jobs = 0; … … 368 468 } 369 469 470 %FEATURES = map { $_ => 1 } split /\s+/, `sh -c "echo '\\\$(info \\\$(.FEATURES))' | $make_path -f- 2>/dev/null"`; 471 370 472 # Set up for valgrind, if requested. 473 474 $make_command = $make_path; 371 475 372 476 if ($valgrind) { -
vendor/gnumake/current/tests/scripts/features/conditionals
r2596 r3138 142 142 'success'); 143 143 144 # SV 47960 : ensure variable assignments in non-taken legs don't cause problems 145 run_make_test(' 146 ifneq ($(FOO),yes) 147 target: 148 else 149 BAR = bar 150 target: 151 endif 152 @echo one 153 ', 154 '', "one\n"); 155 144 156 145 157 # This tells the test driver that the perl test script executed properly. 146 158 1; 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 11 11 close(MAKEFILE); 12 12 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" 14 open(MAKEFILE,"> makefile"); 15 print MAKEFILE "SECOND: ; \@echo It chose makefile\n"; 16 close(MAKEFILE); 15 17 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 21 my $case_sensitive = 0; 22 if (! -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); 21 28 } 22 29 23 # Create another makefile called "Makefile" 24 open(MAKEFILE,"> Makefile"); 25 print MAKEFILE "THIRD: ; \@echo It chose Makefile\n"; 26 close(MAKEFILE); 30 run_make_with_options("","",&get_logfile); 31 compare_output("It chose GNUmakefile\n",&get_logfile(1)); 32 unlink($makefile); 27 33 34 run_make_with_options("","",&get_logfile); 35 compare_output("It chose makefile\n",&get_logfile(1)); 36 unlink("makefile"); 28 37 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"; 38 if ($case_sensitive) { 39 run_make_with_options("","",&get_logfile); 40 compare_output("It chose Makefile\n",&get_logfile(1)); 41 unlink("Makefile"); 37 42 } 38 43 39 &run_make_with_options("","",&get_logfile); 40 &compare_output("It chose Makefile\n",&get_logfile(1)); 41 unlink "Makefile"; 44 1; -
vendor/gnumake/current/tests/scripts/features/double_colon
r2596 r3138 152 152 unlink('result','one','two'); 153 153 154 # TEST 10: SV 33399 : check for proper backslash handling 155 156 run_make_test(' 157 a\ xb :: ; @echo one 158 a\ 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 164 run_make_test('result :: 01 165 @echo update 166 @touch $@ 167 result :: 02 168 @echo update 169 @touch $@ 170 result :: 03 171 @echo update 172 @touch $@ 173 result :: 04 174 @echo update 175 @touch $@ 176 result :: 05 177 @echo update 178 @touch $@ 179 01 02 03 04 05: 180 @touch 01 02 03 04 05 181 ', 182 '-j10 result', "update\nupdate\nupdate\nupdate\nupdate\n"); 183 184 unlink('result', '01', '02', '03', '04', '05'); 185 186 # Test 12: SV 44742 : Double-colon rules with parallelism 187 188 run_make_test(' 189 root: all 190 echo root 191 all:: 192 echo all_one 193 all:: 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 202 run_make_test(' 203 all:: ; @echo one 204 205 all:: joe ; @echo four 206 207 joe: FORCE ; touch joe-is-forced 208 209 FORCE: 210 ', 211 '-j5', "one\ntouch joe-is-forced\nfour\n"); 212 213 unlink('joe-is-forced'); 214 154 215 # This tells the test driver that the perl test script executed properly. 155 216 1; 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 31 31 ."\t-$rm_command cleanit\n" 32 32 ."\t$rm_command foo\n" 33 33 ."clean2: \n" 34 34 ."\t$rm_command cleanit\n" 35 35 ."\t$rm_command foo\n"; … … 43 43 unlink("cleanit"); 44 44 $cleanit_error = `sh -c "$rm_command cleanit 2>&1"`; 45 chomp $cleanit_error; 45 46 $delete_error_code = $? >> 8; 46 47 … … 48 49 # ------- 49 50 50 $answer = "$rm_command cleanit \n"51 .$cleanit_error52 ."$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"; 54 55 55 56 &run_make_with_options($makefile,"",&get_logfile); … … 75 76 # ------- 76 77 77 $answer = "$rm_command cleanit \n"78 .$cleanit_error79 ."$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"; 81 82 82 83 &run_make_with_options($makefile,"clean2 -i",&get_logfile); … … 90 91 } 91 92 93 # Test that error line offset works 94 95 run_make_test(q! 96 all: 97 @echo hi 98 @echo there 99 @exit 1 100 !, 101 '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#:5: all] Error 1", 512); 102 92 103 1; 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 3 3 4 4 $details = "\ 5 Make sure that escaping of `:' works in target names.5 Make sure that escaping of ':' works in target names. 6 6 Make sure escaping of whitespace works in target names. 7 Make sure that escaping of '#' works."; 8 9 10 close(MAKEFILE); 7 Make sure that escaping of '#' works. 8 Make sure that backslash before non-special characters are kept."; 11 9 12 10 … … 27 25 run_make_test(undef, 28 26 'path=pre:', 29 "#MAKEFILE#:2: *** target pattern contains no `%'. Stop.",27 "#MAKEFILE#:2: *** target pattern contains no '%'. Stop.", 30 28 512); 31 29 … … 40 38 run_make_test(undef, 41 39 "'path=pre\\\\:'", 42 "#MAKEFILE#:2: *** target pattern contains no `%'. Stop.",40 "#MAKEFILE#:2: *** target pattern contains no '%'. Stop.", 43 41 512); 44 42 … … 55 53 'foo#bar.ext = (foo#bar.ext)'); 56 54 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. 59 run_make_test(q! 60 foo: foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar 61 foo 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 67 run_make_test(q! 68 all: ..\foo 69 .DEFAULT: ; : '$@' 70 !, 71 '', ": '..\\foo'\n"); 72 57 73 # This tells the test driver that the perl test script executed properly. 58 74 1; -
vendor/gnumake/current/tests/scripts/features/include
r2596 r3138 1 1 # -*-mode: perl; rm-trailing-spaces: nil-*- 2 2 3 $description = "Test various forms of the GNU make `include' command.";3 $description = "Test various forms of the GNU make 'include' command."; 4 4 5 5 $details = "\ … … 61 61 ', 62 62 '', 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", 64 64 512 65 65 ); … … 129 129 ', 130 130 '', 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", 132 132 512); 133 133 … … 145 145 ', 146 146 '', 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", 148 148 512); 149 149 … … 163 163 '', 164 164 "#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", 166 166 512); 167 168 # Test include of make-able file doesn't show an error (Savannah #102) 169 run_make_test(q! 170 .PHONY: default 171 default:; @echo DONE 172 173 inc1:; echo > $@ 174 include inc1 175 include inc2 176 inc2:; echo > $@ 177 !, 178 '', "echo > inc2\necho > inc1\nDONE\n"); 179 180 rmfiles('inc1', 'inc2'); 181 182 # Test include of non-make-able file does show an error (Savannah #102) 183 run_make_test(q! 184 .PHONY: default 185 default:; @echo DONE 186 187 inc1:; echo > $@ 188 include inc1 189 include inc2 190 !, 191 '', "#MAKEFILE#:7: inc2: No such file or directory\n#MAKE#: *** No rule to make target 'inc2'. Stop.\n", 512); 192 193 rmfiles('inc1'); 194 195 # Include same file multiple times 196 197 run_make_test(q! 198 default:; @echo DEFAULT 199 include inc1 200 inc1:; echo > $@ 201 include inc1 202 !, 203 '', "echo > inc1\nDEFAULT\n"); 204 205 rmfiles('inc1'); 206 207 # Included file has a prerequisite that fails to build 208 209 run_make_test(q! 210 default:; @echo DEFAULT 211 include inc1 212 inc1: foo; echo > $@ 213 foo:; 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 217 rmfiles('inc1'); 218 219 # Included file has a prerequisite we don't know how to build 220 221 run_make_test(q! 222 default:; @echo DEFAULT 223 include inc1 224 inc1: 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 228 rmfiles('inc1'); 229 230 # include a directory 167 231 168 232 if ($all_tests) { … … 173 237 foo: ; @echo foo = bar > $@ 174 238 !, 175 '', "#MAKE#: `foo' is up to date.\n");239 '', "#MAKE#: 'foo' is up to date.\n"); 176 240 rmfiles('foo'); 177 241 } -
vendor/gnumake/current/tests/scripts/features/mult_rules
r2596 r3138 48 48 49 49 # 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"; 51 51 52 52 &compare_output($answer,&get_logfile(1)); -
vendor/gnumake/current/tests/scripts/features/parallelism
r2596 r3138 42 42 2.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@", 43 43 "-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); 45 45 46 46 rmfiles(qw(1.inc 2.inc)); … … 61 61 2.inc: ; \@$sleep_command 1; echo THREE.inc; echo '2: ; \@$sleep_command 1; echo THREE' > \$\@", 62 62 "-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); 64 64 65 65 rmfiles(qw(1.inc 2.inc)); … … 92 92 93 93 fail.1 fail.2 fail.3: 94 \@ sleep\$(patsubst fail.%,%,\$\@)94 \@$sleep_command \$(patsubst fail.%,%,\$\@) 95 95 \@echo Fail 96 96 \@exit 1 97 97 98 98 ok: 99 \@ sleep499 \@$sleep_command 4 100 100 \@echo Ok done", 101 '-rR -j5', 'Fail102 #MAKE#: *** [ fail.1] Error 1101 '-rR -j5', "Fail 102 #MAKE#: *** [#MAKEFILE#:8: fail.1] Error 1 103 103 #MAKE#: *** Waiting for unfinished jobs.... 104 104 Fail 105 #MAKE#: *** [ fail.2] Error 1105 #MAKE#: *** [#MAKEFILE#:8: fail.2] Error 1 106 106 Fail 107 #MAKE#: *** [ fail.3] Error 1108 Ok done ',107 #MAKE#: *** [#MAKEFILE#:8: fail.3] Error 1 108 Ok done", 109 109 512); 110 110 … … 141 141 rmfiles('target'); 142 142 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'; 149 147 150 148 run_make_test(q! 149 things = thing1 thing2 150 all: $(things) 151 thing1:; @sleep 1; echo '$@ start'; sleep 2; echo '$@ end' 152 thing2:; @echo '$@ start'; sleep 2; echo '$@ end' 151 153 -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' > $@ 154 inc.mk: ; @touch $@ 162 155 !, 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 158 delete $extraENV{MAKEFLAGS}; 165 159 rmfiles('inc.mk'); 166 160 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 164 utouch(-15, 'file2'); 165 utouch(-10, 'file4'); 166 utouch(-5, 'file1'); 167 168 run_make_test(q! 169 .INTERMEDIATE: file3 170 file4: file3 ; @mv -f $< $@ 171 file3: file2 ; touch $@ 172 file2: file1 ; @touch $@ 177 173 !, 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 176 rmfiles('file1', 'file2', 'file3', 'file4'); 218 177 219 178 # Make sure that all jobserver FDs are closed if we need to re-exec the … … 253 212 254 213 1; 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 82 82 b%: pattern := good $$t 83 83 84 global := or ginal $$t84 global := original $$t 85 85 86 86 … … 104 104 endif 105 105 106 %z: ; @echo \'patt rn: $a;\'106 %z: ; @echo \'pattern: $a;\' 107 107 108 108 … … 110 110 ', 111 111 '', 112 'normal: global: or ginal $t pattern: inherit: ;113 patt rn: global: orginal $t pattern: inherit: ;');112 'normal: global: original $t pattern: inherit: ; 113 pattern: global: original $t pattern: inherit: ;'); 114 114 115 115 … … 119 119 'rec=1', 120 120 'normal: global: new $t pattern: good $t inherit: good $t; 121 patt rn: global: new $t pattern: good $t inherit: good $t;');121 pattern: global: new $t pattern: good $t inherit: good $t;'); 122 122 123 123 # TEST #8: override in pattern-specific variables -
vendor/gnumake/current/tests/scripts/features/patternrules
r2596 r3138 111 111 ', 112 112 "dir=$dir", 113 "#MAKE#: *** [ $dir/foo.bar] Error 1",113 "#MAKE#: *** [#MAKEFILE#:6: $dir/foo.bar] Error 1", 114 114 512); 115 115 … … 204 204 !, 205 205 'foo.tex', 206 "#MAKE#: *** No rule to make target `foo.tex'. Stop.", 512);206 "#MAKE#: *** No rule to make target 'foo.tex'. Stop.", 512); 207 207 208 208 unlink(@f); … … 223 223 # This tells the test driver that the perl test script executed properly. 224 224 1; 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 19 19 ('CFLAGS=-O -w' . ($parallel_jobs ? ' -j 2' : '')), 20 20 ($vos 21 ? "#MAKE#: Entering directory `#PWD#'21 ? "#MAKE#: Entering directory '#PWD#' 22 22 make 'CFLAGS=-O' -f #MAKEFILE# foo 23 23 make CFLAGS=-O … … 27 27 MAKELEVEL = 0 28 28 THE END 29 #MAKE#: Leaving directory `#PWD#'"30 : "#MAKE#: Entering directory `#PWD#'29 #MAKE#: Leaving directory '#PWD#'" 30 : "#MAKE#: Entering directory '#PWD#' 31 31 #MAKEPATH# -f #MAKEFILE# foo 32 #MAKE#[1]: Entering directory `#PWD#'32 #MAKE#[1]: Entering directory '#PWD#' 33 33 #MAKEPATH# 34 34 MAKELEVEL = 1 35 35 #MAKEPATH# -f #MAKEFILE# last 36 #MAKE#[2]: Entering directory `#PWD#'36 #MAKE#[2]: Entering directory '#PWD#' 37 37 #MAKEPATH# 38 38 MAKELEVEL = 2 39 39 THE 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#'")); 43 43 44 44 -
vendor/gnumake/current/tests/scripts/features/reinvoke
r2596 r3138 58 58 # including: this and the previous one test different parts of the code. 59 59 60 run_make_test(undef, "F=b", "[ -f b ] || echo >> b\nhello\n")60 run_make_test(undef, 'F=b', "[ -f b ] || echo >> b\nhello\n") 61 61 62 62 &rmfiles('a','b','c'); 63 63 64 # Ensure command line variables are preserved properly across re-exec 65 # Tests for Savannah bug #30723 66 67 run_make_test(' 68 ifdef RECURSE 69 -include foo30723 70 endif 71 recurse: ; @$(MAKE) -f $(MAKEFILE_LIST) RECURSE=1 test 72 test: ; @echo F.O=$(F.O) 73 foo30723: ; @touch $@ 74 ', 75 '--no-print-directory F.O=bar', "F.O=bar\n"); 76 77 unlink('foo30723'); 78 64 79 # This tells the test driver that the perl test script executed properly. 65 80 1; -
vendor/gnumake/current/tests/scripts/features/se_explicit
r2596 r3138 6 6 # TEST #0: Test handing of '$' in prerequisites with and without second 7 7 # expansion. 8 9 # If we don't support archives then the prerequisite is different 10 my $prereq = exists $FEATURES{'archives'} ? '$' : '$(PRE)'; 8 11 9 12 run_make_test(q! … … 19 22 !, 20 23 '', 21 " \$\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");24 "$prereq\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz"); 22 25 23 26 run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz"); … … 116 119 all : $$(eval $$(info test)) 117 120 !, 118 '', "test\n#MAKE#: Nothing to be done for `all'.\n");121 '', "test\n#MAKE#: Nothing to be done for 'all'.\n"); 119 122 120 123 # TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new … … 153 156 154 157 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 160 run_make_test(q! 161 .PHONY: foo.bar 162 .SECONDEXPANSION: 163 foo: $$(@\\:%=%.bar); @echo '$^' 164 !, 165 '', "foo.bar\n"); 166 156 167 1; -
vendor/gnumake/current/tests/scripts/features/se_implicit
r2596 r3138 223 223 '', "\n"); 224 224 225 # Test #10: Test second expansion with second expansion prerequisites 226 # Ensures pattern_search() recurses with SE prereqs. 227 touch('a'); 228 run_make_test(q! 229 .SECONDEXPANSION: 230 sim_base_rgg := just_a_name 231 sim_base_src := a 232 sim_base_f := a a a 233 sim_%.f: $${sim_$$*_f} 234 echo $@ 235 sim_%.src: $${sim_$$*_src} 236 echo $@ 237 sim_%: \ 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 245 unlink('a'); 246 247 # Ensure that order-only tokens embedded in second expansions are parsed 248 run_make_test(q! 249 .SECONDEXPANSION: 250 PREREQS=p1|p2 251 P2=p2 252 all : foo bar 253 f%o: $$(PREREQS) ; @echo '$@' from '$^' and '$|' 254 b%r: p1|$$(P2) ; @echo '$@' from '$^' and '$|' 255 p% : ; : $@ 256 !, 257 "", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n"); 258 225 259 # This tells the test driver that the perl test script executed properly. 226 260 1; -
vendor/gnumake/current/tests/scripts/features/targetvars
r2596 r3138 238 238 run_make_test(undef, 'FOO=C', "C f1\n"); 239 239 240 # TEST #19: Conditional variables with command-line settings 241 242 run_make_test(' 243 a: FOO ?= f1 244 a: ; @echo "$(FOO)" 245 ', 246 '', "f1\n"); 247 248 run_make_test(undef, 'FOO=C', "C\n"); 249 240 250 # TEST #20: Check for continuation after semicolons 241 251 242 252 run_make_test(q! 243 a: A = 'hello; 253 a: A = 'hello;\ 244 254 world' 245 255 a: ; @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"; 2 3 3 4 $details = ""; 4 5 5 open(MAKEFILE,"> $makefile"); 6 run_make_test(' 7 x = variable1 8 variable2 := Hello 9 y = $(subst 1,2,$(x)) 10 z = y 11 a := $($($(z))) 12 all: 13 @echo $(a) 14 ', 15 '', "Hello\n"); 6 16 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 8 21 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)); 22 run_make_test(' 23 VARIABLE = $(eval VARIABLE := echo hi)$(VARIABLE) 24 wololo: 25 @$(VARIABLE) 26 ', 27 '', "hi\n"); 27 28 28 29 1; -
vendor/gnumake/current/tests/scripts/features/vpath
r2596 r3138 75 75 vpath-d/fail.te: 76 76 !, 77 '', "#MAKE#: Nothing to be done for `default'.\n");77 '', "#MAKE#: Nothing to be done for 'default'.\n"); 78 78 79 79 rmdir('vpath-d'); -
vendor/gnumake/current/tests/scripts/features/vpath3
r2596 r3138 1 # 1 # -*-perl-*- 2 2 3 3 $description = "Test the interaction of the -lfoo feature and vpath"; 4 4 $details = ""; 5 5 6 open(MAKEFILE,"> $makefile"); 6 my @dirs_to_make = qw(a1 b1 a2 b2 b3); 7 for my $d (@dirs_to_make) { 8 mkdir($d, 0777); 9 } 7 10 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 11 my @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"); 33 18 &touch(@files_to_touch); 34 19 35 &run_make_with_options($makefile,"",&get_logfile); 20 my $answer = "a1${pathsep}lib1.a a1${pathsep}libc.a " . 21 "a2${pathsep}lib2.a lib3.a\n"; 22 if ($port_type eq 'VMS-DCL') { 23 $answer =~ s/ /,/g; 24 } 36 25 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"; 26 run_make_test(' 27 vpath %.h b3 28 vpath %.a a1 29 vpath %.so b1 30 vpath % a2 b2 31 vpath % b3 32 all: -l1 -lc -l2 -l3; @echo $^ 33 ', 34 '', $answer); 39 35 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"); 36 unlink(@files_to_touch); 37 for my $d (@dirs_to_make) { 38 rmdir($d); 48 39 } 49 40 -
vendor/gnumake/current/tests/scripts/features/vpathgpath
r2596 r3138 58 58 push(@touchedfiles, "bar.c"); 59 59 60 $answer = "$make_name: Nothing to be done for `general'.\n";60 $answer = "$make_name: Nothing to be done for 'general'.\n"; 61 61 62 62 &compare_output($answer,&get_logfile(1)); -
vendor/gnumake/current/tests/scripts/features/vpathplus
r2596 r3138 87 87 $answer = "not creating notarget.c from notarget.d 88 88 cat notarget.c > notarget.b 2>/dev/null || exit 1 89 $make_name: *** [ notarget.b] Error 189 $make_name: *** [$makefile:16: notarget.b] Error 1 90 90 "; 91 91 … … 127 127 128 128 1; 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 5 5 results.\n"; 6 6 7 open(MAKEFILE, "> $makefile"); 8 9 # The Contents of the MAKEFILE ... 10 11 print MAKEFILE <<'EOMAKE'; 7 run_make_test(q! 12 8 # Simple, just reverse two things 13 9 # 14 10 reverse = $2 $1 15 11 16 # A complex `map' function, using recursive `call'.12 # A complex 'map' function, using recursive 'call'. 17 13 # 18 14 map = $(foreach a,$2,$(call $1,$a)) … … 39 35 DEP_baz = quux blarp 40 36 rest = $(wordlist 2,$(words ${1}),${1}) 41 tclose = $(if $1,$(firstword $1) 37 tclose = $(if $1,$(firstword $1)\ 42 38 $(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1)))) 43 39 … … 49 45 echo '$(call my-if,a,b,c)'; \ 50 46 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"); 52 50 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. 60 54 # 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"; 71 59 72 60 # TEST eclipsing of arguments when invoking sub-calls 73 61 74 $makefile2 = &get_tmpfile; 75 76 open(MAKEFILE,"> $makefile2"); 77 78 print MAKEFILE <<'EOF'; 79 62 run_make_test(q! 80 63 all = $1 $2 $3 $4 $5 $6 $7 $8 $9 81 64 … … 89 72 @echo $(call level2,1,2,3,4,5,6,7,8) 90 73 @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"); 92 76 93 close(MAKEFILE); 77 # Ensure that variables are defined in global scope even in a $(call ...) 94 78 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)); 79 delete $ENV{X123}; 80 81 run_make_test(' 82 tst = $(eval export X123) 83 $(call tst) 84 all: ; @echo "$${X123-not set}" 85 ', 86 '', "\n"); 98 87 99 88 1; 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 55 55 56 56 &run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512); 57 $answer = "Some stuff\n$makefile:1 6: *** error is definitely. Stop.\n";57 $answer = "Some stuff\n$makefile:17: *** error is definitely. Stop.\n"; 58 58 &compare_output($answer,&get_logfile(1)); 59 59 … … 67 67 1; 68 68 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 1 1 # -*-perl-*- 2 2 3 $description = "Test the filter -out function.";3 $description = "Test the filter and filter-out functions."; 4 4 5 5 $details = "The makefile created in this test has two variables. The … … 12 12 functions is the same single .elc name.\n"; 13 13 14 open(MAKEFILE,"> $makefile"); 14 # Basic test -- filter 15 run_make_test(q! 16 files1 := $(filter %.o, foo.elc bar.o lose.o) 17 files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o) 18 all: ; @echo '$(files1) $(files2)' 19 !, 20 '', "bar.o lose.o foo.i bar.o lose.o\n"); 15 21 16 print MAKEFILE <<'EOF'; 22 # Basic test -- filter-out 23 run_make_test(q! 17 24 files1 := $(filter-out %.o, foo.elc bar.o lose.o) 18 25 files2 := $(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 26 all: ; @echo '$(files1) $(files2)' 27 !, 28 '', "foo.elc foo.elc\n"); 21 29 22 close(MAKEFILE); 30 # Escaped patterns 31 run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!, 32 '', "foo%bar\n"); 23 33 24 &run_make_with_options($makefile, "", &get_logfile, 0); 25 $answer = "foo.elc foo.elc\n"; 26 &compare_output($answer,&get_logfile(1)); 34 run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!, 35 '', "foo%%\\%%bar\n"); 36 37 run_make_test(q! 38 X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar) 39 all:;@echo '$(X)'!, 40 '', "foo\\%bar\n"); 27 41 28 42 1; -
vendor/gnumake/current/tests/scripts/functions/foreach
r2596 r3138 1 1 # -*-perl-*- 2 # $Id : foreach,v 1.5 2006/03/10 02:20:46 psmith Exp$2 # $Id$ 3 3 4 4 $description = "Test the foreach function."; … … 54 54 'FOREACH'); 55 55 56 # Allow variable names with trailing space 57 run_make_test(q! 58 $(foreach \ 59 a \ 60 , b c d \ 61 , $(info $a)) 62 all:;@: 63 !, 64 "", "b\nc\nd\n"); 56 65 57 # TEST 2: Check some error conditions. 66 # Allow empty variable names. We still expand the body. 67 68 run_make_test(' 69 x = $(foreach ,1 2 3,a) 70 y := $x 71 72 all: ; @echo $y', 73 '', "a a a\n"); 74 75 # Check some error conditions. 58 76 59 77 run_make_test(' … … 63 81 all: ; @echo $y', 64 82 '', 65 "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'. Stop.",83 "#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'foreach'. Stop.", 66 84 512); 67 85 68 86 run_make_test(' 69 x = $(foreach )87 x = $(foreach x,y) 70 88 y := $x 71 89 72 90 all: ; @echo $y', 73 91 '', 74 "#MAKEFILE#:2: *** insufficient number of arguments ( 1) to function `foreach'. Stop.",92 "#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'foreach'. Stop.", 75 93 512); 76 94 -
vendor/gnumake/current/tests/scripts/functions/shell
r2596 r3138 5 5 $details = ''; 6 6 7 # Test standard shell 8 run_make_test('.PHONY: all 9 OUT := $(shell echo hi) 10 all: ; @echo $(OUT) 11 ','','hi'); 7 12 8 13 # Test shells inside rules. 9 14 run_make_test('.PHONY: all 10 15 all: ; @echo $(shell echo hi) 11 ','','hi'); 16 ','','hi'); 17 18 # Verify .SHELLSTATUS 19 run_make_test('.PHONY: all 20 PRE := $(.SHELLSTATUS) 21 $(shell exit 0) 22 OK := $(.SHELLSTATUS) 23 $(shell exit 1) 24 BAD := $(.SHELLSTATUS) 25 all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD) 26 ','','PRE= OK=0 BAD=1'); 12 27 13 28 … … 28 43 .PHONY: all 29 44 all: ; @echo $$HI 30 ','','hi'); 45 ','','hi'); 46 47 # Test shell errors in recipes including offset 48 run_make_test(' 49 all: 50 @echo hi 51 $(shell ./basdfdfsed there) 52 @echo there 53 ', 54 '', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n"); 31 55 32 56 1; 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-*- 5 2 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 4 the ability of make to sort lists of object. Sort 5 will also remove any duplicate entries. This will also 6 be tested."; 9 7 10 open(MAKEFILE,"> $makefile"); 8 $details = "The make file is built with a list of object in a random order 9 and includes some duplicates. Make should sort all of the elements 10 remove all duplicates\n"; 11 11 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"; 12 run_make_test(' 13 foo := moon_light days 14 foo1:= jazz 15 bar := captured 16 bar2 = boy end, has rise A midnight 17 bar3:= $(foo) 18 s1 := _by 19 s2 := _and_a 20 t1 := $(addsuffix $(s1), $(bar) ) 21 t2 := $(addsuffix $(s2), $(foo1) ) 22 t3 := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) 23 t4 := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) 24 t5 := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) 25 t6 := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) 26 t7 := $(t6) $(t6) $(t6) 27 p1 := $(addprefix $(foo1), $(s2) ) 28 blank:= 29 all: 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 35 A boy captured_by days end, has jazz_and_a midnight moon_light rise 36 A boy captured_by days end, has jazz_and_a midnight moon_light rise 37 '); 34 38 35 39 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. 37 42 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)); 43 run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff 44 all: ; \@echo \$(words \$(sort \$(FOO)))\n", 45 '', "6\n"); 48 46 49 47 1; 50 48 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 53 53 54 54 &run_make_with_options($makefile, "WARNING4=definitely", &get_logfile, 0); 55 $answer = "Some stuff\n$makefile:1 4: warning is definitely\nhi\nthere\n";55 $answer = "Some stuff\n$makefile:15: warning is definitely\nhi\nthere\n"; 56 56 &compare_output($answer,&get_logfile(1)); 57 58 # Test linenumber offset 59 60 run_make_test(q! 61 all: one two 62 $(warning in $@ line 3) 63 @true 64 $(warning in $@ line 5) 65 66 one 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"); 57 77 58 78 # This tells the test driver that the perl test script executed properly. 59 79 1; 60 80 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 89 89 '', "\n"); 90 90 91 # TEST #5: wildcard used to verify file existence 92 93 touch('xxx.yyy'); 94 95 run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, 96 '', "file=xxx.yyy\n"); 97 98 unlink('xxx.yyy'); 99 100 run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, 101 '', "file=\n"); 102 91 103 1; -
vendor/gnumake/current/tests/scripts/functions/word
r2596 r3138 57 57 wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))', 58 58 'word-e1', 59 "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''. Stop.",59 "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''. Stop.", 60 60 512); 61 61 62 62 run_make_test(undef, 63 63 '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.", 65 65 512); 66 66 67 67 run_make_test(undef, 68 68 '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.", 70 70 512); 71 71 72 72 run_make_test(undef, 73 73 'wordlist-e1', 74 "#MAKEFILE#:7: *** non-numeric first argument to `wordlist' function: ''. Stop.",74 "#MAKEFILE#:7: *** non-numeric first argument to 'wordlist' function: ''. Stop.", 75 75 512); 76 76 77 77 run_make_test(undef, 78 78 '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.", 80 80 512); 81 81 82 82 run_make_test(undef, 83 83 '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.", 85 85 512); 86 86 … … 95 95 wordlist-e: ; @echo $(WL)', 96 96 '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.", 98 98 512); 99 99 100 100 run_make_test(undef, 101 101 '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.", 103 103 512); 104 104 105 105 run_make_test(undef, 106 106 '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.", 108 108 512); 109 109 110 110 run_make_test(undef, 111 111 '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.", 113 113 512); 114 114 115 115 run_make_test(undef, 116 116 '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.", 118 118 512); 119 119 120 120 run_make_test(undef, 121 121 '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.", 123 123 512); 124 124 125 125 run_make_test(undef, 126 126 '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.", 128 128 512); 129 129 -
vendor/gnumake/current/tests/scripts/misc/general3
r2596 r3138 27 27 28 28 \$(STR) \$(TAB)", 29 '', "#MAKE#: Nothing to be done for `all'.");29 '', "#MAKE#: Nothing to be done for 'all'."); 30 30 31 31 # TEST 2 … … 311 311 foo bar'); 312 312 313 run_make_test('x:;@-exit 1', '', "#MAKE#: [#MAKEFILE#:1: x] Error 1 (ignored)\n"); 314 313 315 1; -
vendor/gnumake/current/tests/scripts/options/dash-B
r2596 r3138 23 23 '', 'cp bar.x foo'); 24 24 25 run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");25 run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'."); 26 26 run_make_test(undef, '-B', 'cp bar.x foo'); 27 27 … … 29 29 30 30 utouch(1000, 'foo'); 31 run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");31 run_make_test(undef, '', "#MAKE#: Nothing to be done for 'all'."); 32 32 run_make_test(undef, '-B', 'cp bar.x foo'); 33 33 … … 46 46 ', 47 47 '-B', 'MAKE_RESTARTS= 48 #MAKEFILE#:4: foo.x: No such file or directory49 48 MAKE_RESTARTS=1'); 50 49 … … 64 63 ', 65 64 '-B', 'MAKE_RESTARTS= 66 #MAKEFILE#:4: foo.x: No such file or directory67 65 MAKE_RESTARTS=1 68 66 blah.x … … 84 82 85 83 1; 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 35 35 36 36 # 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" 38 38 . "$delete_command EXAMPLE\n" 39 . "$make_name: Leaving directory `$wpath'\n";39 . "$make_name: Leaving directory '$wpath'\n"; 40 40 41 41 &compare_output($answer,&get_logfile(1)); … … 63 63 64 64 # 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" 66 66 . "$delete_command EXAMPLEslash\n" 67 . "$make_name: Leaving directory `$wpath'\n";67 . "$make_name: Leaving directory '$wpath'\n"; 68 68 69 69 &compare_output($answer,&get_logfile(1)); -
vendor/gnumake/current/tests/scripts/options/dash-I
r2596 r3138 52 52 53 53 $answer = "$mkpath ANOTHER -f $makefile 54 ${make_name}[1]: Entering directory `$pwd'54 ${make_name}[1]: Entering directory '$pwd' 55 55 This is another included makefile 56 ${make_name}[1]: Leaving directory `$pwd'\n";56 ${make_name}[1]: Leaving directory '$pwd'\n"; 57 57 58 58 &run_make_with_options($makefile,"-I $workdir recurse",&get_logfile); -
vendor/gnumake/current/tests/scripts/options/dash-W
r2596 r3138 13 13 # Run it again: nothing should happen 14 14 15 run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");15 run_make_test(undef, '', "#MAKE#: 'a.x' is up to date."); 16 16 17 17 # Now run it with -W b.x: should rebuild a.x … … 22 22 23 23 utouch(1000, 'a.x'); 24 run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");24 run_make_test(undef, '', "#MAKE#: 'a.x' is up to date."); 25 25 run_make_test(undef, '-W b.x', 'echo >> a.x'); 26 26 … … 43 43 baz.x: bar.x ; @echo "touch $@" 44 44 ', 45 '', '#MAKEFILE#:3: foo.x: No such file or directory 46 echo >> bar.x 45 '', 'echo >> bar.x 47 46 touch foo.x 48 47 restarts=1 … … 87 86 88 87 1; 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 43 43 "$workdir${pathsep}commands.c","$workdir${pathsep}display.c", 44 44 "$workdir${pathsep}buffer.h", 45 45 "$workdir${pathsep}command.c"); 46 46 47 47 &touch(@files_to_touch); … … 58 58 # Create the answer to what should be produced by this Makefile 59 59 $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'. 61 61 cc -c commands.c 62 62 cc -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"; 64 64 65 65 # COMPARE RESULTS … … 93 93 94 94 $answer = "exit 1 95 $make_name: *** [ foo.o] Error 196 $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"; 97 97 98 98 &compare_output($answer, &get_logfile(1)); … … 107 107 '-k', 108 108 "#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'. 111 111 hi\n", 112 112 512); -
vendor/gnumake/current/tests/scripts/options/dash-n
r2596 r3138 4 4 $details = "Try various uses of -n and ensure they all give the correct results.\n"; 5 5 6 open(MAKEFILE, "> $makefile");6 touch('orig'); 7 7 8 # The Contents of the MAKEFILE ... 9 10 print MAKEFILE <<'EOMAKE'; 11 8 run_make_test(q! 12 9 final: intermediate ; echo >> $@ 13 10 intermediate: 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"); 26 13 27 14 # TEST 1 28 15 29 &run_make_with_options($makefile, "-Worig -n", &get_logfile); 30 $answer = "echo >> intermediate\necho >> final\n"; 31 &compare_output($answer, &get_logfile(1)); 16 run_make_test(undef, '-Worig -n', "echo >> intermediate\necho >> final\n"); 32 17 33 unlink('orig', 'intermediate', 'final');18 rmfiles(qw(orig intermediate final)); 34 19 35 20 # 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 ... 37 24 38 25 $makefile2 = &get_tmpfile; … … 57 44 58 45 &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"; 60 47 &compare_output($answer, &get_logfile(1)); 61 48 … … 63 50 64 51 &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"; 66 53 &compare_output($answer, &get_logfile(1)); 67 54 68 unlink('a', 'b', 'c'); 55 # TEST 4 56 57 unlink(qw(a b)); 58 59 &run_make_with_options($makefile2, "-t -n", &get_logfile); 60 61 open(DASH_N_LOG, ">>" . &get_logfile(1)); 62 print DASH_N_LOG "a exists but should not!\n" if -e 'a'; 63 print DASH_N_LOG "b exists but should not!\n" if -e 'b'; 64 close(DASH_N_LOG); 65 66 &compare_output("touch b\ntouch a\n", &get_logfile(1)); 67 68 # CLEANUP 69 70 unlink(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 78 open(MAKEFILE, "> $topmake"); 79 print MAKEFILE <<"EOF"; 80 foo: ; \@\$(MAKE) -f "$submake" bar 81 EOF 82 close(MAKEFILE); 83 84 85 # The bar target should print what would happen, but not actually run 86 open(MAKEFILE, "> $submake"); 87 print MAKEFILE <<'EOF'; 88 inc: ; touch $@ 89 -include inc 90 bar: ; @echo $(strip $(MAKEFLAGS)) 91 EOF 92 close(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 98 unlink('inc'); 69 99 70 100 1; -
vendor/gnumake/current/tests/scripts/options/dash-q
r2596 r3138 6 6 # TEST 0 7 7 8 run_make_test( '8 run_make_test(qq! 9 9 one: 10 10 two: ; 11 11 three: ; : 12 four: ; $(.XY)13 five: ; \ 14 $(.XY)15 six: ; \ 16 $(.XY)17 18 seven: ; \ 19 $(.XY)20 21 22 ',12 four: ; \$(.XY) 13 five: ; \\ 14 \$(.XY) 15 six: ; \\ 16 \$(.XY) 17 \t\$(.XY) 18 seven: ; \\ 19 \$(.XY) 20 \t: foo 21 \t\$(.XY) 22 !, 23 23 '-q one', ''); 24 24 … … 55 55 '-q', '', 256); 56 56 57 # TEST 7 : Savannah bug # 42249 58 # Make sure we exit with 1 even for prerequisite updates 59 run_make_test(' 60 build-stamp: ; echo $@ 61 build-arch: build-stamp 62 build-x: build-arch 63 build-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 69 run_make_test(' 70 build-stamp: ; echo $@ 71 build-arch: build-stamp-2 72 build-x: build-arch 73 build-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 79 run_make_test(' 80 foo: bar ; echo foo 81 bar: ; @$(MAKE) -f #MAKEFILE# baz 82 baz: ; echo baz 83 ', 84 '-q foo', '', 256); 85 57 86 1; -
vendor/gnumake/current/tests/scripts/options/eval
r2596 r3138 17 17 "eval\neval\nall\nrecurse"); 18 18 19 # Make sure that --eval is handled correctly during restarting 20 run_make_test(q! 21 all: ; @echo $@ 22 -include gen.mk 23 gen.mk: ; @echo > $@ 24 !, 25 '--eval=\$\(info\ eval\)', "eval\neval\nall"); 26 27 unlink('gen.mk'); 28 19 29 1; -
vendor/gnumake/current/tests/scripts/options/symlinks
r2596 r3138 27 27 # With -L, it should update targ 28 28 run_make_test('targ: sym ; @echo make $@ from $<', '', 29 "#MAKE#: `targ' is up to date.");29 "#MAKE#: 'targ' is up to date."); 30 30 run_make_test(undef, '-L', "make targ from sym"); 31 31 … … 37 37 # Now update targ; in all cases targ should be up to date. 38 38 &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."); 41 41 42 42 # Add in a new link between sym and dep. Be sure it's newer than targ. … … 47 47 # Without -L, nothing should happen 48 48 # 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."); 50 50 run_make_test(undef, '-L', "make targ from sym"); 51 51 … … 57 57 symlink("../$dirname/dep", 'sym'); 58 58 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); 60 60 61 61 run_make_test('targ: sym ; @echo make $@ from $<', '-L', -
vendor/gnumake/current/tests/scripts/options/warn-undefined-variables
r2596 r3138 19 19 # With --warn-undefined-variables, it should warn me 20 20 run_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' 23 23 ref"); 24 24 -
vendor/gnumake/current/tests/scripts/targets/DEFAULT
r2596 r3138 36 36 37 37 # 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" 39 39 . "Executing rule BAR\n" 40 . "${make_name}[1]: Leaving directory `$pwd'\n";40 . "${make_name}[1]: Leaving directory '$pwd'\n"; 41 41 42 42 # COMPARE RESULTS -
vendor/gnumake/current/tests/scripts/targets/INTERMEDIATE
r2596 r3138 43 43 44 44 &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"; 46 46 &compare_output($answer, &get_logfile(1)); 47 47 … … 64 64 65 65 &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"; 67 67 &compare_output($answer, &get_logfile(1)); 68 68 -
vendor/gnumake/current/tests/scripts/targets/ONESHELL
r2596 r3138 5 5 $details = ""; 6 6 7 # Some shells (*shakes fist at Solaris*) cannot handle multiple flags in 8 # separate arguments. 9 my $t = `/bin/sh -e -c true 2>/dev/null`; 10 my $multi_ok = $? == 0; 7 11 8 12 # Simple … … 17 21 [ 0"$a" -eq "$$" ] || echo fail 18 22 '); 23 24 # Simple but use multi-word SHELLFLAGS 25 26 if ($multi_ok) { 27 run_make_test(q! 28 .ONESHELL: 29 .SHELLFLAGS = -e -c 30 all: 31 a=$$$$ 32 [ 0"$$a" -eq "$$$$" ] || echo fail 33 !, 34 '', 'a=$$ 35 [ 0"$a" -eq "$$" ] || echo fail 36 '); 37 } 19 38 20 39 # Again, but this time with inner prefix chars -
vendor/gnumake/current/tests/scripts/targets/POSIX
r2596 r3138 1 1 # -*-perl-*- 2 2 3 $description = "Test the behaviour of the .P HONYtarget.";3 $description = "Test the behaviour of the .POSIX target."; 4 4 5 5 $details = ""; … … 18 18 all: ; \@$script 19 19 !, 20 '', "#MAKE#: *** [ all] Error $err\n", 512);20 '', "#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512); 21 21 22 22 # User settings must override .POSIX … … 30 30 '', $out); 31 31 32 # Test the default value of various POSIX-specific variables 33 my %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'); 41 my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX); 42 my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX); 43 run_make_test(qq! 44 .POSIX: 45 all: 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); 53 run_make_test(undef, '', $r); 54 32 55 # This tells the test driver that the perl test script executed properly. 33 56 1; -
vendor/gnumake/current/tests/scripts/targets/SECONDARY
r2596 r3138 45 45 46 46 &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"; 48 48 &compare_output($answer, &get_logfile(1)); 49 49 … … 68 68 69 69 &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"; 71 71 &compare_output($answer, &get_logfile(1)); 72 72 … … 104 104 105 105 &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"; 107 107 &compare_output($answer, &get_logfile(1)); 108 108 … … 130 130 %.c : %.b ; cp $< $@ 131 131 %.b : %.a ; cp $< $@ 132 all : 1.c 2.c', '-rR -j', 132 all : 1.c 2.c 133 2.a: 1.c', '-rR -j', 133 134 'cp 1.a 1.b 135 cp 1.b 1.c 134 136 cp 2.a 2.b 135 cp 1.b 1.c136 137 cp 2.b 2.c 137 138 rm 1.b 2.b'); -
vendor/gnumake/current/tests/scripts/variables/DEFAULT_GOAL
r2596 r3138 43 43 ', 44 44 '', 45 '#MAKE#: *** No rule to make target `foo\'. Stop.',45 "#MAKE#: *** No rule to make target 'foo'. Stop.", 46 46 512); 47 47 -
vendor/gnumake/current/tests/scripts/variables/LIBPATTERNS
r2596 r3138 21 21 all: -lfoo ; @echo "build $@ from $<" 22 22 ', 23 '', "#MAKE#: .LIBPATTERNS element `mtest_foo.a' is not a pattern23 '', "#MAKE#: .LIBPATTERNS element 'mtest_foo.a' is not a pattern 24 24 build all from mtest_foo.a\n"); 25 25 -
vendor/gnumake/current/tests/scripts/variables/MAKE
r2596 r3138 17 17 '', 18 18 "#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"); 21 21 22 22 rmfiles("foo"); -
vendor/gnumake/current/tests/scripts/variables/MAKEFLAGS
r2596 r3138 1 # 1 # -*-perl-*- 2 2 3 3 $description = "Test proper behavior of MAKEFLAGS"; … … 9 9 all: ; @echo $(MAKEFLAGS) 10 10 !, 11 '-e -r -R', ' Rre');11 '-e -r -R', 'erR'); 12 12 13 13 # Long arguments mean everything is prefixed with "-" … … 15 15 all: ; @echo $(MAKEFLAGS) 16 16 !, 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 18 echo erR --trace --no-print-directory 19 erR --trace --no-print-directory"); 18 20 19 21 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 24 run_make_test(q! 24 25 MSG = Fails 25 26 all: … … 27 28 @MSG=Works $(MAKE) -e -f #MAKEFILE# jump 28 29 jump: 29 @echo '$@ : MAKEFLAGS=$(MAKEFLAGS)'30 @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)' 30 31 @$(MAKE) -f #MAKEFILE# print 31 32 print: 32 @echo '$@: MAKEFLAGS=$(MAKEFLAGS)' 33 @echo $(MSG) 33 @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)' 34 34 .PHONY: all jump print 35 35 !, 36 36 '--no-print-directory', 37 37 'all: MAKEFLAGS= --no-print-directory 38 jump: MAKEFLAGS= --no-print-directory -e 39 print: MAKEFLAGS= --no-print-directory -e 40 Works'); 41 } 38 jump Works: MAKEFLAGS=e --no-print-directory 39 print Works: MAKEFLAGS=e --no-print-directory'); 42 40 43 41 1; 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 12 12 ', 13 13 '', 'MAKE_RESTARTS= 14 #MAKEFILE#:4: foo.x: No such file or directory15 14 MAKE_RESTARTS=1'); 16 15 … … 27 26 ', 28 27 '', 'MAKE_RESTARTS= 29 #MAKEFILE#:4: foo.x: No such file or directory30 28 MAKE_RESTARTS=1 31 foo.x:1: bar.x: No such file or directory32 29 MAKE_RESTARTS=2'); 33 30 … … 48 45 ', 49 46 '', "MAKE_RESTARTS= 50 #MAKEFILE#:8: foo.x: No such file or directory51 47 MAKE_RESTARTS=1 52 foo.x:1: bar.x: No such file or directory53 48 MAKE_RESTARTS=2 54 49 recurse MAKE_RESTARTS= 50 #MAKE#[1]: Entering directory '#PWD#' 55 51 MAKE_RESTARTS= 56 #MAKE#[1]: Entering directory `#PWD#'57 52 all MAKE_RESTARTS= 58 #MAKE#[1]: Leaving directory `#PWD#'");53 #MAKE#[1]: Leaving directory '#PWD#'"); 59 54 60 55 rmfiles('foo.x', 'bar.x'); 61 56 62 57 1; 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 71 71 '', $out); 72 72 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. 77 my $t = `/bin/sh -e -c true 2>/dev/null`; 78 my $multi_ok = $? == 0; 79 80 if ($multi_ok) { 81 $flags = '-x -c'; 82 run_make_test(qq! 83 .SHELLFLAGS = $flags 84 all: ; \@$script 85 !, 86 '', $out); 87 } 88 73 89 # We can't just use "false" because on different systems it provides a 74 90 # different exit code--once again Solaris: false exits with 255 not 1 … … 82 98 all: ; \@$script 83 99 !, 84 '', "$out#MAKE#: *** [ all] Error $err\n", 512);100 '', "$out#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512); 85 101 86 102 1; -
vendor/gnumake/current/tests/scripts/variables/define
r2596 r3138 31 31 endef 32 32 33 define posix ::= 34 @echo $(FOO) 35 endef 36 33 37 append = @echo a 34 38 … … 50 54 all: ; $(multi) 51 55 $(simple) 56 $(posix) 52 57 $(append) 53 58 $(cond) 54 59 ', 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 64 run_make_test(' 65 FOO = foo 66 67 define multi= 68 echo hi 69 @echo $(FOO) 70 endef # this is the end 71 72 define simple:= 73 @echo $(FOO) 74 endef 75 76 define posix::= 77 @echo $(FOO) 78 endef 79 80 append = @echo a 81 82 define append+= 83 84 @echo b 85 endef 86 87 define cond?= # this is a conditional 88 @echo first 89 endef 90 91 define cond?= 92 @echo second 93 endef 94 95 FOO = there 96 97 all: ; $(multi) 98 $(simple) 99 $(posix) 100 $(append) 101 $(cond) 102 ', 103 '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n"); 56 104 57 105 # TEST 2: define in true section of conditional (containing conditional) … … 113 161 all: ; @echo ok 114 162 ', 115 '', "#MAKEFILE#:3: extraneous text after `define' directive\nok\n");163 '', "#MAKEFILE#:3: extraneous text after 'define' directive\nok\n"); 116 164 117 165 # TEST 7: NEGATIVE: extra text after endef … … 124 172 all: ; @echo ok 125 173 ', 126 '', "#MAKEFILE#:5: extraneous text after `endef' directive\nok\n");174 '', "#MAKEFILE#:5: extraneous text after 'endef' directive\nok\n"); 127 175 128 176 # TEST 8: NEGATIVE: missing endef … … 135 183 endef$(NAME) 136 184 ', 137 '', "#MAKEFILE#:4: *** missing `endef', unterminated `define'. Stop.\n", 512);185 '', "#MAKEFILE#:4: *** missing 'endef', unterminated 'define'. Stop.\n", 512); 138 186 139 187 # ------------------------- -
vendor/gnumake/current/tests/scripts/variables/flavors
r2596 r3138 74 74 '', "Hello\n"); 75 75 76 # TEST 6: Simple using POSIX syntax 77 run_make_test(' 78 bar = Goodbye 79 foo ::= $(bar) 80 bar = ${ugh} 81 ugh = Hello 82 all: ; @echo $(foo) 83 ', 84 '', "Goodbye\n"); 85 86 # TEST 7: POSIX syntax no spaces 87 run_make_test(' 88 bar = Goodbye 89 foo::=$(bar) 90 bar = ${ugh} 91 ugh = Hello 92 all: ; @echo $(foo) 93 ', 94 '', "Goodbye\n"); 95 76 96 1; -
vendor/gnumake/current/tests/scripts/variables/private
r2596 r3138 76 76 '', "b=a\na=a\n"); 77 77 78 # 9: make sure private suppresses inheritance 79 run_make_test(q! 80 DEFS = FOO 81 all: bar1 82 bar1: private DEFS += 1 83 bar3: private DEFS += 3 84 bar1: bar2 85 bar2: bar3 86 bar1 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 92 run_make_test(q! 93 IA = global 94 PA = global 95 PS = global 96 S = global 97 PS = global 98 SV = global 99 b%: IA += b% 100 b%: private PA += b% 101 b%: private PS = b% 102 bar: all 103 bar: IA += bar 104 bar: private PA += bar 105 bar: private PS = bar 106 a%: IA += a% 107 a%: private PA += a% 108 a%: private PS = a% 109 all: IA += all 110 all: private PA += all 111 all: private PS = all 112 113 bar all: ; @echo '$@: IA=$(IA)'; echo '$@: PA=$(PA)'; echo '$@: PS=$(PS)' 114 !, 115 '', "all: IA=global b% bar a% all 116 all: PA=global a% all 117 all: PS=all 118 bar: IA=global b% bar 119 bar: PA=global b% bar 120 bar: PS=bar\n"); 121 78 122 1; -
vendor/gnumake/current/tests/scripts/variables/special
r2596 r3138 15 15 BAR := bar 16 16 17 all: 18 @echo X1 = $(X1) 19 @echo X2 = $(X2) 20 @echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES))) 17 all: ; @echo X1 = $(X1); echo X2 = $(X2); echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES))) 21 18 ', 22 19 '', "X1 =\nX2 = FOO\nLAST = BAR FOO\n"); 23 20 21 # SV 45728: Test that undefining a variable is reflected properly 24 22 23 &run_make_test(' 24 FOO := foo 25 BAR := bar 26 $(info one: $(sort $(filter FOO BAR BAZ,$(.VARIABLES)))) 27 undefine BAR 28 BAZ := baz 29 $(info two: $(sort $(filter FOO BAR BAZ,$(.VARIABLES)))) 30 all:;@: 31 ', 32 '', "one: BAR FOO\ntwo: BAZ FOO\n"); 25 33 26 34 # $makefile2 = &get_tmpfile; … … 32 40 33 41 # all: foo 34 # 35 # 36 # 42 # @echo X1 = $(X1) 43 # @echo X2 = $(X2) 44 # @echo LAST = $(sort $(.TARGETS)) 37 45 38 46 # X2 := $(sort $(.TARGETS)) … … 54 62 &run_make_test(' 55 63 define foo 56 : foo-one 64 : foo-one\ 57 65 foo-two 58 66 : foo-three … … 115 123 : foo-four'); 116 124 125 # Test that the "did you mean TAB" message is printed properly 126 127 run_make_test(q! 128 $x. 129 !, 130 '', '#MAKEFILE#:2: *** missing separator. Stop.', 512); 131 132 run_make_test(q! 133 foo: 134 bar 135 !, 136 '', '#MAKEFILE#:3: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.', 512); 137 138 run_make_test(q! 139 .RECIPEPREFIX = : 140 foo: 141 bar 142 !, 143 '', '#MAKEFILE#:4: *** missing separator. Stop.', 512); 144 117 145 1; 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 6 6 # Modified 92-02-11 through 92-02-22 by Chris Arthur to further generalize. 7 7 # 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. 11 9 # This file is part of GNU Make. 12 10 # … … 31 29 # variables and then calls &toplevel, which does all the real work. 32 30 33 # $Id : test_driver.pl,v 1.30 2010/07/28 05:39:50 psmith Exp$31 # $Id$ 34 32 35 33 … … 51 49 $test_passed = 1; 52 50 53 54 51 # Timeout in seconds. If the test takes longer than this we'll fail it. 55 52 $test_timeout = 5; 53 $test_timeout = 10 if $^O eq 'VMS'; 56 54 57 55 # Path to Perl … … 65 63 %extraENV = (); 66 64 65 sub 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 67 92 # %origENV is the caller's original environment 68 %origENV = %ENV; 93 if ($^O ne 'VMS') { 94 %origENV = %ENV; 95 } else { 96 my $proc_env = vms_get_process_logicals; 97 %origENV = %{$proc_env}; 98 } 69 99 70 100 sub resetENV … … 73 103 # through Perl 5.004. It was fixed in Perl 5.004_01, but we don't 74 104 # 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 80 126 foreach $v (keys %extraENV) { 81 127 $ENV{$v} = $extraENV{$v}; … … 90 136 foreach (# UNIX-specific things 91 137 'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH', 138 'LD_LIBRARY_PATH', 92 139 # Purify things 93 140 'PURIFYOPTIONS', … … 107 154 # Replace the environment with the new one 108 155 # 109 %origENV = %ENV ;156 %origENV = %ENV unless $^O eq 'VMS'; 110 157 111 158 resetENV(); … … 132 179 &parse_command_line (@ARGV); 133 180 134 print "OS name = `$osname'\n" if $debug;181 print "OS name = '$osname'\n" if $debug; 135 182 136 183 $workpath = "$cwdslash$workdir"; … … 140 187 141 188 &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 } 142 208 143 209 if (-d $workpath) … … 167 233 push (@rmdirs, $dir); 168 234 -d "$workpath/$dir" 169 235 || mkdir ("$workpath/$dir", 0777) 170 236 || &error ("Couldn't mkdir $workpath/$dir: $!\n"); 171 237 } … … 176 242 print "Finding tests...\n"; 177 243 opendir (SCRIPTDIR, $scriptpath) 178 244 || &error ("Couldn't opendir $scriptpath: $!\n"); 179 245 @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR) ); 180 246 closedir (SCRIPTDIR); … … 183 249 next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d "$scriptpath/$dir"); 184 250 push (@rmdirs, $dir); 251 # VMS can have overlayed file systems, so directories may repeat. 252 next if -d "$workpath/$dir"; 185 253 mkdir ("$workpath/$dir", 0777) 186 254 || &error ("Couldn't mkdir $workpath/$dir: $!\n"); 187 255 opendir (SCRIPTDIR, "$scriptpath/$dir") 188 256 || &error ("Couldn't opendir $scriptpath/$dir: $!\n"); 189 257 @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR) ); 190 258 closedir (SCRIPTDIR); … … 192 260 { 193 261 -d $test and next; 194 262 push (@TESTS, "$dir/$test"); 195 263 } 196 264 } … … 204 272 print "\n"; 205 273 206 &run_each_test;274 run_all_tests(); 207 275 208 276 foreach $dir (@rmdirs) … … 222 290 print " in $categories_failed Categor"; 223 291 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"; 225 293 return 0; 226 294 } … … 241 309 $osname = defined($^O) ? $^O : ''; 242 310 311 if ($osname eq 'VMS') 312 { 313 $vos = 0; 314 $pathsep = "/"; 315 return; 316 } 317 243 318 # Find a path to Perl 244 319 … … 277 352 if ($osname =~ /not found/i) 278 353 { 279 354 $osname = "(something posixy with no uname)"; 280 355 } 281 356 elsif ($@ ne "" || $?) … … 284 359 if ($@ ne "" || $?) 285 360 { 286 287 361 $osname = "(something posixy)"; 362 } 288 363 } 289 364 $vos = 0; … … 417 492 } 418 493 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 } 494 sub 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 } 541 626 } 542 627 … … 655 740 local($slurp, $answer_matched) = ('', 0); 656 741 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 this662 # 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 666 742 ++$tests_run; 667 743 668 if ($slurp eq $answer) { 669 $answer_matched = 1; 744 if (! defined $answer) { 745 print "Ignoring output ........ " if $debug; 746 $answer_matched = 1; 670 747 } 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 } 687 893 } 688 }689 894 } 690 895 … … 708 913 local($command) = "diff -c " . &get_basefile . " " . $logfile; 709 914 &run_command_with_output(&get_difffile,$command); 710 } else { 711 &rmfiles (); 712 } 713 714 $suite_passed = 0; 915 } 916 715 917 return 0; 716 918 } … … 732 934 } 733 935 936 my @OUTSTACK = (); 937 my @ERRSTACK = (); 938 734 939 sub attach_default_output 735 940 { … … 744 949 } 745 950 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); 757 961 } 758 962 … … 771 975 } 772 976 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); 790 985 } 791 986 … … 801 996 802 997 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 } 806 1031 alarm 0; 807 1032 }; 808 1033 if ($@) { 809 1034 # The eval failed. If it wasn't SIGALRM then die. 810 $@ eq "timeout\n" or die ;1035 $@ eq "timeout\n" or die "Command failed: $@"; 811 1036 812 1037 # Timed out. Resend the alarm to our process group to kill the children. … … 827 1052 my $code = _run_command(@_); 828 1053 print "run_command returned $code.\n" if $debug; 829 1054 print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $^O eq 'VMS'; 830 1055 return $code; 831 1056 } … … 842 1067 print "\nrun_command_with_output($filename,$runname): @_\n" if $debug; 843 1068 &attach_default_output ($filename); 844 my $code = _run_command(@_); 1069 my $code = eval { _run_command(@_) }; 1070 my $err = $@; 845 1071 &detach_default_output; 1072 1073 $err and die $err; 1074 846 1075 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'; 848 1077 return $code; 849 1078 } … … 905 1134 else 906 1135 { 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 } 908 1145 } 909 1146 } … … 943 1180 foreach $file (@_) { 944 1181 (open(T, ">> $file") && print(T "\n") && close(T)) 945 1182 || &error("Couldn't touch $file: $!\n", 1); 946 1183 } 947 1184 } -
vendor/gnumake/current/variable.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 21 19 #include <assert.h> 22 20 21 #include "filedef.h" 23 22 #include "dep.h" 24 #include "filedef.h"25 23 #include "job.h" 26 24 #include "commands.h" … … 31 29 #endif 32 30 #include "hash.h" 31 32 /* Incremented every time we add or remove a global variable. */ 33 static unsigned long variable_changenum; 33 34 34 35 /* Chain of all pattern-specific variables. */ … … 101 102 { 102 103 struct pattern_var *p; 103 unsigned int targlen = strlen (target);104 unsigned int targlen = strlen (target); 104 105 105 106 for (p = start ? start->next : pattern_vars; p != 0; p = p->next) … … 162 163 } 163 164 164 #ifndef 165 #define VARIABLE_BUCKETS 165 #ifndef VARIABLE_BUCKETS 166 #define VARIABLE_BUCKETS 523 166 167 #endif 167 #ifndef 168 #define PERFILE_VARIABLE_BUCKETS23168 #ifndef PERFILE_VARIABLE_BUCKETS 169 #define PERFILE_VARIABLE_BUCKETS 23 169 170 #endif 170 #ifndef 171 #define SMALL_SCOPE_VARIABLE_BUCKETS13171 #ifndef SMALL_SCOPE_VARIABLE_BUCKETS 172 #define SMALL_SCOPE_VARIABLE_BUCKETS 13 172 173 #endif 173 174 … … 184 185 { 185 186 hash_init (&global_variable_set.table, VARIABLE_BUCKETS, 186 187 variable_hash_1, variable_hash_2, variable_hash_cmp); 187 188 } 188 189 … … 198 199 const char *value, enum variable_origin origin, 199 200 int recursive, struct variable_set *set, 200 const structfloc *flocp)201 const floc *flocp) 201 202 { 202 203 struct variable *v; … … 210 211 var_key.length = length; 211 212 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 212 242 213 243 if (env_overrides && origin == o_env) 214 244 origin = o_env_override; 215 245 216 v = *var_slot;217 246 if (! HASH_VACANT (v)) 218 247 { 219 248 if (env_overrides && v->origin == o_env) 220 221 222 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; 223 252 224 253 /* A variable of this name is already defined. 225 226 254 If the old definition is from a stronger source 255 than this one, don't redefine it. */ 227 256 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); 232 260 if (flocp != 0) 233 261 v->fileinfo = *flocp; 234 262 else 235 263 v->fileinfo.filenm = 0; 236 237 238 264 v->origin = origin; 265 v->recursive = recursive; 266 } 239 267 return v; 240 268 } … … 246 274 v->length = length; 247 275 hash_insert_at (&set->table, v, var_slot); 276 if (set == &global_variable_set) 277 ++variable_changenum; 278 248 279 v->value = xstrdup (value); 249 280 if (flocp != 0) … … 286 317 287 318 static void 288 free_variable_name_and_value (const void *item); 319 free_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 326 void 327 free_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 } 289 334 290 335 void … … 311 356 { 312 357 if (env_overrides && v->origin == o_env) 313 314 315 316 317 /* If the definition is from a stronger source than this one, don't318 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. */ 319 364 if ((int) origin >= (int) v->origin) 320 365 { 321 366 hash_delete_at (&set->table, var_slot); 322 367 free_variable_name_and_value (v); 323 } 368 free (v); 369 if (set == &global_variable_set) 370 ++variable_changenum; 371 } 324 372 } 325 373 } … … 338 386 lookup_special_var (struct variable *var) 339 387 { 340 static unsigned long last_ var_count= 0;388 static unsigned long last_changenum = 0; 341 389 342 390 … … 366 414 */ 367 415 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")) 370 417 { 371 418 unsigned long max = EXPANSION_INCREMENT (strlen (var->value)); … … 403 450 *(p-1) = '\0'; 404 451 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; 410 454 } 411 455 … … 417 461 /* Lookup a variable whose name is a string starting at NAME 418 462 and with LENGTH chars. NAME need not be null-terminated. 419 Returns address of the `struct variable' containing all info463 Returns address of the 'struct variable' containing all info 420 464 on the variable, or nil if no such variable is defined. */ 421 465 … … 438 482 v = (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key); 439 483 if (v && (!is_parent || !v->private_var)) 440 484 return v->special ? lookup_special_var (v) : v; 441 485 442 486 is_parent |= setlist->next_is_parent; … … 444 488 445 489 #ifdef VMS 446 /* since we don't read envp[] on startup, try to get the447 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() */ 448 492 { 449 493 char *vname = alloca (length + 1); … … 505 549 /* Lookup a variable whose name is a string starting at NAME 506 550 and with LENGTH chars in set SET. NAME need not be null-terminated. 507 Returns address of the `struct variable' containing all info551 Returns address of the 'struct variable' containing all info 508 552 on the variable, or nil if no such variable is defined. */ 509 553 … … 538 582 { 539 583 l = (struct variable_set_list *) 540 584 xmalloc (sizeof (struct variable_set_list)); 541 585 l->set = xmalloc (sizeof (struct variable_set)); 542 586 hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS, … … 642 686 set = xmalloc (sizeof (struct variable_set)); 643 687 hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS, 644 688 variable_hash_1, variable_hash_2, variable_hash_cmp); 645 689 646 690 setlist = (struct variable_set_list *) … … 653 697 } 654 698 655 static void656 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 void664 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 672 699 /* Create a new variable set and push it on the current setlist. 673 700 If we're pushing a global scope (that is, the current scope is the global … … 679 706 push_new_variable_scope (void) 680 707 { 681 current_variable_set_list = create_new_variable_set ();708 current_variable_set_list = create_new_variable_set (); 682 709 if (current_variable_set_list->next == &global_setlist) 683 710 { … … 702 729 703 730 /* 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); 705 732 706 733 if (current_variable_set_list != &global_setlist) … … 740 767 struct variable **from_var_end = from_var_slot + from_set->table.ht_size; 741 768 769 int inc = to_set == &global_variable_set ? 1 : 0; 770 742 771 for ( ; from_var_slot < from_var_end; from_var_slot++) 743 772 if (! HASH_VACANT (*from_var_slot)) 744 773 { 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 } 756 788 } 757 789 } … … 787 819 { 788 820 if (last0 == 0) 789 821 *setlist0 = setlist1; 790 822 else 791 823 last0->next = setlist1; 792 824 } 793 825 } … … 800 832 define_automatic_variables (void) 801 833 { 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; 808 835 char buf[200]; 809 836 … … 812 839 813 840 sprintf (buf, "%s%s%s", 814 815 816 817 818 841 version_string, 842 (remote_description == 0 || remote_description[0] == '\0') 843 ? "" : "-", 844 (remote_description == 0 || remote_description[0] == '\0') 845 ? "" : remote_description); 819 846 define_variable_cname ("MAKE_VERSION", buf, o_default, 0); 847 define_variable_cname ("MAKE_HOST", make_host, o_default, 0); 820 848 821 849 #ifdef __MSDOS__ … … 831 859 if (mshp) 832 860 (void) define_variable (shell_str, shlen, 833 861 mshp->value, o_env_override, 0); 834 862 else if (comp) 835 863 { 836 837 838 839 840 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); 841 869 } 842 870 } … … 856 884 if (!replace || !*replace->value) 857 885 if (shell && *shell->value && (shell->origin == o_env 858 859 860 861 free(shell->value);862 863 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 } 865 893 866 894 /* Some people do not like cmd to be used as the default … … 882 910 /* overwrite $SHELL */ 883 911 (void) define_variable (shell_str, shlen, replace->value, 884 912 replace->origin, 0); 885 913 else 886 914 /* provide a definition if there is none */ 887 915 (void) define_variable (shell_str, shlen, default_shell, 888 916 o_default, 0); 889 917 } 890 918 … … 919 947 the automatic variables they are variations of. */ 920 948 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 */ 930 966 define_variable_cname ("@D", "$(patsubst %/,%,$(dir $@))", o_automatic, 1); 931 967 define_variable_cname ("%D", "$(patsubst %/,%,$(dir $%))", o_automatic, 1); … … 949 985 950 986 /* 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. 952 988 The child's MAKELEVEL variable is incremented. */ 953 989 … … 970 1006 971 1007 hash_init (&table, VARIABLE_BUCKETS, 972 1008 variable_hash_1, variable_hash_2, variable_hash_cmp); 973 1009 974 1010 /* Run through all the variable sets in the list, … … 980 1016 v_end = v_slot + set->table.ht_size; 981 1017 for ( ; v_slot < v_end; v_slot++) 982 983 984 985 986 987 988 989 990 991 992 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), 995 1031 &global_variable_set); 996 997 998 999 1000 1001 1002 1003 1004 1005 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; 1006 1042 1007 1043 /* The variable doesn't have a name that can be exported. */ … … 1009 1045 continue; 1010 1046 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; 1047 1082 makelevel_key.length = MAKELEVEL_LENGTH; 1048 1083 hash_delete (&table, &makelevel_key); … … 1055 1090 if (! HASH_VACANT (*v_slot)) 1056 1091 { 1057 1058 1059 1060 1061 1062 1063 1064 1065 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); 1066 1101 #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, ';'); 1070 1105 #endif 1071 1072 1073 1074 1075 1106 *result++ = xstrdup (concat (3, v->name, "=", value)); 1107 free (value); 1108 } 1109 else 1110 { 1076 1111 #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, ';'); 1080 1115 #endif 1081 1082 1116 *result++ = xstrdup (concat (3, v->name, "=", v->value)); 1117 } 1083 1118 } 1084 1119 … … 1108 1143 1109 1144 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 1149 static char * 1150 shell_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 1110 1169 /* Given a variable, a value, and a flavor, define the variable. 1111 1170 See the try_variable_definition() function for details on the parameters. */ 1112 1171 1113 1172 struct variable * 1114 do_variable_definition (const structfloc *flocp, const char *varname,1173 do_variable_definition (const floc *flocp, const char *varname, 1115 1174 const char *value, enum variable_origin origin, 1116 1175 enum variable_flavor flavor, int target_var) … … 1133 1192 /* A simple variable definition "var := value". Expand the value. 1134 1193 We have to allocate memory since otherwise it'll clobber the 1135 1194 variable buffer, and we may still need that if we're looking at a 1136 1195 target-specific variable. */ 1137 1196 p = alloc_value = allocated_variable_expand (value); 1138 1197 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 } 1139 1208 case f_conditional: 1140 1209 /* A conditional variable definition "var ?= value". … … 1149 1218 case f_recursive: 1150 1219 /* A recursive variable definition "var = value". 1151 1220 The value is used verbatim. */ 1152 1221 p = value; 1153 1222 break; … … 1205 1274 memcpy (&alloc_value[oldlen + 1], val, vallen + 1); 1206 1275 1207 if (tp) 1208 free (tp); 1276 free (tp); 1209 1277 } 1210 1278 } … … 1214 1282 /* Many Unix Makefiles include a line saying "SHELL=/bin/sh", but 1215 1283 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, 1217 1285 $SHELL in the environment, if set, points to the real pathname of 1218 1286 the shell. … … 1233 1301 /* See if we can find "/bin/sh.exe", "/bin/sh.com", etc. */ 1234 1302 if (__dosexec_find_on_path (p, NULL, shellpath)) 1235 1236 1237 1238 1303 { 1304 char *tp; 1305 1306 for (tp = shellpath; *tp; tp++) 1239 1307 if (*tp == '\\') 1240 1308 *tp = '/'; 1241 1309 1242 1310 v = define_variable_loc (varname, strlen (varname), 1243 1311 shellpath, origin, flavor == f_recursive, 1244 1312 flocp); 1245 1313 } 1246 1314 else 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 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++) 1279 1347 if (*tp == '\\') 1280 1348 *tp = '/'; 1281 1349 1282 1350 v = define_variable_loc (varname, strlen (varname), 1283 1351 shellpath, origin, 1284 1352 flavor == f_recursive, flocp); 1285 1286 1287 1288 1289 1290 1353 } 1354 else 1355 v = lookup_variable (varname, strlen (varname)); 1356 1357 free (path_string); 1358 } 1291 1359 } 1292 1360 else … … 1296 1364 && streq (varname, "SHELL")) 1297 1365 { 1298 extern c har *default_shell;1366 extern const char *default_shell; 1299 1367 1300 1368 /* Call shell locator function. If it returns TRUE, then 1301 1369 set no_default_sh_exe to indicate sh was found and 1302 1370 set new value for SHELL variable. */ 1303 1371 … … 1331 1399 v = lookup_variable (varname, strlen (varname)); 1332 1400 1333 if (tp) 1334 free (tp); 1401 free (tp); 1335 1402 } 1336 1403 } … … 1352 1419 v->conditional = conditional; 1353 1420 1354 if (alloc_value) 1355 free (alloc_value); 1421 free (alloc_value); 1356 1422 1357 1423 return v->special ? set_special_var (v) : v; … … 1361 1427 /* Parse P (a null-terminated string) as a variable definition. 1362 1428 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. 1364 1431 1365 1432 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 */ 1367 1440 1368 1441 char * 1369 parse_variable_definition (const char *p, enum variable_flavor *flavor)1442 parse_variable_definition (const char *p, struct variable *var) 1370 1443 { 1371 1444 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; 1374 1450 1375 1451 while (1) … … 1378 1454 1379 1455 /* If we find a comment or EOS, it's not a variable definition. */ 1380 if ( c == '\0' || c == '#')1381 1456 if (STOP_SET (c, MAP_COMMENT|MAP_NUL)) 1457 return NULL; 1382 1458 1383 1459 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 1395 1474 /* '$$' 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 } 1411 1489 continue; 1412 1490 } 1413 1491 1414 1492 /* If we find whitespace skip it, and remember we found it. */ 1415 if ( isblank ((unsigned char)c))1493 if (ISBLANK (c)) 1416 1494 { 1417 1495 wspace = 1; 1418 p = next_token (p); 1496 e = p - 1; 1497 NEXT_TOKEN (p); 1419 1498 c = *p; 1420 1499 if (c == '\0') … … 1425 1504 1426 1505 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 (:=, +=, ?=, !=) */ 1433 1514 if (*p == '=') 1434 1515 { … … 1436 1517 { 1437 1518 case ':': 1438 *flavor = f_simple;1519 var->flavor = f_simple; 1439 1520 break; 1440 1521 case '+': 1441 *flavor = f_append;1522 var->flavor = f_append; 1442 1523 break; 1443 1524 case '?': 1444 *flavor = f_conditional; 1525 var->flavor = f_conditional; 1526 break; 1527 case '!': 1528 var->flavor = f_shell; 1445 1529 break; 1446 1530 default: … … 1452 1536 continue; 1453 1537 } 1454 return (char *)++p; 1538 if (! e) 1539 e = p - 1; 1540 ++p; 1541 break; 1455 1542 } 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 } 1459 1558 1460 1559 /* If we skipped whitespace, non-assignments means no var. */ … … 1463 1562 } 1464 1563 1564 var->length = e - var->name; 1565 var->value = next_token (p); 1465 1566 return (char *)p; 1466 1567 } … … 1469 1570 /* Try to interpret LINE (a null-terminated string) as a variable definition. 1470 1571 1471 If LINE was recognized as a variable definition, a pointer to its `struct1572 If LINE was recognized as a variable definition, a pointer to its 'struct 1472 1573 variable' is returned. If LINE is not a variable definition, NULL is 1473 1574 returned. */ 1474 1575 1475 1576 struct variable * 1476 assign_variable_definition (struct variable *v, char *line) 1477 { 1478 char *beg; 1479 char *end; 1480 enum variable_flavor flavor; 1577 assign_variable_definition (struct variable *v, const char *line) 1578 { 1481 1579 char *name; 1482 1580 1483 beg = next_token (line); 1484 line = parse_variable_definition (beg, &flavor); 1485 if (!line) 1581 if (!parse_variable_definition (line, v)) 1486 1582 return NULL; 1487 1583 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 1495 1584 /* 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'; 1499 1588 v->name = allocated_variable_expand (name); 1500 1589 1501 1590 if (v->name[0] == '\0') 1502 fatal (&v->fileinfo, _("empty variable name"));1591 O (fatal, &v->fileinfo, _("empty variable name")); 1503 1592 1504 1593 return v; … … 1515 1604 See the comments for assign_variable_definition(). 1516 1605 1517 If LINE was recognized as a variable definition, a pointer to its `struct1606 If LINE was recognized as a variable definition, a pointer to its 'struct 1518 1607 variable' is returned. If LINE is not a variable definition, NULL is 1519 1608 returned. */ 1520 1609 1521 1610 struct variable * 1522 try_variable_definition (const struct floc *flocp,char *line,1611 try_variable_definition (const floc *flocp, const char *line, 1523 1612 enum variable_origin origin, int target_var) 1524 1613 { … … 1554 1643 switch (v->origin) 1555 1644 { 1645 case o_automatic: 1646 origin = _("automatic"); 1647 break; 1556 1648 case o_default: 1557 1649 origin = _("default"); … … 1570 1662 break; 1571 1663 case o_override: 1572 origin = _("`override' directive"); 1573 break; 1574 case o_automatic: 1575 origin = _("automatic"); 1664 origin = _("'override' directive"); 1576 1665 break; 1577 1666 case o_invalid: … … 1584 1673 fputs (" private", stdout); 1585 1674 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); 1588 1677 putchar ('\n'); 1589 1678 fputs (prefix, stdout); 1590 1679 1591 /* Is this a `define'? */1680 /* Is this a 'define'? */ 1592 1681 if (v->recursive && strchr (v->value, '\n') != 0) 1593 1682 printf ("define %s\n%s\nendef\n", v->name, v->value); … … 1601 1690 p = next_token (v->value); 1602 1691 if (p != v->value && *p == '\0') 1603 1604 1692 /* All whitespace. */ 1693 printf ("$(subst ,,%s)", v->value); 1605 1694 else if (v->recursive) 1606 1695 fputs (v->value, stdout); 1607 1696 else 1608 1609 1610 1611 1612 1613 1614 1697 /* Double up dollar signs. */ 1698 for (p = v->value; *p != '\0'; ++p) 1699 { 1700 if (*p == '$') 1701 putchar ('$'); 1702 putchar (*p); 1703 } 1615 1704 putchar ('\n'); 1616 1705 } 1706 } 1707 1708 1709 static void 1710 print_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 1719 static void 1720 print_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); 1617 1726 } 1618 1727 … … 1621 1730 the actual variable definitions (everything else is comments). */ 1622 1731 1623 void 1624 print_variable_set (struct variable_set *set, char *prefix) 1625 { 1626 hash_map_arg (&set->table, print_variable, prefix); 1732 static void 1733 print_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); 1627 1737 1628 1738 fputs (_("# variable set hash-table stats:\n"), stdout); … … 1639 1749 puts (_("\n# Variables\n")); 1640 1750 1641 print_variable_set (&global_variable_set, "" );1751 print_variable_set (&global_variable_set, "", 0); 1642 1752 1643 1753 puts (_("\n# Pattern-specific Variable Values")); … … 1645 1755 { 1646 1756 struct pattern_var *p; 1647 int rules = 0;1757 unsigned int rules = 0; 1648 1758 1649 1759 for (p = pattern_vars; p != 0; p = p->next) … … 1651 1761 ++rules; 1652 1762 printf ("\n%s :\n", p->target); 1653 print_variable (&p->variable, "# ");1763 print_variable (&p->variable, (void *)"# "); 1654 1764 } 1655 1765 … … 1668 1778 { 1669 1779 if (file->variables != 0) 1670 print_variable_set (file->variables->set, "# "); 1780 print_variable_set (file->variables->set, "# ", 1); 1781 } 1782 1783 void 1784 print_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 } 1671 1798 } 1672 1799 … … 1681 1808 return; 1682 1809 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. */ 1693 1814 convert_Path_to_windows32 (path, ';'); 1694 1815 environ_path = xstrdup (concat (3, "PATH", "=", path)); -
vendor/gnumake/current/variable.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 23 21 enum variable_origin 24 22 { 25 o_default, 26 o_env, 27 o_file, 28 o_env_override, 29 o_command, 30 o_override, /* Variable from an `override' directive. */31 o_automatic, 32 o_invalid 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. */ 33 31 }; 34 32 … … 36 34 { 37 35 f_bogus, /* Bogus (error) */ 38 f_simple, /* Simple definition (:= ) */36 f_simple, /* Simple definition (:= or ::=) */ 39 37 f_recursive, /* Recursive definition (=) */ 40 38 f_append, /* Appending definition (+=) */ 41 f_conditional /* Conditional definition (?=) */ 39 f_conditional, /* Conditional definition (?=) */ 40 f_shell /* Shell assignment (!=) */ 42 41 }; 43 42 44 43 /* Structure that represents one variable definition. 45 44 Each bucket of the hash table is a chain of these, 46 chained through `next'. */45 chained through 'next'. */ 47 46 48 47 #define EXP_COUNT_BITS 15 /* This gets all the bitfields into 32 bits */ … … 51 50 struct variable 52 51 { 53 char *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; 58 unsigned int append:1; 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 59 58 variable. */ 60 59 unsigned int conditional:1; /* Nonzero if set with a ?=. */ 61 unsigned int per_target:1; 60 unsigned int per_target:1; /* Nonzero if a target-specific variable. */ 62 61 unsigned int special:1; /* Nonzero if this is a special variable. */ 63 62 unsigned int exportable:1; /* Nonzero if the variable _could_ be 64 63 exported. */ 65 unsigned int expanding:1; 64 unsigned int expanding:1; /* Nonzero if currently being expanded. */ 66 65 unsigned int private_var:1; /* Nonzero avoids inheritance of this 67 66 target-specific variable. */ … … 70 69 expansions. */ 71 70 enum variable_flavor 72 flavor ENUM_BITFIELD (3); 71 flavor ENUM_BITFIELD (3); /* Variable flavor. */ 73 72 enum variable_origin 74 origin ENUM_BITFIELD (3); 73 origin ENUM_BITFIELD (3); /* Variable origin. */ 75 74 enum variable_export 76 75 { 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. */ 81 80 } export ENUM_BITFIELD (2); 82 81 }; … … 86 85 struct variable_set 87 86 { 88 struct hash_table table; 87 struct hash_table table; /* Hash table of variables. */ 89 88 }; 90 89 … … 93 92 struct variable_set_list 94 93 { 95 struct variable_set_list *next; 96 struct variable_set *set; 94 struct variable_set_list *next; /* Link in the chain. */ 95 struct variable_set *set; /* Variable set. */ 97 96 int next_is_parent; /* True if next is a parent target. */ 98 97 }; … … 112 111 extern struct variable_set_list *current_variable_set_list; 113 112 extern struct variable *default_goal_var; 113 extern struct variable shell_var; 114 114 115 115 /* expand.c */ … … 118 118 char *variable_expand_for_file (const char *line, struct file *file); 119 119 char *allocated_variable_expand_for_file (const char *line, struct file *file); 120 #define 120 #define allocated_variable_expand(line) \ 121 121 allocated_variable_expand_for_file (line, (struct file *) 0) 122 122 char *expand_argument (const char *str, const char *end); … … 135 135 const char *replace_percent); 136 136 char *patsubst_expand (char *o, const char *text, char *pattern, char *replace); 137 char *func_shell_base (char *o, char **argv, int trim_newlines); 138 void shell_completed (int exit_code, int exit_sig); 137 139 138 140 /* expand.c */ … … 148 150 void initialize_file_variables (struct file *file, int reading); 149 151 void print_file_variables (const struct file *file); 150 void print_ variable_set (struct variable_set *set, char *prefix);152 void print_target_variables (const struct file *file); 151 153 void merge_variable_set_lists (struct variable_set_list **to_list, 152 154 struct variable_set_list *from_list); 153 struct variable *do_variable_definition (const structfloc *flocp,155 struct variable *do_variable_definition (const floc *flocp, 154 156 const char *name, const char *value, 155 157 enum variable_origin origin, … … 157 159 int target_var); 158 160 char *parse_variable_definition (const char *line, 159 enum variable_flavor *flavor);160 struct variable *assign_variable_definition (struct variable *v, c har *line);161 struct variable *try_variable_definition (const struct floc *flocp,char *line,161 struct variable *v); 162 struct variable *assign_variable_definition (struct variable *v, const char *line); 163 struct variable *try_variable_definition (const floc *flocp, const char *line, 162 164 enum variable_origin origin, 163 165 int target_var); 164 166 void init_hash_global_variable_set (void); 165 167 void hash_init_function_table (void); 168 void define_new_function(const floc *flocp, const char *name, 169 unsigned int min, unsigned int max, unsigned int flags, 170 gmk_func_ptr func); 166 171 struct variable *lookup_variable (const char *name, unsigned int length); 167 172 struct variable *lookup_variable_in_set (const char *name, unsigned int length, … … 173 178 int recursive, 174 179 struct variable_set *set, 175 const structfloc *flocp);180 const floc *flocp); 176 181 177 182 /* Define a variable in the current variable set. */ … … 215 220 216 221 #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)); \ 221 226 }while(0) 222 227 … … 229 234 230 235 #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 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 19 17 /* We use <config.h> instead of "config.h" so that a compilation 20 18 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). */ 22 20 #include <config.h> 23 21 … … 26 24 #endif 27 25 28 c har *version_string = VERSION;29 c har *make_host = MAKE_HOST;26 const char *version_string = VERSION; 27 const char *make_host = MAKE_HOST; 30 28 31 29 -
vendor/gnumake/current/vmsdir.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 46 45 + 3) & ~3) 47 46 48 #define d_ino d_fileno /* compat ability */47 #define d_ino d_fileno /* compatibility */ 49 48 50 49 -
vendor/gnumake/current/vmsfunctions.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 16 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 17 16 18 #include "make .h"17 #include "makeint.h" 19 18 #include "debug.h" 20 19 #include "job.h" 21 20 21 #include <ctype.h> 22 #include <string.h> 23 22 24 #ifdef __DECC 23 25 #include <starlet.h> 24 26 #endif 25 #include <descrip.h> 27 26 28 #include <rms.h> 27 #include <iodef.h>28 #include <atrdef.h>29 #include <fibdef.h>30 29 #include "vmsdir.h" 31 30 … … 120 119 struct NAM *dnam = (struct NAM *)(dfab->fab$l_nam); 121 120 if (dnam != NULL) 122 121 free (dnam->nam$l_esa); 123 122 free (dnam); 124 123 free (dir); … … 129 128 #endif /* compiled for OpenVMS prior to V7.x */ 130 129 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. */ 133 const char * 134 vms_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. */ 160 const char * 161 vms_progname(const char* argv0) 148 162 { 149 163 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; 174 171 #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); 201 200 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'; 218 209 #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 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 23 22 #include <string.h> 24 23 #include <ctype.h> 24 25 #include "makeint.h" 25 26 26 27 #if VMS … … 139 140 reslt[resltlen] = '\0'; 140 141 141 s = malloc (resltlen+1); 142 if (s == 0) 143 return ""; 142 s = xmalloc (resltlen+1); 144 143 strcpy (s, reslt); 145 144 return s; … … 223 222 max 5 version 224 223 */ 225 #define MAXPATHLEN 512 224 /* todo: VMSMAXPATHLEN is defined for ODS2 names: it needs to be adjusted. */ 225 #define VMSMAXPATHLEN 512 226 226 227 227 enum namestate nstate; 228 static char vmsname[ MAXPATHLEN+1];228 static char vmsname[VMSMAXPATHLEN+1]; 229 229 const char *fptr; 230 230 const char *t; … … 404 404 if (*fptr == 0) /* just // */ 405 405 { 406 char cwdbuf[ MAXPATHLEN+1];407 408 s1 = getcwd(cwdbuf, MAXPATHLEN);406 char cwdbuf[VMSMAXPATHLEN+1]; 407 408 s1 = getcwd(cwdbuf, VMSMAXPATHLEN); 409 409 if (s1 == 0) 410 410 { … … 798 798 { /* got '..' or '../' */ 799 799 char *vp; 800 char cwdbuf[ MAXPATHLEN+1];801 802 vp = getcwd(cwdbuf, MAXPATHLEN);800 char cwdbuf[VMSMAXPATHLEN+1]; 801 802 vp = getcwd(cwdbuf, VMSMAXPATHLEN); 803 803 if (vp == 0) 804 804 { … … 858 858 { 859 859 char *vp; 860 char cwdbuf[ MAXPATHLEN+1];861 862 vp = getcwd(cwdbuf, MAXPATHLEN);860 char cwdbuf[VMSMAXPATHLEN+1]; 861 862 vp = getcwd(cwdbuf, VMSMAXPATHLEN); 863 863 if (vp == 0) 864 864 { -
vendor/gnumake/current/vmsjobs.c
r2596 r3138 2 2 This file must be #included in job.c, as it accesses static functions. 3 3 4 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 5 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 Copyright (C) 1996-2016 Free Software Foundation, Inc. 6 5 This file is part of GNU Make. 7 6 … … 22 21 #include <clidef.h> 23 22 23 /* TODO - VMS specific header file conditionally included in makeint.h */ 24 25 #include <stsdef.h> 26 #include <ssdef.h> 27 void 28 decc$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 49 enum auto_pipe { nopipe, add_pipe, dcl_pipe }; 50 24 51 char *vmsify (char *name, int type); 25 52 26 53 static int vms_jobsefnmask = 0; 54 55 /* returns whether path is assumed to be a unix like shell. */ 56 int 57 _is_unixy_shell (const char *path) 58 { 59 return vms_gnv_shell; 60 } 61 62 #define VMS_GETMSG_MAX 256 63 static char vms_strsignal_text[VMS_GETMSG_MAX + 2]; 64 65 char * 66 vms_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 27 82 28 83 /* Wait for nchildren children to terminate */ 29 84 static void 30 vmsWaitForChildren (int *status)85 vmsWaitForChildren (int *status) 31 86 { 32 87 while (1) 33 88 { 34 89 if (!vms_jobsefnmask) 35 36 37 38 90 { 91 *status = 0; 92 return; 93 } 39 94 40 95 *status = sys$wflor (32, vms_jobsefnmask); 41 96 } 42 97 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 else99 {100 p++;101 if (strchr (SEPCHARS, *p))102 break;103 alast = 1;104 }105 }106 else107 p++;108 }109 110 return p;111 98 } 112 99 … … 117 104 inner mode level AST. 118 105 */ 119 int120 vmsHandleChildTerm (struct child *child)106 static int 107 vmsHandleChildTerm (struct child *child) 121 108 { 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 { 126 118 vms_jobsefnmask &= ~(1 << (child->efn - 32)); 127 119 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 ; 145 151 #else 146 152 c = child; 147 153 #endif 148 154 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; 216 168 } 217 169 218 170 /* VMS: 219 171 Spawn a process executing the command in ARGV and return its pid. */ 220 221 #define MAXCMDLEN 200222 172 223 173 /* local helpers to make ctrl+c and ctrl+y working, see below */ … … 234 184 reEnableAst(void) 235 185 { 236 186 lib$enable_ctrl (&oldCtrlMask,0); 237 187 } 238 188 … … 240 190 astYHandler (void) 241 191 { 242 243 244 245 246 247 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; 248 198 } 249 199 … … 251 201 tryToSetupYAst(void) 252 202 { 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; 297 251 } 298 252 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 278 struct 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 */ 289 static char * 290 posix_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 */ 329 static char * 330 posix_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 */ 396 static char * 397 vms_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 */ 493 static char * 494 posix_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 522 const char *vms_filechars = "0123456789abcdefghijklmnopqrstuvwxyz" \ 523 "ABCDEFGHIJKLMNOPQRSTUVWXYZ[]<>:/_-.$"; 524 525 /* Simple text copy */ 526 static char * 527 parse_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 */ 592 static char * 593 parse_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 */ 613 static struct dsc$descriptor_s * 614 build_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 299 805 int 300 child_execute_job ( char *argv, struct child *child)806 child_execute_job (struct child *child, char *argv) 301 807 { 302 808 int i; 303 static struct dsc$descriptor_s cmddsc; 809 810 static struct dsc$descriptor_s *cmd_dsc; 304 811 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 312 812 int spflags = CLI$M_NOWAIT; 313 813 int status; 314 char *cmd = alloca (strlen (argv) + 512), *p, *q;315 char ifile[256], ofile[256], efile[256];316 814 int comnamelen; 317 815 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 */ 319 828 320 829 /* Parse IO redirection. */ 321 830 322 ifile[0] = 0;323 ofile[0] = 0;324 efile[0] = 0;325 831 child->comname = NULL; 326 832 … … 331 837 332 838 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 } 334 849 335 850 sprintf (procname, "GMAKE_%05x", getpid () & 0xfffff); 336 pnamedsc.dsc$w_length = strlen (procname);851 pnamedsc.dsc$w_length = strlen (procname); 337 852 pnamedsc.dsc$a_pointer = procname; 338 853 pnamedsc.dsc$b_dtype = DSC$K_DTYPE_T; 339 854 pnamedsc.dsc$b_class = DSC$K_CLASS_S; 340 855 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 352 894 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 */ 418 1166 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 } 469 1196 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) 485 1244 { 486 1245 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 */ 499 1251 if (outfile == 0) 500 1252 pfatal_with_name (_("fopen (temporary file)")); 501 1253 comnamelen = strlen (child->comname); 502 1254 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"); 601 1318 602 1319 fclose (outfile); 603 1320 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 } 613 1328 614 1329 child->efn = 0; 615 1330 while (child->efn < 32 || child->efn > 63) 616 1331 { 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)) 619 1334 { 620 1335 if (child->comname) … … 628 1343 } 629 1344 630 sys$clref(child->efn);1345 SYS$CLREF (child->efn); 631 1346 632 1347 vms_jobsefnmask |= (1 << (child->efn - 32)); 633 1348 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 */ 644 1370 645 1371 #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 is649 *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, neither651 *the spawning nor to the spawned one. Hence the caller needs to spawn652 *with CLI$M_NOWAIT to NOT give up the input focus. A sys$waitfr653 *has to follow to simulate the wanted synchronous behaviour.654 *The next problem is ctrl+y which isn't caught by the crtl and655 *therefore isn't converted to SIGQUIT (for a signal handler which is656 *already established). The only way to catch ctrl+y, is an AST657 *assigned to the input channel. But ctrl+y handling of DCL needs to be658 *disabled, otherwise it will handle it. Not to mention the previous659 *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 will661 *make it to the signal handler after the child "normally" terminates.662 *This isn't enough. It seems reasonable for simple command lines like663 *a 'cc foobar.c' spawned in a subprocess but it is unacceptable for664 *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 for667 *ctrl+y, if not one is set up for a channel to SYS$COMMAND. In general668 *this will work except if make is run in a batch environment, but there669 *nobody can press ctrl+y. During the setup the DCL handling of ctrl+y670 *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, force672 *an abort to the subprocess and signal SIGQUIT, which will be caught by673 *the already established handler and will bring us back to common code.674 *After the spawn (now /nowait) a sys$waitfr simulates the /wait and675 *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 common677 *signal handler. Because signals were blocked before entering this code678 *sys$waitfr will always complete and the SIGQUIT will be processed after679 *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 the681 *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 */ 683 1409 684 1410 if (!setupYAstTried) 685 1411 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); 698 1426 } 699 1427 #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; 708 1437 #endif 709 1438 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 { 714 1446 switch (status) 715 1447 { 716 case 0x1c:1448 case SS$_EXQUOTA: 717 1449 errno = EPROCLIM; 718 1450 break; … … 722 1454 } 723 1455 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 724 1467 return (status & 1); 725 1468 } -
vendor/gnumake/current/vpath.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 #include "filedef.h" 21 19 #include "variable.h" … … 29 27 struct vpath 30 28 { 31 struct vpath *next; 29 struct vpath *next; /* Pointer to next struct in the linked list. */ 32 30 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. */ 34 32 unsigned int patlen;/* Length of the pattern. */ 35 33 const char **searchpath; /* Null-terminated list of directories. */ … … 56 54 57 55 void 58 build_vpath_lists ( )56 build_vpath_lists (void) 59 57 { 60 58 register struct vpath *new = 0; … … 92 90 char gp[] = "%"; 93 91 94 /* Empty `vpaths' so the new one will have no next, and `vpaths'95 92 /* Empty 'vpaths' so the new one will have no next, and 'vpaths' 93 will still be nil if P contains no existing directories. */ 96 94 vpaths = 0; 97 95 … … 100 98 101 99 /* Store the created path as the general path, 102 100 and restore the old list of vpaths. */ 103 101 general_vpath = vpaths; 104 102 vpaths = save_vpaths; … … 125 123 char gp[] = "%"; 126 124 127 /* Empty `vpaths' so the new one will have no next, and `vpaths'128 125 /* Empty 'vpaths' so the new one will have no next, and 'vpaths' 126 will still be nil if P contains no existing directories. */ 129 127 vpaths = 0; 130 128 … … 133 131 134 132 /* Store the created path as the GPATH, 135 133 and restore the old list of vpaths. */ 136 134 gpaths = vpaths; 137 135 vpaths = save_vpaths; … … 151 149 pattern. If PATTERN is nil, remove all VPATH listings. Existing 152 150 and readable directories that are not "." given in the DIRPATH 153 separated by the path element separator (defined in make .h) are151 separated by the path element separator (defined in makeint.h) are 154 152 loaded into the directory hash table if they are not there already 155 153 and put in the VPATH searchpath for the given pattern with trailing … … 180 178 path = vpaths; 181 179 while (path != 0) 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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. */ 197 195 /* MSVC erroneously warns without a cast here. */ 198 199 200 201 202 203 204 205 196 free ((void *)path->searchpath); 197 free (path); 198 } 199 else 200 lastpath = path; 201 202 path = next; 203 } 206 204 207 205 return; … … 209 207 210 208 #ifdef WINDOWS32 211 convert_vpath_to_windows32 (dirpath, ';');209 convert_vpath_to_windows32 (dirpath, ';'); 212 210 #endif 213 211 214 212 /* 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)) 216 214 ++dirpath; 217 215 … … 223 221 p = dirpath; 224 222 while (*p != '\0') 225 if ( *p++ == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))223 if (STOP_SET (*p++, MAP_BLANK|MAP_PATHSEP)) 226 224 ++maxelem; 227 225 … … 240 238 while (*p != '\0' 241 239 #if defined(HAVE_DOS_PATHS) && (PATH_SEPARATOR_CHAR == ':') 242 243 244 245 246 247 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] == '\\'))) 248 246 #else 249 250 #endif 251 && !isblank ((unsigned char)*p))252 247 && *p != PATH_SEPARATOR_CHAR 248 #endif 249 && !ISBLANK (*p)) 250 ++p; 253 251 254 252 len = p - v; 255 253 /* Make sure there's no trailing slash, 256 254 but still allow "/" as a directory. */ 257 255 #if defined(__MSDOS__) || defined(__EMX__) || defined(HAVE_DOS_PATHS) 258 256 /* We need also to leave alone a trailing slash in "d:/". */ … … 260 258 #endif 261 259 if (len > 1 && p[-1] == '/') 262 260 --len; 263 261 264 262 /* Put the directory on the vpath list. */ 265 263 if (len > 1 || *v != '.') 266 264 { 267 265 vpath[elem++] = dir_name (strcache_add_len (v, len)); 268 266 if (len > maxvpath) 269 267 maxvpath = len; 270 268 } 271 269 272 270 /* Skip over separators and blanks between entries. */ 273 while ( *p == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))274 271 while (STOP_SET (*p, MAP_BLANK|MAP_PATHSEP)) 272 ++p; 275 273 } 276 274 … … 279 277 struct vpath *path; 280 278 /* ELEM is now incremented one element past the last 281 282 279 entry, to where the nil-pointer terminator goes. 280 Usually this is maxelem - 1. If not, shrink down. */ 283 281 if (elem < (maxelem - 1)) 284 282 vpath = xrealloc (vpath, (elem+1) * sizeof (const char *)); 285 283 286 284 /* Put the nil-pointer terminator on the end of the VPATH list. */ … … 312 310 gpath_search (const char *file, unsigned int len) 313 311 { 314 const char **gp;315 316 312 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 } 320 319 321 320 return 0; … … 341 340 unsigned int maxvpath = path->maxlen; 342 341 unsigned int i; 343 unsigned int flen, vlen,name_dplen;342 unsigned int flen, name_dplen; 344 343 int exists = 0; 345 344 … … 362 361 /* We need the rightmost slash or backslash. */ 363 362 { 364 const char *bslash = strrchr (file, '\\');363 const char *bslash = strrchr (file, '\\'); 365 364 if (!n || bslash > n) 366 365 n = bslash; … … 381 380 { 382 381 int exists_in_cache = 0; 383 char *p; 384 385 p = name; 382 char *p = name; 383 unsigned int vlen = strlen (vpath[i]); 386 384 387 385 /* Put the next VPATH entry into NAME at P and increment P past it. */ 388 vlen = strlen (vpath[i]);389 386 memcpy (p, vpath[i], vlen); 390 387 p += vlen; … … 392 389 /* Add the directory prefix already in *FILE. */ 393 390 if (name_dplen > 0) 394 391 { 395 392 #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 } 401 402 402 403 #ifdef HAVE_DOS_PATHS 403 404 /* Cause the next if to treat backslash and slash alike. */ 404 405 if (p != name && p[-1] == '\\' ) 405 406 p[-1] = '/'; 406 407 #endif 407 408 /* Now add the name-within-directory at the end of NAME. */ 408 409 #ifndef VMS 409 410 if (p != name && p[-1] != '/') 410 411 412 413 411 { 412 *p = '/'; 413 memcpy (p + 1, filename, flen + 1); 414 } 414 415 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); 417 427 418 428 /* Check if the file is mentioned in a makefile. If *FILE is not 419 420 421 422 423 424 425 426 427 428 429 430 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. 431 441 432 442 Special handling for -W / -o: make sure we preserve the special … … 438 448 */ 439 449 { 440 441 450 struct file *f = lookup_file (name); 451 if (f != 0) 442 452 { 443 453 exists = not_target || f->is_target; … … 452 462 453 463 if (!exists) 454 455 456 464 { 465 /* That file wasn't mentioned in the makefile. 466 See if it actually exists. */ 457 467 458 468 #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 = '/'; 460 498 #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 { 489 506 int e; 490 507 … … 516 533 517 534 return strcache_add_len (name, (p + 1 - name) + flen); 518 535 } 519 536 } 520 537 … … 601 618 602 619 for (i = 0; v->searchpath[i] != 0; ++i) 603 604 620 printf ("%s%c", v->searchpath[i], 621 v->searchpath[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR); 605 622 } 606 623 607 624 if (vpaths == 0) 608 puts (_("# No `vpath' search paths."));625 puts (_("# No 'vpath' search paths.")); 609 626 else 610 printf (_("\n# %u `vpath' search paths.\n"), nvpaths);627 printf (_("\n# %u 'vpath' search paths.\n"), nvpaths); 611 628 612 629 if (general_vpath == 0) 613 puts (_("\n# No general ( `VPATH' variable) search path."));630 puts (_("\n# No general ('VPATH' variable) search path.")); 614 631 else 615 632 { … … 617 634 unsigned int i; 618 635 619 fputs (_("\n# General ( `VPATH' variable) search path:\n# "), stdout);636 fputs (_("\n# General ('VPATH' variable) search path:\n# "), stdout); 620 637 621 638 for (i = 0; path[i] != 0; ++i) 622 623 639 printf ("%s%c", path[i], 640 path[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR); 624 641 } 625 642 } -
vendor/gnumake/current/w32/Makefile.am
r2596 r3138 1 1 # 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. 4 3 # This file is part of GNU Make. 5 4 # … … 17 16 # this program. If not, see <http://www.gnu.org/licenses/>. 18 17 18 AUTOMAKE_OPTIONS = subdir-objects 19 19 20 noinst_LIBRARIES = libw32.a 20 21 21 22 libw32_a_SOURCES = subproc/misc.c subproc/sub_proc.c subproc/w32err.c \ 22 pathstuff.c23 compat/posixfcn.c pathstuff.c w32os.c 23 24 24 libw32_a_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/subproc -I$(top_srcdir) 25 libw32_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 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 29 28 opendir(const char* pDirName) 30 29 { 31 32 DIR*pDir;33 char*pEndDirName;34 intnBufferLen;35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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; 83 82 } 84 83 … … 86 85 closedir(DIR *pDir) 87 86 { 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 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; 107 106 } 108 107 … … 110 109 readdir(DIR* pDir) 111 110 { 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 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; 140 139 } 141 140 … … 143 142 rewinddir(DIR* pDir) 144 143 { 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 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; 166 165 } 167 166 … … 169 168 telldir(DIR* pDir) 170 169 { 171 172 173 174 175 176 177 178 179 180 181 182 183 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; 184 183 } 185 184 … … 187 186 seekdir(DIR* pDir, long nPosition) 188 187 { 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 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 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 38 37 struct dirent 39 38 { 40 ino_t d_ino; 39 ino_t d_ino; /* unused - no equivalent on WINDOWS32 */ 41 40 char d_name[NAME_MAX+1]; 42 41 }; 43 42 44 43 typedef struct dir_struct { 45 ULONGdir_ulCookie;46 HANDLEdir_hDirHandle;47 DWORDdir_nNumFiles;48 chardir_pDirectoryName[NAME_MAX+1];49 44 ULONG dir_ulCookie; 45 HANDLE dir_hDirHandle; 46 DWORD dir_nNumFiles; 47 char dir_pDirectoryName[NAME_MAX+1]; 48 struct dirent dir_sdReturn; 50 49 } DIR; 51 50 -
vendor/gnumake/current/w32/include/pathstuff.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 -
vendor/gnumake/current/w32/include/sub_proc.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 22 21 * Component Name: 23 22 * 24 * $Date : 2010/07/13 01:20:43$23 * $Date$ 25 24 * 26 * $Source : /sources/make/make/w32/include/sub_proc.h,v$25 * $Source$ 27 26 * 28 * $Id : sub_proc.h,v 1.12 2010/07/13 01:20:43 psmith Exp$27 * $Id$ 29 28 */ 30 29 … … 34 33 EXTERN_DECL(HANDLE process_init, (VOID_DECL)); 35 34 EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth, 36 35 HANDLE stderrh)); 37 36 EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp, 38 37 char *exec_path, char *as_user)); 39 38 EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data, 40 39 int stdin_data_len)); 41 40 EXTERN_DECL(long process_file_io, (HANDLE proc)); 42 41 EXTERN_DECL(void process_cleanup, (HANDLE proc)); 43 EXTERN_DECL(HANDLE process_wait_for_any, ( VOID_DECL));42 EXTERN_DECL(HANDLE process_wait_for_any, (int block, DWORD* pdwWaitStatus)); 44 43 EXTERN_DECL(void process_register, (HANDLE proc)); 45 EXTERN_DECL(HANDLE process_easy, (char** argv, char** env)); 44 EXTERN_DECL(HANDLE process_easy, (char** argv, char** env, 45 int outfd, int errfd)); 46 46 EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal)); 47 47 EXTERN_DECL(int process_used_slots, (VOID_DECL)); 48 EXTERN_DECL(DWORD process_set_handles, (HANDLE *handles)); 48 49 49 50 /* support routines */ … … 57 58 EXTERN_DECL(int process_errcnt, (HANDLE proc)); 58 59 EXTERN_DECL(void process_pipes, (HANDLE proc, int pipes[3])); 60 EXTERN_DECL(void process_noinherit, (int fildes)); 59 61 60 62 #endif -
vendor/gnumake/current/w32/include/w32err.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 23 22 #endif 24 23 25 EXTERN_DECL(c har * map_windows32_error_to_string, (DWORD error));24 EXTERN_DECL(const char * map_windows32_error_to_string, (DWORD error)); 26 25 27 26 #endif /* !_W32ERR_H */ -
vendor/gnumake/current/w32/pathstuff.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 16 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 17 16 18 #include "make .h"17 #include "makeint.h" 19 18 #include <string.h> 20 19 #include <stdlib.h> … … 29 28 char *etok; /* token separator for old Path */ 30 29 31 32 33 34 35 36 if (isblank((unsigned char) *etok))37 38 39 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)); 40 39 } 41 40 … … 81 80 *etok = to_delim; 82 81 p = ++etok; 83 82 } else 84 83 p += strlen(p); 85 84 } else { … … 116 115 getcwd_fs(char* buf, int len) 117 116 { 118 119 120 121 122 123 124 125 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; 126 125 } 127 126 -
vendor/gnumake/current/w32/subproc/NMakefile
r2596 r3138 1 # NOTE: If you have no `make' program at all to process this makefile, run2 # `build.bat' instead.1 # NOTE: If you have no 'make' program at all to process this makefile, run 2 # 'build.bat' instead. 3 3 # 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. 6 5 # This file is part of GNU Make. 7 6 # -
vendor/gnumake/current/w32/subproc/misc.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 26 25 /* 27 26 * Description: Convert a NULL string terminated UNIX environment block to 28 * 27 * an environment block suitable for a windows32 system call 29 28 * 30 29 * Returns: TRUE= success, FALSE=fail 31 30 * 32 31 * Notes/Dependencies: the environment block is sorted in case-insensitive 33 * 32 * order, is double-null terminated, and is a char *, not a char ** 34 33 */ 35 34 int _cdecl compare(const void *a1, const void *a2) 36 35 { 37 36 return _stricoll(*((char**)a1),*((char**)a2)); 38 37 } 39 38 bool_t 40 arr2envblk(char **arr, char **envblk_out )39 arr2envblk(char **arr, char **envblk_out, int *envsize_needed) 41 40 { 42 43 44 45 41 char **tmp; 42 int size_needed; 43 int arrcnt; 44 char *ptr; 46 45 47 48 49 50 46 arrcnt = 0; 47 while (arr[arrcnt]) { 48 arrcnt++; 49 } 51 50 52 53 54 55 51 tmp = (char**) calloc(arrcnt + 1, sizeof(char *)); 52 if (!tmp) { 53 return FALSE; 54 } 56 55 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; 65 65 66 66 qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare); 67 67 68 69 70 71 72 68 ptr = *envblk_out = calloc(size_needed, 1); 69 if (!ptr) { 70 free(tmp); 71 return FALSE; 72 } 73 73 74 75 76 77 78 79 74 arrcnt = 0; 75 while (tmp[arrcnt]) { 76 strcpy(ptr, tmp[arrcnt]); 77 ptr += strlen(tmp[arrcnt]) + 1; 78 arrcnt++; 79 } 80 80 81 82 81 free(tmp); 82 return TRUE; 83 83 } -
vendor/gnumake/current/w32/subproc/proc.h
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 21 20 typedef int bool_t; 22 21 23 #define E_SCALL 24 #define E_IO 25 #define E_NO_MEM 26 #define E_FORK 22 #define E_SCALL 101 23 #define E_IO 102 24 #define E_NO_MEM 103 25 #define E_FORK 104 27 26 28 extern bool_t arr2envblk(char **arr, char **envblk_out );27 extern bool_t arr2envblk(char **arr, char **envblk_out, int *envsize_needed); 29 28 30 29 #endif -
vendor/gnumake/current/w32/subproc/sub_proc.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 19 18 #include <stdlib.h> 20 19 #include <stdio.h> 20 #include <io.h> /* for _get_osfhandle */ 21 21 #ifdef _MSC_VER 22 22 # include <stddef.h> /* for intptr_t */ … … 24 24 # include <stdint.h> 25 25 #endif 26 #include <string.h> 26 27 #include <process.h> /* for msvc _beginthreadex, _endthreadex */ 27 28 #include <signal.h> 28 29 #include <windows.h> 29 30 31 #include "makeint.h" 32 #include "filedef.h" 33 #include "variable.h" 30 34 #include "sub_proc.h" 31 35 #include "proc.h" … … 34 38 35 39 static char *make_command_line(char *shell_name, char *exec_path, char **argv); 36 extern char *xmalloc (unsigned int);37 40 38 41 typedef struct sub_process_t { 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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; 54 57 } sub_process; 55 58 … … 58 61 static int proc_index = 0; 59 62 static int fake_exits_pending = 0; 63 64 65 /* 66 * Fill a HANDLE list with handles to wait for. 67 */ 68 DWORD 69 process_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 } 60 85 61 86 /* … … 66 91 process_adjust_wait_state(sub_process* pproc) 67 92 { 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 } 84 109 } 85 110 … … 88 113 */ 89 114 static 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; 115 process_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 } 124 155 } 125 156 … … 130 161 process_kill(HANDLE proc, int signal) 131 162 { 132 133 134 163 sub_process* pproc = (sub_process*) proc; 164 pproc->signal = signal; 165 return (TerminateProcess((HANDLE) pproc->pid, signal)); 135 166 } 136 167 … … 144 175 process_register(HANDLE proc) 145 176 { 146 147 177 if (proc_index < MAXIMUM_WAIT_OBJECTS) 178 proc_array[proc_index++] = (sub_process *) proc; 148 179 } 149 180 … … 154 185 process_used_slots(void) 155 186 { 156 187 return proc_index; 157 188 } 158 189 … … 162 193 * you must do 1 of things: 163 194 * 164 * 195 * x = process_easy(...); 165 196 * 166 197 * or 167 198 * 168 * 169 * 199 * x = process_init_fd(); 200 * process_register(x); 170 201 * 171 202 * or 172 203 * 173 * 174 * 204 * x = process_init(); 205 * process_register(x); 175 206 * 176 207 * You must NOT then call process_pipe_io() because this function is … … 180 211 181 212 HANDLE 182 process_wait_for_any( void)183 { 184 sub_process* pproc = process_wait_for_any_private();185 186 187 188 189 190 191 213 process_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() 192 223 */ 193 194 195 224 (void) process_file_io(pproc); 225 return ((HANDLE) pproc); 226 } 196 227 } 197 228 … … 207 238 { 208 239 if (proc == INVALID_HANDLE_VALUE) return ERROR_INVALID_HANDLE; 209 240 return (((sub_process *)proc)->last_err); 210 241 } 211 242 … … 214 245 { 215 246 if (proc == INVALID_HANDLE_VALUE) return EXIT_FAILURE; 216 return (((sub_process *)proc)->exit_code); 247 return (((sub_process *)proc)->exit_code); 248 } 249 250 void 251 process_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); 217 257 } 218 258 … … 227 267 process_outbuf(HANDLE proc) 228 268 { 229 269 return (((sub_process *)proc)->outp); 230 270 } 231 271 … … 233 273 process_errbuf(HANDLE proc) 234 274 { 235 275 return (((sub_process *)proc)->errp); 236 276 } 237 277 … … 239 279 process_outcnt(HANDLE proc) 240 280 { 241 281 return (((sub_process *)proc)->outcnt); 242 282 } 243 283 … … 245 285 process_errcnt(HANDLE proc) 246 286 { 247 287 return (((sub_process *)proc)->errcnt); 248 288 } 249 289 … … 251 291 process_pipes(HANDLE proc, int pipes[3]) 252 292 { 253 254 255 256 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; 257 297 } 258 298 */ 259 299 260 300 HANDLE 261 301 process_init() 262 302 { 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 } 331 332 333 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 334 374 process_init_fd(HANDLE stdinh, HANDLE stdouth, HANDLE stderrh) 335 375 { 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); 352 394 } 353 395 … … 355 397 static HANDLE 356 398 find_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 453 static int 454 batch_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); 404 466 } 405 467 … … 414 476 long 415 477 process_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", 576 712 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]); 591 730 pproc->sv_stdin[1] = 0; 592 731 pproc->sv_stdout[1] = 0; 593 732 pproc->sv_stderr[1] = 0; 594 733 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 */ 603 743 static DWORD 604 744 proc_stdin_thread(sub_process *pproc) 605 745 { 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 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 621 761 } 622 762 … … 624 764 proc_stdout_thread(sub_process *pproc) 625 765 { 626 627 628 629 630 631 632 633 634 635 636 637 /* 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 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; 653 793 } 654 794 … … 656 796 proc_stderr_thread(sub_process *pproc) 657 797 { 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 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; 684 824 } 685 825 … … 694 834 * Notes/Dependencies: 695 835 */ 696 836 long 697 837 process_pipe_io( 698 699 700 701 { 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 /* 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 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 } 832 972 833 973 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 */ 847 988 848 989 /* … … 855 996 * Notes/Dependencies: 856 997 */ 857 998 long 858 999 process_file_io( 859 860 { 861 862 863 864 1000 HANDLE proc) 1001 { 1002 sub_process *pproc; 1003 HANDLE childhand; 1004 DWORD wait_return; 1005 BOOL GetExitCodeResult; 865 1006 DWORD ierr; 866 1007 867 868 pproc = process_wait_for_any_private();869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 /* 904 905 906 907 908 909 910 911 912 913 914 915 916 917 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 } 919 1060 920 1061 done2: 921 922 923 924 1062 if (pproc->lerrno) 1063 return(-1); 1064 else 1065 return(0); 925 1066 926 1067 } … … 928 1069 /* 929 1070 * Description: Clean up any leftover handles, etc. It is up to the 930 * caller to manage and free the input, ou put, and stderr buffers.1071 * caller to manage and free the input, output, and stderr buffers. 931 1072 */ 932 1073 void 933 1074 process_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); 953 1097 } 954 1098 … … 956 1100 /* 957 1101 * Description: 958 * 1102 * Create a command line buffer to pass to CreateProcess 959 1103 * 960 1104 * Returns: the buffer or NULL for failure 961 * 1105 * Shell case: sh_name a:/full/path/to/script argv[1] argv[2] ... 962 1106 * Otherwise: argv[0] argv[1] argv[2] ... 963 1107 * … … 970 1114 make_command_line( char *shell_name, char *full_exec_path, char **argv) 971 1115 { 972 intargc = 0;973 char**argvi;974 int*enclose_in_quotes = NULL;975 int*enclose_in_quotes_i;976 unsigned intbytes_required = 0;977 char*command_line;978 char*command_line_i;979 980 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 */ 981 1125 982 1126 #ifdef HAVE_CYGWIN_SHELL 983 984 1127 have_sh = (shell_name != NULL || strstr(full_exec_path, "sh.exe")); 1128 cygwin_mode = 1; 985 1129 #endif 986 1130 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; 1037 1184 1038 1185 #if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL) 1039 1040 1041 1186 case '\\': 1187 backslash_count++; 1188 break; 1042 1189 #endif 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 if (enclose_in_quotes)free(enclose_in_quotes);1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 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 } 1148 1295 #if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL) 1149 1150 1151 1152 1296 } else if (*p == '\\') { 1297 backslash_count++; 1298 } else { 1299 backslash_count = 0; 1153 1300 #endif 1154 1155 1156 1157 1158 1159 1160 1161 1162 1301 } 1302 1303 /* 1304 * Copy the character. 1305 */ 1306 *(command_line_i++) = *(p++); 1307 } 1308 1309 if (*enclose_in_quotes_i) { 1163 1310 #if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL) 1164 1165 1166 1167 1168 1169 1170 1311 /* 1312 * Add one \ for each \ that precedes the 1313 * closing ". 1314 */ 1315 while(backslash_count--) { 1316 *(command_line_i++) = '\\'; 1317 }; 1171 1318 #endif 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 if (enclose_in_quotes)free(enclose_in_quotes);1191 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; 1192 1339 } 1193 1340 … … 1196 1343 * using the default stdin, stdout, and stderr handles. 1197 1344 * Also, register process so that process_wait_for_any_private() 1198 * 1199 * 1345 * can be used via process_file_io(NULL) or 1346 * process_wait_for_any(). 1200 1347 * 1201 1348 * Returns: … … 1205 1352 HANDLE 1206 1353 process_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; 1214 1364 1215 1365 if (proc_index >= MAXIMUM_WAIT_OBJECTS) { 1216 1217 1366 DB (DB_JOBS, ("process_easy: All process slots used up\n")); 1367 return INVALID_HANDLE_VALUE; 1218 1368 } 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); 1219 1374 if (DuplicateHandle(GetCurrentProcess(), 1220 GetStdHandle(STD_INPUT_HANDLE),1375 tmpIn, 1221 1376 GetCurrentProcess(), 1222 1377 &hIn, … … 1224 1379 TRUE, 1225 1380 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 } 1230 1399 } 1400 if (outfd >= 0) 1401 tmpOut = (HANDLE)_get_osfhandle (outfd); 1402 else 1403 tmpOut = GetStdHandle (STD_OUTPUT_HANDLE); 1231 1404 if (DuplicateHandle(GetCurrentProcess(), 1232 GetStdHandle(STD_OUTPUT_HANDLE),1405 tmpOut, 1233 1406 GetCurrentProcess(), 1234 1407 &hOut, … … 1236 1409 TRUE, 1237 1410 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 } 1242 1429 } 1430 if (errfd >= 0) 1431 tmpErr = (HANDLE)_get_osfhandle (errfd); 1432 else 1433 tmpErr = GetStdHandle(STD_ERROR_HANDLE); 1243 1434 if (DuplicateHandle(GetCurrentProcess(), 1244 GetStdHandle(STD_ERROR_HANDLE),1435 tmpErr, 1245 1436 GetCurrentProcess(), 1246 1437 &hErr, … … 1248 1439 TRUE, 1249 1440 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 } 1254 1459 } 1255 1460 … … 1264 1469 1265 1470 /* 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); 1269 1477 } 1270 1478 -
vendor/gnumake/current/w32/subproc/w32err.c
r2596 r3138 1 1 /* 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. 2 Copyright (C) 1996-2016 Free Software Foundation, Inc. 4 3 This file is part of GNU Make. 5 4 … … 16 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 17 16 17 #include <stdlib.h> 18 18 #include <windows.h> 19 #include "makeint.h" 19 20 #include "w32err.h" 20 21 … … 27 28 * comp.os.ms-windows.programmer.win32 28 29 */ 29 c har *30 const char * 30 31 map_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 */ 40 51 wsprintf (szMessageBuffer, "Error %ld\n", ercode); 41 52 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 } 69 84 return szMessageBuffer; 70 85 }
Note:
See TracChangeset
for help on using the changeset viewer.