- Timestamp:
- Jun 17, 2012 8:45:31 PM (13 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 158 edited
- 9 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
- Property svn:ignore
-
old new 13 13 stamp-* 14 14 makebook* 15 15 16 .*gdbinit 17 .gdb_history 18 16 19 *.dep 17 20 *.dvi … … 31 34 *.pg 32 35 *.pgs 36 33 37 README 34 38 README.DOS 35 39 README.W32 40 README.OS2 36 41 aclocal.m4 37 42 autom4te.cache … … 52 57 config.h.W32 53 58 config.h-vms 59 54 60 loadavg 55 61 loadavg.c 56 62 make 63 57 64 .deps 58 65 .dep_segment 66 ID 67 TAGS 68 59 69 _* 60 70 sun4 … … 72 82 sol2 73 83 i486-linux 84 74 85 customs 86 75 87 install-sh 76 88 mkinstalldirs 89 90 .directive.asc
-
- Property svn:ignore
-
trunk/src/kmk/AUTHORS
r1993 r2591 67 67 68 68 ------------------------------------------------------------------------------- 69 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 70 Free Software Foundation, Inc.69 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 70 2008, 2009, 2010 Free Software Foundation, Inc. 71 71 This file is part of GNU Make. 72 72 -
trunk/src/kmk/ChangeLog
r1993 r2591 1 2010-07-28 Paul Smith <[email protected]> 2 3 Version 3.82 released. 4 5 * configure.in: Change release version. 6 * NEWS: Change the date. 7 8 * read.c (parse_file_seq): Remove GLOB_NOSORT for 9 backward-compatibility. We'll add it back in next release. 10 * NEWS: Note it. 11 12 2010-07-24 Eli Zaretskii <[email protected]> 13 14 * job.c (pid2str) [WINDOWS32]: Fix CPP conditionals for using %Id 15 format. 16 17 2010-07-18 Paul Smith <[email protected]> 18 19 * configure.in: Switch bsd_signal to AC_CHECK_DECLS() to make sure 20 we have a declaration. Fixes Savannah bug #25713 (maybe?) 21 * doc/make.texi (Complex Makefile): Cleanup variable assignments. 22 (One Shell): New subsection for the .ONESHELL special target. 23 24 Patches by Ozkan Sezer <[email protected]>: 25 26 * misc.c (strncasecmp): Local implementation for systems without. 27 * config.h.W32.template (HAVE_STRNICMP): Define on Windows. 28 * configure.in: Check for strncasecmp/strncmpi/strnicmp. 29 * job.c [WINDOWS32]: Don't define dup2 on Windows. 30 (pid2str): Use "%Id" even with MSVC 31 (exec_command): Cast to pid_t when calling pid2str(). 32 * w32/subproc/sub_proc.c [WINDOWS32]: Include config.h first. 33 Use stddef.h on MSVC to get intptr_t. 34 * w32/subproc/misc.c [WINDOWS32]: Include config.h first. 35 * w32/compat/dirent.c [WINDOWS32]: Include config.h first. 36 (readdir): Cast -1 to correct type for d_ino. 37 * w32/pathstuff.c [WINDOWS32]: Ensure make.h is included first. 38 * make.h [WINDOWS32]: Don't prototype alloca() on Windows. 39 Add configuration for strncasecmp(). 40 * main.c (ADD_SIG) [WINDOWS32]: Avoid warnings in MSVC. 41 * config.h.W32.template [WINDOWS32]: Don't warn on unsafe 42 functions or variables. 43 * NMakefile.template [WINDOWS32]: Remove /MACHINE:I386. 44 * main.c (clean_jobserver): Cast due to MSVC brokenness. 45 (decode_switches): Ditto. 46 * vpath.c (construct_vpath_list): Ditto. 47 * rule.c (freerule): Ditto. 48 * ar.c (ar_glob): Ditto. 49 50 2010-07-16 Boris Kolpackov <[email protected]> 51 52 * misc.c (concat): Fix buffer overrun. 53 54 2010-07-12 Paul Smith <[email protected]> 55 56 Update copyrights to add 2010. 57 58 * build_w32.bat: Support for MSVC Windows x86_64 builds. 59 * job.c: Don't define execve() on MSVC/64bit. 60 Patch by Viktor Szakats. Fixes Savannah bug #27590. 61 62 2010-07-12 Eli Zaretskii <[email protected]> 63 64 * make.h (alloca) [!__GNUC__]: Don't define prototype. 65 (int w32_kill): Use pid_t for process ID argument. 66 Fixes Savannah bug #27809. 67 68 2010-07-12 Paul Smith <[email protected]> 69 70 Integrated new .ONESHELL feature. 71 Patch by David Boyce <[email protected]>. Modified by me. 72 73 * NEWS: Add a note about the new feature. 74 * job.c (is_bourne_compatible_shell): Determine whether we're 75 using a standard POSIX shell or not. 76 (start_job_command): Accept '-ec' as POSIX shell flags. 77 (construct_command_argv_internal): If one_shell is set and we are 78 using a POSIX shell, remove "interior" prefix characters such as 79 "@", "+", "-". Also treat "\n" as a special character when 80 choosing the slow path, if ONESHELL is set. 81 * job.h (is_bourne_compatible_argv): Define the new function. 82 83 * make.h (one_shell): New global variable to remember setting. 84 * main.c: Declare it. 85 * read.c (record_files): Set it. 86 * commands.c (chop_commands): If one_shell is set, don't chop 87 commands into multiple lines; just keep one line. 88 89 2010-07-09 Eli Zaretskii <[email protected]> 90 91 * w32/subproc/sub_proc.c: Include stdint.h. 92 (sub_process_t): Use intptr_t for file handles and pid_t for 93 process ID. 94 (process_pipes, process_init_fd, process_begin): Use intptr_t for 95 file handles and pid_t for process ID. Fixes Savannah bug #27809. 96 Patch by Ozkan Sezer <[email protected]> 97 98 * function.c (abspath): Support absolute file names in UNC format. 99 Fixes Savannah bug #30312. 100 101 * job.c (pid2str) [WINDOWS32]: Don't use %Id with GCC < 4.x. 102 (exec_command) [WINDOWS32]: Use pid2str instead of non-portable 103 %Id. 104 105 * main.c (handle_runtime_exceptions): Use %p to print addresses, 106 to DTRT on both 32-bit and 64-bit hosts. Savannah bug #27809. 107 108 * job.c (w32_kill, start_job_command, create_batch_file): Use 109 pid_t for process IDs and intptr_t for the 1st arg of 110 _open_osfhandle. 111 * function.c (windows32_openpipe): Use pid_t for process IDs and 112 intptr_t for the 1st arg of _open_osfhandle. 113 (func_shell): Use pid_t for process IDs. 114 * main.c (main) [WINDOWS32]: Pacify the compiler. 115 * config.h.W32.template (pid_t): Add a definition for 64-bit 116 Windows builds that don't use GCC. Fixes Savannah bug #27809. 117 Patch by Ozkan Sezer <[email protected]> 118 119 2010-07-07 Paul Smith <[email protected]> 120 121 * configure.in: Bump to a new prerelease version 3.81.91. 122 123 2010-07-06 Paul Smith <[email protected]> 124 125 * main.c (main): Set a default value of "-c" for .SHELLFLAGS. 126 * NEWS: Mention the new behavior of .POSIX and the new .SHELLFLAGS 127 variable. 128 * job.c (construct_command_argv): Retrieve the .SHELLFLAGS value 129 and pass it to construct_command_argv_internal(). 130 (construct_command_argv_internal): If .SHELLFLAGS is non-standard 131 use the slow path. Use that value instead of hard-coded "-c". 132 133 2010-07-05 Paul Smith <[email protected]> 134 135 * implicit.c (pattern_search): lastslash can be const. 136 * dir.c (downcase): Remove unused variable. 137 * hash.c (hash_init): Cast sizeof for error message. 138 * arscan.c (ar_scan): Cast to char* for WINDOWS32. 139 (ar_member_touch): Ditto. 140 * ar.c (glob_pattern_p): Avoid symbol collision: open -> opened 141 * signame.c (strsignal): Ditto: signal -> sig 142 * job.c (create_batch_file): Ditto: error -> error_string 143 (pid2str): Portably convert a pid_t into a string 144 (reap_children): Use it. 145 (start_waiting_job): Use it. 146 Savannah bug #27809. Patch by Ozkan Sezer <[email protected]> 147 148 2010-07-03 Paul Smith <[email protected]> 149 150 * read.c (parse_file_seq): All archive groups must end with ')' as 151 the LAST character in a word. If there is no word ending in ')' 152 then it's not an archive group. Fixes Savannah bug #28525. 153 154 2010-07-01 Paul Smith <[email protected]> 155 156 * main.c (main): Append optional features using separate calls. 157 Not as efficient but not all compilers allow conditionals inside 158 macro calls. Fixes Savannah bug #29244. 159 160 2010-01-10 Paul Smith <[email protected]> 161 162 * make.h (patheq): Rename strieq() to patheq() for clarity. 163 * dir.c (dir_contents_file_exists_p): Use it. 164 165 * dir.c (file_impossible): Convert xmalloc/memset to xcalloc. 166 * file.c (enter_file): Ditto. 167 * job.c (new_job): Ditto. 168 169 2009-12-11 Eli Zaretskii <[email protected]> 170 171 * job.c (construct_command_argv_internal) <sh_cmds_dos> 172 [WINDOWS32]: Add "echo." and a few more commands that are built 173 into cmd.exe. Fixes Savannah bug #28126. 174 175 * file.c (lookup_file) [HAVE_DOS_PATHS]: Treat '\\' like we do 176 with '/'. 177 178 2009-11-15 Paul Smith <[email protected]> 179 180 Patches for VMS provided by Hartmut Becker <[email protected]> 181 182 * vmsjobs.c (ctrlYPressed) [VMS]: Deal with CTRL-Y. 183 (vmsHandleChildTerm) [VMS]: Ditto. 184 (astYHandler) [VMS]: Ditto. 185 (tryToSetupYAst) [VMS]: Ditto. 186 (child_execute_job) [VMS]: Ditto. 187 188 * vmsify.c (trnlog) [VMS]: Fix const errors. 189 (vmsify) [VMS]: Ditto. 190 191 * readme.vms [VMS]: Update with notes for 3.82. 192 193 * job.h (comname) [VMS]: Remember the temporary command filename 194 195 * dir.c (vmsify) [VMS]: Fix const errors. 196 (vms_hash) [VMS]: Ditto. 197 (vmsstat_dir) [VMS]: Ditto. 198 (find_directory) [VMS]: Fix case-insensitive option for VMS 199 (dir_contents_file_exists_p) [VMS]: Ditto. 200 (file_impossible) [VMS]: Ditto. 201 202 * config.h-vms.template (HAVE_FDOPEN) [VMS]: Have it. 203 (HAVE_STRCASECMP) [VMS]: Ditto. 204 205 * arscan.c (VMS_get_member_info) [VMS]: Fix timezone computation. 206 (ar_scan) [VMS]: Fix const error. 207 208 2009-11-12 Boris Kolpackov <[email protected]> 209 210 * vpath.c (vpath_search, selective_vpath_search): Add index arguments 211 which allows the caller to get the index of the matching directory. 212 213 * make.h (vpath_search): Update prototype. 214 215 * remake.c (library_search): Implement linker-compatible library 216 search. Use the new VPATH_SEARCH index functionality to keep track 217 of the directory index for each match. Select the match with the 218 lowest directory index. 219 220 * implicit.c (pattern_search): Pass NULL for the index arguments in 221 the VPATH_SEARCH call. 222 223 * doc/make.texi (Directory Search for Link Libraries): Describe the 224 new search behavior. 225 226 * NEWS: Add a note about the new behavior. 227 228 2009-10-25 Paul Smith <[email protected]> 229 230 * AUTHORS, et.al.: Update copyright years. 231 232 * implicit.c (stemlen_compare): Fix qsort() compare bug that 233 caused implicit rules with equal stem lengths to be sorted 234 indeterminately. 235 236 2009-10-24 Paul Smith <[email protected]> 237 238 * main.c (usage): Add --eval to the usage string. 239 (switches): Add the --eval switch. 240 (main): If --eval is given, add them to the simply-expanded variable 241 -*-eval-flags-*- (necessary to allow recursion to work properly). 242 (define_makeflags): Add -*-eval-flags-*- to MAKEFLAGS. 243 244 * NEWS: Describe the new --eval command line argument. 245 * doc/make.texi (Options Summary): Document --eval. 246 247 * dep.h: eval_buffer() returns void. 248 * read.c (eval_buffer): Ditto. 249 (eval): Ditto. 250 251 * variable.h (define_variable_cname): New macro for constant 252 variable names. 253 * default.c (set_default_suffixes): Use it. 254 * main.c (main): Ditto. 255 (handle_non_switch_argument): Ditto. 256 (define_makeflags): Ditto. 257 * read.c (read_all_makefiles): Ditto. 258 * variable.c (define_automatic_variables): Ditto. 259 260 * commands.c (dep_hash_cmp): Avoid casts. 261 (dep_hash_1): Ditto. 262 (dep_hash_2): Ditto. 263 264 2009-10-22 Boris Kolpackov <[email protected]> 265 266 * read.c (read_all_makefiles): Mark the default makefile dependency 267 dontcare. 268 269 2009-10-07 Boris Kolpackov <[email protected]> 270 271 * read.c (do_undefine): Free the expanded variable name. 272 273 * commands.c (dep_hash_cmp, set_file_variables): Move the order-only 274 to normal upgrade logic from dep_hash_cmp to set_file_variables. 275 276 2009-10-06 Boris Kolpackov <[email protected]> 277 278 * dep.h (uniquize_deps): Remove. 279 280 * read.c (uniquize_deps): Merge into set_file_variables in 281 commands.c. 282 (dep_hash_1, dep_hash_2, dep_hash_cmp): Move to commands.c. 283 284 * commands.c (set_file_variables): Avoid modifying the dep 285 chain to achieve uniqueness. Fixes savannah bug 25780. 286 287 * implicit.c (pattern_search): Instead of re-setting all automatic 288 variables for each rule we try, just update $*. 289 290 2009-10-06 Boris Kolpackov <[email protected]> 291 292 * variable.h (undefine_variable_in_set): New function declaration. 293 (undefine_variable_global): New macro. 294 295 * variable.c (undefine_variable_in_set): New function implementation. 296 297 * read.c (vmodifiers): Add undefine_v modifier. 298 (parse_var_assignment): Parse undefine. 299 (do_undefine): Handle the undefine directive. 300 (eval): Call do_undefine if undefine_v is set. 301 302 * main.c (.FEATURES): Add a keyword to indicate the new feature. 303 304 * doc/make.texi (Undefine Directive): Describe the new directive. 305 306 * NEWS: Add a note about the new directive. 307 308 2009-10-05 Boris Kolpackov <[email protected]> 309 310 * implicit.c (pattern_search): Initialize file variables only 311 if we need to parse a rule that requires the second expansion. 312 313 2009-10-03 Paul Smith <[email protected]> 314 315 * make.h: Include <alloca.h> even on systems where __GNUC__ is 316 defined. Not sure why it was done the other way. 317 Requested by David Boyce <[email protected]>. 318 319 2009-09-30 Boris Kolpackov <[email protected]> 320 321 * dep.h (dep): Add the DONTCARE bitfield. 322 323 * filedef.h (file):Add the NO_DIAG bitfield. 324 325 * read.c (eval_makefile): Set the DONTCARE flag in struct dep, 326 not struct file (a file can be a dependency of many targets, 327 some don't care, some do). 328 329 * remake.c (update_goal_chain): Propagate DONTCARE from struct 330 dep to struct file before updating the goal and restore it 331 afterwards. 332 (update_file): Don't prune the dependency graph if this target 333 has failed but the diagnostics hasn't been issued. 334 (complain): Scan the file's dependency graph to find the file 335 that caused the failure. 336 (update_file_1): Use NO_DIAG instead of DONTCARE to decide 337 whether to print diagnostics. 338 339 Fixes Savannah bugs #15110, #25493, #12686, and #17740. 340 341 2009-09-28 Paul Smith <[email protected]> 342 343 * doc/make.texi (Pattern Intro): Move the match algorithm 344 discussion into the "Pattern Match" node. 345 (Pattern Match): Expand on the pattern rule matching algorithm. 346 347 2009-09-28 Andreas Buening <[email protected]> 348 349 * job.c (construct_command_argv_internal) [OS2]: Don't eat too 350 much of the command line on a single pass. 351 352 2009-09-28 Boris Kolpackov <[email protected]> 353 354 * varible.c (create_pattern_var): Insert variables into the 355 PATTERN_VARS list in the shortest patterns first order. 356 357 * implicit.c (tryrule): Add STEMLEN and ORDER members. These are 358 used to sort the rules. 359 (stemlen_compare): Compare two tryrule elements. 360 (pattern_search): Sort the rules so that they are in the shortest 361 stem first order. 362 363 * main.c (.FEATURES): Add a keyword to indicate the new behavior. 364 365 * doc/make.texi (Pattern-specific Variable Values): Describe the 366 new pattern-specific variables application order. 367 (Introduction to Pattern Rules): Describe the new pattern rules 368 search order. 369 370 * NEWS: Add a note about the new behavior. 371 372 2009-09-27 Paul Smith <[email protected]> 373 374 * doc/make.texi (Double-Colon): Mention that pattern rules with 375 double-colons have a different meaning. Savannah bug #27497. 376 377 2009-09-27 Juan Manuel Guerrero <[email protected]> 378 379 * configh.dos.template: Remove unconditional definition of 380 SYS_SIGLIST_DECLARED. 381 Include <sys/version.h> because ports of GCC 4.3.0 and later no 382 longer include it, so macros like __DJGPP_MINOR__ are no longer 383 defined automatically. 384 385 * Makefile.DOS.template (INCLUDES): Use $(prefix) and the 386 corresponding variables to define LIBDIR, INCLUDEDIR and LOCALEDIR 387 instead of using the hardcoded ones. 388 (SUBDIRS): doc subdir added. 389 (INFO_DEPS, DVIS): Values changed to 'make.info' and 'make.dvi'. 390 (TEXI2HTML, TEXI2HTML_FLAGS): Removed. Use makeinfo --html to 391 create html formated docs. texi2html may not be ported to DOS. 392 (make.info, make.dvi, make.ps, make.html): Make targets depend on 393 'make.texi'. 394 (.texi.info, .texi, .texi.dvi): Now invoked recursively. Change 395 -I switch to look in ./ instead of ./doc. 396 (html): Target depend on html-recursive instead of make_1.html. 397 (make_1.html): Removed. 398 (mostlyclean-aminfo): Use $(srcdir)/doc instead of ./ as prefix. 399 (all-recursive): Allow for more than one subdir in the build 400 process. 401 (mostlyclean-recursive, clean-recursive, distclean-recursive) 402 (maintainer-clean-recursive, check-recursive): Enter in doc/ too. 403 (tags-recursive): Allow for more than one subdir in the build 404 process. 405 (info-recursive, dvi-recursive, ps-recursive, html-recursive): New 406 targets. Enter into doc/ to produce the targets. 407 (all-am): $(INFO_DEPS) replaced by info. 408 409 2009-09-26 Paul Smith <[email protected]> 410 411 * read.c (record_files): Use free_ns() to free struct nameseq. 412 (eval): Ditto. 413 414 * rule.c (freerule): Use free_dep_chain(). 415 416 * read.c (record_files): Free FILENAMES chain for implicit rules. 417 (eval): Static pattern targets go into the string cache. 418 419 * function.c (string_glob): Free NAME in the nameseq chain. 420 421 2009-09-25 Boris Kolpackov <[email protected]> 422 423 * implicit.c (pattern_search): Terminate early if we haven't 424 found any rules to try (performance improvement). 425 426 2009-09-25 Boris Kolpackov <[email protected]> 427 428 * implicit.c (pattern_search): Merge three parallel arrays, 429 TRYRULES, MATCHES, and CHECKED_LASTSLASH, into one array 430 of struct TRYRULE. In the old version the latter two arrays 431 had insufficient length. 432 433 2009-09-24 Paul Smith <[email protected]> 434 435 * implicit.c (pattern_search): Add back support for order-only 436 prerequisites for secondary expansion implicit rules, that were 437 accidentally dropped. If we find a "|", enable order-only mode 438 and set IGNORE_MTIME on all deps that are seen afterward. 439 (pattern_search): Fix memory leaks: for intermediate files where 440 we've already set the file variable and pattern variable sets, be 441 sure to either save or free them as appropriate. 442 443 2009-09-23 Paul Smith <[email protected]> 444 445 Rework the way secondary expansion is stored, for efficiency. 446 This changes secondary expansion so that ONLY WHEN we know we have 447 a possibility of needing secondary expansion, do we defer the 448 secondary expansion. This means more parsing the deps but we use 449 a lot less memory (due to the strcache). Also, this fixes 450 Savannah bug #18622. 451 452 * read.c (eval): Don't parse the dep string here anymore. 453 (record_files): Take the dep argument as an unparsed string. If 454 secondary expansion is enabled AND the prereq string has a '$' in 455 it, then set NEED_2ND_EXPANSION and keep the entire string. 456 Otherwise, parse the dep string here to construct the dep list 457 with the names in the strcache. 458 459 * misc.c (copy_dep_chain): For NEED_2ND_EXPANSION, we need to 460 duplicate the name string (others are in the strcache). 461 462 * implicit.c: Remove struct idep and free_idep_chain(): unused. 463 (struct patdeps): New structure to store prereq information. 464 (pattern_search): Use the NEED_2ND_EXPANSION flag to determine 465 which prerequisites need expansion, and expand only those. 466 467 * file.c (split_prereqs): Break parse_prereqs() into two parts: this 468 and enter_prereqs(). split_prereqs() takes a fully-expanded string 469 and splits it into a DEP list, handling order-only prereqs. 470 (enter_prereqs): This function enters a list of DEPs into the file 471 database. If there's a stem defined, expand any pattern chars. 472 (expand_deps): Only try to expand DEPs which have NEED_2ND_EXPANSION 473 set. Use the above functions. 474 (snap_deps): Only perform second expansion on prereqs that need it, 475 as defined by the NEED_2ND_EXPANSION flag. 476 (print_prereqs): New function to print the prereqs 477 (print_file): Call print_prereqs() rather than print inline. 478 479 * hash.h (STRING_COMPARE): Take advantage of strcache() by 480 comparing pointers. 481 (STRING_N_COMPARE): Ditto. 482 (ISTRING_COMPARE): Ditto. 483 484 * dep.h (PARSE_FILE_SEQ): New macro to reduce casts. 485 (parse_file_seq): Return void* 486 * read.c (parse_file_seq): Return void*. 487 (eval): Invoke macroized version of parse_file_seq() 488 * default.c (set_default_suffixes): Ditto. 489 * file.c (split_prereqs): Ditto. 490 * function.c (string_glob): Ditto. 491 * main.c (main): Ditto. 492 * rule.c (install_pattern_rule): Ditto. 493 494 * filedef.h: Add split_prereqs(), enter_prereqs(), etc. 495 496 2009-09-16 Paul Smith <[email protected]> 497 498 * misc.c (alloc_dep, free_dep): Now that we have xcalloc(), 499 convert to macros. 500 * dep.h: Create alloc_dep() / free_dep() macros. 501 502 * implicit.c (pattern_search): Take advantage of the new 503 parse_file_seq() to add the directory prefix to each prereq. 504 505 * dep.h: Remove multi_glob() and enhance parse_file_seq() to do it 506 all. Avoid reversing chains. Support adding prefixes. 507 * read.c (parse_file_seq): Rewrite to support globbing. Allow for 508 cached/non-cached results. 509 (eval): Remove multi_glob() & invoke new parse_file_seq(). 510 * rule.c (install_pattern_rule): Ditto. 511 * main.c (main): Ditto. 512 * implicit.c (pattern_search): Ditto. 513 * function.c (string_glob): Ditto. 514 * file.c (parse_prereqs): Ditto. 515 * default.c (set_default_suffixes): Ditto. 516 517 * variable.c (parse_variable_definition): Don't run off the end of 518 the string if it ends in whitespace (found with valgrind). 519 520 * commands.c (set_file_variables): Keep space for all targets in 521 $? if -B is given (found with valgrind). 522 523 2009-09-15 Paul Smith <[email protected]> 524 525 * misc.c (concat): Make concat() variadic so it takes >3 arguments. 526 (xcalloc): Add new function. 527 * make.h: New declarations. 528 529 * ar.c (ar_glob_match): New calling method for concat(). 530 * main.c (main): Ditto. 531 (decode_env_switches): Ditto. 532 * read.c (eval_makefile): Ditto. 533 (tilde_expand): Ditto. 534 (parse_file_seq): Ditto. 535 * variable.c (target_environment): Ditto. 536 (sync_Path_environment): Ditto. 537 538 * ar.c (ar_glob_match): Use xcalloc(). 539 * dir.c (file_impossible): Ditto. 540 * file.c (enter_file): Ditto. 541 * job.c (new_job): Ditto. 542 * read.c (parse_file_seq): Ditto. 543 * vmsfunctions.c (opendir): Ditto. 544 545 2009-09-14 Rafi Einstein <[email protected]> (tiny patch) 546 547 * w32/subproc/sub_proc.c (process_begin): Check *ep non-NULL 548 inside the loop that looks up environment for PATH. 549 550 2009-08-31 Eli Zaretskii <[email protected]> 551 552 * function.c (windows32_openpipe): Update envp after calling 553 sync_Path_environment. 554 555 2009-08-02 Paul Smith <[email protected]> 556 557 * remake.c (notice_finished_file): Ensure file->cmds is not null 558 before looping through them. Fixes Savannah bug #21824. 559 560 * doc/make.texi (Wildcard Examples): Clarify when objects is 561 wildcard-expanded. Fixes Savannah bug #24509. Patch by Martin Dorey. 562 (Include): Clarify the behavior of -include. 563 Fixes Savannah bug #18963. 564 565 2009-08-01 Paul Smith <[email protected]> 566 567 * doc/make.texi (Catalogue of Rules): Clarify where -c, -F, 568 etc. come on the command line. Fixes Savannah bug #27093. 569 570 * expand.c (expand_argument): If the argument is large enough use 571 xmalloc() instead of alloca(). Fixes Savannah bug #27143. 572 573 * variable.c (do_variable_definition): Avoid using alloca() to 574 hold values, which can be large. Fixes Savannah bug #23960. 575 576 * job.c (new_job): Use memmove() instead of strcpy() since both 577 pointers are in the same memory block. Fixes Savannah bug #27148. 578 Patch by Petr Machata. 579 580 2009-07-29 Ralf Wildenhues <[email protected]> 581 582 * job.c (construct_command_argv_internal): Add "ulimit" and 583 "unset" to the sh_cmds for Unixy shells. 584 585 2009-07-29 Ralf Wildenhues <[email protected]> 586 587 * configure.in: Move side-effects outside AC_CACHE_VAL arguments 588 that set make_cv_sys_gnu_glob, so they are also correctly set 589 when the cache has been populated before. 590 591 2009-07-04 Eli Zaretskii <[email protected]> 592 593 * function.c (func_realpath) [!HAVE_REALPATH]: Require the file to 594 exist, as realpath(3) does where it's supported. 595 596 2006-07-04 Eli Zaretskii <[email protected]> 597 598 * function.c (IS_ABSOLUTE, ROOT_LEN): New macros. 599 (abspath): Support systems that define HAVE_DOS_PATHS (have 600 drive letters in their file names). Use IS_PATHSEP instead of a 601 literal '/' comparison. Fixes Savannah bug #26886. 602 603 2009-06-14 Paul Smith <[email protected]> 604 605 * remake.c (update_file_1): Remember the original file we marked 606 as updating, so we can clear that flag again. If we find a target 607 via vpath, FILE might change. 608 (check_dep): Ditto. Fixes Savannah bug #13529. 609 Patch by Reid Madsen <[email protected]>. 610 611 2009-06-13 Paul Smith <[email protected]> 612 613 * doc/make.texi (MAKEFILES Variable): Be explicit that files 614 included by MAKEFILES cannot give default goals. 615 * read.c (eval): If set_default is not set, pass the no-default-goal 616 value when we read included makefiles. Fixes Savannah bug #13401. 617 618 * ar.c (ar_name): Ensure that targets with empty parens aren't 619 considered archive member references: archive members must have a 620 non-empty "member" string. Fixes Savannah bug #18435. 621 622 * function.c (string_glob): Rely on multi_glob() to determine 623 whether files exist or not. Remove call to file_exists_p() which 624 is not always correct. Fixes Savannah bug #21231. 625 * read.c (multi_glob): Add a new argument EXISTS_ONLY; if true 626 then only files that really exist will be returned. 627 * dep.h: Add new argument to multi_glob(). 628 * rule.c (install_pattern_rule): Ditto. 629 * read.c (eval): Ditto. 630 * main.c (main): Ditto. 631 * implicit.c (pattern_search): Ditto. 632 * file.c (parse_prereqs): Ditto. 633 * default.c (set_default_suffixes): Ditto. 634 635 2009-06-09 Paul Smith <[email protected]> 636 637 * commands.c (set_file_variables): If always_make_flag is set, 638 always add the prereq to $?. Fixes Savannah bug #17825. 639 640 * remake.c (update_file_1): When rebuilding deps of FILE, also try 641 to rebuild the deps of all the also_make targets for that file. 642 Fixes Savannah bug #19108. 643 644 * implicit.c (pattern_search): Undo test for is_target, added by 645 BorisK on 21 Sep 2004. This goes against step 5c in the "Implicit 646 Rule Search Algorithm". Fixes Savannah bug #17752. 647 648 * main.c (clean_jobserver): Clear the jobserver_fds options and 649 set job_slots to the default when we clean up. 650 (define_makeflags): Return the new MAKEFLAGS value. 651 (main): Reset MAKEFLAGS in the environment when we re-exec. 652 Fixes Savannah bug #18124. 653 654 2009-06-08 Paul Smith <[email protected]> 655 656 * read.c (eval): Collapse continuations post-semicolon on target- 657 specific variables. Fixes Savannah bug #17521. 658 659 2009-06-07 Paul Smith <[email protected]> 660 661 * job.c (reap_children): For older systems without waitpid() (are 662 there any of these left?) run wait(2) inside EINTRLOOP to handle 663 EINTR errors. Fixes Savannah bug #16401. 664 665 * (various): Debug message cleanup. Fixes Savannah bug #16469. 666 667 * main.c: Fix bsd_signal() typedef. Fixes Savannah bug #16473. 668 669 * file.c (snap_deps): Set SNAPPED_DEPS at the start of snapping, 670 not the end, to catch second expansion $(eval ...) defining new 671 target/prereq relationships during snap_deps. 672 Fixes Savannah bug #24622. 673 674 * read.c (record_files): The second-expansion "f->updating" hack 675 was not completely correct: if assumed that the target with 676 commands always had prerequisites; if one didn't then the ordering 677 was messed up. Fixed for now to use f->updating to decide whether 678 to preserve the last element in the deps list... but this whole 679 area of constructing and reversing the deps list is too confusing 680 and needs to be reworked. Fixes Savannah bug #21198. 681 682 2009-06-06 Paul Smith <[email protected]> 683 684 * hash.c (hash_insert): Remove useless test for NULL. 685 Fixes Savannah bug #21823. 686 687 * make.h: Move SET_STACK_SIZE determination to make.h. 688 * main.c (main): New global variable, STACK_LIMIT, holds the 689 original stack limit when make was started. 690 * job.c (start_job_command): Reset the stack limit, if we changed it. 691 Fixes Savannah bug #22010. 692 693 * remake.c (check_dep): Only set the target's state to not-started 694 if it's not already running. Found this while testing -j10 builds 695 of glibc: various targets were being rebuilt multiple times. 696 Fix from Knut St. Osmundsen; fixes a problem reported in Savannah 697 bug #15919. 698 699 * read.c (multi_glob): Don't pass GLOB_NOCHECK to glob(3); instead 700 handle the GLOB_NOMATCH error. This is to work around Sourceware.org 701 Bugzilla bug 10246. 702 703 2009-06-04 Paul Smith <[email protected]> 704 705 * read.c (eval): Skip initial whitespace (ffeed, vtab, etc.) 706 707 * maintMakefile: Modify access of config and gnulib Savannah 708 modules to use GIT instead of CVS. 709 710 * main.c (main): Initialize the LENGTH field in SHELL_VAR. 711 Fixes Savannah bug #24655. 712 713 * read.c (eval_buffer): Don't dereference reading_file if it's NULL; 714 this can happen during some invocations of $(eval ...) for example. 715 Fixes Savannah bug #24588. Patch by Lars Jessen <[email protected]> 716 717 2009-06-02 Paul Smith <[email protected]> 718 719 * configure.in: Check for fileno() 720 * read.c (eval_makefile): If fileno() is available, set CLOSE_ON_EXEC 721 for the makefile file so invocations of $(shell ...) don't inherit it. 722 Fixes Savannah bug #24277. 723 724 2009-06-01 Paul Smith <[email protected]> 725 726 * main.c (main): The previous fix for .DEFAULT_GOAL had issues; 727 expansion was handled incorrectly. Rework the default goal 728 handling to save the variable only. Remove default_goal_file and 729 default_goal_name. 730 * read.c (eval): Check default_goal_var, not default_goal_name. 731 * read.c (record_target_var): Don't check default_goal_file here. 732 733 2009-05-31 Paul Smith <[email protected]> 734 735 * main.c (main): Expand the .DEFAULT_GOAL variable before using 736 it, and if the multi_glob() returns nothing (say it expanded to 737 nothing but spaces) then don't crash. Fixes Savannah bug #25697. 738 739 * doc/make.texi (Quick Reference): Add $(if ..), $(or ..), and 740 $(and ..) to the reference. Fixes Savannah bug #25694. 741 742 * make.1: Be clear that some recipes will be executed even with -n. 743 * doc/make.texi: Ditto. Fixes Savannah bug #25460. 744 745 * doc/make.texi (Override Directive): Make more clear how 746 overrides and appends interact. 747 Elucidates part of Savannah bug #26207. 748 749 * read.c (record_target_var): Don't reset the origin on 750 target-specific variables; try_variable_definition() will handle 751 this correctly. Fixes Savannah bug #26207. 752 753 * maintMakefile (do-po-update): Copy PO files into $(top_srcdir). 754 Fixes Savannah bug #25712. 755 756 * implicit.c (pattern_search): Keep a pointer to the beginning of 757 the filename and save that instead of the constructed pointer. 758 Fixes Savannah bug #26593. 759 Patch by Mark Seaborn <[email protected]> 760 761 2009-05-30 Paul Smith <[email protected]> 762 763 * doc/make.texi (Multi-Line): Add a description of the new abilities 764 of define/endef. Rename "Sequences" to "Multi-Line" and fix some 765 "command sequence" vs. "recipe" syntax. 766 * read.c (do_define): Modify to allow assignment tokens (=, :=, etc.) 767 after a define, to create variables with those flavors. 768 769 2009-05-25 Paul Smith <[email protected]> 770 771 Reworked the parser for variable assignments to allow multiple 772 modifiers, and in any order. Also allows variable and 773 prerequisites to be modifier names ('export', 'private', etc.) 774 775 * NEWS: Add notes about user-visible changes. 776 777 * read.c (struct vmodifiers): Remember what modifiers were seen. 778 (parse_var_assignment): New function to parse variable assignments. 779 (eval): Call the new function. Handle variable assignments earlier. 780 781 * variable.c (parse_variable_definition): Only parse; don't create var. 782 (assign_variable_definition): Call parse, then create the var. 783 784 2009-05-24 Paul Smith <[email protected]> 785 786 * doc/make.texi: Fix the ISBN for the GNU make manual. Incorrect 787 value noticed by Hans Stol <[email protected]>. 788 789 2009-03-14 Eli Zaretskii <[email protected]> 790 791 * w32/pathstuff.c (convert_Path_to_windows32): Fix last change. 792 Fixes Savannah bug #25412. 793 794 * w32/subproc/sub_proc.c <top level>: Update Copyright years. Add 795 prototype for xmalloc. 796 (find_file): Accept 3 arguments PATH_VAR, FULL_FNAME, and FULL_LEN 797 instead of an LPOFSTRUCT pointer. Use xmalloc instead of malloc. 798 Loop over an array of extensions, instead of duplicating the same 799 code inline. Use SearchPath followed by CreateFile, instead of 800 the obsolete OpenFile. Fixes Savannah bug #17277. 801 (process_begin): Find $(PATH) in `envp', and pass a pointer to it 802 to `find_file'. Fixes Savannah bug #25662. 803 804 2009-03-07 Eli Zaretskii <[email protected]> 805 806 * function.c (func_shell): Don't close pipedes[1] if it is -1. 807 Fixes Savannah bug #20495. 808 809 2009-02-28 Ralf Wildenhues <address@hidden> 810 811 * doc/make.texi (Instead of Execution): Document interaction of 812 -t with phony targets. 813 814 2009-02-23 Ramon Garcia <[email protected]> 815 816 Introduce a new keyword "private" which applies to target-specific 817 variables and prevents their values from being inherited. 818 819 * variable.h (struct variable): Add private_var flag to each variable. 820 Add a flag to specify which list entry switches to the parent target. 821 * variable.c (define_variable_in_set): Initialize private_var flag. 822 (lookup_variable): Skip private variables in parent contexts. 823 (initialize_file_variables): Set next_is_parent appropriately. 824 (print_variable): Show the private_var flag. 825 * read.c (eval): Recognize the private keyword. 826 (record_target_var): Set private_var. 827 * doc/make.texi (Suppressing Inheritance): Add documentation. 828 829 2008-10-26 Paul Smith <[email protected]> 830 831 * configure.in: Check for strndup(). 832 * misc.c (xstrndup): Rename savestring to xstrndup. Use strndup 833 if it's available. 834 * make.h: Rename savestring to xstrndup. 835 * commands.c (chop_commands): Ditto. 836 * function.c (func_foreach): Ditto. 837 * read.c (eval, record_files): Ditto. 838 * variable.c (define_variable_in_set): Ditto. 839 1 840 2008-09-30 Eli Zaretskii <[email protected]> 2 841 … … 816 1655 817 1656 * make.1: Fix some display errors and document all existing options. 818 Patch providedby Mike Frysinger <[email protected]>.1657 Patch by Mike Frysinger <[email protected]>. 819 1658 820 1659 2005-12-11 Paul D. Smith <[email protected]> … … 3164 4003 3165 4004 3166 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software3167 Foundation, Inc.4005 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free 4006 Software Foundation, Inc. 3168 4007 This file is part of GNU Make. 3169 4008 -
trunk/src/kmk/ChangeLog.1
r1993 r2591 4984 4984 4985 4985 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 4986 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation,4987 Inc.4986 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 Free 4987 Software Foundation, Inc. 4988 4988 This file is part of GNU Make. 4989 4989 -
trunk/src/kmk/Makefile.DOS.template
r1993 r2591 3 3 # 4 4 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 5 # 2004, 2005, 2006, 2007 Free Software Foundation, Inc.5 # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 6 6 # This file is part of GNU Make. 7 7 # … … 86 86 man_MANS = make.1 87 87 88 INCLUDES = -I$(srcdir)/glob -DLIBDIR=\" c:/djgpp/lib\" -DINCLUDEDIR=\"c:/djgpp/include\" -DLOCALEDIR=\"$(localedir)\"88 INCLUDES = -I$(srcdir)/glob -DLIBDIR=\"$(prefix)$(libdir)\" -DINCLUDEDIR=\"$(prefix)$(includedir)\" -DLOCALEDIR=\"$(prefix)$(localedir)\" 89 89 90 90 BUILT_SOURCES = README build.sh-in … … 92 92 EXTRA_DIST = $(BUILT_SOURCES) $(man_MANS) README.customs remote-cstms.c make-stds.texi texinfo.tex SCOPTIONS SMakefile Makefile.ami README.Amiga config.ami amiga.c amiga.h NMakefile README.DOS configh.dos configure.bat makefile.com README.W32 build_w32.bat config.h-W32 subproc.bat make.lnk config.h-vms makefile.vms readme.vms vmsdir.h vmsfunctions.c vmsify.c 93 93 94 SUBDIRS = glob 94 SUBDIRS = glob doc 95 95 mkinstalldirs = ${exec_prefix}/bin/gmkdir -p 96 96 CONFIG_HEADER = config.h … … 116 116 TEXI2DVI = texi2dvi 117 117 TEXINFO_TEX = $(srcdir)/config/texinfo.tex 118 INFO_DEPS = make.info119 DVIS = make.dvi118 INFO_DEPS = doc/make.info 119 DVIS = doc/make.dvi 120 120 TEXINFOS = doc/make.texi 121 121 noinst_TEXINFOS = doc/fdl.texi doc/make-stds.texi 122 122 man1dir = $(mandir)/man1 123 123 MANS = $(man_MANS) 124 125 TEXI2HTML = texi2html126 TEXI2HTML_FLAGS = -split_chapter127 124 128 125 NROFF = nroff … … 192 189 # Documentation 193 190 194 make.info: doc/make.texi 195 make.dvi: doc/make.texi 191 make.info: make.texi 192 make.dvi: make.texi 193 make.ps: make.dvi make.texi 194 make.html: make.texi 196 195 197 196 … … 201 200 @command.com /c if exist make.info* del make.info* 202 201 @command.com /c if exist make.i* del make.i* 203 $(MAKEINFO) -I$(srcdir) /doc--no-split $< -o ./$@202 $(MAKEINFO) -I$(srcdir) --no-split $< -o ./$@ 204 203 205 204 .texi: 206 205 @command.com /c if exist make.info* del make.info* 207 206 @command.com /c if exist make.i* del make.i* 208 $(MAKEINFO) -I$(srcdir) /doc--no-split $< -o ./$@207 $(MAKEINFO) -I$(srcdir) --no-split $< -o ./$@ 209 208 210 209 .texi.dvi: 211 TEXINPUTS="$(srcdir) /doc;$$TEXINPUTS" MAKEINFO='$(MAKEINFO) -I $(srcdir)/doc' $(TEXI2DVI) $<210 TEXINPUTS="$(srcdir);$$TEXINPUTS" MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $< 212 211 213 212 .dvi.ps: … … 216 215 # Other documentation formats 217 216 218 html: make_1.html 219 220 make_1.html: $(TEXINFOS) $(noinst_TEXINFOS) 221 $(TEXI2HTML) $(TEXI2HTML_FLAGS) $(srcdir)/doc/make.texi 217 html: html-recursive 218 219 .texi.html: 220 @command.com /c if exist make.html* del make.html* 221 $(MAKEINFO) --html -I$(srcdir) --no-split $< -o ./$@ 222 222 223 223 install-info-am: $(INFO_DEPS) 224 224 @$(NORMAL_INSTALL) 225 225 $(mkinstalldirs) $(DESTDIR)$(infodir) 226 @for file in $(INFO_DEPS); do d=$(srcdir); for ifile in `cd $$d && echo $$file`; do if test -f $$d/$$ifile; then echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; else : ; fi; done; done226 @for file in $(INFO_DEPS); do iifile=`echo $$file | sed "s|doc/||"`; d=$(srcdir); for ifile in `cd $$d && echo $$file`; do if test -f $$d/$$ifile; then echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$iifile"; $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$iifile; else : ; fi; done; done 227 227 @$(POST_INSTALL) 228 @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then for file in $(INFO_DEPS); do echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file"; install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :; done; else : ; fi228 @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then for file in $(INFO_DEPS); do iifile=`echo $$file | sed "s|doc/||"`; echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$iifile"; install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$iifile || :; done; else : ; fi 229 229 230 230 uninstall-info: … … 238 238 239 239 mostlyclean-aminfo: 240 -rm -f make.aux make.cp make.cps make.dvi make.fn make.fns make.ky \ 241 make.kys make.ps make.log make.pg make.toc make.tp make.tps \ 242 make.vr make.vrs make.op make.tr make.cv make.cn 240 -rm -f $(srcdir)/doc/make.aux $(srcdir)/doc/make.cp $(srcdir)/doc/make.cps $(srcdir)/doc/make.dvi \ 241 $(srcdir)/doc/make.fn $(srcdir)/doc/make.fns $(srcdir)/doc/make.ky $(srcdir)/doc/make.kys \ 242 $(srcdir)/doc/make.ps $(srcdir)/doc/make.log $(srcdir)/doc/make.pg $(srcdir)/doc/make.toc \ 243 $(srcdir)/doc/make.tp $(srcdir)/doc/make.tps $(srcdir)/doc/make.vr $(srcdir)/doc/make.vrs \ 244 $(srcdir)/doc/make.op $(srcdir)/doc/make.tr $(srcdir)/doc/make.cv $(srcdir)/doc/make.cn \ 245 $(srcdir)/doc/make.html 243 246 244 247 clean-aminfo: … … 292 295 # a single directory, yell bloody murder. 293 296 all-recursive: 294 ifeq ($( words $(SUBDIRS)), 1)297 ifeq ($(findstring glob, $(SUBDIRS)), glob) 295 298 @command.com /c if not exist glob\\nul md glob 296 @echo Making all in $(SUBDIRS) 297 $(MAKE) -C $(SUBDIRS) -f ../Makefile INCLUDES='-I$(srcdir) -I$(srcdir)/glob' DEFS='-I.. -I$(srcdir)' VPATH=$(srcdir)/glob libglob.a 298 else 299 @echo FATAL: There is more than one directory in "($(SUBDIRS))" 300 @$(EXIT_FAIL) 299 @echo Making all in glob 300 $(MAKE) -C glob -f ../Makefile INCLUDES='-I$(srcdir) -I$(srcdir)/glob' DEFS='-I.. -I$(srcdir)' VPATH=$(srcdir)/glob libglob.a 301 301 endif 302 302 … … 311 311 mostlyclean-recursive clean-recursive distclean-recursive \ 312 312 maintainer-clean-recursive check-recursive: 313 ifeq ($(words $(SUBDIRS)), 1) 314 @echo Making $(shell echo $@ | sed s/-recursive//) in $(SUBDIRS) 315 $(MAKE) -C $(SUBDIRS) -f ../Makefile $(shell echo $@ | sed s/-recursive//)-am 313 ifeq ($(words $(SUBDIRS)), 2) 314 @echo Making $(shell echo $@ | sed s/-recursive//) in glob 315 $(MAKE) -C glob -f ../Makefile $(shell echo $@ | sed s/-recursive//)-am 316 @echo Making $(shell echo $@ | sed s/-recursive//) in doc 317 $(MAKE) -C doc -f ../Makefile $(shell echo $@ | sed s/-recursive//)-am 316 318 else 317 @echo FATAL: There is more than onedirectory in "($(SUBDIRS))"319 @echo FATAL: There is more than two directory in "($(SUBDIRS))" 318 320 @$(EXIT_FAIL) 319 321 endif … … 323 325 324 326 tags-recursive: 325 ifeq ($(words $(SUBDIRS)), 1)327 ifeq ($(words $(SUBDIRS)), 2) 326 328 $(MAKE) tags-in-glob 327 329 else 328 @echo FATAL: There is more than onedirectory in "($(SUBDIRS))"330 @echo FATAL: There is more than two directory in "($(SUBDIRS))" 329 331 @$(EXIT_FAIL) 330 332 endif … … 377 379 $(MAKE) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook 378 380 379 info: $(INFO_DEPS) info-recursive 380 dvi: $(DVIS) dvi-recursive 381 info: info-recursive 382 info-recursive: 383 ifeq ($(findstring doc, $(SUBDIRS)), doc) 384 @command.com /c if not exist doc\\nul md doc 385 @echo Making all in doc 386 $(MAKE) -C doc -f ../Makefile VPATH=$(srcdir)/doc make.info 387 endif 388 389 dvi: dvi-recursive 390 dvi-recursive: 391 ifeq ($(findstring doc, $(SUBDIRS)), doc) 392 @command.com /c if not exist doc\\nul md doc 393 @echo Making all in doc 394 $(MAKE) -C doc -f ../Makefile VPATH=$(srcdir)/doc make.dvi 395 endif 396 397 ps: ps-recursive 398 ps-recursive: 399 ifeq ($(findstring doc, $(SUBDIRS)), doc) 400 @command.com /c if not exist doc\\nul md doc 401 @echo Making all in doc 402 $(MAKE) -C doc -f ../Makefile VPATH=$(srcdir)/doc make.ps 403 endif 404 405 html-recursive: 406 ifeq ($(findstring doc, $(SUBDIRS)), doc) 407 @command.com /c if not exist doc\\nul md doc 408 @echo Making all in doc 409 $(MAKE) -C doc -f ../Makefile VPATH=$(srcdir)/doc make.html 410 endif 411 381 412 check: all-am check-recursive check-local 382 413 @: … … 385 416 $(MAKE) all-recursive 386 417 387 all-am: Makefile $( INFO_DEPS) $(PROGRAMS) config.h418 all-am: Makefile $(PROGRAMS) config.h info 388 419 389 420 install-exec-am: install-binPROGRAMS -
trunk/src/kmk/Makefile.am
r2548 r2591 2 2 # 3 3 # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 4 # 2007 Free Software Foundation, Inc.4 # 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 5 5 # This file is part of GNU Make. 6 6 # -
trunk/src/kmk/Makefile.ami
r1993 r2591 5 5 # 6 6 # Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 7 # 2005, 2006, 2007 Free Software Foundation, Inc.7 # 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 8 8 # This file is part of GNU Make. 9 9 # -
trunk/src/kmk/NEWS
r1993 r2591 1 1 GNU make NEWS -*-indented-text-*- 2 2 History of user-visible changes. 3 1 April 20063 28 July 2010 4 4 5 5 See the end of this file for copyrights and conditions. … … 11 11 12 12 13 Version 3.81.90 13 Version 3.82 14 15 A complete list of bugs fixed in this version is available here: 16 17 http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=104&set=custom 14 18 15 19 * Compiling GNU make now requires a conforming ISO C 1989 compiler and 16 20 standard runtime library. 21 22 * WARNING: Future backward-incompatibility! 23 Wildcards are not documented as returning sorted values, but up to and 24 including this release the results have been sorted and some makefiles are 25 apparently depending on that. In the next release of GNU make, for 26 performance reasons, we may remove that sorting. If your makefiles 27 require sorted results from wildcard expansions, use the $(sort ...) 28 function to request it explicitly. 29 30 * WARNING: Backward-incompatibility! 31 The POSIX standard for make was changed in the 2008 version in a 32 fundamentally incompatible way: make is required to invoke the shell as if 33 the '-e' flag were provided. Because this would break many makefiles that 34 have been written to conform to the original text of the standard, the 35 default behavior of GNU make remains to invoke the shell with simply '-c'. 36 However, any makefile specifying the .POSIX special target will follow the 37 new POSIX standard and pass '-e' to the shell. See also .SHELLFLAGS 38 below. 39 40 * WARNING: Backward-incompatibility! 41 The '$?' variable now contains all prerequisites that caused the target to 42 be considered out of date, even if they do not exist (previously only 43 existing targets were provided in $?). 44 45 * WARNING: Backward-incompatibility! 46 As a result of parser enhancements, three backward-compatibility issues 47 exist: first, a prerequisite containing an "=" cannot be escaped with a 48 backslash any longer. You must create a variable containing an "=" and 49 use that variable in the prerequisite. Second, variable names can no 50 longer contain whitespace, unless you put the whitespace in a variable and 51 use the variable. Third, in previous versions of make it was sometimes 52 not flagged as an error for explicit and pattern targets to appear in the 53 same rule. Now this is always reported as an error. 54 55 * WARNING: Backward-incompatibility! 56 The pattern-specific variables and pattern rules are now applied in the 57 shortest stem first order instead of the definition order (variables 58 and rules with the same stem length are still applied in the definition 59 order). This produces the usually-desired behavior where more specific 60 patterns are preferred. To detect this feature search for 'shortest-stem' 61 in the .FEATURES special variable. 62 63 * WARNING: Backward-incompatibility! 64 The library search behavior has changed to be compatible with the standard 65 linker behavior. Prior to this version for prerequisites specified using 66 the -lfoo syntax make first searched for libfoo.so in the current 67 directory, vpath directories, and system directories. If that didn't yield 68 a match, make then searched for libfoo.a in these directories. Starting 69 with this version make searches first for libfoo.so and then for libfoo.a 70 in each of these directories in order. 71 72 * New command line option: --eval=STRING causes STRING to be evaluated as 73 makefile syntax (akin to using the $(eval ...) function). The evaluation 74 is performed after all default rules and variables are defined, but before 75 any makefiles are read. 17 76 18 77 * New special variable: .RECIPEPREFIX allows you to reset the recipe 19 78 introduction character from the default (TAB) to something else. The 20 79 first character of this variable value is the new recipe introduction 21 character. If the variable is set to the empty string, TAB is used 22 again. It can be set and reset at will; rules will be parsed 23 according to the current value. 80 character. If the variable is set to the empty string, TAB is used again. 81 It can be set and reset at will; recipes will use the value active when 82 they were first parsed. To detect this feature check the value of 83 $(.RECIPEPREFIX). 84 85 * New special variable: .SHELLFLAGS allows you to change the options passed 86 to the shell when it invokes recipes. By default the value will be "-c" 87 (or "-ec" if .POSIX is set). 88 89 * New special target: .ONESHELL instructs make to invoke a single instance 90 of the shell and provide it with the entire recipe, regardless of how many 91 lines it contains. As a special feature to allow more straightforward 92 conversion of makefiles to use .ONESHELL, any recipe line control 93 characters ('@', '+', or '-') will be removed from the second and 94 subsequent recipe lines. This happens _only_ if the SHELL value is deemed 95 to be a standard POSIX-style shell. If not, then no interior line control 96 characters are removed (as they may be part of the scripting language used 97 with the alternate SHELL). 98 99 * New variable modifier 'private': prefixing a variable assignment with the 100 modifier 'private' suppresses inheritance of that variable by 101 prerequisites. This is most useful for target- and pattern-specific 102 variables. 103 104 * New make directive: 'undefine' allows you to undefine a variable so that 105 it appears as if it was never set. Both $(flavor) and $(origin) functions 106 will return 'undefined' for such a variable. To detect this feature search 107 for 'undefine' in the .FEATURES special variable. 108 109 * The parser for variable assignments has been enhanced to allow multiple 110 modifiers ('export', 'override', 'private') on the same line as variables, 111 including define/endef variables, and in any order. Also, it is possible 112 to create variables and targets named as these modifiers. 113 114 * The 'define' make directive now allows a variable assignment operator 115 after the variable name, to allow for simple, conditional, or appending 116 multi-line variable assignment. 24 117 25 118 … … 60 153 61 154 * WARNING: Backward-incompatibility! 62 63 155 In order to comply with POSIX, the way in which GNU make processes 64 156 backslash-newline sequences in recipes has changed. If your makefiles … … 1059 1151 ------------------------------------------------------------------------------- 1060 1152 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1061 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software 1062 Foundation, Inc. 1063 This file is part of GNU Make. 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. 1064 1155 1065 1156 GNU Make is free software; you can redistribute it and/or modify it under the -
trunk/src/kmk/NMakefile.template
r1993 r2591 5 5 # 6 6 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 7 # 2006, 2007 Free Software Foundation, Inc.7 # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 8 8 # This file is part of GNU Make. 9 9 # … … 34 34 35 35 LDFLAGS_debug = w32\subproc\WinDebug\subproc.lib /NOLOGO /SUBSYSTEM:console\ 36 /INCREMENTAL:no /PDB:WinDebug/make.pdb /MACHINE:I386 \ 37 /OUT:WinDebug/make.exe /DEBUG 36 /INCREMENTAL:no /PDB:WinDebug/make.pdb /OUT:WinDebug/make.exe /DEBUG 38 37 LDFLAGS_release = w32\subproc\WinRel\subproc.lib /NOLOGO /SUBSYSTEM:console\ 39 /INCREMENTAL:no / MACHINE:I386 /OUT:WinRel/make.exe38 /INCREMENTAL:no /OUT:WinRel/make.exe 40 39 41 40 all: config.h subproc Release Debug -
trunk/src/kmk/README.Amiga
r1993 r2591 64 64 ------------------------------------------------------------------------------- 65 65 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 66 2005, 2006, 2007 Free Software Foundation, Inc.66 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 67 67 This file is part of GNU Make. 68 68 -
trunk/src/kmk/README.DOS.template
r1993 r2591 327 327 ------------------------------------------------------------------------------- 328 328 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 329 2006, 2007 Free Software Foundation, Inc.329 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 330 330 This file is part of GNU Make. 331 331 -
trunk/src/kmk/README.OS2.template
r1993 r2591 162 162 163 163 ------------------------------------------------------------------------------- 164 Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 164 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 165 Foundation, Inc. 165 166 This file is part of GNU Make. 166 167 -
trunk/src/kmk/README.W32.template
r1993 r2591 275 275 ------------------------------------------------------------------------------- 276 276 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 277 2006, 2007, 2008 Free Software Foundation, Inc.277 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 278 278 This file is part of GNU Make. 279 279 -
trunk/src/kmk/README.customs
r1993 r2591 98 98 99 99 ------------------------------------------------------------------------------- 100 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free101 Software Foundation, Inc.100 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 101 2009, 2010 Free Software Foundation, Inc. 102 102 This file is part of GNU Make. 103 103 -
trunk/src/kmk/README.cvs
r1993 r2591 2 2 3 3 ------------------------------------------------------------------------------- 4 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.5 This file is part of GNU Make.4 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free 5 Software Foundation, Inc. This file is part of GNU Make. 6 6 7 7 GNU Make is free software; you can redistribute it and/or modify it under the … … 211 211 make check 212 212 213 Or, for a debugging version: 214 215 autoreconf -i && ./configure CFLAGS=-g && make update && make && make check 216 213 217 Or, all-in-one: 214 218 -
trunk/src/kmk/README.template
r1993 r2591 174 174 ------------------------------------------------------------------------------- 175 175 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 176 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software177 Foundation, Inc.176 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 177 2010 Free Software Foundation, Inc. 178 178 This file is part of GNU Make. 179 179 -
trunk/src/kmk/SMakefile.template
r1993 r2591 5 5 # 6 6 # Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 7 # 2005, 2006, 2007 Free Software Foundation, Inc.7 # 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 8 8 # This file is part of GNU Make. 9 9 # -
trunk/src/kmk/TODO.private
r1993 r2591 66 66 67 67 3) Multi-token pattern rule matching (allow %1/%2.c : %1/obj/%2.o, 68 etc., or something like that). I have an implementation of this 69 already, it just needs some refinement... maybe. Additionally I 70 think it only works for static pattern rules; it might need to be 71 fixed up to work with normal pattern rules, too. 68 etc., or something like that). Maybe using regex? 72 69 73 70 4) Provide a .TARGETS variable, containing the names of the targets … … 130 127 131 128 ------------------------------------------------------------------------------- 132 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007133 Free Software Foundation, Inc.129 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 130 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 134 131 This file is part of GNU Make. 135 132 -
trunk/src/kmk/acinclude.m4
r1993 r2591 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 Free Software Foundation, Inc.4 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 5 dnl 2008, 2009, 2010 Free Software Foundation, Inc. 6 6 dnl This file is part of GNU Make. 7 7 dnl -
trunk/src/kmk/amiga.c
r1993 r2591 1 1 /* Running commands on Amiga 2 2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 2005, 2006, 2007 Free Software Foundation, Inc.3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/amiga.h
r1993 r2591 1 1 /* Definitions for amiga specific things 2 2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 2005, 2006, 2007 Free Software Foundation, Inc.3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/ar.c
r1993 r2591 1 1 /* Interface to `ar' archives for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software 4 Foundation, Inc. 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 6 This file is part of GNU Make. 6 7 … … 25 26 #include <fnmatch.h> 26 27 27 /* Return nonzero if NAME is an archive-member reference, zero if not. 28 An archive-member reference is a name like `lib(member)'. 28 /* Return nonzero if NAME is an archive-member reference, zero if not. An 29 archive-member reference is a name like `lib(member)' where member is a 30 non-empty string. 29 31 If a name like `lib((entry))' is used, a fatal error is signaled at 30 32 the attempt to use this unsupported feature. */ … … 40 42 41 43 end = p + strlen (p) - 1; 42 if (*end != ')' )44 if (*end != ')' || end == p + 1) 43 45 return 0; 44 46 … … 199 201 { 200 202 /* We have a match. Add it to the chain. */ 201 struct nameseq *new = xmalloc (state->size); 202 memset (new, '\0', state->size); 203 new->name = strcache_add (concat (state->arname, mem, ")")); 203 struct nameseq *new = xcalloc (state->size); 204 new->name = strcache_add (concat (4, state->arname, "(", mem, ")")); 204 205 new->next = state->chain; 205 206 state->chain = new; … … 216 217 { 217 218 const char *p; 218 int open = 0;219 int opened = 0; 219 220 220 221 for (p = pattern; *p != '\0'; ++p) … … 231 232 232 233 case '[': 233 open = 1;234 opened = 1; 234 235 break; 235 236 236 237 case ']': 237 if (open )238 if (opened) 238 239 return 1; 239 240 break; … … 252 253 struct nameseq *n; 253 254 const char **names; 254 char *name;255 255 unsigned int i; 256 256 … … 260 260 /* Scan the archive for matches. 261 261 ar_glob_match will accumulate them in STATE.chain. */ 262 i = strlen (arname); 263 name = alloca (i + 2); 264 memcpy (name, arname, i); 265 name[i] = '('; 266 name[i + 1] = '\0'; 267 state.arname = name; 262 state.arname = arname; 268 263 state.pattern = member_pattern; 269 264 state.size = size; … … 282 277 283 278 /* Sort them alphabetically. */ 284 qsort (names, i, sizeof (*names), alpha_compare); 279 /* MSVC erroneously warns without a cast here. */ 280 qsort ((void *)names, i, sizeof (*names), alpha_compare); 285 281 286 282 /* Put them back into the chain in the sorted order. */ -
trunk/src/kmk/arscan.c
r2546 r2591 1 1 /* Library function for scanning an archive file. 2 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 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 67 67 if (! (status & 1)) 68 68 { 69 error (NILF, _("lbr$set_module failed to extract module info, status = %d"),69 error (NILF, _("lbr$set_module() failed to extract module info, status = %d"), 70 70 status); 71 71 … … 82 82 * know if this causes problems in other VMS environments. 83 83 */ 84 val = decc$fix_time (&mhd->mhd$l_datim) + timezone - daylight*3600; 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 } 85 106 #endif 86 107 … … 152 173 if (! (status & 1)) 153 174 { 154 error (NILF, _("lbr$ini_control failed with status = %d"),status);175 error (NILF, _("lbr$ini_control() failed with status = %d"), status); 155 176 return -2; 156 177 } 157 178 158 libdesc.dsc$a_pointer = archive; 179 /* there is no such descriptor with "const char *dsc$a_pointer" */ 180 libdesc.dsc$a_pointer = (char *)archive; 159 181 libdesc.dsc$w_length = strlen (archive); 160 182 … … 251 273 }; 252 274 # endif 275 # define TOCHAR(_m) (_m) 253 276 #else 254 277 /* These should allow us to read Windows (VC++) libraries (according to Frank … … 267 290 # define ar_uid UserID 268 291 # define ar_gid GroupID 292 /* In Windows the member names have type BYTE so we must cast them. */ 293 # define TOCHAR(_m) ((char *)(_m)) 269 294 #endif 270 295 … … 610 635 611 636 #ifndef M_XENIX 612 sscanf ( member_header.ar_mode, "%o", &eltmode);613 eltsize = atol ( member_header.ar_size);637 sscanf (TOCHAR (member_header.ar_mode), "%o", &eltmode); 638 eltsize = atol (TOCHAR (member_header.ar_size)); 614 639 #else /* Xenix. */ 615 640 eltmode = (unsigned short int) member_header.ar_mode; … … 621 646 member_offset + AR_HDR_SIZE, eltsize, 622 647 #ifndef M_XENIX 623 atol ( member_header.ar_date),624 atoi ( member_header.ar_uid),625 atoi ( member_header.ar_gid),648 atol (TOCHAR (member_header.ar_date)), 649 atoi (TOCHAR (member_header.ar_uid)), 650 atoi (TOCHAR (member_header.ar_gid)), 626 651 #else /* Xenix. */ 627 652 member_header.ar_date, … … 794 819 for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++) 795 820 ar_hdr.ar_date[ui] = ' '; 796 sprintf ( ar_hdr.ar_date, "%ld", (long int) statbuf.st_mtime);821 sprintf (TOCHAR (ar_hdr.ar_date), "%ld", (long int) statbuf.st_mtime); 797 822 #ifdef AIAMAG 798 823 ar_hdr.ar_date[strlen(ar_hdr.ar_date)] = ' '; -
trunk/src/kmk/build.template
r1993 r2591 4 4 5 5 # Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 6 # 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.6 # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 7 7 # This file is part of GNU Make. 8 8 # -
trunk/src/kmk/build_w32.bat
r1993 r2591 1 <<<<<<< .working2 1 @echo off 3 2 rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 4 rem 2006 Free Software Foundation, Inc.3 rem 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 5 4 rem This file is part of GNU Make. 5 rem 6 rem GNU Make is free software; you can redistribute it and/or modify it under 7 rem the terms of the GNU General Public License as published by the Free 8 rem Software Foundation; either version 3 of the License, or (at your option) 9 rem any later version. 10 rem 11 rem GNU Make is distributed in the hope that it will be useful, but WITHOUT 12 rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for. 14 rem more details. 15 rem 16 rem You should have received a copy of the GNU General Public License along 17 rem with this program. If not, see <http://www.gnu.org/licenses/>. 6 18 7 rem GNU Make is free software; you can redistribute it and/or modify it under the 8 rem terms of the GNU General Public License as published by the Free Software 9 rem Foundation; either version 2, or (at your option) any later version. 10 11 rem GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 12 rem WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 13 rem A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 15 rem You should have received a copy of the GNU General Public License along with 16 rem GNU Make; see the file COPYING. If not, write to the Free Software 17 rem Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 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 19 24 if not exist config.h copy config.h.W32 config.h 20 25 cd w32\subproc … … 90 95 echo off 91 96 echo "Linking WinDebug/%make%.exe" 92 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 / MACHINE:I386 /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.obj97 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 93 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 94 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG / MACHINE:I386 /OUT:.\WinDebug/%make%.exe @link.dbg99 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /OUT:.\WinDebug/%make%.exe @link.dbg 95 100 if not exist .\WinDebug/%make%.exe echo "WinDebug build failed" 96 101 if exist .\WinDebug/%make%.exe echo "WinDebug build succeeded!" … … 157 162 echo off 158 163 echo "Linking WinRel/%make%.exe" 159 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 / MACHINE:I386 /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.obj164 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 160 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 161 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /MACHINE:I386 /OUT:.\WinRel/%make%.exe @link.rel 162 if not exist .\WinRel/%make%.exe echo "WinRel build failed" 163 if exist .\WinRel/%make%.exe echo "WinRel build succeeded!" 164 set make= 165 GoTo BuildEnd 166 :GCCBuild 167 echo on 168 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c variable.c 169 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c rule.c 170 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c remote-stub.c 171 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c commands.c 172 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c file.c 173 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getloadavg.c 174 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c default.c 175 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c signame.c 176 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c expand.c 177 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c dir.c 178 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c main.c 179 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getopt1.c 180 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c job.c 181 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c read.c 182 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c version.c 183 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getopt.c 184 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c arscan.c 185 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c remake.c 186 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c hash.c 187 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c strcache.c 188 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c misc.c 189 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ar.c 190 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c function.c 191 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c vpath.c 192 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c implicit.c 193 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./glob/glob.c -o glob.o 194 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./glob/fnmatch.c -o fnmatch.o 195 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./w32/pathstuff.c -o pathstuff.o 196 gcc -mthreads -gstabs+ -ggdb3 -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 197 :BuildEnd 198 echo on 199 ======= 200 @echo off 201 rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 202 rem 2006, 2007 Free Software Foundation, Inc. 203 rem This file is part of GNU Make. 204 rem 205 rem GNU Make is free software; you can redistribute it and/or modify it under 206 rem the terms of the GNU General Public License as published by the Free 207 rem Software Foundation; either version 3 of the License, or (at your option) 208 rem any later version. 209 rem 210 rem GNU Make is distributed in the hope that it will be useful, but WITHOUT 211 rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 212 rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for. 213 rem more details. 214 rem 215 rem You should have received a copy of the GNU General Public License along 216 rem with this program. If not, see <http://www.gnu.org/licenses/>. 217 218 if exist config.h.W32 GoTo NotCVS 219 sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.in > config.h.W32.sed 220 echo s,%%PACKAGE%%,make,g >> config.h.W32.sed 221 sed -f config.h.W32.sed config.h.W32.template > config.h.W32 222 :NotCVS 223 if not exist config.h copy config.h.W32 config.h 224 cd w32\subproc 225 echo "Creating the subproc library" 226 %ComSpec% /c build.bat %1 227 cd ..\.. 228 229 if exist link.dbg del link.dbg 230 if exist link.rel del link.rel 231 echo "Creating GNU Make for Windows 9X/NT/2K/XP" 232 if "%1" == "gcc" GoTo GCCBuild 233 set make=gnumake 234 echo on 235 if not exist .\WinDebug\nul mkdir .\WinDebug 236 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 237 echo WinDebug\variable.obj >>link.dbg 238 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 239 echo WinDebug\rule.obj >>link.dbg 240 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 241 echo WinDebug\remote-stub.obj >>link.dbg 242 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 243 echo WinDebug\commands.obj >>link.dbg 244 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 245 echo WinDebug\file.obj >>link.dbg 246 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 247 echo WinDebug\getloadavg.obj >>link.dbg 248 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 249 echo WinDebug\default.obj >>link.dbg 250 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 251 echo WinDebug\signame.obj >>link.dbg 252 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 253 echo WinDebug\expand.obj >>link.dbg 254 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 255 echo WinDebug\dir.obj >>link.dbg 256 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 257 echo WinDebug\main.obj >>link.dbg 258 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 259 echo WinDebug\getopt1.obj >>link.dbg 260 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 261 echo WinDebug\job.obj >>link.dbg 262 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 263 echo WinDebug\read.obj >>link.dbg 264 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 265 echo WinDebug\version.obj >>link.dbg 266 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 267 echo WinDebug\getopt.obj >>link.dbg 268 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 269 echo WinDebug\arscan.obj >>link.dbg 270 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 271 echo WinDebug\hash.obj >>link.dbg 272 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 273 echo WinDebug\strcache.obj >>link.dbg 274 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 275 echo WinDebug\remake.obj >>link.dbg 276 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 277 echo WinDebug\misc.obj >>link.dbg 278 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 279 echo WinDebug\ar.obj >>link.dbg 280 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 281 echo WinDebug\function.obj >>link.dbg 282 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 283 echo WinDebug\vpath.obj >>link.dbg 284 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 285 echo WinDebug\implicit.obj >>link.dbg 286 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 287 echo WinDebug\dirent.obj >>link.dbg 288 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 289 echo WinDebug\glob.obj >>link.dbg 290 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 291 echo WinDebug\fnmatch.obj >>link.dbg 292 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 293 echo WinDebug\pathstuff.obj >>link.dbg 294 echo off 295 echo "Linking WinDebug/%make%.exe" 296 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 /MACHINE:I386 /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 297 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 298 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /MACHINE:I386 /OUT:.\WinDebug/%make%.exe @link.dbg 299 if not exist .\WinDebug/%make%.exe echo "WinDebug build failed" 300 if exist .\WinDebug/%make%.exe echo "WinDebug build succeeded!" 301 if not exist .\WinRel\nul mkdir .\WinRel 302 echo on 303 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 304 echo WinRel\variable.obj >>link.rel 305 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 306 echo WinRel\rule.obj >>link.rel 307 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 308 echo WinRel\remote-stub.obj >>link.rel 309 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 310 echo WinRel\commands.obj >>link.rel 311 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 312 echo WinRel\file.obj >>link.rel 313 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 314 echo WinRel\getloadavg.obj >>link.rel 315 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 316 echo WinRel\default.obj >>link.rel 317 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 318 echo WinRel\signame.obj >>link.rel 319 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 320 echo WinRel\expand.obj >>link.rel 321 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 322 echo WinRel\dir.obj >>link.rel 323 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 324 echo WinRel\main.obj >>link.rel 325 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 326 echo WinRel\getopt1.obj >>link.rel 327 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 328 echo WinRel\job.obj >>link.rel 329 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 330 echo WinRel\read.obj >>link.rel 331 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 332 echo WinRel\version.obj >>link.rel 333 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 334 echo WinRel\getopt.obj >>link.rel 335 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 336 echo WinRel\arscan.obj >>link.rel 337 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 338 echo WinRel\remake.obj >>link.rel 339 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 340 echo WinRel\hash.obj >>link.rel 341 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 342 echo WinRel\strcache.obj >>link.rel 343 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 344 echo WinRel\misc.obj >>link.rel 345 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 346 echo WinRel\ar.obj >>link.rel 347 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 348 echo WinRel\function.obj >>link.rel 349 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 350 echo WinRel\vpath.obj >>link.rel 351 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 352 echo WinRel\implicit.obj >>link.rel 353 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 354 echo WinRel\dirent.obj >>link.rel 355 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 356 echo WinRel\glob.obj >>link.rel 357 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 358 echo WinRel\fnmatch.obj >>link.rel 359 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 360 echo WinRel\pathstuff.obj >>link.rel 361 echo off 362 echo "Linking WinRel/%make%.exe" 363 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 /MACHINE:I386 /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 364 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 365 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /MACHINE:I386 /OUT:.\WinRel/%make%.exe @link.rel 166 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /OUT:.\WinRel/%make%.exe @link.rel 366 167 if not exist .\WinRel/%make%.exe echo "WinRel build failed" 367 168 if exist .\WinRel/%make%.exe echo "WinRel build succeeded!" … … 401 202 :BuildEnd 402 203 echo on 403 >>>>>>> .merge-right.r1992 -
trunk/src/kmk/commands.c
r2027 r2591 1 1 /* Command processing for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 44 44 45 45 46 #ifndef CONFIG_WITH_STRCACHE2 47 48 static unsigned long 49 dep_hash_1 (const void *key) 50 { 51 const struct dep *d = key; 52 return_STRING_HASH_1 (dep_name (d)); 53 } 54 55 static unsigned long 56 dep_hash_2 (const void *key) 57 { 58 const struct dep *d = key; 59 return_STRING_HASH_2 (dep_name (d)); 60 } 61 62 static int 63 dep_hash_cmp (const void *x, const void *y) 64 { 65 const struct dep *dx = x; 66 const struct dep *dy = y; 67 return strcmp (dep_name (dx), dep_name (dy)); 68 } 69 70 71 #else /* CONFIG_WITH_STRCACHE2 */ 72 73 /* Exploit the fact that all names are in the string cache. This means equal 74 names shall have the same storage and there is no need for hashing or 75 comparing. Use the address as the first hash, avoiding any touching of 76 the name, and the length as the second. */ 77 78 static unsigned long 79 dep_hash_1 (const void *key) 80 { 81 const char *name = dep_name ((struct dep const *) key); 82 assert (strcache2_is_cached (&file_strcache, name)); 83 return (size_t) name / sizeof(void *); 84 } 85 86 static unsigned long 87 dep_hash_2 (const void *key) 88 { 89 const char *name = dep_name ((struct dep const *) key); 90 return strcache2_get_len (&file_strcache, name); 91 } 92 93 static int 94 dep_hash_cmp (const void *x, const void *y) 95 { 96 struct dep *dx = (struct dep *) x; 97 struct dep *dy = (struct dep *) y; 98 const char *dxname = dep_name (dx); 99 const char *dyname = dep_name (dy); 100 int cmp = dxname == dyname ? 0 : 1; 101 102 /* check preconds: both cached and the cache contains no duplicates. */ 103 assert (strcache2_is_cached (&file_strcache, dxname)); 104 assert (strcache2_is_cached (&file_strcache, dyname)); 105 assert (cmp == 0 || strcmp (dxname, dyname) != 0); 106 107 /* If the names are the same but ignore_mtimes are not equal, one of these 108 is an order-only prerequisite and one isn't. That means that we should 109 remove the one that isn't and keep the one that is. */ 110 111 if (!cmp && dx->ignore_mtime != dy->ignore_mtime) 112 dx->ignore_mtime = dy->ignore_mtime = 0; 113 114 return cmp; 115 } 116 117 #endif /* CONFIG_WITH_STRCACHE2 */ 118 46 119 /* Set FILE's automatic variables up. */ 47 120 … … 53 126 #endif 54 127 { 55 conststruct dep *d;128 struct dep *d; 56 129 const char *at, *percent, *star, *less; 57 130 #ifdef CONFIG_WITH_STRCACHE2 … … 138 211 if (!d->ignore_mtime) 139 212 { 140 less = dep_name (d); 213 if (!d->need_2nd_expansion) 214 less = dep_name (d); 141 215 break; 142 216 } … … 214 288 unsigned int len; 215 289 290 struct hash_table dep_hash; 291 void **slot; 292 216 293 /* Compute first the value for $+, which is supposed to contain 217 294 duplicate dependencies as they were listed in the makefile. */ 218 295 219 296 plus_len = 0; 297 bar_len = 0; 220 298 for (d = file->deps; d != 0; d = d->next) 221 299 if (! d->ignore_mtime) 300 { 301 if (!d->need_2nd_expansion) 302 { 222 303 #ifndef CONFIG_WITH_STRCACHE2 223 plus_len += strlen (dep_name (d)) + 1; 224 #else 225 plus_len += strcache2_get_len (&file_strcache, dep_name (d)) + 1; 226 #endif 304 if (d->ignore_mtime) 305 bar_len += strlen (dep_name (d)) + 1; 306 else 307 plus_len += strlen (dep_name (d)) + 1; 308 #else 309 if (d->ignore_mtime) 310 bar_len += strcache2_get_len (&file_strcache, dep_name (d)) + 1; 311 else 312 plus_len += strcache2_get_len (&file_strcache, dep_name (d)) + 1; 313 #endif 314 } 315 } 316 317 if (bar_len == 0) 318 bar_len++; 227 319 if (plus_len == 0) 228 320 plus_len++; … … 230 322 if (plus_len > plus_max) 231 323 plus_value = xrealloc (plus_value, plus_max = plus_len); 324 232 325 cp = plus_value; 233 326 234 327 qmark_len = plus_len + 1; /* Will be this or less. */ 235 328 for (d = file->deps; d != 0; d = d->next) 236 if (! d->ignore_mtime )329 if (! d->ignore_mtime && ! d->need_2nd_expansion) 237 330 { 238 331 const char *c = dep_name (d); … … 255 348 cp += len; 256 349 *cp++ = FILE_LIST_SEPARATOR; 257 if (! d->changed)350 if (! (d->changed || always_make_flag)) 258 351 qmark_len -= len + 1; /* Don't space in $? for this one. */ 259 352 } … … 263 356 cp[cp > plus_value ? -1 : 0] = '\0'; 264 357 DEFINE_VARIABLE ("+", 1, plus_value); 265 266 /* Make sure that no dependencies are repeated. This does not267 really matter for the purpose of updating targets, but it268 might make some names be listed twice for $^ and $?. */269 270 uniquize_deps (file->deps);271 272 bar_len = 0;273 for (d = file->deps; d != 0; d = d->next)274 if (d->ignore_mtime)275 #ifndef CONFIG_WITH_STRCACHE2276 bar_len += strlen (dep_name (d)) + 1;277 #else278 bar_len += strcache2_get_len (&file_strcache, dep_name (d)) + 1;279 #endif280 if (bar_len == 0)281 bar_len++;282 358 283 359 /* Compute the values for $^, $?, and $|. */ … … 293 369 bp = bar_value; 294 370 371 /* Make sure that no dependencies are repeated in $^, $?, and $|. It 372 would be natural to combine the next two loops but we can't do it 373 because of a situation where we have two dep entries, the first 374 is order-only and the second is normal (see below). */ 375 376 hash_init (&dep_hash, 500, dep_hash_1, dep_hash_2, dep_hash_cmp); 377 295 378 for (d = file->deps; d != 0; d = d->next) 296 379 { 297 const char *c = dep_name (d); 298 380 if (d->need_2nd_expansion) 381 continue; 382 383 slot = hash_find_slot (&dep_hash, d); 384 if (HASH_VACANT (*slot)) 385 hash_insert_at (&dep_hash, d, slot); 386 else 387 { 388 /* Check if the two prerequisites have different ignore_mtime. 389 If so then we need to "upgrade" one that is order-only. */ 390 391 struct dep* hd = (struct dep*) *slot; 392 393 if (d->ignore_mtime != hd->ignore_mtime) 394 d->ignore_mtime = hd->ignore_mtime = 0; 395 } 396 } 397 398 for (d = file->deps; d != 0; d = d->next) 399 { 400 const char *c; 401 402 if (d->need_2nd_expansion || hash_find_item (&dep_hash, d) != d) 403 continue; 404 405 c = dep_name (d); 299 406 #ifndef NO_ARCHIVES 300 407 if (ar_name (c)) 301 408 { 302 409 c = strchr (c, '(') + 1; … … 313 420 if (d->ignore_mtime) 314 421 { 315 422 memcpy (bp, c, len); 316 423 bp += len; 317 424 *bp++ = FILE_LIST_SEPARATOR; 318 425 } 319 426 else 320 427 { 321 428 memcpy (cp, c, len); 322 429 cp += len; 323 430 *cp++ = FILE_LIST_SEPARATOR; 324 if (d->changed )431 if (d->changed || always_make_flag) 325 432 { 326 433 memcpy (qp, c, len); … … 331 438 } 332 439 440 hash_free (&dep_hash, 0); 441 333 442 /* Kill the last spaces and define the variables. */ 334 443 … … 352 461 file->org_deps = copy_dep_chain (file->deps); 353 462 354 uniquize_deps (file->deps); 463 /** @todo do uniquize_deps (file->deps); in the $(dep-* ) functions, it'll 464 * save even more space that way. */ 355 465 } 356 466 #endif /* CONFIG_WITH_LAZY_DEPS_VARS */ … … 365 475 chop_commands (struct commands *cmds) 366 476 { 367 const char *p;368 477 unsigned int nlines, idx; 369 478 char **lines; … … 375 484 return; 376 485 377 /* Chop CMDS->commands up into lines in CMDS->command_lines. 378 Also set the corresponding CMDS->lines_flags elements, 379 and the CMDS->any_recurse flag. */ 380 381 nlines = 5; 382 lines = xmalloc (5 * sizeof (char *)); 383 idx = 0; 384 p = cmds->commands; 385 while (*p != '\0') 386 { 387 const char *end = p; 388 find_end:; 389 end = strchr (end, '\n'); 390 if (end == 0) 391 end = p + strlen (p); 392 else if (end > p && end[-1] == '\\') 486 /* Chop CMDS->commands up into lines in CMDS->command_lines. */ 487 488 if (one_shell) 489 { 490 int l = strlen (cmds->commands); 491 492 nlines = 1; 493 lines = xmalloc (nlines * sizeof (char *)); 494 lines[0] = xstrdup (cmds->commands); 495 496 /* Strip the trailing newline. */ 497 if (l > 0 && lines[0][l-1] == '\n') 498 lines[0][l-1] = '\0'; 499 } 500 else 501 { 502 const char *p; 503 504 nlines = 5; 505 lines = xmalloc (nlines * sizeof (char *)); 506 idx = 0; 507 p = cmds->commands; 508 while (*p != '\0') 393 509 { 394 int backslash = 1; 395 const char *b; 396 for (b = end - 2; b >= p && *b == '\\'; --b) 397 backslash = !backslash; 398 if (backslash) 510 const char *end = p; 511 find_end:; 512 end = strchr (end, '\n'); 513 if (end == 0) 514 end = p + strlen (p); 515 else if (end > p && end[-1] == '\\') 399 516 { 400 ++end; 401 goto find_end; 517 int backslash = 1; 518 const char *b; 519 for (b = end - 2; b >= p && *b == '\\'; --b) 520 backslash = !backslash; 521 if (backslash) 522 { 523 ++end; 524 goto find_end; 525 } 402 526 } 527 528 if (idx == nlines) 529 { 530 nlines += 2; 531 lines = xrealloc (lines, nlines * sizeof (char *)); 532 } 533 lines[idx++] = xstrndup (p, end - p); 534 p = end; 535 if (*p != '\0') 536 ++p; 403 537 } 404 538 405 if (idx == nlines)539 if (idx != nlines) 406 540 { 407 nlines += 2;541 nlines = idx; 408 542 lines = xrealloc (lines, nlines * sizeof (char *)); 409 543 } 410 lines[idx++] = savestring (p, end - p); 411 p = end; 412 if (*p != '\0') 413 ++p; 414 } 415 416 if (idx != nlines) 417 { 418 nlines = idx; 419 lines = xrealloc (lines, nlines * sizeof (char *)); 420 } 544 } 545 546 /* Finally, set the corresponding CMDS->lines_flags elements and the 547 CMDS->any_recurse flag. */ 421 548 422 549 cmds->ncommand_lines = nlines; … … 429 556 cmds->lines_flags = xmalloc (nlines * sizeof (cmds->lines_flags[0])); 430 557 #endif 558 431 559 for (idx = 0; idx < nlines; ++idx) 432 560 { 433 561 int flags = 0; 434 435 for (p = lines[idx]; 436 #ifndef CONFIG_WITH_COMMANDS_FUNC 437 isblank ((unsigned char)*p) || *p == '-' || *p == '@' || *p == '+'; 438 #else 439 isblank ((unsigned char)*p) || *p == '-' || *p == '@' || *p == '+' || *p == '%'; 440 #endif 441 ++p) 442 switch (*p) 562 const char *p = lines[idx]; 563 564 while (isblank (*p) || *p == '-' || *p == '@' || *p == '+' IF_WITH_COMMANDS_FUNC(|| *p == '%')) 565 switch (*(p++)) 443 566 { 444 567 case '+': -
trunk/src/kmk/commands.h
r2056 r2591 1 1 /* Definition of data structures describing shell commands for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 -
trunk/src/kmk/config
- Property svn:ignore
-
old new 1 1 *.m4 2 2 config.* 3 mkinstalldirs 4 texinfo.tex 5 mdate-sh 6 compile 7 depcomp 8 install-sh 9 missing 10 3 11 Makefile 4 12 Makefile.in
-
- Property svn:ignore
-
trunk/src/kmk/config.ami.template
r1993 r2591 1 1 /* config.h -- hand-massaged for Amiga -*-C-*- 2 2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 2005, 2006, 2007 Free Software Foundation, Inc.3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/config.h-vms.template
r1993 r2591 2 2 3 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 4 2006, 2007 Free Software Foundation, Inc.4 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 76 76 /* Define to 1 if you don't have vprintf but do have _doprnt. */ 77 77 /* #undef HAVE_DOPRNT */ 78 79 /* Define to 1 if you have the fdopen function. */ 80 #define HAVE_FDOPEN 1 78 81 79 82 /* Define to 1 if your system has a working fnmatch function. */ … … 290 293 291 294 /* Define to 1 if you have the strcasecmp function. */ 292 /* #undef HAVE_STRCASECMP */ 295 #define HAVE_STRCASECMP 1 293 296 294 297 /* Define to 1 if you have the strcmpi function. */ -
trunk/src/kmk/config.h.W32.template
r2134 r2591 2 2 3 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 4 2006, 2007 Free Software Foundation, Inc.4 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 25 25 # pragma warning(disable:4131) /* uses old-style declarator */ 26 26 # pragma warning(disable:4702) /* unreachable code */ 27 # define _CRT_SECURE_NO_WARNINGS /* function or variable may be unsafe */ 28 # define _CRT_NONSTDC_NO_WARNINGS /* functions w/o a leading underscore */ 27 29 #endif 28 30 … … 228 230 229 231 /* Define to 1 if you have the `strcmpi' function. */ 230 #define HAVE_STRCMPI 1 232 /* #undef HAVE_STRCMPI */ 231 233 232 234 /* Define to 1 if you have the `stricmp' function. */ 233 /* #undef HAVE_STRICMP */ 235 #define HAVE_STRICMP 1 236 237 /* Define to 1 if you have the `strncasecmp' function. */ 238 /* #undef HAVE_STRNCASECMP */ 239 240 /* Define to 1 if you have the `strncmpi' function. */ 241 /* #undef HAVE_STRNCMPI */ 242 243 /* Define to 1 if you have the `strnicmp' function. */ 244 #define HAVE_STRNICMP 1 234 245 235 246 /* Define to 1 if you have the `strchr' function. */ … … 427 438 /* GCC 4.x reportedly defines pid_t. */ 428 439 #ifndef _PID_T_ 440 #ifdef _WIN64 441 #define pid_t __int64 442 #else 429 443 #define pid_t int 444 #endif 430 445 #endif 431 446 -
trunk/src/kmk/config.h.darwin
r2145 r2591 41 41 /* Define to 1 if you have the `bsd_signal' function. */ 42 42 #define HAVE_BSD_SIGNAL 1 43 #define HAVE_DECL_BSD_SIGNAL 1 43 44 44 45 /* Use case insensitive file names */ … … 79 80 #define HAVE_FDOPEN 1 80 81 82 /* Define to 1 if you have the `fileno' function. */ 83 #define HAVE_FILENO 1 84 81 85 /* Define to 1 if you have the `fork' function. */ 82 86 #define HAVE_FORK 1 … … 202 206 /* #undef HAVE_STRCMPI */ 203 207 208 /* Define to 1 if you have the `strncasecmp' function. */ 209 #define HAVE_STRNCASECMP 1 210 211 /* Define to 1 if you have the `strncmpi' function. */ 212 /* #undef HAVE_STRNCMPI */ 213 214 /* Define to 1 if you have the `strncmp' function. */ 215 /* #undef HAVE_STRNICMP */ 216 204 217 /* Define to 1 if you have the `strcoll' function and it is properly defined. 205 218 */ … … 208 221 /* Define to 1 if you have the `strdup' function. */ 209 222 #define HAVE_STRDUP 1 223 224 /* Define to 1 if you have the `strndup' function. */ 225 /* #undef HAVE_STRNDUP */ 210 226 211 227 /* Define to 1 if you have the `strerror' function. */ … … 315 331 316 332 /* Define to the full name and version of this package. */ 317 #define PACKAGE_STRING "GNU make 3.8 1.90"333 #define PACKAGE_STRING "GNU make 3.82" 318 334 319 335 /* Define to the one symbol short name of this package. */ … … 321 337 322 338 /* Define to the version of this package. */ 323 #define PACKAGE_VERSION "3.8 1.90"339 #define PACKAGE_VERSION "3.82" 324 340 325 341 /* Define to the character that separates directories in PATH. */ … … 374 390 375 391 /* Version number of package */ 376 #define VERSION "3.8 1.90"392 #define VERSION "3.82" 377 393 378 394 /* Use platform specific coding */ -
trunk/src/kmk/config.h.freebsd
r2134 r2591 319 319 320 320 /* Define to the full name and version of this package. */ 321 #define PACKAGE_STRING "GNU make 3.8 1.90"321 #define PACKAGE_STRING "GNU make 3.82" 322 322 323 323 /* Define to the one symbol short name of this package. */ … … 325 325 326 326 /* Define to the version of this package. */ 327 #define PACKAGE_VERSION "3.8 1.90"327 #define PACKAGE_VERSION "3.82" 328 328 329 329 /* Define to the character that separates directories in PATH. */ … … 378 378 379 379 /* Version number of package */ 380 #define VERSION "3.8 1.90"380 #define VERSION "3.82" 381 381 382 382 /* Use platform specific coding */ -
trunk/src/kmk/config.h.haiku
r2546 r2591 315 315 316 316 /* Define to the full name and version of this package. */ 317 #define PACKAGE_STRING "GNU make 3.8 1.90"317 #define PACKAGE_STRING "GNU make 3.82" 318 318 319 319 /* Define to the one symbol short name of this package. */ … … 324 324 325 325 /* Define to the version of this package. */ 326 #define PACKAGE_VERSION "3.8 1.90"326 #define PACKAGE_VERSION "3.82" 327 327 328 328 /* Define to the character that separates directories in PATH. */ … … 391 391 392 392 /* Version number of package */ 393 #define VERSION "3.8 1.90"393 #define VERSION "3.82" 394 394 395 395 /* Use platform specific coding */ -
trunk/src/kmk/config.h.linux
r2134 r2591 315 315 316 316 /* Define to the full name and version of this package. */ 317 #define PACKAGE_STRING "GNU make 3.8 1.90"317 #define PACKAGE_STRING "GNU make 3.82" 318 318 319 319 /* Define to the one symbol short name of this package. */ … … 321 321 322 322 /* Define to the version of this package. */ 323 #define PACKAGE_VERSION "3.8 1.90"323 #define PACKAGE_VERSION "3.82" 324 324 325 325 /* Define to the character that separates directories in PATH. */ … … 374 374 375 375 /* Version number of package */ 376 #define VERSION "3.8 1.90"376 #define VERSION "3.82" 377 377 378 378 /* Use platform specific coding */ -
trunk/src/kmk/config.h.os2
r2134 r2591 332 332 333 333 /* Define to the full name and version of this package. */ 334 #define PACKAGE_STRING "GNU make 3.8 1"334 #define PACKAGE_STRING "GNU make 3.82" 335 335 336 336 /* Define to the one symbol short name of this package. */ … … 338 338 339 339 /* Define to the version of this package. */ 340 #define PACKAGE_VERSION "3.8 1"340 #define PACKAGE_VERSION "3.82" 341 341 342 342 /* Define to 1 if the C compiler supports function prototypes. */ -
trunk/src/kmk/config.h.solaris
r2134 r2591 315 315 316 316 /* Define to the full name and version of this package. */ 317 #define PACKAGE_STRING "GNU make 3.8 1.90"317 #define PACKAGE_STRING "GNU make 3.82" 318 318 319 319 /* Define to the one symbol short name of this package. */ … … 321 321 322 322 /* Define to the version of this package. */ 323 #define PACKAGE_VERSION "3.8 1.90"323 #define PACKAGE_VERSION "3.82" 324 324 325 325 /* Define to the character that separates directories in PATH. */ … … 374 374 375 375 /* Version number of package */ 376 #define VERSION "3.8 1.90"376 #define VERSION "3.82" 377 377 378 378 /* Use platform specific coding */ -
trunk/src/kmk/config.h.win
r2178 r2591 344 344 345 345 /* Define to the full name and version of this package. */ 346 #define PACKAGE_STRING "GNU make 3.8 1.90"346 #define PACKAGE_STRING "GNU make 3.82" 347 347 348 348 /* Define to the one symbol short name of this package. */ … … 350 350 351 351 /* Define to the version of this package. */ 352 #define PACKAGE_VERSION "3.8 1.90"352 #define PACKAGE_VERSION "3.82" 353 353 354 354 /* Define to 1 if the C compiler supports function prototypes. */ … … 400 400 401 401 /* Version number of package */ 402 #define VERSION "3.8 1.90"402 #define VERSION "3.82" 403 403 404 404 /* Define if using the dmalloc debugging malloc package */ -
trunk/src/kmk/config/ChangeLog
r1993 r2591 30 30 31 31 32 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 32 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software 33 Foundation, Inc. 33 34 This file is part of GNU Make. 34 35 -
trunk/src/kmk/config/Makefile.am
r1993 r2591 1 1 # -*-Makefile-*-, or close enough 2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,3 # Inc.2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free 3 # Software Foundation, Inc. 4 4 # This file is part of GNU Make. 5 5 # -
trunk/src/kmk/config/dospaths.m4
r1993 r2591 3 3 # 4 4 # Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 # 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.5 # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 6 6 # This file is part of GNU Make. 7 7 # -
trunk/src/kmk/configh.dos.template
r1993 r2591 2 2 3 3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 4 2004, 2005, 2006, 2007 Free Software Foundation, Inc.4 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 17 17 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 18 19 /* Include this header to make __DJGPP_MINOR__ available because DJGPP ports 20 of GCC 4.3.0 and later no longer do it automatically. */ 21 #include <sys/version.h> 22 19 23 /* Many things are defined already by a system header. */ 20 24 #include <sys/config.h> … … 22 26 #if __DJGPP__ > 2 || __DJGPP_MINOR__ > 1 23 27 24 /* Define to 1 if `sys_siglist' is declared by <signal.h> .*/28 /* Define to 1 if `sys_siglist' is declared by <signal.h> or <unistd.h>. */ 25 29 # define SYS_SIGLIST_DECLARED 1 26 30 … … 108 112 #define PROTOTYPES 1 109 113 110 /* Define to 1 if `sys_siglist' is declared by <signal.h> or <unistd.h>. */111 #define SYS_SIGLIST_DECLARED 1112 113 114 /* Version number of package */ 114 115 #define VERSION "%VERSION%" -
trunk/src/kmk/configure.bat
r1993 r2591 1 <<<<<<< .working2 1 @echo off 3 2 rem Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 4 rem 2004, 2005, 2006 Free Software Foundation, Inc. 5 rem This file is part of GNU Make. 6 7 rem GNU Make is free software; you can redistribute it and/or modify it under 8 rem the terms of the GNU General Public License as published by the Free 9 rem Software Foundation; either version 2, or (at your option) any later 10 rem version. 11 12 rem GNU Make is distributed in the hope that it will be useful, but WITHOUT 13 rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 rem more details. 16 17 rem You should have received a copy of the GNU General Public License along 18 rem with GNU Make; see the file COPYING. If not, write to the Free Software 19 rem Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 21 echo Configuring MAKE for DJGPP 22 23 rem The SmallEnv trick protects against too small environment block, 24 rem in which case the values will be truncated and the whole thing 25 rem goes awry. COMMAND.COM will say "Out of environment space", but 26 rem many people don't care, so we force them to care by refusing to go. 27 28 rem Where is the srcdir? 29 set XSRC=. 30 if not "%XSRC%"=="." goto SmallEnv 31 if "%1%"=="" goto SrcDone 32 set XSRC=%1 33 if not "%XSRC%"=="%1" goto SmallEnv 34 35 :SrcDone 36 37 update %XSRC%/configh.dos ./config.h 38 39 rem Do they have Make? 40 redir -o junk.$$$ -eo make -n -f NUL 41 rem REDIR will return 1 if it cannot run Make. 42 rem If it can run Make, it will usually return 2, 43 rem but 0 is also OK with us. 44 if errorlevel 2 goto MakeOk 45 if not errorlevel 1 goto MakeOk 46 if exist junk.$$$ del junk.$$$ 47 echo No Make program found--use DOSBUILD.BAT to build Make. 48 goto End 49 50 rem They do have Make. Generate the Makefile. 51 52 :MakeOk 53 del junk.$$$ 54 update %XSRC%/Makefile.DOS ./Makefile 55 echo Done. 56 if not "%XSRC%"=="." echo Invoke Make thus: "make srcdir=%XSRC%" 57 goto End 58 59 :SmallEnv 60 echo Your environment is too small. Please enlarge it and run me again. 61 62 :End 63 set XRSC= 64 ======= 65 @echo off 66 rem Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 67 rem 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 3 rem 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 68 4 rem This file is part of GNU Make. 69 5 rem … … 124 60 :End 125 61 set XRSC= 126 >>>>>>> .merge-right.r1992 -
trunk/src/kmk/configure.in
r2134 r2591 2 2 # 3 3 # Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 4 # 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.4 # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 5 5 # This file is part of GNU Make. 6 6 # … … 18 18 # this program. If not, see <http://www.gnu.org/licenses/>. 19 19 20 AC_INIT([GNU make],[3.8 1.90],[[email protected]])20 AC_INIT([GNU make],[3.82],[[email protected]]) 21 21 22 22 AC_PREREQ(2.59) 23 AC_REVISION([[$Id: configure.in,v 1.1 48 2007/07/04 19:35:17psmith Exp $]])23 AC_REVISION([[$Id: configure.in,v 1.156 2010/07/28 05:39:50 psmith Exp $]]) 24 24 25 25 # Autoconf setup … … 149 149 fi 150 150 151 AC_CHECK_FUNCS( strdup mkstemp mktemp fdopen\152 bsd_signaldup2 getcwd realpath sigsetmask sigaction \151 AC_CHECK_FUNCS( strdup strndup mkstemp mktemp fdopen fileno \ 152 dup2 getcwd realpath sigsetmask sigaction \ 153 153 getgroups seteuid setegid setlinebuf setreuid setregid \ 154 154 getrlimit setrlimit setvbuf pipe strerror strsignal \ 155 155 lstat readlink atexit) 156 156 157 # We need to check declarations, not just existence, because on Tru64 this 158 # function is not declared without special flags, which themselves cause 159 # other problems. We'll just use our own. 160 AC_CHECK_DECLS([bsd_signal], [], [], [[#include <signal.h>]]) 161 157 162 AC_FUNC_SETVBUF_REVERSED 158 163 … … 160 165 # It doesn't hurt much to use our own if we can't find it so I don't 161 166 # make the effort here. 162 AC_CHECK_FUNCS(strcasecmp str cmpi stricmp)167 AC_CHECK_FUNCS(strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp) 163 168 164 169 # strcoll() is used by the GNU glob library … … 349 354 # Check the system to see if it provides GNU glob. If not, use our 350 355 # local version. 351 352 356 AC_MSG_CHECKING(if system libc has GNU glob) 353 357 AC_CACHE_VAL(make_cv_sys_gnu_glob, [ … … 366 370 ], [AC_MSG_RESULT(yes) 367 371 make_cv_sys_gnu_glob=yes], [AC_MSG_RESULT([no; using local copy]) 368 AC_SUBST(GLOBINC) GLOBINC='-I$(srcdir)/glob'369 AC_SUBST(GLOBLIB) GLOBLIB=glob/libglob.a370 372 make_cv_sys_gnu_glob=no])]) 373 if test "$make_cv_sys_gnu_glob" = no; then 374 GLOBINC='-I$(srcdir)/glob' 375 GLOBLIB=glob/libglob.a 376 fi 377 AC_SUBST(GLOBINC) 378 AC_SUBST(GLOBLIB) 379 371 380 # Tell automake about this, so it can build the right .c files. 372 381 AM_CONDITIONAL(USE_LOCAL_GLOB, test "$make_cv_sys_gnu_glob" = no) -
trunk/src/kmk/debug.h
r1993 r2591 1 1 /* Debugging macros and interface. 2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free3 Software Foundation, Inc.2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 3 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/default.c
r2056 r2591 1 1 /* Data base of default implicit rules for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 550 550 551 551 if (no_builtin_rules_flag) 552 define_variable ("SUFFIXES", 8, "", o_default, 0);552 define_variable_cname ("SUFFIXES", "", o_default, 0); 553 553 else 554 554 { 555 555 char *p = default_suffixes; 556 suffix_file->deps = (struct dep *) 557 #ifndef CONFIG_WITH_ALLOC_CACHES 558 multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1), 559 sizeof (struct dep)); 560 #else 561 multi_glob (parse_file_seq (&p, '\0', &dep_cache, 1), &dep_cache); 562 #endif 563 define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0); 556 suffix_file->deps = enter_prereqs(PARSE_FILE_SEQ (&p, struct dep, '\0', 557 NULL, 0), 558 NULL); 559 define_variable_cname ("SUFFIXES", default_suffixes, o_default, 0); 564 560 } 565 561 } -
trunk/src/kmk/dep.h
r1993 r2591 1 1 /* Definitions of dependency data structures for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 44 44 unsigned int staticpattern : 1; 45 45 unsigned int need_2nd_expansion : 1; 46 unsigned int dontcare : 1; 47 46 48 #ifdef CONFIG_WITH_INCLUDEDEP 47 49 unsigned int includedep : 1; … … 59 61 60 62 63 #define PARSEFS_NONE (0x0000) 64 #define PARSEFS_NOSTRIP (0x0001) 65 #define PARSEFS_NOAR (0x0002) 66 #define PARSEFS_NOGLOB (0x0004) 67 #define PARSEFS_EXISTS (0x0008) 68 #define PARSEFS_NOCACHE (0x0010) 69 61 70 #ifndef CONFIG_WITH_ALLOC_CACHES 62 struct nameseq *multi_glob (struct nameseq *chain, unsigned int size); 71 #define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \ 72 (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f)) 63 73 #else 64 struct nameseq *multi_glob (struct nameseq *chain, struct alloccache *cache); 74 # define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \ 75 (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f), \ 76 &PARSE_FILE_SEQ_IGNORE_ ## _t ## _cache) 77 # define PARSE_FILE_SEQ_IGNORE_struct 65 78 #endif 79 66 80 #ifdef VMS 67 struct nameseq*parse_file_seq ();81 void *parse_file_seq (); 68 82 #else 69 # ifndef CONFIG_WITH_ALLOC_CACHES 70 struct nameseq *parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip); 71 # else 72 struct nameseq *parse_file_seq (char **stringp, int stopchar, struct alloccache *cache, int strip); 73 # endif 83 void *parse_file_seq (char **stringp, unsigned int size, 84 int stopchar, const char *prefix, int flags 85 IF_WITH_ALLOC_CACHES_PARAM(struct alloccache *cache)); 74 86 #endif 87 75 88 char *tilde_expand (const char *name); 76 89 … … 79 92 #endif 80 93 81 #define dep_name(d) ((d)->name == 0 ? (d)->file->name : (d)->name)94 #define dep_name(d) ((d)->name == 0 ? (d)->file->name : (d)->name) 82 95 83 struct dep *alloc_dep (void); 84 void free_dep (struct dep *d); 96 97 #ifndef CONFIG_WITH_ALLOC_CACHES 98 #define alloc_dep() (xcalloc (sizeof (struct dep))) 99 #define free_ns(_n) free (_n) 100 #define free_dep(_d) free_ns (_d) 101 #else 102 #define alloc_dep() alloccache_calloc (&dep_cache) 103 #define free_ns(_n) alloccache_free (&nameseq_cache, _n) 104 #define free_dep(_d) alloccache_free (&dep_cache, _d) 105 #endif 106 85 107 struct dep *copy_dep_chain (const struct dep *d); 86 108 void free_dep_chain (struct dep *d); 87 109 void free_ns_chain (struct nameseq *n); 88 110 struct dep *read_all_makefiles (const char **makefiles); 89 #ifndef CONFIG_WITH_VALUE_LENGTH 90 int eval_buffer (char *buffer); 91 #else 92 int eval_buffer (char *buffer, char *eos); 93 #endif 111 void eval_buffer (char *buffer IF_WITH_VALUE_LENGTH(COMMA char *eos)); 94 112 int update_goal_chain (struct dep *goals); 95 void uniquize_deps (struct dep *);96 113 97 114 #ifdef CONFIG_WITH_INCLUDEDEP … … 100 117 void eval_include_dep (const char *name, struct floc *f, enum incdep_op op); 101 118 void incdep_flush_and_term (void); 102 103 /* read.c */104 void record_files (struct nameseq *filenames, const char *pattern,105 const char *pattern_percent, struct dep *deps,106 unsigned int cmds_started, char *commands,107 unsigned int commands_idx, int two_colon,108 const struct floc *flocp);109 119 #endif 110 120 -
trunk/src/kmk/dir.c
r1993 r2591 1 1 /* Directory hashing for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 24 24 # define NAMLEN(dirent) strlen((dirent)->d_name) 25 25 # ifdef VMS 26 char *vmsify (char *name, int type); 26 /* its prototype is in vmsdir.h, which is not needed for HAVE_DIRENT_H */ 27 const char *vmsify (const char *name, int type); 27 28 # endif 28 29 #else … … 133 134 static PATH_VAR (new_filename); 134 135 char *df; 135 int i;136 136 137 137 if (filename == 0) … … 139 139 140 140 df = new_filename; 141 142 /* First, transform the name part. */143 141 while (*filename != '\0') 144 142 { … … 156 154 157 155 static int 158 vms_hash (c har *name)156 vms_hash (const char *name) 159 157 { 160 158 int h = 0; … … 182 180 /* fake stat entry for a directory */ 183 181 static int 184 vmsstat_dir (c har *name, struct stat *st)182 vmsstat_dir (const char *name, struct stat *st) 185 183 { 186 184 char *s; … … 195 193 if (s) 196 194 { 195 /* to keep the compiler happy we said "const char *name", now we cheat */ 197 196 *s++ = 0; 198 197 st->st_dev = (char *)vms_hash (name); … … 203 202 { 204 203 st->st_dev = 0; 205 s = name; 206 h = vms_hash (s); 204 h = vms_hash (name); 207 205 } 208 206 … … 496 494 #else 497 495 p = name + strlen (name); 496 # if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS) 497 dir_key.name = strcache_add_len (downcase(name), p - name); 498 # else 498 499 dir_key.name = strcache_add_len (name, p - name); 500 # endif 499 501 dir_slot = (struct directory **) hash_find_slot_strcached (&directories, &dir_key); 500 502 #endif … … 516 518 #endif 517 519 #ifndef CONFIG_WITH_STRCACHE2 520 #if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS) 521 dir->name = strcache_add_len (downcase(name), p - name); 522 #else 518 523 dir->name = strcache_add_len (name, p - name); 519 #else 524 #endif 525 #else /* CONFIG_WITH_STRCACHE2 */ 520 526 dir->name = dir_key.name; 521 #endif 527 #endif /* CONFIG_WITH_STRCACHE2 */ 522 528 hash_insert_at (&directories, dir, dir_slot); 523 529 /* The directory is not in the name hash table. … … 826 832 dirfile_slot = (struct dirfile **) hash_find_slot (&dir->dirfiles, &dirfile_key); 827 833 #else 834 # if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS) 835 dirfile_key.name = strcache_add_len (downcase(d->d_name), len); 836 # else 828 837 dirfile_key.name = strcache_add_len (d->d_name, len); 838 # endif 829 839 dirfile_key.length = len; 830 840 dirfile_slot = (struct dirfile **) hash_find_slot_strcached (&dir->dirfiles, &dirfile_key); … … 844 854 #endif 845 855 #ifndef CONFIG_WITH_STRCACHE2 856 #if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS) 857 df->name = strcache_add_len (downcase(d->d_name), len); 858 #else 846 859 df->name = strcache_add_len (d->d_name, len); 847 #else 860 #endif 861 #else /* CONFIG_WITH_STRCACHE2 */ 848 862 df->name = dirfile_key.name; 849 #endif 863 #endif /* CONFIG_WITH_STRCACHE2 */ 850 864 df->length = len; 851 865 df->impossible = 0; … … 854 868 /* Check if the name matches the one we're searching for. */ 855 869 #ifndef CONFIG_WITH_STRCACHE2 856 if (filename != 0 && strieq (d->d_name, filename))870 if (filename != 0 && patheq (d->d_name, filename)) 857 871 #else 858 872 if (filename != 0 && dirfile_key.name == filename) … … 1010 1024 1011 1025 if (dir->contents == 0) 1012 { 1013 /* The directory could not be stat'd. We allocate a contents 1014 structure for it, but leave it out of the contents hash table. */ 1026 /* The directory could not be stat'd. We allocate a contents 1027 structure for it, but leave it out of the contents hash table. */ 1015 1028 #ifndef CONFIG_WITH_ALLOC_CACHES 1016 dir->contents = xmalloc (sizeof (struct directory_contents)); 1017 #else 1018 dir->contents = alloccache_alloc (&directory_contents_cache); 1019 #endif 1020 memset (dir->contents, '\0', sizeof (struct directory_contents)); 1021 } 1029 dir->contents = xcalloc (sizeof (struct directory_contents)); 1030 #else 1031 dir->contents = alloccache_calloc (&directory_contents_cache); 1032 #endif 1022 1033 1023 1034 if (dir->contents->dirfiles.ht_vec == 0) … … 1040 1051 #endif 1041 1052 new->length = strlen (filename); 1053 #if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS) 1054 new->name = strcache_add_len (downcase(filename), new->length); 1055 #else 1042 1056 new->name = strcache_add_len (filename, new->length); 1057 #endif 1043 1058 new->impossible = 1; 1044 1059 #ifndef CONFIG_WITH_STRCACHE2 -
trunk/src/kmk/doc
- Property svn:ignore
-
trunk/src/kmk/doc/Makefile.am
r1993 r2591 1 1 # -*-Makefile-*-, or close enough 2 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software3 # Foundation, Inc.2 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 3 # 2010 Free Software Foundation, Inc. 4 4 # This file is part of GNU Make. 5 5 # -
trunk/src/kmk/doc/make.texi
r1993 r2591 4 4 5 5 @include version.texi 6 @set EDITION 0.7 07 @set RCSID $Id: make.texi,v 1. 52 2008/05/18 15:11:40psmith Exp $6 @set EDITION 0.71 7 @set RCSID $Id: make.texi,v 1.66 2010/07/19 07:10:54 psmith Exp $ 8 8 9 9 @settitle GNU @code{make} … … 14 14 @syncodeindex pg cp 15 15 @c FSF publishers: format makebook.texi instead of using this file directly. 16 @c ISBN provided by Lisa M. Opus Goldstein <[email protected]>, 5 May 200417 @set ISBN 1-882114-83- 516 @c ISBN confirmed by Jasimin Huang <[email protected]> on 25 Mar 2009 17 @set ISBN 1-882114-83-3 18 18 @c %**end of header 19 19 … … 27 27 28 28 Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 29 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 30 Free Software Foundation, Inc.29 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 30 2008, 2009, 2010 Free Software Foundation, Inc. 31 31 32 32 @quotation … … 39 39 License.'' 40 40 41 (a) The FSF's Back-Cover Text is: ``You are free to copy and modify42 this GNU Manual. Buying copies from GNU Press supports the FSFin41 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and 42 modify this GNU manual. Buying copies from the FSF supports it in 43 43 developing GNU and promoting software freedom.'' 44 44 @end quotation … … 202 202 * Interrupts:: What happens when a recipe is interrupted. 203 203 * Recursion:: Invoking @code{make} from makefiles. 204 * Sequences::Defining canned recipes.204 * Canned Recipes:: Defining canned recipes. 205 205 * Empty Recipes:: Defining useful, do-nothing recipes. 206 206 … … 234 234 * Override Directive:: How to set a variable in the makefile even if 235 235 the user has set it with a command argument. 236 * Defining::An alternate way to set a variable237 to a verbatimstring.236 * Multi-Line:: An alternate way to set a variable 237 to a multi-line string. 238 238 * Environment:: Variable values can come from the environment. 239 239 * Target-specific:: Variable values can be defined on a per-target … … 241 241 * Pattern-specific:: Target-specific variable values can be applied 242 242 to a group of targets that match a pattern. 243 * Suppressing Inheritance:: Suppress inheritance of variables. 243 244 * Special Variables:: Variables with special meaning or behavior. 244 245 … … 524 525 525 526 @cindex tabs in rules 526 A @dfn{recipe} is an action that @code{make} carries out. 527 A recipe may have more than one command, each on its own line. 528 @strong{Please note:} you need to put a tab character at the beginning of 529 every command line! This is an obscurity that catches the unwary. If 530 you prefer to prefix your recipes with a character other than tab, 531 you can set the @code{.CMDPREFIX} variable to an alternate character 532 (@pxref{Special Variables}).527 A @dfn{recipe} is an action that @code{make} carries out. A recipe 528 may have more than one command, either on the same line or each on its 529 own line. @strong{Please note:} you need to put a tab character at 530 the beginning of every recipe line! This is an obscurity that catches 531 the unwary. If you prefer to prefix your recipes with a character 532 other than tab, you can set the @code{.RECIPEPREFIX} variable to an 533 alternate character (@pxref{Special Variables}). 533 534 534 535 Usually a recipe is in a rule with prerequisites and serves to create a … … 629 630 prerequisites. These recipes say how to update the target file. A 630 631 tab character (or whatever character is specified by the 631 @code{. CMDPREFIX} variable; @pxref{Special Variables}) must come at632 @code{.RECIPEPREFIX} variable; @pxref{Special Variables}) must come at 632 633 the beginning of every line in the recipe to distinguish recipes from 633 634 other lines in the makefile. (Bear in mind that @code{make} does not 634 635 know anything about how the recipes work. It is up to you to supply 635 636 recipes that will update the target file properly. All @code{make} 636 does is execute the commands in the recipe you have specified when the637 target fileneeds to be updated.)@refill637 does is execute the recipe you have specified when the target file 638 needs to be updated.)@refill 638 639 @cindex recipe 639 640 … … 996 997 @item 997 998 Defining a variable from a verbatim string containing multiple lines 998 (@pxref{ Defining, ,Defining Variables Verbatim}).999 (@pxref{Multi-Line, ,Defining Multi-Line Variables}). 999 1000 @end itemize 1000 1001 … … 1097 1098 Extra spaces are allowed and ignored at the beginning of the line, but 1098 1099 the first character must not be a tab (or the value of 1099 @code{. CMDPREFIX})---if the line begins with a tab, it will be1100 @code{.RECIPEPREFIX})---if the line begins with a tab, it will be 1100 1101 considered a recipe line. Whitespace is required between 1101 1102 @code{include} and the file names, and between file names; extra … … 1171 1172 1172 1173 If you want @code{make} to simply ignore a makefile which does not exist 1173 andcannot be remade, with no error message, use the @w{@code{-include}}1174 or cannot be remade, with no error message, use the @w{@code{-include}} 1174 1175 directive instead of @code{include}, like this: 1175 1176 … … 1179 1180 1180 1181 This acts like @code{include} in every way except that there is no 1181 error (not even a warning) if any of the @var{filenames} do not exist. 1182 error (not even a warning) if any of the @var{filenames} (or any 1183 prerequisites of any of the @var{filenames}) do not exist or cannot be 1184 remade. 1185 1182 1186 For compatibility with some other @code{make} implementations, 1183 1187 @code{sinclude} is another name for @w{@code{-include}}. … … 1191 1195 If the environment variable @code{MAKEFILES} is defined, @code{make} 1192 1196 considers its value as a list of names (separated by whitespace) of 1193 additional makefiles to be read before the others. This works much like 1194 the @code{include} directive: various directories are searched for those 1195 files (@pxref{Include, ,Including Other Makefiles}). In addition, the 1196 default goal is never taken from one of these makefiles and it is not an 1197 error if the files listed in @code{MAKEFILES} are not found.@refill 1197 additional makefiles to be read before the others. This works much 1198 like the @code{include} directive: various directories are searched 1199 for those files (@pxref{Include, ,Including Other Makefiles}). In 1200 addition, the default goal is never taken from one of these makefiles 1201 (or any makefile included by them) and it is not an error if the files 1202 listed in @code{MAKEFILES} are not found.@refill 1198 1203 1199 1204 @cindex recursion, and @code{MAKEFILES} variable … … 1269 1274 1270 1275 When you use the @samp{-t} or @samp{--touch} option 1271 (@pxref{Instead of Execution, ,Instead of Executing the Recipe}),1276 (@pxref{Instead of Execution, ,Instead of Executing Recipes}), 1272 1277 you would not want to use an out-of-date makefile to decide which 1273 1278 targets to touch. So the @samp{-t} option has no effect on updating … … 1387 1392 define @var{immediate} 1388 1393 @var{deferred} 1394 endef 1395 1396 define @var{immediate} = 1397 @var{deferred} 1398 endef 1399 1400 define @var{immediate} ?= 1401 @var{deferred} 1402 endef 1403 1404 define @var{immediate} := 1405 @var{immediate} 1406 endef 1407 1408 define @var{immediate} += 1409 @var{deferred} or @var{immediate} 1389 1410 endef 1390 1411 @end example … … 1748 1769 @cindex tab character (in commands) 1749 1770 The @var{recipe} lines start with a tab character (or the first 1750 character in the value of the @code{. CMDPREFIX} variable;1771 character in the value of the @code{.RECIPEPREFIX} variable; 1751 1772 @pxref{Special Variables}). The first recipe line may appear on the line 1752 1773 after the prerequisites, with a tab character, or may appear on the … … 1802 1823 GNU @code{make}: normal prerequisites such as described in the 1803 1824 previous section, and @dfn{order-only} prerequisites. A normal 1804 prerequisite makes two statements: first, it imposes an order of1805 execution of recipes: any recipes necessary to build any of a 1806 target's prerequisites will be fully executed before any recipe 1807 necessary to build the target. Second, it imposes a dependency 1808 relationship: if any prerequisite is newer than the target, then the1809 target is considered out-of-date and must berebuilt.1825 prerequisite makes two statements: first, it imposes an order in which 1826 recipes will be invoked: the recipes for all prerequisites of a target 1827 will be completed before the recipe for the target is run. Second, it 1828 imposes a dependency relationship: if any prerequisite is newer than 1829 the target, then the target is considered out-of-date and must be 1830 rebuilt. 1810 1831 1811 1832 Normally, this is exactly what you want: if a target's prerequisite is … … 1949 1970 @noindent 1950 1971 then the value of the variable @code{objects} is the actual string 1951 @samp{*.o}. However, if you use the value of @code{objects} in a target, 1952 prerequisite, or recipe, wildcard expansion will take place at that time. 1953 To set @code{objects} to the expansion, instead use: 1972 @samp{*.o}. However, if you use the value of @code{objects} in a 1973 target or prerequisite, wildcard expansion will take place there. If 1974 you use the value of @code{objects} in a recipe, the shell may perform 1975 wildcard expansion when the recipe runs. To set @code{objects} to the 1976 expansion, instead use: 1954 1977 1955 1978 @example … … 2403 2426 2404 2427 When a prerequisite's name has the form @samp{-l@var{name}}, @code{make} 2405 handles it specially by searching for the file @file{lib@var{name}.so} in 2406 the current directory, in directories specified by matching @code{vpath} 2428 handles it specially by searching for the file @file{lib@var{name}.so}, 2429 and, if it is not found, for the file @file{lib@var{name}.a} in the current 2430 directory, in directories specified by matching @code{vpath} 2407 2431 search paths and the @code{VPATH} search path, and then in the 2408 2432 directories @file{/lib}, @file{/usr/lib}, and @file{@var{prefix}/lib} … … 2410 2434 @code{make} behave as if @var{prefix} is defined to be the root of the 2411 2435 DJGPP installation tree). 2412 2413 If that file is not found, then the file @file{lib@var{name}.a} is2414 searched for, in the same directories as above.2415 2436 2416 2437 For example, if there is a @file{/usr/lib/libcurses.a} library on your … … 2435 2456 @samp{-l@var{name}} is seen, @code{make} will replace the percent in 2436 2457 each pattern in the list with @var{name} and perform the above directory 2437 searches using that library filename. If no library is found, the next 2438 word in the list will be used. 2458 searches using each library filename. 2439 2459 2440 2460 The default value for @code{.LIBPATTERNS} is @samp{lib%.so lib%.a}, … … 2854 2874 recipes in parallel (unless its makefile also contains this target). 2855 2875 Any prerequisites on this target are ignored. 2876 2877 @findex .ONESHELL 2878 @item .ONESHELL 2879 @cindex recipe execution, single invocation 2880 2881 If @code{.ONESHELL} is mentioned as a target, then when a target is 2882 built all lines of the recipe will be given to a single invocation of 2883 the shell rather than each line being invoked separately 2884 (@pxref{Execution, ,Recipe Execution}). 2885 2886 @findex .POSIX 2887 @item .POSIX 2888 @cindex POSIX-conforming mode, setting 2889 2890 If @code{.POSIX} is mentioned as a target, then the makefile will be 2891 parsed and run in POSIX-conforming mode. This does @emph{not} mean 2892 that only POSIX-conforming makefiles will be accepted: all advanced 2893 GNU @code{make} features are still available. Rather, this target 2894 causes @code{make} to behave as required by POSIX in those areas 2895 where @code{make}'s default behavior differs. 2896 2897 In particular, if this target is mentioned then recipes will be 2898 invoked as if the shell had been passed the @code{-e} flag: the first 2899 failing command in a recipe will cause the recipe to fail immediately. 2856 2900 @end table 2857 2901 … … 3168 3212 @cindex @code{::} rules (double-colon) 3169 3213 3170 @dfn{Double-colon} rules are rules written with @samp{::} instead of 3171 @samp{:} after the target names. They are handled differently from 3172 ordinary rules when the same target appears in more than one rule. 3214 @dfn{Double-colon} rules are explicit rules written with @samp{::} 3215 instead of @samp{:} after the target names. They are handled 3216 differently from ordinary rules when the same target appears in more 3217 than one rule. Pattern rules with double-colons have an entirely 3218 different meaning (@pxref{Match-Anything Rules}). 3173 3219 3174 3220 When a target appears in multiple rules, all the rules must be the same … … 3351 3397 Users use many different shell programs, but recipes in makefiles are 3352 3398 always interpreted by @file{/bin/sh} unless the makefile specifies 3353 otherwise. @xref{Execution, , CommandExecution}.3399 otherwise. @xref{Execution, ,Recipe Execution}. 3354 3400 3355 3401 @menu … … 3361 3407 * Interrupts:: What happens when a recipe is interrupted. 3362 3408 * Recursion:: Invoking @code{make} from makefiles. 3363 * Sequences::Defining canned recipes.3409 * Canned Recipes:: Defining canned recipes. 3364 3410 * Empty Recipes:: Defining useful, do-nothing recipes. 3365 3411 @end menu … … 3379 3425 3380 3426 Each line in the recipe must start with a tab (or the first character 3381 in the value of the @code{. CMDPREFIX} variable; @pxref{Special3427 in the value of the @code{.RECIPEPREFIX} variable; @pxref{Special 3382 3428 Variables}), except that the first recipe line may be attached to the 3383 3429 target-and-prerequisites line with a semicolon in between. @emph{Any} … … 3629 3675 @cindex @code{--dry-run} 3630 3676 @cindex @code{--recon} 3631 When @code{make} is given the flag @samp{-n} or @samp{--just-print} 3632 it only echoes recipes, it won't execute them. @xref{Options Summary, 3633 ,Summary of Options}. In this case and only this case, even the 3634 recipe lines starting with @samp{@@} are printed. This flag is useful for 3635 finding out which recipes @code{make} thinks are necessary without 3636 actuallydoing them.3677 When @code{make} is given the flag @samp{-n} or @samp{--just-print} it 3678 only echoes most recipes, without executing them. @xref{Options 3679 Summary, ,Summary of Options}. In this case even the recipe lines 3680 starting with @samp{@@} are printed. This flag is useful for finding 3681 out which recipes @code{make} thinks are necessary without actually 3682 doing them. 3637 3683 3638 3684 @cindex @code{-s} … … 3654 3700 3655 3701 When it is time to execute recipes to update a target, they are 3656 executed by invoking a new subshell for each line of the recipe. (In 3657 practice, @code{make} may take shortcuts that do not affect the 3658 results.) 3702 executed by invoking a new subshell for each line of the recipe, 3703 unless the @code{.ONESHELL} special target is in effect 3704 (@pxref{One Shell, ,Using One Shell}) (In practice, @code{make} may 3705 take shortcuts that do not affect the results.) 3659 3706 3660 3707 @cindex @code{cd} (shell command) … … 3684 3731 3685 3732 @menu 3733 * One Shell:: One shell for all lines in a recipe 3686 3734 * Choosing the Shell:: How @code{make} chooses the shell used 3687 3735 to run recipes. 3688 3736 @end menu 3689 3737 3690 @node Choosing the Shell, , Execution, Execution 3738 @node One Shell, Choosing the Shell, Execution, Execution 3739 @subsection Using One Shell 3740 @cindex recipe lines, single shell 3741 @cindex @code{.ONESHELL}, use of 3742 @findex .ONESHELL 3743 3744 Sometimes you would prefer that all the lines in the recipe be passed 3745 to a single invocation of the shell. There are generally two 3746 situations where this is useful: first, it can improve performance in 3747 makefiles where recipes consist of many command lines, by avoiding 3748 extra processes. Second, you might want newlines to be included in 3749 your recipe command (for example perhaps you are using a very 3750 different interpreter as your @code{SHELL}). If the @code{.ONESHELL} 3751 special target appears anywhere in the makefile then @emph{all} 3752 recipe lines for each target will be provided to a single invocation 3753 of the shell. Newlines between recipe lines will be preserved. For 3754 example: 3755 3756 @example 3757 .ONESHELL: 3758 foo : bar/lose 3759 cd $(@@D) 3760 gobble $(@@F) > ../$@@ 3761 @end example 3762 3763 @noindent 3764 would now work as expected even though the commands are on different 3765 recipe lines. 3766 3767 If @code{.ONESHELL} is provided, then only the first line of the 3768 recipe will be checked for the special prefix characters (@samp{@@}, 3769 @samp{-}, and @samp{+}). Subsequent lines will include the special 3770 characters in the recipe line when the @code{SHELL} is invoked. If 3771 you want your recipe to start with one of these special characters 3772 you'll need to arrange for them to not be the first characters on the 3773 first line, perhaps by adding a comment or similar. For example, this 3774 would be a syntax error in Perl because the first @samp{@@} is removed 3775 by make: 3776 3777 @example 3778 .ONESHELL: 3779 SHELL = /usr/bin/perl 3780 .SHELLFLAGS = -e 3781 show : 3782 @@f = qw(a b c); 3783 print "@@f\n"; 3784 @end example 3785 3786 @noindent 3787 However, either of these alternatives would work properly: 3788 3789 @example 3790 .ONESHELL: 3791 SHELL = /usr/bin/perl 3792 .SHELLFLAGS = -e 3793 show : 3794 # Make sure "@@" is not the first character on the first line 3795 @@f = qw(a b c); 3796 print "@@f\n"; 3797 @end example 3798 3799 @noindent 3800 or 3801 3802 @example 3803 .ONESHELL: 3804 SHELL = /usr/bin/perl 3805 .SHELLFLAGS = -e 3806 show : 3807 my @@f = qw(a b c); 3808 print "@@f\n"; 3809 @end example 3810 3811 As a special feature, if @code{SHELL} is determined to be a 3812 POSIX-style shell, the special prefix characters in ``internal'' 3813 recipe lines will @emph{removed} before the recipe is processed. This 3814 feature is intended to allow existing makefiles to add the 3815 @code{.ONESHELL} special target and still run properly without 3816 extensive modifications. Since the special prefix characters are not 3817 legal at the beginning of a line in a POSIX shell script this is not a 3818 loss in functionality. For example, this works as expected: 3819 3820 @example 3821 .ONESHELL: 3822 foo : bar/lose 3823 @@cd $(@@D) 3824 @@gobble $(@@F) > ../$@@ 3825 @end example 3826 3827 Even with this special feature, however, makefiles with 3828 @code{.ONESHELL} will behave differently in ways that could be 3829 noticeable. For example, normally if any line in the recipe fails, 3830 that causes the rule to fail and no more recipe lines are processed. 3831 Under @code{.ONESHELL} a failure of any but the final recipe line will 3832 not be noticed by @code{make}. You can modify @code{.SHELLFLAGS} to 3833 add the @code{-e} option to the shell which will cause any failure 3834 anywhere in the command line to cause the shell to fail, but this 3835 could itself cause your recipe to behave differently. Ultimately you 3836 may need to harden your recipe lines to allow them to work with 3837 @code{.ONESHELL}. 3838 3839 @node Choosing the Shell, , One Shell, Execution 3691 3840 @subsection Choosing the Shell 3692 3841 @cindex shell, choosing the 3693 3842 @cindex @code{SHELL}, value of 3843 @cindex @code{.SHELLFLAGS}, value of 3694 3844 3695 3845 @vindex SHELL 3846 @vindex .SHELLFLAGS 3696 3847 The program used as the shell is taken from the variable @code{SHELL}. 3697 3848 If this variable is not set in your makefile, the program 3698 @file{/bin/sh} is used as the shell. 3849 @file{/bin/sh} is used as the shell. The argument(s) passed to the 3850 shell are taken from the variable @code{.SHELLFLAGS}. The default 3851 value of @code{.SHELLFLAGS} is @code{-c} normally, or @code{-ec} in 3852 POSIX-conforming mode. 3699 3853 3700 3854 @cindex environment, @code{SHELL} in … … 3786 3940 on MS-DOS unaltered if you have e.g.@: @file{sh.exe} installed in some 3787 3941 directory along your @code{PATH}. 3942 3943 @vindex SHELL 3944 @vindex .SHELLFLAGS 3788 3945 3789 3946 @node Parallel, Errors, Execution, Recipes … … 4014 4171 times to prevent other sorts of trouble. 4015 4172 4016 @node Recursion, Sequences, Interrupts, Recipes4173 @node Recursion, Canned Recipes, Interrupts, Recipes 4017 4174 @section Recursive Use of @code{make} 4018 4175 @cindex recursion … … 4360 4517 ensure that there are only @samp{N} jobs running at the same time 4361 4518 between them all. Note that any job that is marked recursive 4362 (@pxref{Instead of Execution, ,Instead of Executing theRecipes})4519 (@pxref{Instead of Execution, ,Instead of Executing Recipes}) 4363 4520 doesn't count against the total jobs (otherwise we could get @samp{N} 4364 4521 sub-@code{make}s running and have no slots left over for any real work!) … … 4496 4653 disable it. 4497 4654 4498 @node Sequences, Empty Recipes, Recursion, Recipes4655 @node Canned Recipes, Empty Recipes, Recursion, Recipes 4499 4656 @section Defining Canned Recipes 4500 4657 @cindex canned recipes … … 4509 4666 not conflict with other variable names. 4510 4667 4511 Here is an example of defining a canned recipe s:4512 4513 @example 4514 define run-yacc 4668 Here is an example of defining a canned recipe: 4669 4670 @example 4671 define run-yacc = 4515 4672 yacc $(firstword $^) 4516 4673 mv y.tab.c $@@ … … 4526 4683 parentheses, variable names, and so on, all become part of the value of the 4527 4684 variable you are defining. 4528 @xref{ Defining, ,Defining Variables Verbatim},4685 @xref{Multi-Line, ,Defining Multi-Line Variables}, 4529 4686 for a complete explanation of @code{define}. 4530 4687 … … 4567 4724 4568 4725 @example 4569 define frobnicate 4726 define frobnicate = 4570 4727 @@echo "frobnicating target $@@" 4571 4728 frob-step-1 $< -o $@@-step-1 … … 4590 4747 (@xref{Echoing, ,Recipe Echoing}, for a full explanation of @samp{@@}.) 4591 4748 4592 @node Empty Recipes, , Sequences, Recipes4749 @node Empty Recipes, , Canned Recipes, Recipes 4593 4750 @section Using Empty Recipes 4594 4751 @cindex empty recipes … … 4685 4842 * Override Directive:: How to set a variable in the makefile even if 4686 4843 the user has set it with a command argument. 4687 * Defining:: An alternate way to set a variable 4688 to a verbatim string. 4844 * Multi-Line:: An alternate way to set a variable 4845 to a multi-line string. 4846 * Undefine Directive:: How to undefine a variable so that it appears 4847 as if it was never set. 4689 4848 * Environment:: Variable values can come from the environment. 4690 4849 * Target-specific:: Variable values can be defined on a per-target … … 4692 4851 * Pattern-specific:: Target-specific variable values can be applied 4693 4852 to a group of targets that match a pattern. 4853 * Suppressing Inheritance:: Suppress inheritance of variables. 4694 4854 * Special Variables:: Variables with special meaning or behavior. 4695 4855 @end menu … … 4761 4921 Variables of this sort are defined by lines using @samp{=} 4762 4922 (@pxref{Setting, ,Setting Variables}) or by the @code{define} directive 4763 (@pxref{ Defining, ,Defining Variables Verbatim}). The value you specify4923 (@pxref{Multi-Line, ,Defining Multi-Line Variables}). The value you specify 4764 4924 is installed verbatim; if it contains references to other variables, 4765 4925 these references are expanded whenever this variable is substituted (in … … 5188 5348 dir = foo 5189 5349 $(dir)_sources := $(wildcard $(dir)/*.c) 5190 define $(dir)_print 5350 define $(dir)_print = 5191 5351 lpr $($(dir)_sources) 5192 5352 endef … … 5217 5377 You can specify a value in the makefile, either 5218 5378 with an assignment (@pxref{Setting, ,Setting Variables}) or with a 5219 verbatim definition (@pxref{ Defining, ,Defining Variables Verbatim}).@refill5379 verbatim definition (@pxref{Multi-Line, ,Defining Multi-Line Variables}).@refill 5220 5380 5221 5381 @item … … 5425 5585 value. 5426 5586 5427 @node Override Directive, Defining, Appending, Using Variables5587 @node Override Directive, Multi-Line, Appending, Using Variables 5428 5588 @section The @code{override} Directive 5429 5589 @findex override … … 5458 5618 @xref{Appending, ,Appending More Text to Variables}. 5459 5619 5620 Variable assignments marked with the @code{override} flag have a 5621 higher priority than all other assignments, except another 5622 @code{override}. Subsequent assignments or appends to this variable 5623 which are not marked @code{override} will be ignored. 5624 5460 5625 The @code{override} directive was not invented for escalation in the war 5461 5626 between makefiles and command arguments. It was invented so you can alter … … 5475 5640 5476 5641 @example 5477 override define foo 5642 override define foo = 5478 5643 bar 5479 5644 endef … … 5485 5650 @end iftex 5486 5651 @ifnottex 5487 @xref{ Defining, ,Defining Variables Verbatim}.5652 @xref{Multi-Line, ,Defining Multi-Line Variables}. 5488 5653 @end ifnottex 5489 5654 5490 @node Defining, Environment, Override Directive, Using Variables5491 @section Defining Variables Verbatim5655 @node Multi-Line, Undefine Directive, Override Directive, Using Variables 5656 @section Defining Multi-Line Variables 5492 5657 @findex define 5493 5658 @findex endef 5659 @cindex multi-line variable definition 5660 @cindex variables, multi-line 5494 5661 @cindex verbatim variable definition 5495 5662 @cindex defining variables verbatim … … 5498 5665 Another way to set the value of a variable is to use the @code{define} 5499 5666 directive. This directive has an unusual syntax which allows newline 5500 characters to be included in the value, which is convenient for defining5501 both canned sequences of commands 5502 (@pxref{Sequences, ,Defining Canned Command Sequences}), and also5503 sections of makefile syntax to use with @code{eval} (@pxref{Eval Function}). 5504 5505 The @code{define} directive is followed on the same line by the name of the5506 variable and nothing more. The value to give the variable appears on the 5507 following lines. The end of the value is marked by a line containing just 5508 the word @code{endef}. Aside from this difference in syntax, @code{define} 5509 works just like @samp{=}: it creates a recursively-expanded variable 5510 (@pxref{Flavors, ,The Two Flavors of Variables}). 5511 The variable name may contain function and variable references, which 5512 areexpanded when the directive is read to find the actual variable name5667 characters to be included in the value, which is convenient for 5668 defining both canned sequences of commands (@pxref{Canned Recipes, 5669 ,Defining Canned Recipes}), and also sections of makefile syntax to 5670 use with @code{eval} (@pxref{Eval Function}).@refill 5671 5672 The @code{define} directive is followed on the same line by the name 5673 of the variable being defined and an (optional) assignment operator, 5674 and nothing more. The value to give the variable appears on the 5675 following lines. The end of the value is marked by a line containing 5676 just the word @code{endef}. Aside from this difference in syntax, 5677 @code{define} works just like any other variable definition. The 5678 variable name may contain function and variable references, which are 5679 expanded when the directive is read to find the actual variable name 5513 5680 to use. 5681 5682 You may omit the variable assignment operator if you prefer. If 5683 omitted, @code{make} assumes it to be @samp{=} and creates a 5684 recursively-expanded variable (@pxref{Flavors, ,The Two Flavors of Variables}). 5685 When using a @samp{+=} operator, the value is appended to the previous 5686 value as with any other append operation: with a single space 5687 separating the old and new values. 5514 5688 5515 5689 You may nest @code{define} directives: @code{make} will keep track of … … 5518 5692 prefix character are considered part of a recipe, so any @code{define} 5519 5693 or @code{endef} strings appearing on such a line will not be 5520 considered @code{make} operators.5521 5522 @example 5523 define two-lines 5694 considered @code{make} directives. 5695 5696 @example 5697 define two-lines = 5524 5698 echo foo 5525 5699 echo $(bar) … … 5551 5725 5552 5726 @example 5553 override define two-lines 5727 override define two-lines = 5554 5728 foo 5555 5729 $(bar) … … 5560 5734 @xref{Override Directive, ,The @code{override} Directive}. 5561 5735 5562 @node Environment, Target-specific, Defining, Using Variables 5736 @node Undefine Directive, Environment, Multi-Line, Using Variables 5737 @section Undefining Variables 5738 @findex undefine 5739 @cindex undefining variable 5740 5741 If you want to clear a variable, setting its value to empty is usually 5742 sufficient. Expanding such a variable will yield the same result (empty 5743 string) regardless of whether it was set or not. However, if you are 5744 using the @code{flavor} (@pxref{Flavor Function}) and 5745 @code{origin} (@pxref{Origin Function}) functions, there is a difference 5746 between a variable that was never set and a variable with an empty value. 5747 In such situations you may want to use the @code{undefine} directive to 5748 make a variable appear as if it was never set. For example: 5749 5750 @example 5751 foo := foo 5752 bar = bar 5753 5754 undefine foo 5755 undefine bar 5756 5757 $(info $(origin foo)) 5758 $(info $(flavor bar)) 5759 @end example 5760 5761 This example will print ``undefined'' for both variables. 5762 5763 If you want to undefine a command-line variable definition, you can use 5764 the @code{override} directive together with @code{undefine}, similar to 5765 how this is done for variable definitions: 5766 5767 @example 5768 override undefine CFLAGS 5769 @end example 5770 5771 @node Environment, Target-specific, Undefine Directive, Using Variables 5563 5772 @section Variables from the Environment 5564 5773 … … 5626 5835 @end example 5627 5836 5628 @noindent 5629 or like this: 5630 5631 @example 5632 @var{target} @dots{} : override @var{variable-assignment} 5633 @end example 5634 5635 @noindent 5636 or like this: 5637 5638 @example 5639 @var{target} @dots{} : export @var{variable-assignment} 5640 @end example 5837 Target-specific variable assignments can be prefixed with any or all of the 5838 special keywords @code{export}, @code{override}, or @code{private}; 5839 these apply their normal behavior to this instance of the variable only. 5641 5840 5642 5841 Multiple @var{target} values create a target-specific variable value for … … 5684 5883 ignore the target-specific values from any other targets. 5685 5884 5686 @node Pattern-specific, S pecial Variables, Target-specific, Using Variables5885 @node Pattern-specific, Suppressing Inheritance, Target-specific, Using Variables 5687 5886 @section Pattern-specific Variable Values 5688 5887 @cindex pattern-specific variables … … 5693 5892 @code{make} supports pattern-specific variable values. In this form, 5694 5893 the variable is defined for any target that matches the pattern 5695 specified. If a target matches more than one pattern, all the 5696 matching pattern-specific variables are interpreted in the order in 5697 which they were defined in the makefile, and collected together into 5698 one set. Variables defined in this way are searched after any 5699 target-specific variables defined explicitly for that target, and 5700 before target-specific variables defined for the parent target. 5894 specified. 5701 5895 5702 5896 Set a pattern-specific variable value like this: … … 5705 5899 @var{pattern} @dots{} : @var{variable-assignment} 5706 5900 @end example 5707 5708 @noindent5709 or like this:5710 5711 @example5712 @var{pattern} @dots{} : override @var{variable-assignment}5713 @end example5714 5715 @noindent5716 5901 where @var{pattern} is a %-pattern. As with target-specific variable 5717 5902 values, multiple @var{pattern} values create a pattern-specific variable … … 5730 5915 matching the pattern @code{%.o}. 5731 5916 5732 @node Special Variables, , Pattern-specific, Using Variables 5917 If a target matches more than one pattern, the matching pattern-specific 5918 variables with longer stems are interpreted first. This results in more 5919 specific variables taking precedence over the more generic ones, for 5920 example: 5921 5922 @example 5923 %.o: %.c 5924 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@ 5925 5926 lib/%.o: CFLAGS := -fPIC -g 5927 %.o: CFLAGS := -g 5928 5929 all: foo.o lib/bar.o 5930 @end example 5931 5932 In this example the first definition of the @code{CFLAGS} variable 5933 will be used to update @file{lib/bar.o} even though the second one 5934 also applies to this target. Pattern-specific variables which result 5935 in the same stem length are considered in the order in which they 5936 were defined in the makefile. 5937 5938 Pattern-specific variables are searched after any target-specific 5939 variables defined explicitly for that target, and before target-specific 5940 variables defined for the parent target. 5941 5942 @node Suppressing Inheritance, Special Variables, Pattern-specific, Using Variables 5943 @section Suppressing Inheritance 5944 @findex private 5945 @cindex suppressing inheritance 5946 @cindex inheritance, suppressing 5947 5948 As described in previous sections, @code{make} variables are inherited 5949 by prerequisites. This capability allows you to modify the behavior 5950 of a prerequisite based on which targets caused it to be rebuilt. For 5951 example, you might set a target-specific variable on a @code{debug} 5952 target, then running @samp{make debug} will cause that variable to be 5953 inherited by all prerequisites of @code{debug}, while just running 5954 @samp{make all} (for example) would not have that assignment. 5955 5956 Sometimes, however, you may not want a variable to be inherited. For 5957 these situations, @code{make} provides the @code{private} modifier. 5958 Although this modifier can be used with any variable assignment, it 5959 makes the most sense with target- and pattern-specific variables. Any 5960 variable marked @code{private} will be visible to its local target but 5961 will not be inherited by prerequisites of that target. A global 5962 variable marked @code{private} will be visible in the global scope but 5963 will not be inherited by any target, and hence will not be visible 5964 in any recipe. 5965 5966 As an example, consider this makefile: 5967 @example 5968 EXTRA_CFLAGS = 5969 5970 prog: private EXTRA_CFLAGS = -L/usr/local/lib 5971 prog: a.o b.o 5972 @end example 5973 5974 Due to the @code{private} modifier, @code{a.o} and @code{b.o} will not 5975 inherit the @code{EXTRA_CFLAGS} variable assignment from the 5976 @code{progs} target. 5977 5978 @node Special Variables, , Suppressing Inheritance, Using Variables 5733 5979 @comment node-name, next, previous, up 5734 5980 @section Other Special Variables … … 5834 6080 variable). You should not set, modify, or export this variable. 5835 6081 5836 @vindex . CMDPREFIX @r{(change the recipe prefix character)}5837 @item . CMDPREFIX6082 @vindex .RECIPEPREFIX @r{(change the recipe prefix character)} 6083 @item .RECIPEPREFIX 5838 6084 The first character of the value of this variable is used as the 5839 6085 character make assumes is introducing a recipe line. If the variable … … 5843 6089 @example 5844 6090 @group 5845 . CMDPREFIX = >6091 .RECIPEPREFIX = > 5846 6092 all: 5847 6093 > @@echo Hello, world … … 5849 6095 @end example 5850 6096 5851 The value of @code{. CMDPREFIX} can be changed multiple times; once set6097 The value of @code{.RECIPEPREFIX} can be changed multiple times; once set 5852 6098 it stays in effect for all rules parsed until it is modified. 5853 6099 … … 7175 7421 all: $(PROGRAMS) 7176 7422 7177 define PROGRAM_template 7423 define PROGRAM_template = 7178 7424 $(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) 7179 7425 ALL_OBJS += $$($(1)_OBJS) … … 7228 7474 @item environment 7229 7475 7230 if @var{variable} was defined as an environment variable and the7231 @ samp{-e} option is @emph{not} turned on (@pxref{Options Summary, ,Summary of Options}).7476 if @var{variable} was inherited from the environment provided to 7477 @code{make}. 7232 7478 7233 7479 @item environment override 7234 7480 7235 if @var{variable} was defined as an environment variable and the 7236 @w{@samp{-e}} option @emph{is} turned on (@pxref{Options Summary, 7237 ,Summary of Options}).@refill 7481 if @var{variable} was inherited from the environment provided to 7482 @code{make}, and is overriding a setting for @var{variable} in the 7483 makefile as a result of the @w{@samp{-e}} option (@pxref{Options 7484 Summary, ,Summary of Options}).@refill 7238 7485 7239 7486 @item file … … 7476 7723 The exit status is one if you use the @samp{-q} flag and @code{make} 7477 7724 determines that some target is not already up to date. 7478 @xref{Instead of Execution, ,Instead of Executing theRecipes}.7725 @xref{Instead of Execution, ,Instead of Executing Recipes}. 7479 7726 @end table 7480 7727 … … 7653 7900 7654 7901 @node Instead of Execution, Avoiding Compilation, Goals, Running 7655 @section Instead of Executing theRecipes7902 @section Instead of Executing Recipes 7656 7903 @cindex execution, instead of 7657 7904 @cindex recipes, instead of executing … … 7673 7920 7674 7921 ``No-op''. The activity is to print what recipe would be used to make 7675 the targets up to date, but not actually execute it. 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}). 7676 7924 7677 7925 @item -t … … 7715 7963 7716 7964 With the @samp{-n} flag, @code{make} prints the recipe that it would 7717 normally execute but does not execute it.7965 normally execute but usually does not execute it. 7718 7966 7719 7967 With the @samp{-t} flag, @code{make} ignores the recipes in the rules … … 7741 7989 not run unless they too begin with @samp{+} or contain @samp{$(MAKE)} or 7742 7990 @samp{$@{MAKE@}} (@xref{MAKE Variable, ,How the @code{MAKE} Variable Works}.) 7991 7992 @cindex phony targets and recipe execution 7993 The @samp{-t} flag prevents phony targets (@pxref{Phony Targets}) from 7994 being updated, unless there are recipe lines beginning with @samp{+} 7995 or containing @samp{$(MAKE)} or @samp{$@{MAKE@}}. 7743 7996 7744 7997 The @samp{-W} flag provides two features: … … 8007 8260 @xref{Environment, ,Variables from the Environment}. 8008 8261 8262 @item --eval=@var{string} 8263 @cindex @code{--eval} 8264 @c Extra blank line here makes the table look better. 8265 8266 Evaluate @var{string} as makefile syntax. This is a command-line 8267 version of the @code{eval} function (@pxref{Eval Function}). The 8268 evaluation is performed after the default rules and variables have 8269 been defined, but before any makefiles are read. 8270 8009 8271 @item -f @var{file} 8010 8272 @cindex @code{-f} … … 8090 8352 @c Extra blank line here makes the table look better. 8091 8353 8092 Print the recipe that would be executed, but do not execute it. 8093 @xref{Instead of Execution, ,Instead of Executing the Recipes}. 8354 Print the recipe that would be executed, but do not execute it (except 8355 in certain circumstances). 8356 @xref{Instead of Execution, ,Instead of Executing Recipes}. 8094 8357 8095 8358 @item -o @var{file} … … 8128 8391 return an exit status that is zero if the specified targets are already 8129 8392 up to date, one if any remaking is required, or two if an error is 8130 encountered. @xref{Instead of Execution, ,Instead of Executing the8393 encountered. @xref{Instead of Execution, ,Instead of Executing 8131 8394 Recipes}.@refill 8132 8395 … … 8190 8453 instead of running their recipes. This is used to pretend that the 8191 8454 recipes were done, in order to fool future invocations of 8192 @code{make}. @xref{Instead of Execution, ,Instead of Executing theRecipes}.8455 @code{make}. @xref{Instead of Execution, ,Instead of Executing Recipes}. 8193 8456 8194 8457 @item -v … … 8231 8494 @code{make}, except that the modification time is changed only in the 8232 8495 imagination of @code{make}. 8233 @xref{Instead of Execution, ,Instead of Executing theRecipes}.8496 @xref{Instead of Execution, ,Instead of Executing Recipes}. 8234 8497 8235 8498 @item --warn-undefined-variables … … 8421 8684 @pindex .c 8422 8685 @file{@var{n}.o} is made automatically from @file{@var{n}.c} with 8423 a recipe of the form @samp{$(CC) -c $(CPPFLAGS) $(CFLAGS)}.@refill8686 a recipe of the form @samp{$(CC) $(CPPFLAGS) $(CFLAGS) -c}.@refill 8424 8687 8425 8688 @item Compiling C++ programs … … 8431 8694 @file{@var{n}.o} is made automatically from @file{@var{n}.cc}, 8432 8695 @file{@var{n}.cpp}, or @file{@var{n}.C} with a recipe of the form 8433 @samp{$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)}. We encourage you to use the8696 @samp{$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c}. We encourage you to use the 8434 8697 suffix @samp{.cc} for C++ source files instead of @samp{.C}.@refill 8435 8698 … … 8439 8702 @pindex .p 8440 8703 @file{@var{n}.o} is made automatically from @file{@var{n}.p} 8441 with the recipe @samp{$(PC) -c $(PFLAGS)}.@refill8704 with the recipe @samp{$(PC) $(PFLAGS) -c}.@refill 8442 8705 8443 8706 @item Compiling Fortran and Ratfor programs … … 8454 8717 @table @samp 8455 8718 @item .f 8456 @samp{$(FC) -c $(FFLAGS)}.8719 @samp{$(FC) $(FFLAGS) -c}. 8457 8720 @item .F 8458 @samp{$(FC) -c $(FFLAGS) $(CPPFLAGS)}.8721 @samp{$(FC) $(FFLAGS) $(CPPFLAGS) -c}. 8459 8722 @item .r 8460 @samp{$(FC) -c $(FFLAGS) $(RFLAGS)}.8723 @samp{$(FC) $(FFLAGS) $(RFLAGS) -c}. 8461 8724 @end table 8462 8725 … … 8469 8732 @table @samp 8470 8733 @item .F 8471 @samp{$(FC) -F $(CPPFLAGS) $(FFLAGS)}.8734 @samp{$(FC) $(CPPFLAGS) $(FFLAGS) -F}. 8472 8735 @item .r 8473 @samp{$(FC) -F $(FFLAGS) $(RFLAGS)}.8736 @samp{$(FC) $(FFLAGS) $(RFLAGS) -F}. 8474 8737 @end table 8475 8738 … … 9066 9329 pattern. @xref{Last Resort}. 9067 9330 9331 More than one pattern rule may match a target. In this case 9332 @code{make} will choose the ``best fit'' rule. @xref{Pattern Match, 9333 ,How Patterns Match}. 9334 9068 9335 @c !!! The end of of this paragraph should be rewritten. --bob 9069 9336 Pattern rules may have more than one target. Unlike normal rules, … … 9081 9348 @cindex target, multiple in pattern rule 9082 9349 9083 The order in which pattern rules appear in the makefile is important9084 since this is the order in which they are considered.9085 Of equally applicable9086 rules, only the first one found is used. The rules you write take precedence9087 over those that are built in. Note however, that a rule whose9088 prerequisites actually exist or are mentioned always takes priority over a9089 rule with prerequisites that must be made by chaining other implicit rules.9090 @cindex pattern rules, order of9091 @cindex order of pattern rules9092 9093 9350 @node Pattern Examples, Automatic Variables, Pattern Intro, Pattern Rules 9094 9351 @subsection Pattern Rule Examples … … 9403 9660 @file{src/car}.@refill 9404 9661 9662 @cindex pattern rules, order of 9663 @cindex order of pattern rules 9664 A pattern rule can be used to build a given file only if there is a 9665 target pattern that matches the file name, @emph{and} all 9666 prerequisites in that rule either exist or can be built. The rules 9667 you write take precedence over those that are built in. Note however, 9668 that a rule whose prerequisites actually exist or are mentioned always 9669 takes priority over a rule with prerequisites that must be made by 9670 chaining other implicit rules. 9671 9672 @cindex stem, shortest 9673 It is possible that more than one pattern rule will meet these 9674 criteria. In that case, @code{make} will choose the rule with the 9675 shortest stem (that is, the pattern that matches most specifically). 9676 If more than one pattern rule has the shortest stem, @code{make} will 9677 choose the first one found in the makefile. 9678 9679 This algorithm results in more specific rules being preferred over 9680 more generic ones; for example: 9681 9682 @example 9683 %.o: %.c 9684 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@ 9685 9686 %.o : %.f 9687 $(COMPILE.F) $(OUTPUT_OPTION) $< 9688 9689 lib/%.o: lib/%.c 9690 $(CC) -fPIC -c $(CFLAGS) $(CPPFLAGS) $< -o $@@ 9691 @end example 9692 9693 Given these rules and asked to build @file{bar.o} where both 9694 @file{bar.c} and @file{bar.f} exist, @code{make} will choose the first 9695 rule and compile @file{bar.c} into @file{bar.o}. In the same 9696 situation where @file{bar.c} does not exist, then @code{make} will 9697 choose the second rule and compile @file{bar.f} into @file{bar.o}. 9698 9699 If @code{make} is asked to build @file{lib/bar.o} and both 9700 @file{lib/bar.c} and @file{lib/bar.f} exist, then the third rule will 9701 be chosen since the stem for this rule (@samp{bar}) is shorter than 9702 the stem for the first rule (@samp{lib/bar}). If @file{lib/bar.c} 9703 does not exist then the third rule is not eligible and the second rule 9704 will be used, even though the stem is longer. 9705 9405 9706 @node Match-Anything Rules, Canceling Rules, Pattern Match, Pattern Rules 9406 9707 @subsection Match-Anything Pattern Rules … … 10084 10385 The ``what if'' flag (@samp{-W} in GNU @code{make}) was (as far as we know) 10085 10386 invented by Andrew Hume in @code{mk}. 10086 @xref{Instead of Execution, ,Instead of Executing theRecipes}.10387 @xref{Instead of Execution, ,Instead of Executing Recipes}. 10087 10388 10088 10389 @item … … 10102 10403 @item 10103 10404 The special significance of @samp{+} characters preceding recipe lines 10104 (@pxref{Instead of Execution, ,Instead of Executing theRecipes}) is10405 (@pxref{Instead of Execution, ,Instead of Executing Recipes}) is 10105 10406 mandated by @cite{IEEE Standard 1003.2-1992} (POSIX.2). 10106 10407 … … 10147 10448 @item 10148 10449 Make verbatim variable definitions with @code{define}. 10149 @xref{ Defining, ,Defining Variables Verbatim}.10450 @xref{Multi-Line, ,Defining Multi-Line Variables}. 10150 10451 10151 10452 @item … … 10355 10656 @table @code 10356 10657 @item define @var{variable} 10658 @itemx define @var{variable} = 10659 @itemx define @var{variable} := 10660 @itemx define @var{variable} += 10661 @itemx define @var{variable} ?= 10357 10662 @itemx endef 10358 10359 Define a multi-line, recursively-expanded variable.@* 10360 @xref{Sequences}. 10663 Define multi-line variables.@* 10664 @xref{Multi-Line}. 10665 10666 @item undefine @var{variable} 10667 Undefining variables.@* 10668 @xref{Undefine Directive}. 10361 10669 10362 10670 @item ifdef @var{variable} … … 10370 10678 @itemx else 10371 10679 @itemx endif 10372 10373 10680 Conditionally evaluate part of the makefile.@* 10374 10681 @xref{Conditionals}. … … 10377 10684 @itemx -include @var{file} 10378 10685 @itemx sinclude @var{file} 10379 10380 10686 Include another makefile.@* 10381 10687 @xref{Include, ,Including Other Makefiles}. 10382 10688 10383 @item override @var{variable} = @var{value} 10384 @itemx override @var{variable} := @var{value} 10385 @itemx override @var{variable} += @var{value} 10386 @itemx override @var{variable} ?= @var{value} 10387 @itemx override define @var{variable} 10388 @itemx endef 10389 10689 @item override @var{variable-assignment} 10390 10690 Define a variable, overriding any previous definition, even one from 10391 10691 the command line.@* … … 10393 10693 10394 10694 @item export 10395 10396 10695 Tell @code{make} to export all variables to child processes by default.@* 10397 10696 @xref{Variables/Recursion, , Communicating Variables to a Sub-@code{make}}. 10398 10697 10399 10698 @item export @var{variable} 10400 @itemx export @var{variable} = @var{value} 10401 @itemx export @var{variable} := @var{value} 10402 @itemx export @var{variable} += @var{value} 10403 @itemx export @var{variable} ?= @var{value} 10699 @itemx export @var{variable-assignment} 10404 10700 @itemx unexport @var{variable} 10405 10701 Tell @code{make} whether or not to export a particular variable to child 10406 10702 processes.@* 10407 10703 @xref{Variables/Recursion, , Communicating Variables to a Sub-@code{make}}. 10704 10705 @item private @var{variable-assignment} 10706 Do not allow this variable assignment to be inherited by prerequisites.@* 10707 @xref{Suppressing Inheritance}. 10408 10708 10409 10709 @item vpath @var{pattern} @var{path} … … 10515 10815 10516 10816 @item $(error @var{text}@dots{}) 10517 10518 10817 When this function is evaluated, @code{make} generates a fatal error 10519 10818 with the message @var{text}.@* … … 10521 10820 10522 10821 @item $(warning @var{text}@dots{}) 10523 10524 10822 When this function is evaluated, @code{make} generates a warning with 10525 10823 the message @var{text}.@* … … 10527 10825 10528 10826 @item $(shell @var{command}) 10529 10530 10827 Execute a shell command and return its output.@* 10531 10828 @xref{Shell Function, , The @code{shell} Function}. 10532 10829 10533 10830 @item $(origin @var{variable}) 10534 10535 10831 Return a string describing how the @code{make} variable @var{variable} was 10536 10832 defined.@* … … 10538 10834 10539 10835 @item $(flavor @var{variable}) 10540 10541 10836 Return a string describing the flavor of the @code{make} variable 10542 10837 @var{variable}.@* … … 10544 10839 10545 10840 @item $(foreach @var{var},@var{words},@var{text}) 10546 10547 10841 Evaluate @var{text} with @var{var} bound to each word in @var{words}, 10548 10842 and concatenate the results.@* 10549 10843 @xref{Foreach Function, ,The @code{foreach} Function}. 10550 10844 10845 @item $(if @var{condition},@var{then-part}[,@var{else-part}]) 10846 Evaluate the condition @var{condition}; if it's non-empty substitute 10847 the expansion of the @var{then-part} otherwise substitute the 10848 expansion of the @var{else-part}.@* 10849 @xref{Conditional Functions, ,Functions for Conditionals}. 10850 10851 @item $(or @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]]) 10852 Evaluate each condition @var{conditionN} one at a time; substitute the 10853 first non-empty expansion. If all expansions are empty, substitute 10854 the empty string.@* 10855 @xref{Conditional Functions, ,Functions for Conditionals}. 10856 10857 @item $(and @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]]) 10858 Evaluate each condition @var{conditionN} one at a time; if any 10859 expansion results in the empty string substitute the empty string. If 10860 all expansions result in a non-empty string, substitute the expansion 10861 of the last @var{condition}.@* 10862 @xref{Conditional Functions, ,Functions for Conditionals}. 10863 10551 10864 @item $(call @var{var},@var{param},@dots{}) 10552 10553 10865 Evaluate the variable @var{var} replacing any references to @code{$(1)}, 10554 10866 @code{$(2)} with the first, second, etc.@: @var{param} values.@* … … 10556 10868 10557 10869 @item $(eval @var{text}) 10558 10559 10870 Evaluate @var{text} then read the results as makefile commands. 10560 10871 Expands to the empty string.@* … … 10562 10873 10563 10874 @item $(value @var{var}) 10564 10565 10875 Evaluates to the contents of the variable @var{var}, with no expansion 10566 10876 performed on it.@* … … 10747 11057 second form of the error above. Remember that every line in the 10748 11058 recipe must begin with a tab character (unless you set 10749 @code{. CMDPREFIX}; @pxref{Special Variables}). Eight spaces do not11059 @code{.RECIPEPREFIX}; @pxref{Special Variables}). Eight spaces do not 10750 11060 count. @xref{Rule Syntax}. 10751 11061 … … 11007 11317 #### End of system configuration section. #### 11008 11318 11009 SRC1 = tar.c create.c extract.c buffer.c \ 11010 getoldopt.c update.c gnu.c mangle.c 11011 SRC2 = version.c list.c names.c diffarch.c \ 11012 port.c wildmat.c getopt.c 11013 SRC3 = getopt1.c regex.c getdate.y 11014 SRCS = $(SRC1) $(SRC2) $(SRC3) 11015 OBJ1 = tar.o create.o extract.o buffer.o \ 11016 getoldopt.o update.o gnu.o mangle.o 11017 OBJ2 = version.o list.o names.o diffarch.o \ 11018 port.o wildmat.o getopt.o 11019 OBJ3 = getopt1.o regex.o getdate.o $(RTAPELIB) 11020 OBJS = $(OBJ1) $(OBJ2) $(OBJ3) 11319 @group 11320 SRCS_C = tar.c create.c extract.c buffer.c \ 11321 getoldopt.c update.c gnu.c mangle.c \ 11322 version.c list.c names.c diffarch.c \ 11323 port.c wildmat.c getopt.c getopt1.c \ 11324 regex.c 11325 SRCS_Y = getdate.y 11326 SRCS = $(SRCS_C) $(SRCS_Y) 11327 OBJS = $(SRCS_C:.c=.o) $(SRCS_Y:.y=.o) $(RTAPELIB) 11328 @end group 11021 11329 @group 11022 11330 AUX = README COPYING ChangeLog Makefile.in \ -
trunk/src/kmk/dosbuild.bat
r1993 r2591 1 1 @echo off 2 rem Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 3 rem Free Software Foundation, Inc.2 rem Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 3 rem 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 rem This file is part of GNU Make. 5 5 rem -
trunk/src/kmk/electric.c
r2413 r2591 159 159 160 160 void * 161 xcalloc ( size_t size, size_t items)161 xcalloc (unsigned size) 162 162 { 163 163 void *result; 164 result = xmalloc (size * items);165 return memset (result, 0, size * items);164 result = xmalloc (size); 165 return memset (result, 0, size); 166 166 } 167 167 -
trunk/src/kmk/electric.h
r2413 r2591 33 33 34 34 void xfree (void *); 35 void *xcalloc ( size_t, size_t);35 void *xcalloc (unsigned int); 36 36 void *xmalloc (unsigned int); 37 37 void *xrealloc (void *, unsigned int); … … 39 39 40 40 #define free(a) xfree(a) 41 #define calloc(a,b) xcalloc((a) ,(b))41 #define calloc(a,b) xcalloc((a) * (b)) 42 42 #define malloc(a) xmalloc(a) 43 43 #define realloc(a,b) xrealloc((a),(b)) -
trunk/src/kmk/expand.c
r2548 r2591 1 1 /* Variable expansion functions for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 539 539 if (*p == '\0') 540 540 break; 541 else 542 541 542 ++p; 543 543 } 544 544 … … 845 845 { 846 846 #ifndef CONFIG_WITH_VALUE_LENGTH 847 char *tmp; 847 char *tmp, *alloc = NULL; 848 char *r; 848 849 #endif 849 850 … … 855 856 return allocated_variable_expand (str); 856 857 857 tmp = alloca (end - str + 1); 858 if (end - str + 1 > 1000) 859 tmp = alloc = xmalloc (end - str + 1); 860 else 861 tmp = alloca (end - str + 1); 862 858 863 memcpy (tmp, str, end - str); 859 864 tmp[end - str] = '\0'; 860 865 861 return allocated_variable_expand (tmp); 866 r = allocated_variable_expand (tmp); 867 868 if (alloc) 869 free (alloc); 870 871 return r; 862 872 #else /* CONFIG_WITH_VALUE_LENGTH */ 863 873 if (!end) … … 1103 1113 value = variable_expand_for_file (line, file); 1104 1114 1105 #if 01106 /* Waste a little memory and save time. */1107 value = xrealloc (value, strlen (value))1108 #endif1109 1110 1115 variable_buffer = obuf; 1111 1116 variable_buffer_length = olen; -
trunk/src/kmk/file.c
r2024 r2591 1 1 /* Target file management for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 119 119 name += 2; 120 120 #endif 121 while (name[0] == '.' && name[1] == '/' && name[2] != '\0') 121 while (name[0] == '.' 122 #ifdef HAVE_DOS_PATHS 123 && (name[1] == '/' || name[1] == '\\') 124 #else 125 && name[1] == '/' 126 #endif 127 && name[2] != '\0') 122 128 { 123 129 name += 2; 124 while (*name == '/') 130 while (*name == '/' 131 #ifdef HAVE_DOS_PATHS 132 || *name == '\\' 133 #endif 134 ) 125 135 /* Skip following slashes: ".//foo" is "foo", not "/foo". */ 126 136 ++name; … … 230 240 231 241 #ifndef CONFIG_WITH_ALLOC_CACHES 232 new = xmalloc (sizeof (struct file)); 233 memset (new, '\0', sizeof (struct file)); 242 new = xcalloc (sizeof (struct file)); 234 243 #else 235 244 new = alloccache_calloc (&file_cache); … … 511 520 512 521 522 /* Given a string containing prerequisites (fully expanded), break it up into 523 a struct dep list. Enter each of these prereqs into the file database. 524 */ 513 525 struct dep * 514 parse_prereqs (char *p) 515 { 516 #ifndef CONFIG_WITH_ALLOC_CACHES 517 struct dep *new = (struct dep *) 518 multi_glob (parse_file_seq (&p, '|', sizeof (struct dep), 1), 519 sizeof (struct dep)); 520 #else 521 struct dep *new = (struct dep *) 522 multi_glob (parse_file_seq (&p, '|', &dep_cache, 1), &dep_cache); 523 #endif 526 split_prereqs (char *p) 527 { 528 struct dep *new = PARSE_FILE_SEQ (&p, struct dep, '|', NULL, 0); 524 529 525 530 if (*p) … … 530 535 531 536 ++p; 532 #ifndef CONFIG_WITH_ALLOC_CACHES 533 ood = (struct dep *) 534 multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1), 535 sizeof (struct dep)); 536 #else 537 ood = (struct dep *) 538 multi_glob (parse_file_seq (&p, '\0', &dep_cache, 1), &dep_cache); 539 #endif 537 ood = PARSE_FILE_SEQ (&p, struct dep, '\0', NULL, 0); 540 538 541 539 if (! new) … … 556 554 } 557 555 556 /* Given a list of prerequisites, enter them into the file database. 557 If STEM is set then first expand patterns using STEM. */ 558 struct dep * 559 enter_prereqs (struct dep *deps, const char *stem) 560 { 561 struct dep *d1; 562 563 if (deps == 0) 564 return 0; 565 566 /* If we have a stem, expand the %'s. We use patsubst_expand to translate 567 the prerequisites' patterns into plain prerequisite names. */ 568 if (stem) 569 { 570 const char *pattern = "%"; 571 char *buffer = variable_expand (""); 572 struct dep *dp = deps, *dl = 0; 573 574 while (dp != 0) 575 { 576 char *percent; 577 int nl = strlen (dp->name) + 1; 578 char *nm = alloca (nl); 579 memcpy (nm, dp->name, nl); 580 percent = find_percent (nm); 581 if (percent) 582 { 583 char *o; 584 585 /* We have to handle empty stems specially, because that 586 would be equivalent to $(patsubst %,dp->name,) which 587 will always be empty. */ 588 if (stem[0] == '\0') 589 { 590 memmove (percent, percent+1, strlen (percent)); 591 o = variable_buffer_output (buffer, nm, strlen (nm) + 1); 592 } 593 else 594 o = patsubst_expand_pat (buffer, stem, pattern, nm, 595 pattern+1, percent+1); 596 597 /* If the name expanded to the empty string, ignore it. */ 598 if (buffer[0] == '\0') 599 { 600 struct dep *df = dp; 601 if (dp == deps) 602 dp = deps = deps->next; 603 else 604 dp = dl->next = dp->next; 605 free_dep (df); 606 continue; 607 } 608 609 /* Save the name. */ 610 dp->name = strcache_add_len (buffer, o - buffer); 611 } 612 dp->stem = stem; 613 dp->staticpattern = 1; 614 dl = dp; 615 dp = dp->next; 616 } 617 } 618 619 /* Enter them as files, unless they need a 2nd expansion. */ 620 for (d1 = deps; d1 != 0; d1 = d1->next) 621 { 622 if (d1->need_2nd_expansion) 623 continue; 624 625 d1->file = lookup_file (d1->name); 626 if (d1->file == 0) 627 d1->file = enter_file (d1->name); 628 d1->staticpattern = 0; 629 d1->name = 0; 630 } 631 632 return deps; 633 } 634 558 635 /* Set the intermediate flag. */ 559 636 … … 570 647 { 571 648 struct dep *d; 572 struct dep * old = f->deps;649 struct dep **dp; 573 650 const char *file_stem = f->stem; 574 unsigned int last_dep_has_cmds = f->updating;575 651 int initialized = 0; 576 652 577 653 f->updating = 0; 578 f->deps = 0; 579 580 for (d = old; d != 0; d = d->next) 581 { 582 struct dep *new, *d1; 654 655 /* Walk through the dependencies. For any dependency that needs 2nd 656 expansion, expand it then insert the result into the list. */ 657 dp = &f->deps; 658 d = f->deps; 659 while (d != 0) 660 { 583 661 char *p; 584 #ifdef CONFIG_WITH_STRCACHE2 585 unsigned int len; 586 #endif 587 588 if (! d->name) 589 continue; 662 struct dep *new, *next; 663 char *name = (char *)d->name; 664 665 if (! d->name || ! d->need_2nd_expansion) 666 { 667 /* This one is all set already. */ 668 dp = &d->next; 669 d = d->next; 670 continue; 671 } 590 672 591 673 #ifdef CONFIG_WITH_INCLUDEDEP … … 597 679 if (d->includedep) 598 680 { 599 new = d1= alloc_dep();681 struct dep *d1 = new = alloc_dep(); 600 682 d1->staticpattern = 0; 601 683 d1->need_2nd_expansion = 0; … … 618 700 } 619 701 else 702 { 703 #endif /* CONFIG_WITH_INCLUDEDEP */ 704 705 /* If it's from a static pattern rule, convert the patterns into 706 "$*" so they'll expand properly. */ 707 if (d->staticpattern) 620 708 { 621 #endif 622 623 /* Create the dependency list. 624 If we're not doing 2nd expansion, then it's just the name. We will 625 still need to massage it though. */ 626 if (! d->need_2nd_expansion) 709 char *o; 710 d->name = o = variable_expand (""); 711 o = subst_expand (o, name, "%", "$*", 1, 2, 0); 712 *o = '\0'; 713 free (name); 714 #ifndef CONFIG_WITH_STRCACHE2 715 d->name = name = xstrdup (variable_buffer); /* bird not d->name, can be reallocated */ 716 #else 717 d->name = strcache2_add (&file_strcache, variable_buffer, o - variable_buffer); 718 #endif 719 d->staticpattern = 0; 720 } 721 722 /* We're going to do second expansion so initialize file variables for 723 the file. Since the stem for static pattern rules comes from 724 individual dep lines, we will temporarily set f->stem to d->stem. */ 725 if (!initialized) 627 726 { 628 p = variable_expand (""); 629 #ifndef CONFIG_WITH_STRCACHE2 630 variable_buffer_output (p, d->name, strlen (d->name) + 1); 727 initialize_file_variables (f, 0); 728 initialized = 1; 729 } 730 731 if (d->stem != 0) 732 f->stem = d->stem; 733 734 #if defined(CONFIG_WITH_COMMANDS_FUNC) || defined (CONFIG_WITH_DOT_MUST_MAKE) 735 set_file_variables (f, 0 /* real call, f->deps == 0 so we're ok. */); 631 736 #else 632 len = strcache2_get_len (&file_strcache, d->name); 633 variable_buffer_output (p, d->name, len + 1); 634 #endif 635 p = variable_buffer; 737 set_file_variables (f); 738 #endif 739 740 p = variable_expand_for_file (d->name, f); 741 742 if (d->stem != 0) 743 f->stem = file_stem; 744 745 /* At this point we don't need the name anymore: free it. */ 746 free (name); 747 748 /* Parse the prerequisites and enter them into the file database. */ 749 new = enter_prereqs (split_prereqs (p), d->stem); 750 751 /* If there were no prereqs here (blank!) then throw this one out. */ 752 if (new == 0) 753 { 754 *dp = d->next; 755 free_dep (d); 756 d = *dp; 757 continue; 636 758 } 637 else638 {639 /* If it's from a static pattern rule, convert the patterns into640 "$*" so they'll expand properly. */641 if (d->staticpattern)642 {643 char *o;644 char *buffer = variable_expand ("");645 646 o = subst_expand (buffer, d->name, "%", "$*", 1, 2, 0);647 buffer = variable_buffer; /* bird - variable_buffer may have been reallocated. */648 649 d->name = strcache_add_len (variable_buffer,650 o - variable_buffer);651 d->staticpattern = 0; /* Clear staticpattern so that we don't652 re-expand %s below. */653 }654 655 /* We are going to do second expansion so initialize file variables656 for the file. Since the stem for static pattern rules comes from657 individual dep lines, we will temporarily set f->stem to d->stem.658 */659 if (!initialized)660 {661 initialize_file_variables (f, 0);662 initialized = 1;663 }664 665 if (d->stem != 0)666 f->stem = d->stem;667 668 #if defined(CONFIG_WITH_COMMANDS_FUNC) || defined (CONFIG_WITH_DOT_MUST_MAKE)669 set_file_variables (f, 0 /* real call, f->deps == 0 so we're ok. */);670 #else671 set_file_variables (f);672 #endif673 674 #if !defined (CONFIG_WITH_VALUE_LENGTH) || !defined (CONFIG_WITH_STRCACHE2)675 p = variable_expand_for_file (d->name, f);676 #else677 len = strcache2_get_len (&file_strcache, d->name);678 p = variable_expand_for_file_2 (NULL, d->name, len, f, &len);679 #endif680 681 if (d->stem != 0)682 f->stem = file_stem;683 }684 685 /* Parse the prerequisites. */686 new = parse_prereqs (p);687 688 /* If this dep list was from a static pattern rule, expand the %s. We689 use patsubst_expand to translate the prerequisites' patterns into690 plain prerequisite names. */691 if (new && d->staticpattern)692 {693 const char *pattern = "%";694 char *buffer = variable_expand ("");695 struct dep *dp = new, *dl = 0;696 697 while (dp != 0)698 {699 char *percent;700 #ifndef KMK701 int nl = strlen (dp->name) + 1;702 char *nm = alloca (nl);703 memcpy (nm, dp->name, nl);704 percent = find_percent (nm);705 #else /* KMK - don't make a stack copy unless it's actually required! */706 unsigned int nl = strcache2_get_len (&file_strcache, dp->name);707 char *nm;708 percent = memchr (dp->name, '%', nl);709 if (percent)710 {711 nm = alloca (nl + 1);712 memcpy (nm, dp->name, nl + 1);713 percent = find_percent (nm);714 }715 #endif /* KMK */716 if (percent)717 {718 char *o;719 720 /* We have to handle empty stems specially, because that721 would be equivalent to $(patsubst %,dp->name,) which722 will always be empty. */723 if (d->stem[0] == '\0')724 {725 memmove (percent, percent+1, strlen (percent));726 o = variable_buffer_output (buffer, nm, strlen (nm) + 1);727 }728 else729 {730 o = patsubst_expand_pat (buffer, d->stem, pattern, nm,731 pattern+1, percent+1);732 o = variable_buffer_output (o, "", 1); /* bird fix - patsubst_expand_pat doesn't terminate,733 the if case does and strcache would appreciate it. */734 }735 buffer = variable_buffer; /* bird fix - variable_buffer may have been reallocated. */736 737 738 /* If the name expanded to the empty string, ignore it. */739 if (buffer[0] == '\0')740 {741 struct dep *df = dp;742 if (dp == new)743 dp = new = new->next;744 else745 dp = dl->next = dp->next;746 free_dep (df);747 continue;748 }749 750 /* Save the name. */751 dp->name = strcache_add_len (buffer, o - buffer - 1); /* bird fix - don't include the terminator. */752 }753 dl = dp;754 dp = dp->next;755 }756 }757 758 /* Enter them as files. */759 for (d1 = new; d1 != 0; d1 = d1->next)760 {761 d1->file = lookup_file (d1->name);762 if (d1->file == 0)763 d1->file = enter_file (d1->name);764 d1->name = 0;765 d1->staticpattern = 0;766 d1->need_2nd_expansion = 0;767 }768 759 769 760 #ifdef CONFIG_WITH_INCLUDEDEP 770 } 771 #endif 772 773 /* Add newly parsed deps to f->deps. If this is the last dependency 774 line and this target has commands then put it in front so the 775 last dependency line (the one with commands) ends up being the 776 first. This is important because people expect $< to hold first 777 prerequisite from the rule with commands. If it is not the last 778 dependency line or the rule does not have commands then link it 779 at the end so it appears in makefile order. */ 780 781 if (new != 0) 782 { 783 if (d->next == 0 && last_dep_has_cmds) 784 { 785 struct dep **d_ptr; 786 for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next) 787 ; 788 789 *d_ptr = f->deps; 790 f->deps = new; 791 } 792 else 793 { 794 struct dep **d_ptr; 795 for (d_ptr = &f->deps; *d_ptr; d_ptr = &(*d_ptr)->next) 796 ; 797 798 *d_ptr = new; 799 } 800 } 801 } 802 803 free_dep_chain (old); 761 } 762 #endif 763 764 /* Add newly parsed prerequisites. */ 765 next = d->next; 766 *dp = new; 767 for (dp = &new->next, d = new->next; d != 0; dp = &d->next, d = d->next) 768 ; 769 *dp = next; 770 d = *dp; 771 } 772 } 773 774 /* Reset the updating flag. */ 775 776 static void 777 reset_updating (const void *item) 778 { 779 struct file *f = (struct file *) item; 780 f->updating = 0; 804 781 } 805 782 … … 816 793 struct file *f2; 817 794 struct dep *d; 818 struct file **file_slot_0; 819 struct file **file_slot; 820 struct file **file_end; 821 822 /* Perform second expansion and enter each dependency name as a file. */ 823 824 /* Expand .SUFFIXES first; it's dependencies are used for $$* calculation. */ 825 for (f = lookup_file (".SUFFIXES"); f != 0; f = f->prev) 826 expand_deps (f); 795 796 /* Remember that we've done this. Once we start snapping deps we can no 797 longer define new targets. */ 798 snapped_deps = 1; 827 799 828 800 #ifdef CONFIG_WITH_2ND_TARGET_EXPANSION … … 832 804 if (second_target_expansion) 833 805 { 806 struct file **file_slot_0, **file_end, **file_slot; 834 807 # ifdef KMK /* turn on warnings here. */ 835 808 int save = warn_undefined_variables_flag; … … 862 835 #endif /* CONFIG_WITH_INCLUDEDEP */ 863 836 864 /* For every target that's not .SUFFIXES, expand its dependencies. 865 We must use hash_dump (), because within this loop we might add new files 866 to the table, possibly causing an in-situ table expansion. */ 867 file_slot_0 = (struct file **) hash_dump (&files, 0, 0); 868 file_end = file_slot_0 + files.ht_fill; 869 for (file_slot = file_slot_0; file_slot < file_end; file_slot++) 870 for (f = *file_slot; f != 0; f = f->prev) 871 #ifndef CONFIG_WITH_STRCACHE2 872 if (strcmp (f->name, ".SUFFIXES") != 0) 873 #else 874 if (f->name != suffixes_strcached) 875 #endif 837 /* Perform second expansion and enter each dependency name as a file. We 838 must use hash_dump() here because within these loops we likely add new 839 files to the table, possibly causing an in-situ table expansion. 840 841 We only need to do this if second_expansion has been defined; if it 842 hasn't then all deps were expanded as the makefile was read in. If we 843 ever change make to be able to unset .SECONDARY_EXPANSION this will have 844 to change. */ 845 846 if (second_expansion) 847 { 848 struct file **file_slot_0 = (struct file **) hash_dump (&files, 0, 0); 849 struct file **file_end = file_slot_0 + files.ht_fill; 850 struct file **file_slot; 851 const char *suffixes; 852 853 /* Expand .SUFFIXES: its prerequisites are used for $$* calc. */ 854 f = lookup_file (".SUFFIXES"); 855 suffixes = f ? f->name : 0; 856 for (; f != 0; f = f->prev) 876 857 expand_deps (f); 858 877 859 #ifdef KMK 878 /* This is a HACK to work around the still broken test #9 in879 features/double_colon. It produces the wrong result if the build is880 parallel because of changed evaluation order. Just make these881 problematic rules execute in single field till a proper fix is882 forthcomming... */883 884 for (file_slot = file_slot_0; file_slot < file_end; file_slot++)885 if ( (f = *file_slot) != 0886 && f->double_colon887 && ( f->double_colon != f888 || f->last != f))889 for (f2 = f->double_colon; f2 != 0; f2 = f2->prev)890 f2->command_flags |= COMMANDS_NOTPARALLEL;860 /* This is a HACK to work around the still broken test #9 in 861 features/double_colon. It produces the wrong result if the build is 862 parallel because of changed evaluation order. Just make these 863 problematic rules execute in single field till a proper fix is 864 forthcomming... */ 865 866 for (file_slot = file_slot_0; file_slot < file_end; file_slot++) 867 if ( (f = *file_slot) != 0 868 && f->double_colon 869 && ( f->double_colon != f 870 || f->last != f)) 871 for (f2 = f->double_colon; f2 != 0; f2 = f2->prev) 872 f2->command_flags |= COMMANDS_NOTPARALLEL; 891 873 #endif /* KMK */ 892 free (file_slot_0); 874 875 /* For every target that's not .SUFFIXES, expand its prerequisites. */ 876 877 for (file_slot = file_slot_0; file_slot < file_end; file_slot++) 878 for (f = *file_slot; f != 0; f = f->prev) 879 if (f->name != suffixes) 880 expand_deps (f); 881 free (file_slot_0); 882 } 883 else 884 /* We're not doing second expansion, so reset updating. */ 885 hash_map (&files, reset_updating); 893 886 894 887 /* Now manage all the special targets. */ … … 985 978 /* This needs more work: what if the user sets this in the makefile? 986 979 if (posix_pedantic) 987 define_variable (STRING_SIZE_TUPLE("OUTPUT_OPTION"), "", o_default, 1);980 define_variable_cname ("OUTPUT_OPTION", "", o_default, 1); 988 981 */ 989 982 #endif 990 991 /* Remember that we've done this. */992 snapped_deps = 1;993 983 } 994 984 … … 1121 1111 /* Print the data base of files. */ 1122 1112 1113 void 1114 print_prereqs (const struct dep *deps) 1115 { 1116 const struct dep *ood = 0; 1117 1118 /* Print all normal dependencies; note any order-only deps. */ 1119 for (; deps != 0; deps = deps->next) 1120 if (! deps->ignore_mtime) 1121 printf (" %s", dep_name (deps)); 1122 else if (! ood) 1123 ood = deps; 1124 1125 /* Print order-only deps, if we have any. */ 1126 if (ood) 1127 { 1128 printf (" | %s", dep_name (ood)); 1129 for (ood = ood->next; ood != 0; ood = ood->next) 1130 if (ood->ignore_mtime) 1131 printf (" %s", dep_name (ood)); 1132 } 1133 1134 putchar ('\n'); 1135 } 1136 1123 1137 static void 1124 1138 print_file (const void *item) 1125 1139 { 1126 1140 const struct file *f = item; 1127 struct dep *d;1128 struct dep *ood = 0;1129 1141 1130 1142 putchar ('\n'); … … 1158 1170 printf ("%s:%s", f->name, f->double_colon ? ":" : ""); 1159 1171 1160 /* Print all normal dependencies; note any order-only deps. */ 1161 for (d = f->deps; d != 0; d = d->next) 1162 if (! d->ignore_mtime) 1163 printf (" %s", dep_name (d)); 1164 else if (! ood) 1165 ood = d; 1166 1167 /* Print order-only deps, if we have any. */ 1168 if (ood) 1169 { 1170 printf (" | %s", dep_name (ood)); 1171 for (d = ood->next; d != 0; d = d->next) 1172 if (d->ignore_mtime) 1173 printf (" %s", dep_name (d)); 1174 } 1175 1176 putchar ('\n'); 1172 print_prereqs (f->deps); 1177 1173 1178 1174 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET … … 1206 1202 if (f->also_make != 0) 1207 1203 { 1204 const struct dep *d; 1208 1205 fputs (_("# Also makes:"), stdout); 1209 1206 for (d = f->also_make; d != 0; d = d->next) … … 1300 1297 do{\ 1301 1298 if (_p->_n && _p->_n[0] && !strcache_iscached (_p->_n)) \ 1302 printf ("%s: Field %snot cached: %s\n", _p->name, # _n, _p->_n); \1299 error (NULL, "%s: Field '%s' not cached: %s\n", _p->name, # _n, _p->_n); \ 1303 1300 }while(0) 1304 1301 … … 1317 1314 for (d = f->deps; d != 0; d = d->next) 1318 1315 { 1319 VERIFY_CACHED (d, name); 1316 if (! d->need_2nd_expansion) 1317 VERIFY_CACHED (d, name); 1320 1318 VERIFY_CACHED (d, stem); 1321 1319 } -
trunk/src/kmk/filedef.h
r2001 r2591 1 1 /* Definition of target file data structures for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 107 107 unsigned int considered:1; /* equal to 'considered' if file has been 108 108 considered on current scan of goal chain */ 109 unsigned int no_diag:1; /* True if the file failed to update and no 110 diagnostics has been issued (dontcare). */ 111 109 112 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 110 113 unsigned int multi_maybe:1; /* Nonzero if this file isn't always updated … … 117 120 and the expanding done in snap_deps. */ 118 121 #endif 119 120 122 }; 121 123 122 124 123 extern struct file *default_goal_file, *suffix_file, *default_file; 124 extern char **default_goal_name; 125 extern struct file *suffix_file, *default_file; 125 126 126 127 … … 130 131 #endif 131 132 struct file *enter_file (const char *name); 132 struct dep *parse_prereqs (char *prereqs); 133 struct dep *split_prereqs (char *prereqstr); 134 struct dep *enter_prereqs (struct dep *prereqs, const char *stem); 133 135 void remove_intermediates (int sig); 134 136 void snap_deps (void); … … 139 141 void init_hash_files (void); 140 142 char *build_target_list (char *old_list); 143 void print_prereqs (const struct dep *deps); 144 void print_file_data_base (void); 141 145 142 146 #if FILE_TIMESTAMP_HI_RES -
trunk/src/kmk/function.c
r2574 r2591 1 1 /* Builtin function expansion for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 514 514 unsigned int idx; 515 515 516 #ifndef CONFIG_WITH_ALLOC_CACHES 517 chain = multi_glob (parse_file_seq 518 (&line, '\0', sizeof (struct nameseq), 519 /* We do not want parse_file_seq to strip `./'s. 520 That would break examples like: 521 $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)). */ 522 0), 523 sizeof (struct nameseq)); 524 #else /* CONFIG_WITH_ALLOC_CACHES */ 525 chain = multi_glob (parse_file_seq 526 (&line, '\0', &nameseq_cache, 527 /* We do not want parse_file_seq to strip `./'s. 528 That would break examples like: 529 $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)). */ 530 0), 531 &nameseq_cache); 532 #endif /* CONFIG_WITH_ALLOC_CACHES */ 516 chain = PARSE_FILE_SEQ (&line, struct nameseq, '\0', NULL, 517 /* We do not want parse_file_seq to strip `./'s. 518 That would break examples like: 519 $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)). */ 520 PARSEFS_NOSTRIP|PARSEFS_NOCACHE|PARSEFS_EXISTS); 533 521 534 522 if (result == 0) … … 541 529 while (chain != 0) 542 530 { 543 const char *name = chain->name;544 unsigned int len = strlen (name);545 546 531 struct nameseq *next = chain->next; 532 unsigned int len = strlen (chain->name); 533 534 if (idx + len + 1 > length) 535 { 536 length += (len + 1) * 2; 537 result = xrealloc (result, length); 538 } 539 memcpy (&result[idx], chain->name, len); 540 idx += len; 541 result[idx++] = ' '; 542 543 /* Because we used PARSEFS_NOCACHE above, we have to free() NAME. */ 544 free ((char *)chain->name); 547 545 #ifndef CONFIG_WITH_ALLOC_CACHES 548 546 free (chain); … … 551 549 #endif 552 550 chain = next; 553 554 /* multi_glob will pass names without globbing metacharacters555 through as is, but we want only files that actually exist. */556 if (file_exists_p (name))557 {558 if (idx + len + 1 > length)559 {560 length += (len + 1) * 2;561 result = xrealloc (result, length);562 }563 memcpy (&result[idx], name, len);564 idx += len;565 result[idx++] = ' ';566 }567 551 } 568 552 … … 1346 1330 1347 1331 free (var->value); 1348 var->value = savestring(p, len);1332 var->value = xstrndup (p, len); 1349 1333 1350 1334 result = allocated_variable_expand (body); … … 2220 2204 2221 2205 void 2222 windows32_openpipe (int *pipedes, int *pid_p, char **command_argv, char **envp)2206 windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp) 2223 2207 { 2224 2208 SECURITY_ATTRIBUTES saAttr; … … 2241 2225 TRUE, 2242 2226 DUPLICATE_SAME_ACCESS) == FALSE) { 2243 fatal (NILF, _(" create_child_process: DuplicateHandle(In) failed (e=%ld)\n"),2227 fatal (NILF, _("windows32_openpipe(): DuplicateHandle(In) failed (e=%ld)\n"), 2244 2228 GetLastError()); 2245 2229 … … 2252 2236 TRUE, 2253 2237 DUPLICATE_SAME_ACCESS) == FALSE) { 2254 fatal (NILF, _(" create_child_process: DuplicateHandle(Err) failed (e=%ld)\n"),2238 fatal (NILF, _("windows32_open_pipe(): DuplicateHandle(Err) failed (e=%ld)\n"), 2255 2239 GetLastError()); 2256 2240 } … … 2262 2246 2263 2247 if (!hProcess) 2264 fatal (NILF, _("windows32_openpipe 2248 fatal (NILF, _("windows32_openpipe(): process_init_fd() failed\n")); 2265 2249 2266 2250 /* make sure that CreateProcess() has Path it needs */ 2267 2251 sync_Path_environment(); 2252 /* `sync_Path_environment' may realloc `environ', so take note of 2253 the new value. */ 2254 envp = environ; 2268 2255 2269 2256 if (!process_begin(hProcess, command_argv, envp, command_argv[0], NULL)) { … … 2272 2259 2273 2260 /* set the pid for returning to caller */ 2274 *pid_p = ( int) hProcess;2261 *pid_p = (pid_t) hProcess; 2275 2262 2276 2263 /* set up to read data from child */ 2277 pipedes[0] = _open_osfhandle(( long) hChildOutRd, O_RDONLY);2264 pipedes[0] = _open_osfhandle((intptr_t) hChildOutRd, O_RDONLY); 2278 2265 2279 2266 /* this will be closed almost right away */ 2280 pipedes[1] = _open_osfhandle(( long) hChildOutWr, O_APPEND);2267 pipedes[1] = _open_osfhandle((intptr_t) hChildOutWr, O_APPEND); 2281 2268 } else { 2282 2269 /* reap/cleanup the failed process */ … … 2293 2280 /* set status for return */ 2294 2281 pipedes[0] = pipedes[1] = -1; 2295 *pid_p = -1;2282 *pid_p = (pid_t)-1; 2296 2283 } 2297 2284 } … … 2366 2353 #ifndef _AMIGA 2367 2354 static char * 2368 func_shell (char * o, char **argv, const char *funcname UNUSED)2355 func_shell (char * volatile o, char **argv, const char *funcname UNUSED) 2369 2356 { 2370 2357 char *batch_filename = NULL; … … 2374 2361 #endif 2375 2362 char **command_argv; 2376 const char * error_prefix;2363 const char * volatile error_prefix; /* bird: this volatile and the 'o' one, is for shutting up gcc warnings */ 2377 2364 char **envp; 2378 2365 int pipedes[2]; 2379 int pid;2366 pid_t pid; 2380 2367 2381 2368 #ifndef __MSDOS__ … … 2467 2454 free (command_argv); 2468 2455 2469 /* Close the write side of the pipe. */2470 # ifdef _MSC_VER /* Avoid annoying msvcrt when debugging. (bird) */ 2471 if (pipedes[1] != -1) 2472 # endif 2473 2456 /* Close the write side of the pipe. We test for -1, since 2457 pipedes[1] is -1 on MS-Windows, and some versions of MS 2458 libraries barf when `close' is called with -1. */ 2459 if (pipedes[1] >= 0) 2460 close (pipedes[1]); 2474 2461 #endif 2475 2462 … … 3442 3429 3443 3430 3431 #ifdef HAVE_DOS_PATHS 3432 #define IS_ABSOLUTE(n) (n[0] && n[1] == ':') 3433 #define ROOT_LEN 3 3434 #else 3435 #define IS_ABSOLUTE(n) (n[0] == '/') 3436 #define ROOT_LEN 1 3437 #endif 3438 3444 3439 /* Return the absolute name of file NAME which does not contain any `.', 3445 3440 `..' components nor any repeated path separators ('/'). */ … … 3453 3448 char *dest; 3454 3449 const char *start, *end, *apath_limit; 3450 unsigned long root_len = ROOT_LEN; 3455 3451 3456 3452 if (name[0] == '\0' || apath == NULL) … … 3479 3475 apath_limit = apath + GET_PATH_MAX; 3480 3476 3481 #ifdef HAVE_DOS_PATHS /* bird added this */ 3482 if (isalpha(name[0]) && name[1] == ':') 3483 { 3484 /* drive spec */ 3485 apath[0] = toupper(name[0]); 3486 apath[1] = ':'; 3487 apath[2] = '/'; 3488 name += 2; 3489 } 3490 else 3491 #endif /* HAVE_DOS_PATHS */ 3492 if (name[0] != '/') 3477 if (!IS_ABSOLUTE(name)) 3493 3478 { 3494 3479 /* It is unlikely we would make it until here but just to make sure. */ … … 3498 3483 strcpy (apath, starting_directory); 3499 3484 3485 #ifdef HAVE_DOS_PATHS 3486 if (IS_PATHSEP(name[0])) 3487 { 3488 if (IS_PATHSEP(name[1])) 3489 { 3490 /* A UNC. Don't prepend a drive letter. */ 3491 apath[0] = name[0]; 3492 apath[1] = name[1]; 3493 root_len = 2; 3494 } 3495 /* We have /foo, an absolute file name except for the drive 3496 letter. Assume the missing drive letter is the current 3497 drive, which we can get if we remove from starting_directory 3498 everything past the root directory. */ 3499 apath[root_len] = '\0'; 3500 } 3501 #endif 3502 3500 3503 dest = strchr (apath, '\0'); 3501 3504 } 3502 3505 else 3503 3506 { 3504 apath[0] = '/'; 3505 dest = apath + 1; 3507 strncpy (apath, name, root_len); 3508 apath[root_len] = '\0'; 3509 dest = apath + root_len; 3510 /* Get past the root, since we already copied it. */ 3511 name += root_len; 3512 #ifdef HAVE_DOS_PATHS 3513 if (!IS_PATHSEP(apath[2])) 3514 { 3515 /* Convert d:foo into d:./foo and increase root_len. */ 3516 apath[2] = '.'; 3517 apath[3] = '/'; 3518 dest++; 3519 root_len++; 3520 /* strncpy above copied one character too many. */ 3521 name--; 3522 } 3523 else 3524 apath[2] = '/'; /* make sure it's a forward slash */ 3525 #endif 3506 3526 } 3507 3527 … … 3511 3531 3512 3532 /* Skip sequence of multiple path-separators. */ 3513 while ( *start == '/')3533 while (IS_PATHSEP(*start)) 3514 3534 ++start; 3515 3535 3516 3536 /* Find end of path component. */ 3517 for (end = start; *end != '\0' && *end != '/'; ++end)3537 for (end = start; *end != '\0' && !IS_PATHSEP(*end); ++end) 3518 3538 ; 3519 3539 … … 3527 3547 { 3528 3548 /* Back up to previous component, ignore if at root already. */ 3529 if (dest > apath + 1)3530 while ((--dest)[-1] != '/');3549 if (dest > apath + root_len) 3550 for (--dest; !IS_PATHSEP(dest[-1]); --dest); 3531 3551 } 3532 3552 else 3533 3553 { 3534 if ( dest[-1] != '/')3554 if (!IS_PATHSEP(dest[-1])) 3535 3555 *dest++ = '/'; 3536 3556 … … 3546 3566 3547 3567 /* Unless it is root strip trailing separator. */ 3548 #ifdef HAVE_DOS_PATHS /* bird (is this correct? what about UNC?) */ 3549 if (dest > apath + 1 + (apath[0] != '/') && dest[-1] == '/') 3550 #else 3551 if (dest > apath + 1 && dest[-1] == '/') 3552 #endif 3568 if (dest > apath + root_len && IS_PATHSEP(dest[-1])) 3553 3569 --dest; 3554 3570 … … 3567 3583 int doneany = 0; 3568 3584 unsigned int len = 0; 3585 #ifndef HAVE_REALPATH 3586 struct stat st; 3587 #endif 3569 3588 PATH_VAR (in); 3570 3589 PATH_VAR (out); … … 3581 3600 realpath (in, out) 3582 3601 #else 3583 abspath (in, out) 3602 abspath (in, out) && stat (out, &st) == 0 3584 3603 #endif 3585 3604 ) -
trunk/src/kmk/getloadavg.c
r1993 r2591 1 1 /* Get the system load averages. 2 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 Free Software Foundation, Inc.3 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 4 2008, 2009, 2010 Free Software Foundation, Inc. 5 5 6 6 GNU Make is free software; you can redistribute it and/or modify it under the -
trunk/src/kmk/getopt.c
r1993 r2591 5 5 6 6 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 7 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software8 Foundation, Inc.7 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 8 2010 Free Software Foundation, Inc. 9 9 10 10 NOTE: The canonical source of this file is maintained with the GNU C Library. … … 683 683 { 684 684 if (opterr) 685 if (argv[optind - 1][1] == '-') 686 /* --option */ 687 fprintf (stderr, 688 _("%s: option `--%s' doesn't allow an argument\n"), 689 argv[0], pfound->name); 690 else 691 /* +option or -option */ 692 fprintf (stderr, 693 _("%s: option `%c%s' doesn't allow an argument\n"), 694 argv[0], argv[optind - 1][0], pfound->name); 685 { 686 if (argv[optind - 1][1] == '-') 687 /* --option */ 688 fprintf (stderr, 689 _("%s: option `--%s' doesn't allow an argument\n"), 690 argv[0], pfound->name); 691 else 692 /* +option or -option */ 693 fprintf (stderr, 694 _("%s: option `%c%s' doesn't allow an argument\n"), 695 argv[0], argv[optind - 1][0], pfound->name); 696 } 695 697 696 698 nextchar += strlen (nextchar); -
trunk/src/kmk/getopt.h
r1993 r2591 1 1 /* Declarations for getopt. 2 2 Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,4 Inc.3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free 4 Software Foundation, Inc. 5 5 6 6 NOTE: The canonical source of this file is maintained with the GNU C Library. -
trunk/src/kmk/getopt1.c
r1993 r2591 1 1 /* getopt_long and getopt_long_only entry points for GNU getopt. 2 2 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 6 6 NOTE: The canonical source of this file is maintained with the GNU C Library. -
trunk/src/kmk/gettext.h
r1993 r2591 1 1 /* Convenience header for conditional use of GNU <libintl.h>. 2 2 Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 3 2006, 2007 Free Software Foundation, Inc.3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/glob
- Property svn:ignore
--- +++
- Property svn:ignore
-
trunk/src/kmk/glob/ChangeLog
r1993 r2591 1 2008-09-28 Juan Manuel Guerrero <[email protected]> 2 3 * glob.c (my_realloc) [__DJGPP__]: Don't define, and don't 4 redefine realloc to call it, since the DJGPP's realloc handles 5 NULL pointers correctly. 6 1 7 2007-12-22 Juan Manuel Guerrero <[email protected]> (tiny change) 2 8 3 * glob /glob.c [__GNU_LIBRARY__ && __DJGPP__]: Add a realloc9 * glob.c [__GNU_LIBRARY__ && __DJGPP__]: Add a realloc 4 10 declaration that matches the one in the DJGPP libc. 5 11 -
trunk/src/kmk/glob/glob.c
r2001 r2591 183 183 #endif 184 184 185 #if !defined (__GNU_LIBRARY__) && !defined(ELECTRIC_HEAP) && !defined(__APPLE__)/* bird (last two) */185 #if !defined __GNU_LIBRARY__ && !defined __DJGPP__ && !defined ELECTRIC_HEAP && !defined __APPLE__ /* bird (last two) */ 186 186 # ifdef __GNUC__ 187 187 __inline … … 192 192 static void * 193 193 my_realloc (void *p, unsigned int n) 194 # elif defined(__DJGPP__)195 static void *196 my_realloc (void *p, size_t n)197 194 # else 198 195 static char * … … 210 207 # define realloc my_realloc 211 208 # endif /* __SASC */ 212 #endif /* __GNU_LIBRARY__ */209 #endif /* __GNU_LIBRARY__ || __DJGPP__ */ 213 210 214 211 … … 390 387 /* Allocate working buffer large enough for our work. Note that 391 388 we have at least an opening and closing brace. */ 392 size_t firstc; 389 size_t firstc; /* bird: correct type. */ 393 390 char *alt_start; 394 391 const char *p; -
trunk/src/kmk/hash.c
r1993 r2591 1 1 /* hash.c -- hash table maintenance 2 Copyright (C) 1995, 1999, 2002 Free Software Foundation, Inc.2 Copyright (C) 1995, 1999, 2002, 2010 Free Software Foundation, Inc. 3 3 Written by Greg McGary <[email protected]> <[email protected]> 4 4 … … 51 51 if (ht->ht_vec == 0) 52 52 { 53 fprintf (stderr, _("can't allocate %l dbytes for hash table: memory exhausted"),54 ht->ht_size * sizeof(struct token *));53 fprintf (stderr, _("can't allocate %lu bytes for hash table: memory exhausted"), 54 ht->ht_size * (unsigned long) sizeof (struct token *)); 55 55 exit (1); 56 56 } … … 252 252 { 253 253 void **slot = hash_find_slot (ht, item); 254 const void *old_item = slot ? *slot : 0;254 const void *old_item = *slot; 255 255 hash_insert_at (ht, item, slot); 256 256 return (void *)((HASH_VACANT (old_item)) ? 0 : old_item); -
trunk/src/kmk/hash.h
r1993 r2591 1 1 /* hash.h -- decls for hash table 2 Copyright (C) 1995, 1999, 2002 Free Software Foundation, Inc.2 Copyright (C) 1995, 1999, 2002, 2010 Free Software Foundation, Inc. 3 3 Written by Greg McGary <[email protected]> <[email protected]> 4 4 … … 98 98 /* hash and comparison macros for case-sensitive string keys. */ 99 99 100 /* Due to the strcache, it's not uncommon for the string pointers to 101 be identical. Take advantage of that to short-circuit string compares. */ 102 100 103 #define STRING_HASH_1(KEY, RESULT) do { \ 101 104 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ … … 121 124 122 125 #define STRING_COMPARE(X, Y, RESULT) do { \ 123 RESULT =strcmp ((X), (Y)); \126 RESULT = (X) == (Y) ? 0 : strcmp ((X), (Y)); \ 124 127 } while (0) 125 128 #define return_STRING_COMPARE(X, Y) do { \ 126 return strcmp ((X), (Y)); \129 return (X) == (Y) ? 0 : strcmp ((X), (Y)); \ 127 130 } while (0) 128 131 … … 157 160 158 161 #define STRING_N_COMPARE(X, Y, N, RESULT) do { \ 159 RESULT = strncmp ((X), (Y), (N)); \162 RESULT = (X) == (Y) ? 0 : strncmp ((X), (Y), (N)); \ 160 163 } while (0) 161 164 #define return_STRING_N_COMPARE(X, Y, N) do { \ 162 return strncmp ((X), (Y), (N)); \165 return (X) == (Y) ? 0 : strncmp ((X), (Y), (N)); \ 163 166 } while (0) 164 167 … … 190 193 191 194 #define ISTRING_COMPARE(X, Y, RESULT) do { \ 192 RESULT = strcasecmp ((X), (Y)); \195 RESULT = (X) == (Y) ? 0 : strcasecmp ((X), (Y)); \ 193 196 } while (0) 194 197 #define return_ISTRING_COMPARE(X, Y) do { \ 195 return strcasecmp ((X), (Y)); \198 return (X) == (Y) ? 0 : strcasecmp ((X), (Y)); \ 196 199 } while (0) 197 200 -
trunk/src/kmk/implicit.c
r2024 r2591 1 1 /* Implicit rule searching for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 49 49 return 1; 50 50 51 #ifndef 51 #ifndef NO_ARCHIVES 52 52 /* If this is an archive member reference, use just the 53 53 archive member name to search for implicit rules. */ … … 57 57 _("Looking for archive-member implicit rule for `%s'.\n")); 58 58 if (pattern_search (file, 1, depth, 0)) 59 59 return 1; 60 60 } 61 61 #endif … … 64 64 } 65 65 66 67 68 #ifdef CONFIG_WITH_ALLOC_CACHES69 struct alloccache idep_cache;70 #endif71 72 /* Struct idep captures information about implicit prerequisites73 that come from implicit rules. */74 struct idep75 {76 struct idep *next; /* struct dep -compatible interface */77 const char *name; /* name of the prerequisite */78 struct file *intermediate_file; /* intermediate file, 0 otherwise */79 const char *intermediate_pattern; /* pattern for intermediate file */80 unsigned char had_stem; /* had % substituted with stem */81 unsigned char ignore_mtime; /* ignore_mtime flag */82 };83 84 static void85 free_idep_chain (struct idep *p)86 {87 struct idep *n;88 89 for (; p != 0; p = n)90 {91 n = p->next;92 #ifndef CONFIG_WITH_ALLOC_CACHES93 free (p);94 #else95 alloccache_free (&idep_cache, p);96 #endif97 }98 }99 66 100 67 … … 103 70 length of the word. */ 104 71 105 static c har *72 static const char * 106 73 get_next_word (const char *buffer, unsigned int *length) 107 74 { … … 181 148 *length = p - beg; 182 149 183 return (char *)beg; 150 return beg; 151 } 152 153 /* This structure stores information about the expanded prerequisites for a 154 pattern rule. NAME is always set to the strcache'd name of the prereq. 155 FILE and PATTERN will be set for intermediate files only. IGNORE_MTIME is 156 copied from the prerequisite we expanded. 157 */ 158 struct patdeps 159 { 160 const char *name; 161 const char *pattern; 162 struct file *file; 163 unsigned int ignore_mtime : 1; 164 }; 165 166 /* This structure stores information about pattern rules that we need 167 to try. 168 */ 169 struct tryrule 170 { 171 struct rule *rule; 172 173 /* Index of the target in this rule that matched the file. */ 174 unsigned int matches; 175 176 /* Stem length for this match. */ 177 unsigned int stemlen; 178 179 /* Definition order of this rule. Used to implement stable sort.*/ 180 unsigned int order; 181 182 /* Nonzero if the LASTSLASH logic was used in matching this rule. */ 183 char checked_lastslash; 184 }; 185 186 int 187 stemlen_compare (const void *v1, const void *v2) 188 { 189 const struct tryrule *r1 = v1; 190 const struct tryrule *r2 = v2; 191 int r = r1->stemlen - r2->stemlen; 192 return r != 0 ? r : (int)(r1->order - r2->order); 184 193 } 185 194 … … 209 218 210 219 /* The last slash in FILENAME (or nil if there is none). */ 211 c har *lastslash;220 const char *lastslash; 212 221 213 222 /* This is a file-object used as an argument in 214 223 recursive calls. It never contains any data 215 224 except during a recursive call. */ 216 struct file *int ermediate_file = 0;217 218 /* This linked list records all the prerequisites actually219 found for a rule along with some other useful information220 (see struct idep for details). */221 struct idep* deps = 0;222 223 /* 1 if we need to remove explicit prerequisites, 0 otherwise.*/224 unsigned int remove_explicit_deps = 0;225 struct file *int_file = 0; 226 227 /* List of dependencies found recursively. */ 228 struct patdeps *deplist 229 = xmalloc (max_pattern_deps * sizeof (struct patdeps)); 230 struct patdeps *pat = deplist; 231 232 /* All the prerequisites actually found for a rule, after expansion. */ 233 struct dep *deps; 225 234 226 235 /* Names of possible dependencies are constructed in this buffer. */ … … 233 242 234 243 /* Buffer in which we store all the rules that are possibly applicable. */ 235 struct rule **tryrules = xmalloc (num_pattern_rules * max_pattern_targets236 * sizeof (struct rule *));244 struct tryrule *tryrules = xmalloc (num_pattern_rules * max_pattern_targets 245 * sizeof (struct tryrule)); 237 246 238 247 /* Number of valid elements in TRYRULES. */ 239 248 unsigned int nrules; 240 249 241 /* The numbers of the rule targets of each rule242 in TRYRULES that matched the target file. */243 unsigned int *matches = alloca (num_pattern_rules * sizeof (unsigned int));244 245 /* Each element is nonzero if LASTSLASH was used in246 matching the corresponding element of TRYRULES. */247 char *checked_lastslash = alloca (num_pattern_rules * sizeof (char));248 249 250 /* The index in TRYRULES of the rule we found. */ 250 251 unsigned int foundrule; … … 252 253 /* Nonzero if should consider intermediate files as dependencies. */ 253 254 int intermed_ok; 255 256 /* Nonzero if we have initialized file variables for this target. */ 257 int file_vars_initialized = 0; 254 258 255 259 /* Nonzero if we have matched a pattern-rule target … … 257 261 int specific_rule_matched = 0; 258 262 263 struct dep dep_simple; 264 259 265 unsigned int ri; /* uninit checks OK */ 260 266 struct rule *rule; 261 struct dep *dep, *expl_d; 262 263 struct idep *d; 264 struct idep **id_ptr; 265 struct dep **d_ptr; 267 268 char *pathdir = NULL; 269 unsigned long pathlen; 266 270 267 271 PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */ 268 272 269 #ifdef CONFIG_WITH_ALLOC_CACHES 270 if (!idep_cache.size) 271 alloccache_init (&idep_cache, sizeof (struct idep), "idep", NULL, NULL); 272 #endif 273 274 #ifndef NO_ARCHIVES 273 #ifndef NO_ARCHIVES 275 274 if (archive || ar_name (filename)) 276 275 lastslash = 0; … … 279 278 { 280 279 /* Set LASTSLASH to point at the last slash in FILENAME 281 282 280 but not counting any slash at the end. (foo/bar/ counts as 281 bar/ in directory foo/, not empty in directory foo/bar/.) */ 283 282 #ifdef VMS 284 283 lastslash = strrchr (filename, ']'); 285 284 if (lastslash == 0) 286 285 lastslash = strrchr (filename, ':'); 287 286 #else 288 287 lastslash = strrchr (filename, '/'); 289 288 #ifdef HAVE_DOS_PATHS 290 289 /* Handle backslashes (possibly mixed with forward slashes) 291 290 and the case of "d:file". */ 292 291 { 293 294 295 296 297 lastslash = (char *)filename + 1;292 char *bslash = strrchr (filename, '\\'); 293 if (lastslash == 0 || bslash > lastslash) 294 lastslash = bslash; 295 if (lastslash == 0 && filename[0] && filename[1] == ':') 296 lastslash = filename + 1; 298 297 } 299 298 #endif 300 299 #endif 301 300 if (lastslash != 0 && lastslash[1] == '\0') 302 301 lastslash = 0; 303 302 } 304 303 305 /* First see which pattern rules match this target 306 and may be considered. Put them in TRYRULES. */ 304 pathlen = lastslash - filename + 1; 305 306 /* First see which pattern rules match this target and may be considered. 307 Put them in TRYRULES. */ 307 308 308 309 nrules = 0; … … 312 313 313 314 /* If the pattern rule has deps but no commands, ignore it. 314 315 Users cancel built-in rules by redefining them without commands. */ 315 316 if (rule->deps != 0 && rule->cmds == 0) 316 317 continue; 317 318 318 319 /* If this rule is in use by a parent pattern_search, 319 320 don't use it here. */ 320 321 if (rule->in_use) 321 322 323 324 322 { 323 DBS (DB_IMPLICIT, (_("Avoiding implicit rule recursion.\n"))); 324 continue; 325 } 325 326 326 327 for (ti = 0; ti < rule->num; ++ti) 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 328 { 329 const char *target = rule->targets[ti]; 330 const char *suffix = rule->suffixes[ti]; 331 int check_lastslash; 332 333 /* Rules that can match any filename and are not terminal 334 are ignored if we're recursing, so that they cannot be 335 intermediate files. */ 336 if (recursions > 0 && target[1] == '\0' && !rule->terminal) 337 continue; 338 339 if (rule->lens[ti] > namelen) 340 /* It can't possibly match. */ 341 continue; 342 343 /* From the lengths of the filename and the pattern parts, 344 find the stem: the part of the filename that matches the %. */ 345 stem = filename + (suffix - target - 1); 346 stemlen = namelen - rule->lens[ti] + 1; 347 348 /* Set CHECK_LASTSLASH if FILENAME contains a directory 349 prefix and the target pattern does not contain a slash. */ 349 350 350 351 check_lastslash = 0; … … 366 367 #endif 367 368 } 368 if (check_lastslash) 369 { 370 /* If so, don't include the directory prefix in STEM here. */ 371 unsigned int difference = lastslash - filename + 1; 372 if (difference > stemlen) 373 continue; 374 stemlen -= difference; 375 stem += difference; 376 } 377 378 /* Check that the rule pattern matches the text before the stem. */ 379 if (check_lastslash) 380 { 381 if (stem > (lastslash + 1) 382 && !strneq (target, lastslash + 1, stem - lastslash - 1)) 383 continue; 384 } 385 else if (stem > filename 386 && !strneq (target, filename, stem - filename)) 387 continue; 388 389 /* Check that the rule pattern matches the text after the stem. 390 We could test simply use streq, but this way we compare the 391 first two characters immediately. This saves time in the very 392 common case where the first character matches because it is a 393 period. */ 394 if (*suffix != stem[stemlen] 395 || (*suffix != '\0' && !streq (&suffix[1], &stem[stemlen + 1]))) 396 continue; 397 398 /* Record if we match a rule that not all filenames will match. */ 399 if (target[1] != '\0') 400 specific_rule_matched = 1; 401 402 /* A rule with no dependencies and no commands exists solely to set 403 specific_rule_matched when it matches. Don't try to use it. */ 404 if (rule->deps == 0 && rule->cmds == 0) 405 continue; 406 407 /* Record this rule in TRYRULES and the index of the matching 408 target in MATCHES. If several targets of the same rule match, 409 that rule will be in TRYRULES more than once. */ 410 tryrules[nrules] = rule; 411 matches[nrules] = ti; 412 checked_lastslash[nrules] = check_lastslash; 413 ++nrules; 414 } 369 if (check_lastslash) 370 { 371 /* If so, don't include the directory prefix in STEM here. */ 372 if (pathlen > stemlen) 373 continue; 374 stemlen -= pathlen; 375 stem += pathlen; 376 } 377 378 /* Check that the rule pattern matches the text before the stem. */ 379 if (check_lastslash) 380 { 381 if (stem > (lastslash + 1) 382 && !strneq (target, lastslash + 1, stem - lastslash - 1)) 383 continue; 384 } 385 else if (stem > filename 386 && !strneq (target, filename, stem - filename)) 387 continue; 388 389 /* Check that the rule pattern matches the text after the stem. 390 We could test simply use streq, but this way we compare the 391 first two characters immediately. This saves time in the very 392 common case where the first character matches because it is a 393 period. */ 394 if (*suffix != stem[stemlen] 395 || (*suffix != '\0' && !streq (&suffix[1], &stem[stemlen + 1]))) 396 continue; 397 398 /* Record if we match a rule that not all filenames will match. */ 399 if (target[1] != '\0') 400 specific_rule_matched = 1; 401 402 /* A rule with no dependencies and no commands exists solely to set 403 specific_rule_matched when it matches. Don't try to use it. */ 404 if (rule->deps == 0 && rule->cmds == 0) 405 continue; 406 407 /* Record this rule in TRYRULES and the index of the matching 408 target in MATCHES. If several targets of the same rule match, 409 that rule will be in TRYRULES more than once. */ 410 tryrules[nrules].rule = rule; 411 tryrules[nrules].matches = ti; 412 tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0); 413 tryrules[nrules].order = nrules; 414 tryrules[nrules].checked_lastslash = check_lastslash; 415 ++nrules; 416 } 415 417 } 418 419 /* Bail out early if we haven't found any rules. */ 420 if (nrules == 0) 421 goto done; 422 423 /* Sort the rules to place matches with the shortest stem first. This 424 way the most specific rules will be tried first. */ 425 if (nrules > 1) 426 qsort (tryrules, nrules, sizeof (struct tryrule), stemlen_compare); 416 427 417 428 /* If we have found a matching rule that won't match all filenames, … … 419 430 if (specific_rule_matched) 420 431 for (ri = 0; ri < nrules; ++ri) 421 if (!tryrules[ri] ->terminal)422 423 424 for (j = 0; j < tryrules[ri]->num; ++j)425 if (tryrules[ri]->targets[j][1] == '\0')432 if (!tryrules[ri].rule->terminal) 433 { 434 unsigned int j; 435 for (j = 0; j < tryrules[ri].rule->num; ++j) 436 if (tryrules[ri].rule->targets[j][1] == '\0') 426 437 { 427 tryrules[ri] = 0;438 tryrules[ri].rule = 0; 428 439 break; 429 440 } 430 } 431 432 /* We are going to do second expansion so initialize file variables 433 for the rule. */ 434 initialize_file_variables (file, 0); 441 } 435 442 436 443 /* Try each rule once without intermediate files, then once with them. */ 437 for (intermed_ok = 0; intermed_ok == !!intermed_ok; ++intermed_ok)444 for (intermed_ok = 0; intermed_ok < 2; ++intermed_ok) 438 445 { 439 /* Try each pattern rule till we find one that applies.440 If it does, expand its dependencies (as substituted) 441 and chain them in DEPS. */ 442 446 pat = deplist; 447 448 /* Try each pattern rule till we find one that applies. If it does, 449 expand its dependencies (as substituted) and chain them in DEPS. */ 443 450 for (ri = 0; ri < nrules; ri++) 444 { 445 struct file *f; 451 { 452 struct dep *dep; 453 int check_lastslash; 446 454 unsigned int failed = 0; 447 int check_lastslash;448 455 int file_variables_set = 0; 449 450 rule = tryrules[ri]; 451 452 remove_explicit_deps = 0; 453 454 /* RULE is nil when we discover that a rule, 455 already placed in TRYRULES, should not be applied. */ 456 if (rule == 0) 457 continue; 458 459 /* Reject any terminal rules if we're 460 looking to make intermediate files. */ 461 if (intermed_ok && rule->terminal) 462 continue; 463 464 /* Mark this rule as in use so a recursive 465 pattern_search won't try to use it. */ 466 rule->in_use = 1; 467 468 /* From the lengths of the filename and the matching pattern parts, 469 find the stem: the part of the filename that matches the %. */ 470 stem = filename 471 + (rule->suffixes[matches[ri]] - rule->targets[matches[ri]]) - 1; 472 stemlen = namelen - rule->lens[matches[ri]] + 1; 473 check_lastslash = checked_lastslash[ri]; 474 if (check_lastslash) 475 { 476 stem += lastslash - filename + 1; 477 stemlen -= (lastslash - filename) + 1; 478 } 479 480 DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"), 456 unsigned int deps_found = 0; 457 /* NPTR points to the part of the prereq we haven't processed. */ 458 const char *nptr = 0; 459 const char *dir = NULL; 460 int order_only = 0; 461 unsigned int matches; 462 463 rule = tryrules[ri].rule; 464 465 /* RULE is nil when we discover that a rule, already placed in 466 TRYRULES, should not be applied. */ 467 if (rule == 0) 468 continue; 469 470 /* Reject any terminal rules if we're looking to make intermediate 471 files. */ 472 if (intermed_ok && rule->terminal) 473 continue; 474 475 /* From the lengths of the filename and the matching pattern parts, 476 find the stem: the part of the filename that matches the %. */ 477 matches = tryrules[ri].matches; 478 stem = filename + (rule->suffixes[matches] 479 - rule->targets[matches]) - 1; 480 stemlen = (namelen - rule->lens[matches]) + 1; 481 check_lastslash = tryrules[ri].checked_lastslash; 482 if (check_lastslash) 483 { 484 stem += pathlen; 485 stemlen -= pathlen; 486 487 /* We need to add the directory prefix, so set it up. */ 488 if (! pathdir) 489 { 490 pathdir = alloca (pathlen + 1); 491 memcpy (pathdir, filename, pathlen); 492 pathdir[pathlen] = '\0'; 493 } 494 dir = pathdir; 495 } 496 497 DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"), 481 498 (int) stemlen, stem)); 482 499 483 500 strncpy (stem_str, stem, stemlen); 484 501 stem_str[stemlen] = '\0'; 502 503 /* If there are no prerequisites, then this rule matches. */ 504 if (rule->deps == 0) 505 break; 485 506 486 507 /* Temporary assign STEM to file->stem (needed to set file … … 488 509 file->stem = stem_str; 489 510 490 /* Try each dependency; see if it "exists". */ 491 492 for (dep = rule->deps; dep != 0; dep = dep->next) 493 { 494 unsigned int len; 511 /* Mark this rule as in use so a recursive pattern_search won't try 512 to use it. */ 513 rule->in_use = 1; 514 515 /* Try each prerequisite; see if it exists or can be created. We'll 516 build a list of prereq info in DEPLIST. Due to 2nd expansion we 517 may have to process multiple prereqs for a single dep entry. */ 518 519 pat = deplist; 520 dep = rule->deps; 521 nptr = dep_name (dep); 522 while (1) 523 { 524 struct dep *dl, *d; 495 525 char *p; 496 char *p2; 497 unsigned int order_only = 0; /* Set if '|' was seen. */ 498 499 /* In an ideal world we would take the dependency line, 500 substitute the stem, re-expand the whole line and chop it 501 into individual prerequisites. Unfortunately this won't work 502 because of the "check_lastslash" twist. Instead, we will 503 have to go word by word, taking $()'s into account, for each 504 word we will substitute the stem, re-expand, chop it up, and, 505 if check_lastslash != 0, add the directory part to each 526 527 /* If we're out of name to parse, start the next prereq. */ 528 if (! nptr) 529 { 530 dep = dep->next; 531 if (dep == 0) 532 break; 533 nptr = dep_name (dep); 534 } 535 536 /* If we don't need a second expansion, just replace the %. */ 537 if (! dep->need_2nd_expansion) 538 { 539 dep_simple = *dep; 540 dep_simple.next = 0; 541 p = strchr (nptr, '%'); 542 if (p == 0) 543 dep_simple.name = nptr; 544 else 545 { 546 char *o = depname; 547 if (check_lastslash) 548 { 549 memcpy (o, filename, pathlen); 550 o += pathlen; 551 } 552 memcpy (o, nptr, p - nptr); 553 o += p - nptr; 554 memcpy (o, stem_str, stemlen); 555 o += stemlen; 556 strcpy (o, p + 1); 557 dep_simple.name = strcache_add (depname); 558 } 559 dl = &dep_simple; 560 561 /* We've used up this dep, so next time get a new one. */ 562 nptr = 0; 563 ++deps_found; 564 } 565 566 /* We have to perform second expansion on this prereq. In an 567 ideal world we would take the dependency line, substitute the 568 stem, re-expand the whole line and chop it into individual 569 prerequisites. Unfortunately this won't work because of the 570 "check_lastslash" twist. Instead, we will have to go word by 571 word, taking $()'s into account. For each word we will 572 substitute the stem, re-expand, chop it up, and, if 573 check_lastslash != 0, add the directory part to each 506 574 resulting prerequisite. */ 507 508 p = get_next_word (dep->name, &len); 509 510 while (1) 575 else 511 576 { 512 577 int add_dir = 0; 513 int had_stem = 0; 514 578 unsigned int len; 579 580 nptr = get_next_word (nptr, &len); 581 if (nptr == 0) 582 continue; 583 584 /* See this is a transition to order-only prereqs. */ 585 if (! order_only && len == 1 && nptr[0] == '|') 586 { 587 order_only = 1; 588 nptr += len; 589 continue; 590 } 591 592 /* If the dependency name has %, substitute the stem. If we 593 just replace % with the stem value then later, when we do 594 the 2nd expansion, we will re-expand this stem value 595 again. This is not good if you have certain characters 596 in your stem (like $). 597 598 Instead, we will replace % with $* and allow the second 599 expansion to take care of it for us. This way (since $* 600 is a simple variable) there won't be additional 601 re-expansion of the stem. */ 602 603 p = lindex (nptr, nptr + len, '%'); 515 604 if (p == 0) 516 break; /* No more words */ 517 518 /* Is there a pattern in this prerequisite? */ 519 520 for (p2 = p; p2 < p + len && *p2 != '%'; ++p2) 521 ; 522 523 if (dep->need_2nd_expansion) 524 { 525 /* If the dependency name has %, substitute the stem. 526 527 Watch out, we are going to do something tricky 528 here. If we just replace % with the stem value, 529 later, when we do the second expansion, we will 530 re-expand this stem value once again. This is not 531 good especially if you have certain characters in 532 your stem (like $). 533 534 Instead, we will replace % with $* and allow the 535 second expansion to take care of it for us. This way 536 (since $* is a simple variable) there won't be 537 additional re-expansion of the stem. */ 538 539 if (p2 < p + len) 540 { 541 unsigned int i = p2 - p; 542 memcpy (depname, p, i); 543 memcpy (depname + i, "$*", 2); 544 memcpy (depname + i + 2, p2 + 1, len - i - 1); 545 depname[len + 2 - 1] = '\0'; 546 547 if (check_lastslash) 548 add_dir = 1; 549 550 had_stem = 1; 551 } 552 else 553 { 554 memcpy (depname, p, len); 555 depname[len] = '\0'; 556 } 557 558 /* Set file variables. Note that we cannot do it once 559 at the beginning of the function because of the stem 560 value. */ 561 if (!file_variables_set) 562 { 605 { 606 memcpy (depname, nptr, len); 607 depname[len] = '\0'; 608 } 609 else 610 { 611 unsigned int i = p - nptr; 612 memcpy (depname, nptr, i); 613 memcpy (depname + i, "$*", 2); 614 memcpy (depname + i + 2, p + 1, len - i - 1); 615 depname[len + 2 - 1] = '\0'; 616 617 if (check_lastslash) 618 add_dir = 1; 619 } 620 621 /* Initialize and set file variables if we haven't already 622 done so. */ 623 if (!file_vars_initialized) 624 { 625 initialize_file_variables (file, 0); 563 626 #if defined(CONFIG_WITH_COMMANDS_FUNC) || defined (CONFIG_WITH_DOT_MUST_MAKE) 564 627 set_file_variables (file, 0 /* real call */); 565 628 #else 566 629 set_file_variables (file); 567 630 #endif 568 file_variables_set = 1; 569 } 570 571 p2 = variable_expand_for_file (depname, file); 572 } 573 else 574 { 575 if (p2 < p + len) 576 { 577 unsigned int i = p2 - p; 578 memcpy (depname, p, i); 579 memcpy (depname + i, stem_str, stemlen); 580 memcpy (depname + i + stemlen, p2 + 1, len - i - 1); 581 depname[len + stemlen - 1] = '\0'; 582 583 if (check_lastslash) 584 add_dir = 1; 585 586 had_stem = 1; 587 } 588 else 589 { 590 memcpy (depname, p, len); 591 depname[len] = '\0'; 592 } 593 594 p2 = depname; 595 } 596 597 /* Parse the dependencies. */ 598 599 while (1) 600 { 601 id_ptr = &deps; 602 603 for (; *id_ptr; id_ptr = &(*id_ptr)->next) 604 ; 605 606 #ifndef CONFIG_WITH_ALLOC_CACHES 607 *id_ptr = (struct idep *) 608 multi_glob ( 609 parse_file_seq (&p2, 610 order_only ? '\0' : '|', 611 sizeof (struct idep), 612 1), sizeof (struct idep)); 613 #else 614 *id_ptr = (struct idep *) 615 multi_glob ( 616 parse_file_seq (&p2, 617 order_only ? '\0' : '|', 618 &idep_cache, 1), 619 &idep_cache); 620 #endif 621 622 /* @@ It would be nice to teach parse_file_seq or 623 multi_glob to add prefix. This would save us some 624 reallocations. */ 625 626 if (order_only || add_dir || had_stem) 627 { 628 unsigned long l = lastslash - filename + 1; 629 630 for (d = *id_ptr; d != 0; d = d->next) 631 { 632 if (order_only) 633 d->ignore_mtime = 1; 634 635 if (add_dir) 636 { 637 char *n = alloca (strlen (d->name) + l + 1); 638 memcpy (n, filename, l); 639 memcpy (n+l, d->name, strlen (d->name) + 1); 640 d->name = strcache_add (n); 641 } 642 643 if (had_stem) 644 d->had_stem = 1; 645 } 646 } 647 648 if (!order_only && *p2) 631 file_vars_initialized = 1; 632 } 633 /* Update the stem value in $* for this rule. */ 634 else if (!file_variables_set) 635 { 636 define_variable_for_file ( 637 "*", 1, file->stem, o_automatic, 0, file); 638 file_variables_set = 1; 639 } 640 641 /* Perform the 2nd expansion. */ 642 p = variable_expand_for_file (depname, file); 643 644 /* Parse the expanded string. */ 645 dl = PARSE_FILE_SEQ (&p, struct dep, order_only ? '\0' : '|', 646 add_dir ? dir : NULL, 0); 647 648 for (d = dl; d != NULL; d = d->next) 649 { 650 ++deps_found; 651 if (order_only) 652 d->ignore_mtime = 1; 653 } 654 655 /* Set up for the next word. */ 656 nptr += len; 657 } 658 659 /* If there are more than max_pattern_deps prerequisites (due to 660 2nd expansion), reset it and realloc the arrays. */ 661 662 if (deps_found > max_pattern_deps) 663 { 664 unsigned int l = pat - deplist; 665 deplist = xrealloc (deplist, 666 deps_found * sizeof (struct patdeps)); 667 pat = deplist + l; 668 max_pattern_deps = deps_found; 669 } 670 671 /* Go through the nameseq and handle each as a prereq name. */ 672 for (d = dl; d != 0; d = d->next) 673 { 674 struct dep *expl_d; 675 int is_rule = d->name == dep_name (dep); 676 677 if (file_impossible_p (d->name)) 678 { 679 /* If this prereq has already been ruled "impossible", 680 then the rule fails. Don't bother trying it on the 681 second pass either since we know that will fail. */ 682 DBS (DB_IMPLICIT, 683 (is_rule 684 ? _("Rejecting impossible rule prerequisite `%s'.\n") 685 : _("Rejecting impossible implicit prerequisite `%s'.\n"), 686 d->name)); 687 tryrules[ri].rule = 0; 688 689 failed = 1; 690 break; 691 } 692 693 memset (pat, '\0', sizeof (struct patdeps)); 694 pat->ignore_mtime = d->ignore_mtime; 695 696 DBS (DB_IMPLICIT, 697 (is_rule 698 ? _("Trying rule prerequisite `%s'.\n") 699 : _("Trying implicit prerequisite `%s'.\n"), d->name)); 700 701 /* If this prereq is also explicitly mentioned for FILE, 702 skip all tests below since it must be built no matter 703 which implicit rule we choose. */ 704 705 for (expl_d = file->deps; expl_d != 0; expl_d = expl_d->next) 706 if (streq (dep_name (expl_d), d->name)) 707 break; 708 if (expl_d != 0) 709 { 710 (pat++)->name = d->name; 711 continue; 712 } 713 714 /* The DEP->changed flag says that this dependency resides 715 in a nonexistent directory. So we normally can skip 716 looking for the file. However, if CHECK_LASTSLASH is 717 set, then the dependency file we are actually looking for 718 is in a different directory (the one gotten by prepending 719 FILENAME's directory), so it might actually exist. */ 720 721 /* @@ dep->changed check is disabled. */ 722 if (lookup_file (d->name) != 0 723 /*|| ((!dep->changed || check_lastslash) && */ 724 || file_exists_p (d->name)) 725 { 726 (pat++)->name = d->name; 727 continue; 728 } 729 730 /* This code, given FILENAME = "lib/foo.o", dependency name 731 "lib/foo.c", and VPATH=src, searches for 732 "src/lib/foo.c". */ 733 { 734 const char *vname = vpath_search (d->name, 0, NULL, NULL); 735 if (vname) 649 736 { 650 ++p2; 651 order_only = 1; 737 DBS (DB_IMPLICIT, 738 (_("Found prerequisite `%s' as VPATH `%s'\n"), 739 d->name, vname)); 740 (pat++)->name = d->name; 652 741 continue; 653 742 } 654 655 break; 656 } 657 658 p += len; 659 p = get_next_word (p, &len); 660 } 661 } 662 663 /* Reset the stem in FILE. */ 664 665 file->stem = 0; 666 667 /* @@ This loop can be combined with the previous one. I do 668 it separately for now for transparency.*/ 669 670 for (d = deps; d != 0; d = d->next) 671 { 672 const char *name = d->name; 673 674 if (file_impossible_p (name)) 675 { 676 /* If this dependency has already been ruled "impossible", 677 then the rule fails and don't bother trying it on the 678 second pass either since we know that will fail too. */ 679 DBS (DB_IMPLICIT, 680 (d->had_stem 681 ? _("Rejecting impossible implicit prerequisite `%s'.\n") 682 : _("Rejecting impossible rule prerequisite `%s'.\n"), 683 name)); 684 tryrules[ri] = 0; 685 743 } 744 745 /* We could not find the file in any place we should look. 746 Try to make this dependency as an intermediate file, but 747 only on the second pass. */ 748 749 if (intermed_ok) 750 { 751 DBS (DB_IMPLICIT, 752 (_("Looking for a rule with intermediate file `%s'.\n"), 753 d->name)); 754 755 if (int_file == 0) 756 int_file = alloca (sizeof (struct file)); 757 memset (int_file, '\0', sizeof (struct file)); 758 int_file->name = d->name; 759 760 if (pattern_search (int_file, 761 0, 762 depth + 1, 763 recursions + 1)) 764 { 765 pat->pattern = int_file->name; 766 int_file->name = d->name; 767 pat->file = int_file; 768 (pat++)->name = d->name; 769 int_file = 0; 770 continue; 771 } 772 773 /* If we have tried to find P as an intermediate file 774 and failed, mark that name as impossible so we won't 775 go through the search again later. */ 776 if (int_file->variables) 777 free_variable_set (int_file->variables); 778 if (int_file->pat_variables) 779 free_variable_set (int_file->pat_variables); 780 file_impossible (d->name); 781 } 782 783 /* A dependency of this rule does not exist. Therefore, this 784 rule fails. */ 686 785 failed = 1; 687 786 break; 688 787 } 689 788 690 DBS (DB_IMPLICIT, 691 (d->had_stem 692 ? _("Trying implicit prerequisite `%s'.\n") 693 : _("Trying rule prerequisite `%s'.\n"), name)); 694 695 /* If this prerequisite also happened to be explicitly mentioned 696 for FILE skip all the test below since it it has to be built 697 anyway, no matter which implicit rule we choose. */ 698 699 for (expl_d = file->deps; expl_d != 0; expl_d = expl_d->next) 700 if (streq (dep_name (expl_d), name)) 701 break; 702 if (expl_d != 0) 703 continue; 704 705 /* The DEP->changed flag says that this dependency resides in a 706 nonexistent directory. So we normally can skip looking for 707 the file. However, if CHECK_LASTSLASH is set, then the 708 dependency file we are actually looking for is in a different 709 directory (the one gotten by prepending FILENAME's directory), 710 so it might actually exist. */ 711 712 /* @@ dep->changed check is disabled. */ 713 if (((f = lookup_file (name)) != 0 && f->is_target) 714 /*|| ((!dep->changed || check_lastslash) && */ 715 || file_exists_p (name)) 716 continue; 717 718 /* This code, given FILENAME = "lib/foo.o", dependency name 719 "lib/foo.c", and VPATH=src, searches for "src/lib/foo.c". */ 720 { 721 const char *vname = vpath_search (name, 0); 722 if (vname) 723 { 724 DBS (DB_IMPLICIT, 725 (_("Found prerequisite `%s' as VPATH `%s'\n"), 726 name, vname)); 727 continue; 728 } 729 } 730 731 732 /* We could not find the file in any place we should look. Try 733 to make this dependency as an intermediate file, but only on 734 the second pass. */ 735 736 if (intermed_ok) 737 { 738 if (intermediate_file == 0) 739 intermediate_file = alloca (sizeof (struct file)); 740 741 DBS (DB_IMPLICIT, 742 (_("Looking for a rule with intermediate file `%s'.\n"), 743 name)); 744 745 memset (intermediate_file, '\0', sizeof (struct file)); 746 intermediate_file->name = name; 747 if (pattern_search (intermediate_file, 748 0, 749 depth + 1, 750 recursions + 1)) 751 { 752 d->intermediate_pattern = intermediate_file->name; 753 intermediate_file->name = strcache_add (name); 754 d->intermediate_file = intermediate_file; 755 intermediate_file = 0; 756 757 continue; 758 } 759 760 /* If we have tried to find P as an intermediate 761 file and failed, mark that name as impossible 762 so we won't go through the search again later. */ 763 if (intermediate_file->variables) 764 free_variable_set (intermediate_file->variables); 765 file_impossible (name); 766 } 767 768 /* A dependency of this rule does not exist. Therefore, 769 this rule fails. */ 770 failed = 1; 771 break; 789 /* Free the ns chain. */ 790 if (dl != &dep_simple) 791 free_dep_chain (dl); 792 793 if (failed) 794 break; 772 795 } 773 796 797 /* Reset the stem in FILE. */ 798 799 file->stem = 0; 800 774 801 /* This rule is no longer `in use' for recursive searches. */ 775 rule->in_use = 0; 776 777 if (failed) 778 { 779 /* This pattern rule does not apply. If some of its 780 dependencies succeeded, free the data structure 781 describing them. */ 782 free_idep_chain (deps); 783 deps = 0; 784 } 785 else 786 /* This pattern rule does apply. Stop looking for one. */ 787 break; 788 } 789 790 /* If we found an applicable rule without 791 intermediate files, don't try with them. */ 802 rule->in_use = 0; 803 804 if (! failed) 805 /* This pattern rule does apply. Stop looking for one. */ 806 break; 807 808 /* This pattern rule does not apply. If some of its dependencies 809 succeeded, free the data structure describing them. */ 810 /* free_idep_chain (deps); */ 811 deps = 0; 812 } 813 814 /* If we found an applicable rule without intermediate files, don't try 815 with them. */ 792 816 if (ri < nrules) 793 817 break; 794 818 795 819 rule = 0; 796 820 } 797 821 798 /* RULE is nil if the loop went all the way 799 through the list and everything failed. */ 822 /* RULE is nil if the loop went through the list but everything failed. */ 800 823 if (rule == 0) 801 824 goto done; … … 803 826 foundrule = ri; 804 827 805 /* If we are recursing, store the pattern that matched 806 FILE NAME in FILE->name for use in upper levels. */828 /* If we are recursing, store the pattern that matched FILENAME in 829 FILE->name for use in upper levels. */ 807 830 808 831 if (recursions > 0) 809 832 /* Kludge-o-matic */ 810 file->name = rule->targets[ matches[foundrule]];811 812 /* FOUND_FILES lists the dependencies for the rule we found.813 This includes the intermediate files, if any.814 Convert them into entries on the deps-chainof FILE. */815 816 if (remove_explicit_deps)833 file->name = rule->targets[tryrules[foundrule].matches]; 834 835 /* DEPLIST lists the prerequisites for the rule we found. This includes the 836 intermediate files, if any. Convert them into entries on the deps-chain 837 of FILE. */ 838 839 while (pat-- > deplist) 817 840 { 818 /* Remove all the dependencies that didn't come from 819 this implicit rule. */ 820 821 dep = file->deps; 822 while (dep != 0) 841 struct dep *dep; 842 const char *s; 843 844 if (pat->file != 0) 823 845 { 824 struct dep *next = dep->next; 825 free_dep (dep); 826 dep = next; 827 } 828 file->deps = 0; 829 } 830 831 expl_d = file->deps; /* We will add them at the end. */ 832 d_ptr = &file->deps; 833 834 for (d = deps; d != 0; d = d->next) 835 { 836 const char *s; 837 838 if (d->intermediate_file != 0) 839 { 840 /* If we need to use an intermediate file, 841 make sure it is entered as a target, with the info that was 842 found for it in the recursive pattern_search call. 843 We know that the intermediate file did not already exist as 844 a target; therefore we can assume that the deps and cmds 845 of F below are null before we change them. */ 846 847 struct file *imf = d->intermediate_file; 848 register struct file *f = lookup_file (imf->name); 846 /* If we need to use an intermediate file, make sure it is entered 847 as a target, with the info that was found for it in the recursive 848 pattern_search call. We know that the intermediate file did not 849 already exist as a target; therefore we can assume that the deps 850 and cmds of F below are null before we change them. */ 851 852 struct file *imf = pat->file; 853 struct file *f = lookup_file (imf->name); 849 854 850 855 /* We don't want to delete an intermediate file that happened … … 854 859 f->precious = 1; 855 860 else 856 f = enter_file (strcache_add (imf->name)); 857 858 f->deps = imf->deps; 859 f->cmds = imf->cmds; 860 f->stem = imf->stem; 861 f = enter_file (imf->name); 862 863 f->deps = imf->deps; 864 f->cmds = imf->cmds; 865 f->stem = imf->stem; 866 f->variables = imf->variables; 867 f->pat_variables = imf->pat_variables; 868 f->pat_searched = imf->pat_searched; 861 869 f->also_make = imf->also_make; 862 870 f->is_target = 1; 863 864 if (!f->precious) 871 f->intermediate = 1; 872 f->tried_implicit = 1; 873 874 imf = lookup_file (pat->pattern); 875 if (imf != 0 && imf->precious) 876 f->precious = 1; 877 878 for (dep = f->deps; dep != 0; dep = dep->next) 865 879 { 866 imf = lookup_file (d->intermediate_pattern);867 if (imf != 0 && imf->precious)868 f->precious = 1;880 dep->file = enter_file (dep->name); 881 dep->name = 0; 882 dep->file->tried_implicit |= dep->changed; 869 883 } 870 871 f->intermediate = 1; 872 f->tried_implicit = 1; 873 for (dep = f->deps; dep != 0; dep = dep->next) 874 { 875 dep->file = enter_file (dep->name); 876 dep->name = 0; 877 dep->file->tried_implicit |= dep->changed; 878 } 879 } 884 } 880 885 881 886 dep = alloc_dep (); 882 dep->ignore_mtime = d->ignore_mtime; 883 s = d->name; /* Hijacking the name. */ 884 d->name = 0; 885 if (recursions == 0) 886 { 887 dep->file = lookup_file (s); 888 if (dep->file == 0) 889 dep->file = enter_file (s); 890 } 887 dep->ignore_mtime = pat->ignore_mtime; 888 s = strcache_add (pat->name); 889 if (recursions) 890 dep->name = s; 891 891 else 892 dep->name = s; 893 894 if (d->intermediate_file == 0 && tryrules[foundrule]->terminal) 895 { 896 /* If the file actually existed (was not an intermediate file), 897 and the rule that found it was a terminal one, then we want 898 to mark the found file so that it will not have implicit rule 899 search done for it. If we are not entering a `struct file' for 900 it now, we indicate this with the `changed' flag. */ 901 if (dep->file == 0) 902 dep->changed = 1; 903 else 904 dep->file->tried_implicit = 1; 905 } 906 907 *d_ptr = dep; 908 d_ptr = &dep->next; 892 { 893 dep->file = lookup_file (s); 894 if (dep->file == 0) 895 dep->file = enter_file (s); 896 } 897 898 if (pat->file == 0 && tryrules[foundrule].rule->terminal) 899 { 900 /* If the file actually existed (was not an intermediate file), and 901 the rule that found it was a terminal one, then we want to mark 902 the found file so that it will not have implicit rule search done 903 for it. If we are not entering a `struct file' for it now, we 904 indicate this with the `changed' flag. */ 905 if (dep->file == 0) 906 dep->changed = 1; 907 else 908 dep->file->tried_implicit = 1; 909 } 910 911 dep->next = file->deps; 912 file->deps = dep; 909 913 } 910 914 911 *d_ptr = expl_d; 912 913 if (!checked_lastslash[foundrule]) 915 if (!tryrules[foundrule].checked_lastslash) 914 916 { 915 /* Always allocate new storage, since STEM might be 916 on the stack for anintermediate file. */917 /* Always allocate new storage, since STEM might be on the stack for an 918 intermediate file. */ 917 919 file->stem = strcache_add_len (stem, stemlen); 918 920 fullstemlen = stemlen; … … 924 926 925 927 /* We want to prepend the directory from 926 928 the original FILENAME onto the stem. */ 927 929 fullstemlen = dirlen + stemlen; 928 930 sp = alloca (fullstemlen + 1); … … 942 944 /* Set precious flag. */ 943 945 { 944 struct file *f = lookup_file (rule->targets[ matches[foundrule]]);946 struct file *f = lookup_file (rule->targets[tryrules[foundrule].matches]); 945 947 if (f && f->precious) 946 948 file->precious = 1; … … 952 954 if (rule->num > 1) 953 955 for (ri = 0; ri < rule->num; ++ri) 954 if (ri != matches[foundrule]) 955 { 956 char *p = alloca (rule->lens[ri] + fullstemlen + 1); 957 struct file *f; 958 struct dep *new = alloc_dep (); 959 960 /* GKM FIMXE: handle '|' here too */ 961 memcpy (p, rule->targets[ri], 956 if (ri != tryrules[foundrule].matches) 957 { 958 char *nm = alloca (rule->lens[ri] + fullstemlen + 1); 959 char *p = nm; 960 struct file *f; 961 struct dep *new = alloc_dep (); 962 963 /* GKM FIMXE: handle '|' here too */ 964 memcpy (p, rule->targets[ri], 962 965 rule->suffixes[ri] - rule->targets[ri] - 1); 963 964 965 966 966 p += rule->suffixes[ri] - rule->targets[ri] - 1; 967 memcpy (p, file->stem, fullstemlen); 968 p += fullstemlen; 969 memcpy (p, rule->suffixes[ri], 967 970 rule->lens[ri] - (rule->suffixes[ri] - rule->targets[ri])+1); 968 new->name = strcache_add ( p);969 970 971 972 973 974 971 new->name = strcache_add (nm); 972 new->file = enter_file (new->name); 973 new->next = file->also_make; 974 975 /* Set precious flag. */ 976 f = lookup_file (rule->targets[ri]); 977 if (f && f->precious) 975 978 new->file->precious = 1; 976 979 977 /* Set the is_target flag so that this file is not treated 978 asintermediate by the pattern rule search algorithm and980 /* Set the is_target flag so that this file is not treated as 981 intermediate by the pattern rule search algorithm and 979 982 file_exists_p cannot pick it up yet. */ 980 983 new->file->is_target = 1; 981 984 982 983 985 file->also_make = new; 986 } 984 987 985 988 done: 986 free_idep_chain (deps);987 989 free (tryrules); 990 free (deplist); 988 991 989 992 return rule != 0; -
trunk/src/kmk/incdep.c
r2546 r2591 114 114 }; 115 115 116 struct incdep_recorded_file s117 { 118 struct incdep_recorded_file s*next;116 struct incdep_recorded_file 117 { 118 struct incdep_recorded_file *next; 119 119 120 120 /* the parameters */ 121 121 struct strcache2_entry *filename_entry; /* dep strcache; converted to a nameseq record. */ 122 const char *pattern; /* NULL */123 const char *pattern_percent; /* NULL */124 122 struct dep *deps; /* All the names are dep strcache entries. */ 125 unsigned int cmds_started; /* 0 */126 char *commands; /* NULL */127 unsigned int commands_idx; /* 0 */128 int two_colon; /* 0 */129 123 const struct floc *flocp; /* NILF */ 130 124 }; … … 149 143 struct incdep_variable_def *recorded_variable_defs_tail; 150 144 151 struct incdep_recorded_file s *recorded_files_head;152 struct incdep_recorded_file s *recorded_files_tail;145 struct incdep_recorded_file *recorded_file_head; 146 struct incdep_recorded_file *recorded_file_tail; 153 147 #endif 154 148 … … 232 226 static void incdep_flush_it (struct floc *); 233 227 static void eval_include_dep_file (struct incdep *, struct floc *); 228 static void incdep_commit_recorded_file (const char *filename, struct dep *deps, 229 const struct floc *flocp); 234 230 235 231 … … 501 497 assert (!cur->recorded_variables_in_set_head); 502 498 assert (!cur->recorded_variable_defs_head); 503 assert (!cur->recorded_file s_head);499 assert (!cur->recorded_file_head); 504 500 #endif 505 501 … … 727 723 if (rec_size < sizeof (struct incdep_variable_def)) 728 724 rec_size = sizeof (struct incdep_variable_def); 729 if (rec_size < sizeof (struct incdep_recorded_file s))730 rec_size = sizeof (struct incdep_recorded_file s);725 if (rec_size < sizeof (struct incdep_recorded_file)) 726 rec_size = sizeof (struct incdep_recorded_file); 731 727 alloccache_init (&incdep_rec_caches[i], rec_size, "incdep rec", 732 728 incdep_cache_allocator, (void *)(size_t)i); … … 849 845 struct incdep_variable_in_set *rec_vis; 850 846 struct incdep_variable_def *rec_vd; 851 struct incdep_recorded_file s*rec_f;847 struct incdep_recorded_file *rec_f; 852 848 853 849 /* define_variable_in_set */ … … 898 894 /* record_files */ 899 895 900 rec_f = cur->recorded_file s_head;901 cur->recorded_file s_head = cur->recorded_files_tail = NULL;896 rec_f = cur->recorded_file_head; 897 cur->recorded_file_head = cur->recorded_file_tail = NULL; 902 898 if (rec_f) 903 899 do … … 905 901 void *free_me = rec_f; 906 902 struct dep *dep; 907 struct nameseq *filenames;908 903 909 904 for (dep = rec_f->deps; dep; dep = dep->next) 910 905 dep->name = incdep_flush_strcache_entry ((struct strcache2_entry *)dep->name); 911 906 912 filenames = (struct nameseq *) alloccache_alloc (&nameseq_cache); 913 filenames->next = 0; 914 filenames->name = incdep_flush_strcache_entry (rec_f->filename_entry); 915 916 record_files (filenames, 917 rec_f->pattern, 918 rec_f->pattern_percent, 919 rec_f->deps, 920 rec_f->cmds_started, 921 rec_f->commands, 922 rec_f->commands_idx, 923 rec_f->two_colon, 924 rec_f->flocp); 907 incdep_commit_recorded_file (incdep_flush_strcache_entry (rec_f->filename_entry), 908 rec_f->deps, 909 rec_f->flocp); 925 910 926 911 rec_f = rec_f->next; … … 1074 1059 } 1075 1060 1076 /* Record files.*/1061 /* Similar to record_files in read.c, only much much simpler. */ 1077 1062 static void 1078 incdep_record_files (struct incdep *cur, 1079 const char *filename, const char *pattern, 1080 const char *pattern_percent, struct dep *deps, 1081 unsigned int cmds_started, char *commands, 1082 unsigned int commands_idx, int two_colon, 1083 const struct floc *flocp) 1063 incdep_commit_recorded_file (const char *filename, struct dep *deps, 1064 const struct floc *flocp) 1065 { 1066 struct file *f; 1067 1068 /* Perform some validations. */ 1069 if (filename[0] == '.' 1070 && ( streq(filename, ".POSIX") 1071 || streq(filename, ".EXPORT_ALL_VARIABLES") 1072 || streq(filename, ".INTERMEDIATE") 1073 || streq(filename, ".LOW_RESOLUTION_TIME") 1074 || streq(filename, ".NOTPARALLEL") 1075 || streq(filename, ".ONESHELL") 1076 || streq(filename, ".PHONY") 1077 || streq(filename, ".PRECIOUS") 1078 || streq(filename, ".SECONDARY") 1079 || streq(filename, ".SECONDTARGETEXPANSION") 1080 || streq(filename, ".SILENT") 1081 || streq(filename, ".SHELLFLAGS") 1082 || streq(filename, ".SUFFIXES") 1083 ) 1084 ) 1085 { 1086 error (flocp, _("reserved filename '%s' used in dependency file, ignored"), filename); 1087 return; 1088 } 1089 1090 /* Lookup or create an entry in the database. */ 1091 f = enter_file (filename); 1092 if (f->double_colon) 1093 { 1094 error (flocp, _("dependency file '%s' has a double colon entry already, ignoring"), filename); 1095 return; 1096 } 1097 f->is_target = 1; 1098 1099 /* Append dependencies. */ 1100 deps = enter_prereqs (deps, NULL); 1101 if (deps) 1102 { 1103 struct dep *last = f->deps; 1104 if (!last) 1105 f->deps = deps; 1106 else 1107 { 1108 while (last->next) 1109 last = last->next; 1110 last->next = deps; 1111 } 1112 } 1113 } 1114 1115 /* Record a file.*/ 1116 static void 1117 incdep_record_file (struct incdep *cur, 1118 const char *filename, 1119 struct dep *deps, 1120 const struct floc *flocp) 1084 1121 { 1085 1122 if (cur->worker_tid == -1) 1086 { 1087 struct nameseq *filenames = (struct nameseq *) alloccache_alloc (&nameseq_cache); 1088 filenames->next = 0; 1089 filenames->name = filename; 1090 record_files (filenames, pattern, pattern_percent, deps, cmds_started, 1091 commands, commands_idx, two_colon, flocp); 1092 } 1123 incdep_commit_recorded_file (filename, deps, flocp); 1093 1124 #ifdef PARSE_IN_WORKER 1094 1125 else 1095 1126 { 1096 struct incdep_recorded_file s*rec =1097 (struct incdep_recorded_file s*) incdep_alloc_rec (cur);1127 struct incdep_recorded_file *rec = 1128 (struct incdep_recorded_file *) incdep_alloc_rec (cur); 1098 1129 1099 1130 rec->filename_entry = (struct strcache2_entry *)filename; 1100 rec->pattern = pattern;1101 rec->pattern_percent = pattern_percent;1102 1131 rec->deps = deps; 1103 rec->cmds_started = cmds_started;1104 rec->commands = commands;1105 rec->commands_idx = commands_idx;1106 rec->two_colon = two_colon;1107 1132 rec->flocp = flocp; 1108 1133 1109 1134 rec->next = NULL; 1110 if (cur->recorded_file s_tail)1111 cur->recorded_file s_tail->next = rec;1135 if (cur->recorded_file_tail) 1136 cur->recorded_file_tail->next = rec; 1112 1137 else 1113 cur->recorded_file s_head = rec;1114 cur->recorded_file s_tail = rec;1138 cur->recorded_file_head = rec; 1139 cur->recorded_file_tail = rec; 1115 1140 } 1116 1141 #endif … … 1531 1556 1532 1557 /* enter the file with its dependencies. */ 1533 incdep_record_files (curdep, 1534 filename, NULL, NULL, deps, 0, NULL, 0, 0, f); 1558 incdep_record_file (curdep, filename, deps, f); 1535 1559 } 1536 1560 } … … 1630 1654 cur->recorded_variable_defs_head = NULL; 1631 1655 cur->recorded_variable_defs_tail = NULL; 1632 cur->recorded_file s_head = NULL;1633 cur->recorded_file s_tail = NULL;1656 cur->recorded_file_head = NULL; 1657 cur->recorded_file_tail = NULL; 1634 1658 #endif 1635 1659 -
trunk/src/kmk/job.c
r2564 r2591 1 1 /* Job execution and handling for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 182 182 #endif /* Don't have `union wait'. */ 183 183 184 #if ndef HAVE_UNISTD_H184 #if !defined(HAVE_UNISTD_H) && !defined(WINDOWS32) 185 185 # ifndef _MSC_VER /* bird */ 186 186 int dup2 (); … … 196 196 #endif 197 197 198 /* Different systems have different requirements for pid_t. 199 Plus we have to support gettext string translation... Argh. */ 200 static const char * 201 pid2str (pid_t pid) 202 { 203 static char pidstring[100]; 204 #if defined(WINDOWS32) && (__GNUC__ > 3 || _MSC_VER > 1300) 205 /* %Id is only needed for 64-builds, which were not supported by 206 older versions of Windows compilers. */ 207 sprintf (pidstring, "%Id", pid); 208 #else 209 sprintf (pidstring, "%lu", (unsigned long) pid); 210 #endif 211 return pidstring; 212 } 213 198 214 int getloadavg (double loadavg[], int nelem); 199 215 int start_remote_job (char **argv, char **envp, int stdin_fd, int *is_remote, … … 248 264 */ 249 265 int 250 w32_kill( int pid, int sig)266 w32_kill(pid_t pid, int sig) 251 267 { 252 268 return ((process_kill((HANDLE)pid, sig) == TRUE) ? 0 : -1); … … 261 277 { 262 278 const char *const ext = unixy ? "sh" : "bat"; 263 const char *error = NULL;279 const char *error_string = NULL; 264 280 char temp_path[MAXPATHLEN]; /* need to know its length */ 265 281 unsigned path_size = GetTempPath(sizeof temp_path, temp_path); … … 307 323 else 308 324 { 309 error = map_windows32_error_to_string (er);325 error_string = map_windows32_error_to_string (er); 310 326 break; 311 327 } … … 316 332 char *const path = xmalloc (final_size); 317 333 memcpy (path, temp_path, final_size); 318 *fd = _open_osfhandle (( long)h, 0);334 *fd = _open_osfhandle ((intptr_t)h, 0); 319 335 if (unixy) 320 336 { … … 330 346 331 347 *fd = -1; 332 if (error == NULL)333 error = _("Cannot create a temporary file\n");334 fatal (NILF, error );348 if (error_string == NULL) 349 error_string = _("Cannot create a temporary file\n"); 350 fatal (NILF, error_string); 335 351 336 352 /* not reached */ … … 383 399 #endif /* __EMX__ */ 384 400 401 /* determines whether path looks to be a Bourne-like shell. */ 402 int 403 is_bourne_compatible_shell (const char *path) 404 { 405 /* list of known unix (Bourne-like) shells */ 406 const char *unix_shells[] = { 407 "sh", 408 "bash", 409 "ksh", 410 "rksh", 411 "zsh", 412 "ash", 413 "dash", 414 NULL 415 }; 416 unsigned i, len; 417 418 /* find the rightmost '/' or '\\' */ 419 const char *name = strrchr (path, '/'); 420 char *p = strrchr (path, '\\'); 421 422 if (name && p) /* take the max */ 423 name = (name > p) ? name : p; 424 else if (p) /* name must be 0 */ 425 name = p; 426 else if (!name) /* name and p must be 0 */ 427 name = path; 428 429 if (*name == '/' || *name == '\\') name++; 430 431 /* this should be able to deal with extensions on Windows-like systems */ 432 for (i = 0; unix_shells[i] != NULL; i++) { 433 len = strlen(unix_shells[i]); 434 #if defined(WINDOWS32) || defined(__MSDOS__) 435 if ((strncasecmp (name, unix_shells[i], len) == 0) && 436 (strlen(name) >= len && (name[len] == '\0' || name[len] == '.'))) 437 #else 438 if ((strncmp (name, unix_shells[i], len) == 0) && 439 (strlen(name) >= len && name[len] == '\0')) 440 #endif 441 return 1; /* a known unix-style shell */ 442 } 443 444 /* if not on the list, assume it's not a Bourne-like shell */ 445 return 0; 446 } 447 385 448 386 449 … … 537 600 { 538 601 completed_child = c; 539 DB (DB_JOBS, (_("builtin child 0x%08lx (%s) PID %ld%s Status %ld\n"),540 ( unsigned long int)c, c->file->name,541 (long) c->pid, c->remote ? _(" (remote)") : "",602 DB (DB_JOBS, (_("builtin child %p (%s) PID %s %s Status %ld\n"), 603 (void *)c, c->file->name, 604 pid2str (c->pid), c->remote ? _(" (remote)") : "", 542 605 (long) c->status)); 543 606 } 544 607 else 545 608 #endif 546 DB (DB_JOBS, (_("Live child 0x%08lx (%s) PID %ld%s\n"),547 ( unsigned long int) c, c->file->name,548 (long) c->pid,c->remote ? _(" (remote)") : ""));609 DB (DB_JOBS, (_("Live child %p (%s) PID %s %s\n"), 610 (void *)c, c->file->name, pid2str (c->pid), 611 c->remote ? _(" (remote)") : "")); 549 612 #ifdef VMS 550 613 break; … … 681 744 } 682 745 else 683 DB (DB_VERBOSE, ("Main thread handle = 0x%08lx\n", 684 (unsigned long)main_thread)); 746 DB (DB_VERBOSE, ("Main thread handle = %p\n", main_thread)); 685 747 } 686 748 … … 745 807 746 808 DB (DB_JOBS, (child_failed 747 ? _("Reaping losing child 0x%08lx PID %ld %s\n") 748 : _("Reaping winning child 0x%08lx PID %ld %s\n"), 749 (unsigned long int) c, (long) c->pid, 750 c->remote ? _(" (remote)") : "")); 809 ? _("Reaping losing child %p PID %s %s\n") 810 : _("Reaping winning child %p PID %s %s\n"), 811 (void *)c, pid2str (c->pid), c->remote ? _(" (remote)") : "")); 751 812 752 813 if (c->sh_batch_file) { … … 859 920 notice_finished_file (c->file); 860 921 861 DB (DB_JOBS, (_("Removing child 0x%08lx PID %ld%s from chain.\n"), 862 (unsigned long int) c, (long) c->pid, 863 c->remote ? _(" (remote)") : "")); 922 DB (DB_JOBS, (_("Removing child %p PID %s%s from chain.\n"), 923 (void *)c, pid2str (c->pid), c->remote ? _(" (remote)") : "")); 864 924 865 925 /* Block fatal signals while frobnicating the list, so that … … 908 968 #endif 909 969 if (!jobserver_tokens) 910 fatal (NILF, "INTERNAL: Freeing child 0x%08lx(%s) but no tokens left!\n",911 ( unsigned long int)child, child->file->name);970 fatal (NILF, "INTERNAL: Freeing child %p (%s) but no tokens left!\n", 971 (void *)child, child->file->name); 912 972 913 973 /* If we're using the jobserver and this child is not the only outstanding … … 925 985 pfatal_with_name (_("write jobserver")); 926 986 927 DB (DB_JOBS, (_("Released token for child 0x%08lx(%s).\n"),928 ( unsigned long int)child, child->file->name));987 DB (DB_JOBS, (_("Released token for child %p (%s).\n"), 988 (void *)child, child->file->name)); 929 989 } 930 990 … … 1031 1091 rval = sigaction (SIGCLD, &sa, NULL); 1032 1092 #endif 1033 if (rval != 0) 1093 if (rval != 0) 1034 1094 fprintf (stderr, "sigaction: %s (%d)\n", strerror (errno), errno); 1035 1095 #if defined SIGALRM … … 1062 1122 static int bad_stdin = -1; 1063 1123 #endif 1064 register char *p; 1065 int flags; 1124 char *p; 1125 /* Must be volatile to silence bogus GCC warning about longjmp/vfork. */ 1126 /*volatile*/ int flags; 1066 1127 #ifdef VMS 1067 1128 char *argv; 1068 1129 #else 1069 1130 char **argv; 1131 char ** volatile volatile_argv; 1132 int volatile volatile_flags; 1070 1133 #endif 1071 1134 … … 1229 1292 unixy_shell /* the test is complicated and we already did it */ 1230 1293 #else 1231 (argv[0] && !strcmp (argv[0], "/bin/sh")) 1232 #endif 1233 && (argv[1] 1234 && argv[1][0] == '-' && argv[1][1] == 'c' && argv[1][2] == '\0') 1294 (argv[0] && is_bourne_compatible_shell(argv[0])) 1295 #endif 1296 && (argv[1] && argv[1][0] == '-' 1297 && 1298 ((argv[1][1] == 'c' && argv[1][2] == '\0') 1299 || 1300 (argv[1][1] == 'e' && argv[1][2] == 'c' && argv[1][3] == '\0'))) 1235 1301 && (argv[2] && argv[2][0] == ':' && argv[2][1] == '\0') 1236 1302 && argv[3] == NULL) … … 1435 1501 1436 1502 #else /* !__EMX__ */ 1503 volatile_argv = argv; /* shut up gcc */ 1504 volatile_flags = flags; /* ditto */ 1437 1505 1438 1506 child->pid = vfork (); 1439 1507 environ = parent_environ; /* Restore value child may have clobbered. */ 1508 argv = volatile_argv; /* shut up gcc */ 1440 1509 if (child->pid == 0) 1441 1510 { … … 1445 1514 /* If we aren't running a recursive command and we have a jobserver 1446 1515 pipe, close it before exec'ing. */ 1447 if (!( flags & COMMANDS_RECURSE) && job_fds[0] >= 0)1516 if (!(volatile_flags & COMMANDS_RECURSE) && job_fds[0] >= 0) 1448 1517 { 1449 1518 close (job_fds[0]); … … 1452 1521 if (job_rfd >= 0) 1453 1522 close (job_rfd); 1523 1524 #ifdef SET_STACK_SIZE 1525 /* Reset limits, if necessary. */ 1526 if (stack_limit.rlim_cur) 1527 setrlimit (RLIMIT_STACK, &stack_limit); 1528 #endif 1454 1529 1455 1530 child_execute_job (child->good_stdin ? 0 : bad_stdin, 1, … … 1553 1628 1554 1629 if (hPID != INVALID_HANDLE_VALUE) 1555 child->pid = ( int) hPID;1630 child->pid = (pid_t) hPID; 1556 1631 else { 1557 1632 int i; … … 1675 1750 case cs_running: 1676 1751 c->next = children; 1677 DB (DB_JOBS, (_("Putting child 0x%08lx (%s) PID %ld%s on the chain.\n"),1678 ( unsigned long int) c, c->file->name,1679 (long) c->pid,c->remote ? _(" (remote)") : ""));1752 DB (DB_JOBS, (_("Putting child %p (%s) PID %s%s on the chain.\n"), 1753 (void *)c, c->file->name, pid2str (c->pid), 1754 c->remote ? _(" (remote)") : "")); 1680 1755 children = c; 1681 1756 /* One more job slot is in use. */ … … 1820 1895 Copy the remaining uninteresting text to the output. */ 1821 1896 if (out != in) 1822 strcpy (out, in);1897 memmove (out, in, strlen (in) + 1); 1823 1898 1824 1899 /* Finally, expand the line. */ … … 1830 1905 `struct child', and add that to the chain. */ 1831 1906 1832 c = xmalloc (sizeof (struct child)); 1833 memset (c, '\0', sizeof (struct child)); 1907 c = xcalloc (sizeof (struct child)); 1834 1908 c->file = file; 1835 1909 c->command_lines = lines; … … 1935 2009 if (got_token == 1) 1936 2010 { 1937 DB (DB_JOBS, (_("Obtained token for child 0x%08lx(%s).\n"),1938 ( unsigned long int)c, c->file->name));2011 DB (DB_JOBS, (_("Obtained token for child %p (%s).\n"), 2012 (void *)c, c->file->name)); 1939 2013 break; 1940 2014 } … … 2288 2362 int i; 2289 2363 fprintf(stderr, 2290 _("process_easy() failed failedto launch process (e=%ld)\n"),2364 _("process_easy() failed to launch process (e=%ld)\n"), 2291 2365 process_last_err(hPID)); 2292 2366 for (i = 0; argv[i]; i++) … … 2317 2391 break; 2318 2392 else 2393 { 2394 char *pidstr = xstrdup (pid2str ((pid_t)hWaitPID)); 2395 2319 2396 fprintf(stderr, 2320 _("make reaped child pid %ld, still waiting for pid %ld\n"), 2321 (DWORD)hWaitPID, (DWORD)hPID); 2397 _("make reaped child pid %s, still waiting for pid %s\n"), 2398 pidstr, pid2str ((pid_t)hPID)); 2399 free (pidstr); 2400 } 2322 2401 } 2323 2402 … … 2478 2557 static char ** 2479 2558 construct_command_argv_internal (char *line, char **restp, char *shell, 2480 char * ifs, int flags,2559 char *shellflags, char *ifs, int flags, 2481 2560 char **batch_filename_ptr) 2482 2561 { … … 2519 2598 "continue", "export", "read", "readonly", 2520 2599 "shift", "times", "trap", "switch", "unset", 2521 0 };2600 "ulimit", 0 }; 2522 2601 2523 2602 char *sh_chars; … … 2561 2640 #elif defined (WINDOWS32) 2562 2641 static char sh_chars_dos[] = "\"|&<>"; 2563 static char *sh_cmds_dos[] = { "break", "call", "cd", "chcp", "chdir", "cls", 2564 "copy", "ctty", "date", "del", "dir", "echo", 2565 "erase", "exit", "for", "goto", "if", "if", "md", 2566 "mkdir", "path", "pause", "prompt", "rd", "rem", 2567 "ren", "rename", "rmdir", "set", "shift", "time", 2568 "type", "ver", "verify", "vol", ":", 0 }; 2642 static char *sh_cmds_dos[] = { "assoc", "break", "call", "cd", "chcp", 2643 "chdir", "cls", "color", "copy", "ctty", 2644 "date", "del", "dir", "echo", "echo.", 2645 "endlocal", "erase", "exit", "for", "ftype", 2646 "goto", "if", "if", "md", "mkdir", "path", 2647 "pause", "prompt", "rd", "rem", "ren", 2648 "rename", "rmdir", "set", "setlocal", 2649 "shift", "time", "title", "type", "ver", 2650 "verify", "vol", ":", 0 }; 2569 2651 static char sh_chars_sh[] = "#;\"*?[]&|<>(){}$`^"; 2570 2652 static char *sh_cmds_sh[] = { "cd", "eval", "exec", "exit", "login", … … 2588 2670 "login", "logout", "read", "readonly", "set", 2589 2671 "shift", "switch", "test", "times", "trap", 2590 "u mask", "wait", "while", 0 };2672 "ulimit", "umask", "unset", "wait", "while", 0 }; 2591 2673 # ifdef HAVE_DOS_PATHS 2592 2674 /* This is required if the MSYS/Cygwin ports (which do not define … … 2727 2809 if (*ap != ' ' && *ap != '\t' && *ap != '\n') 2728 2810 goto slow; 2811 2812 if (shellflags != 0) 2813 if (shellflags[0] != '-' 2814 || ((shellflags[1] != 'c' || shellflags[2] != '\0') 2815 && (shellflags[1] != 'e' || shellflags[2] != 'c' || shellflags[3] != '\0'))) 2816 goto slow; 2729 2817 2730 2818 i = strlen (line) + 1; … … 2810 2898 goto slow; 2811 2899 #endif /* !KMK */ 2900 else if (one_shell && *p == '\n') 2901 /* In .ONESHELL mode \n is a separator like ; or && */ 2902 goto slow; 2812 2903 #ifdef __MSDOS__ 2813 2904 else if (*p == '.' && p[1] == '.' && p[2] == '.' && p[3] != '.') … … 3032 3123 return 0; 3033 3124 #endif /* WINDOWS32 */ 3125 3034 3126 { 3035 3127 /* SHELL may be a multi-word command. Construct a command line 3036 " SHELL -cLINE", with all special chars in LINE escaped.3128 "$(SHELL) $(.SHELLFLAGS) LINE", with all special chars in LINE escaped. 3037 3129 Then recurse, expanding this command line to get the final 3038 3130 argument list. */ 3039 3131 3040 3132 unsigned int shell_len = strlen (shell); 3041 #ifndef VMS3042 static char minus_c[] = " -c ";3043 #else3044 static char minus_c[] = "";3045 #endif3046 3133 unsigned int line_len = strlen (line); 3047 3048 char *new_line = alloca (shell_len + (sizeof (minus_c)-1) 3049 + (line_len*2) + 1); 3134 unsigned int sflags_len = strlen (shellflags); 3050 3135 char *command_ptr = NULL; /* used for batch_mode_shell mode */ 3136 char *new_line; 3051 3137 3052 3138 # ifdef __EMX__ /* is this necessary? */ 3053 3139 if (!unixy_shell) 3054 minus_c[1] = '/'; /* " /c" */3140 shellflags[0] = '/'; /* "/c" */ 3055 3141 # endif 3056 3142 3143 /* In .ONESHELL mode we are allowed to throw the entire current 3144 recipe string at a single shell and trust that the user 3145 has configured the shell and shell flags, and formatted 3146 the string, appropriately. */ 3147 if (one_shell) 3148 { 3149 /* If the shell is Bourne compatible, we must remove and ignore 3150 interior special chars [@+-] because they're meaningless to 3151 the shell itself. If, however, we're in .ONESHELL mode and 3152 have changed SHELL to something non-standard, we should 3153 leave those alone because they could be part of the 3154 script. In this case we must also leave in place 3155 any leading [@+-] for the same reason. */ 3156 3157 /* Remove and ignore interior prefix chars [@+-] because they're 3158 meaningless given a single shell. */ 3159 #if defined __MSDOS__ || defined (__EMX__) 3160 if (unixy_shell) /* the test is complicated and we already did it */ 3161 #else 3162 if (is_bourne_compatible_shell(shell)) 3163 #endif 3164 { 3165 const char *f = line; 3166 char *t = line; 3167 3168 /* Copy the recipe, removing and ignoring interior prefix chars 3169 [@+-]: they're meaningless in .ONESHELL mode. */ 3170 while (f[0] != '\0') 3171 { 3172 int esc = 0; 3173 3174 /* This is the start of a new recipe line. 3175 Skip whitespace and prefix characters. */ 3176 while (isblank (*f) || *f == '-' || *f == '@' || *f == '+') 3177 ++f; 3178 3179 /* Copy until we get to the next logical recipe line. */ 3180 while (*f != '\0') 3181 { 3182 *(t++) = *(f++); 3183 if (f[-1] == '\\') 3184 esc = !esc; 3185 else 3186 { 3187 /* On unescaped newline, we're done with this line. */ 3188 if (f[-1] == '\n' && ! esc) 3189 break; 3190 3191 /* Something else: reset the escape sequence. */ 3192 esc = 0; 3193 } 3194 } 3195 } 3196 *t = '\0'; 3197 } 3198 3199 new_argv = xmalloc (4 * sizeof (char *)); 3200 new_argv[0] = xstrdup(shell); 3201 new_argv[1] = xstrdup(shellflags); 3202 new_argv[2] = line; 3203 new_argv[3] = NULL; 3204 return new_argv; 3205 } 3206 3207 new_line = alloca (shell_len + 1 + sflags_len + 1 3208 + (line_len*2) + 1); 3057 3209 ap = new_line; 3058 3210 memcpy (ap, shell, shell_len); 3059 3211 ap += shell_len; 3060 memcpy (ap, minus_c, sizeof (minus_c) - 1); 3061 ap += sizeof (minus_c) - 1; 3212 *(ap++) = ' '; 3213 memcpy (ap, shellflags, sflags_len); 3214 ap += sflags_len; 3215 *(ap++) = ' '; 3062 3216 command_ptr = ap; 3063 3217 for (p = line; *p != '\0'; ++p) … … 3109 3263 *ap++ = *p; 3110 3264 } 3111 if (ap == new_line + shell_len + s izeof (minus_c) - 1)3265 if (ap == new_line + shell_len + sflags_len + 2) 3112 3266 /* Line was empty. */ 3113 3267 return 0; … … 3161 3315 } else 3162 3316 #endif /* WINDOWS32 */ 3317 3163 3318 if (unixy_shell) 3164 new_argv = construct_command_argv_internal (new_line, 0, 0, 0, flags, 0); 3319 new_argv = construct_command_argv_internal (new_line, 0, 0, 0, 0, flags, 0); 3320 3165 3321 #ifdef __EMX__ 3166 3322 else if (!unixy_shell) … … 3173 3329 char *q = new_line; 3174 3330 memcpy (new_line, line, line_len + 1); 3175 /* replace all backslash-newline combination and also following tabs */ 3176 while (*q != '\0') 3331 /* Replace all backslash-newline combination and also following tabs. 3332 Important: stop at the first '\n' because that's what the loop above 3333 did. The next line starting at restp[0] will be executed during the 3334 next call of this function. */ 3335 while (*q != '\0' && *q != '\n') 3177 3336 { 3178 3337 if (q[0] == '\\' && q[1] == '\n') … … 3235 3394 cannot backslash-escape the special characters (see above). */ 3236 3395 new_argv = xmalloc (sizeof (char *)); 3237 line_len = strlen (new_line) - shell_len - s izeof (minus_c) + 1;3396 line_len = strlen (new_line) - shell_len - sflags_len - 2; 3238 3397 new_argv[0] = xmalloc (line_len + 1); 3239 3398 strncpy (new_argv[0], 3240 new_line + shell_len + s izeof (minus_c) - 1, line_len);3399 new_line + shell_len + sflags_len + 2, line_len); 3241 3400 new_argv[0][line_len] = '\0'; 3242 3401 } … … 3270 3429 int cmd_flags, char **batch_filename_ptr) 3271 3430 { 3272 char *shell, *ifs ;3431 char *shell, *ifs, *shellflags; 3273 3432 char **argv; 3274 3433 … … 3375 3534 #endif /* __EMX__ */ 3376 3535 3536 shellflags = allocated_variable_expand_for_file ("$(.SHELLFLAGS)", file); 3377 3537 ifs = allocated_variable_expand_for_file ("$(IFS)", file); 3378 3538 … … 3400 3560 unixy_shell = 1; 3401 3561 batch_mode_shell = 0; 3402 argv = construct_command_argv_internal (line, restp, shell, ifs,3562 argv = construct_command_argv_internal (line, restp, shell, shellflags, ifs, 3403 3563 cmd_flags, batch_filename_ptr); 3404 3564 batch_mode_shell = saved_batch_mode_shell; … … 3410 3570 else 3411 3571 #endif /* CONFIG_WITH_KMK_BUILTIN */ 3412 argv = construct_command_argv_internal (line, restp, shell, ifs,3572 argv = construct_command_argv_internal (line, restp, shell, shellflags, ifs, 3413 3573 cmd_flags, batch_filename_ptr); 3414 3574 3415 3575 free (shell); 3576 free (shellflags); 3416 3577 free (ifs); 3417 3578 #endif /* !VMS */ … … 3437 3598 return fd; 3438 3599 } 3439 #endif /* !HA PE_DUP2 && !_AMIGA */3600 #endif /* !HAVE_DUP2 && !_AMIGA */ 3440 3601 3441 3602 #ifdef CONFIG_WITH_PRINT_TIME_SWITCH -
trunk/src/kmk/job.h
r2101 r2591 1 1 /* Definitions for managing subprocesses in GNU Make. 2 2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 3 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 3 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 4 Foundation, Inc. 4 5 This file is part of GNU Make. 5 6 … … 54 55 int efn; /* Completion event flag number */ 55 56 int cstatus; /* Completion status */ 57 char *comname; /* Temporary command file name */ 56 58 #endif 57 59 char *sh_batch_file; /* Script file for shell commands */ … … 74 76 extern struct child *children; 75 77 78 int is_bourne_compatible_shell(const char *path); 76 79 void new_job (struct file *file); 77 80 void reap_children (int block, int err); -
trunk/src/kmk/kmkbuiltin.c
r2413 r2591 120 120 if (!argv[argc]) 121 121 { 122 printf("kmk_builtin: out of memory. argc=%d len=%d\n", argc, pszEnd - pszCmd + 1);122 printf("kmk_builtin: out of memory. argc=%d len=%d\n", argc, (int)(pszEnd - pszCmd + 1)); 123 123 break; 124 124 } -
trunk/src/kmk/kmkbuiltin/cmp_util.c
r2113 r2591 363 363 364 364 bytes_read = read(fd1, b1, blk_sz); 365 if (bytes_read != blk_sz)365 if (bytes_read != (off_t)blk_sz) 366 366 goto l_read_error; 367 367 368 368 bytes_read = read(fd2, b2, blk_sz); 369 if (bytes_read != blk_sz)369 if (bytes_read != (off_t)blk_sz) 370 370 goto l_read_error; 371 371 -
trunk/src/kmk/kmkbuiltin/darwin.c
r2413 r2591 29 29 #include "config.h" 30 30 #include <sys/stat.h> 31 #include <sys/time.h> 31 32 #include <unistd.h> 32 33 -
trunk/src/kmk/kmkbuiltin/echo.c
r2113 r2591 39 39 #endif /* not lint */ 40 40 #include <sys/cdefs.h> 41 / /__FBSDID("$FreeBSD: src/bin/echo/echo.c,v 1.17 2004/04/06 20:06:46 markm Exp $");41 /*__FBSDID("$FreeBSD: src/bin/echo/echo.c,v 1.17 2004/04/06 20:06:46 markm Exp $");*/ 42 42 #endif 43 43 -
trunk/src/kmk/kmkbuiltin/expr.c
r2121 r2591 281 281 } 282 282 283 #ifdef __GNUC__ 284 __attribute__((noreturn)) 285 #endif 283 286 static void 284 287 error(void) -
trunk/src/kmk/kmkbuiltin/kDepObj.c
r2413 r2591 274 274 275 275 /* process selected record types. */ 276 dprintf(("%#07 x: %#04x %#05x\n", (const KU8*)pHdr - pbFile, pHdr->bType, pHdr->cbRec));276 dprintf(("%#07" KUPTR_PRI ": %#04x %#05x\n", (const KU8*)pHdr - pbFile, pHdr->bType, pHdr->cbRec)); 277 277 switch (pHdr->bType) 278 278 { … … 692 692 if (off + 8 > cbSrcFiles) 693 693 { 694 fprintf(stderr, "%s: CV source file entry at %08" KX32_PRI " is too long; cbSrcFiles=%#" K SIZE_PRI "\n",694 fprintf(stderr, "%s: CV source file entry at %08" KX32_PRI " is too long; cbSrcFiles=%#" KX32_PRI "\n", 695 695 argv0, off, cbSrcFiles); 696 696 return 1; … … 701 701 if (off + cbSrc > cbSrcFiles) 702 702 { 703 fprintf(stderr, "%s: CV source file entry at %08" KX32_PRI " is too long; cbSrc=%#" KX32_PRI " cbSrcFiles=%#" K SIZE_PRI "\n",703 fprintf(stderr, "%s: CV source file entry at %08" KX32_PRI " is too long; cbSrc=%#" KX32_PRI " cbSrcFiles=%#" KX32_PRI "\n", 704 704 argv0, off, cbSrc, cbSrcFiles); 705 705 return 1; -
trunk/src/kmk/kmkbuiltin/kbuild_version.c
r2413 r2591 53 53 54 54 printf("%.*s - kBuild version %d.%d.%d (r%u)\n", 55 tmp - argv0, argv0,55 (int)(tmp - argv0), argv0, 56 56 KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, KBUILD_VERSION_PATCH, 57 57 KBUILD_SVN_REV); -
trunk/src/kmk/kmkbuiltin/printf.c
r2141 r2591 207 207 (void)funcname; 208 208 if (rc != 0) 209 fatal (NILF, _("$(%s): failure rc=%d\n"), rc);209 fatal (NILF, _("$(%s): failure rc=%d\n"), funcname, rc); 210 210 return o; 211 211 } -
trunk/src/kmk/main.c
r2549 r2591 1 1 /* Argument parsing and main program of GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 81 81 void print_dir_data_base (void); 82 82 void print_rule_data_base (void); 83 void print_file_data_base (void);84 83 void print_vpath_data_base (void); 85 84 … … 110 109 static void decode_switches (int argc, char **argv, int env); 111 110 static void decode_env_switches (char *envar, unsigned int len); 112 static voiddefine_makeflags (int all, int makefile);111 static const char *define_makeflags (int all, int makefile); 113 112 static char *quote_for_env (char *out, const char *in); 114 113 static void initialize_global_hash_tables (void); … … 265 264 static struct stringlist *makefiles = 0; 266 265 266 /* Size of the stack when we started. */ 267 268 #ifdef SET_STACK_SIZE 269 struct rlimit stack_limit; 270 #endif 271 272 267 273 /* Number of job slots (commands that can be run at once). */ 268 274 … … 309 315 310 316 static struct stringlist *new_files = 0; 317 318 /* List of strings to be eval'd. */ 319 static struct stringlist *eval_strings = 0; 311 320 312 321 /* If nonzero, we should just print usage and exit. */ … … 382 391 -e, --environment-overrides\n\ 383 392 Environment variables override makefiles.\n"), 393 N_("\ 394 --eval=STRING Evaluate STRING as a makefile statement.\n"), 384 395 N_("\ 385 396 -f FILE, --file=FILE, --makefile=FILE\n\ … … 544 555 { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0, 545 556 "warn-undefined-variables" }, 557 { CHAR_MAX+6, string, &eval_strings, 1, 0, 0, 0, 0, "eval" }, 546 558 { 0, 0, 0, 0, 0, 0, 0, 0, 0 } 547 559 }; … … 596 608 unsigned int makelevel; 597 609 598 /* First file defined in the makefile whose name does not 599 start with `.'. This is the default to remake if the 600 command line does not specify. */ 601 602 struct file *default_goal_file; 603 604 /* Pointer to the value of the .DEFAULT_GOAL special 605 variable. */ 606 char ** default_goal_name; 610 /* Pointer to the value of the .DEFAULT_GOAL special variable. 611 The value will be the name of the goal to remake if the command line 612 does not override it. It can be set by the makefile, or else it's 613 the first target defined in the makefile whose name does not start 614 with '.'. */ 615 616 struct variable * default_goal_var; 607 617 608 618 /* Pointer to structure for the file .DEFAULT … … 622 632 int second_expansion; 623 633 634 /* Nonzero if we have seen the '.ONESHELL' target. 635 This causes the entire recipe to be handed to SHELL 636 as a single string, potentially containing newlines. */ 637 638 int one_shell; 639 624 640 #ifdef CONFIG_WITH_2ND_TARGET_EXPANSION 625 641 /* Nonzero if we have seen the '.SECONDTARGETEXPANSION' target. … … 630 646 631 647 #ifndef CONFIG_WITH_EXTENDED_NOTPARALLEL 648 632 649 /* Nonzero if we have seen the `.NOTPARALLEL' target. 633 650 This turns off parallel builds for this invocation of make. */ … … 667 684 #endif 668 685 669 #if ! defined HAVE_BSD_SIGNAL && !defined bsd_signal686 #if !HAVE_DECL_BSD_SIGNAL && !defined bsd_signal 670 687 # if !defined HAVE_SIGACTION 671 688 # define bsd_signal signal 672 689 # else 673 typedef RETSIGTYPE (*bsd_signal_ret_t) ( );690 typedef RETSIGTYPE (*bsd_signal_ret_t) (int); 674 691 675 692 static bsd_signal_ret_t … … 924 941 { 925 942 sprintf(errmsg, 926 _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x% lx)\n"),927 prg, exrec->ExceptionCode, (DWORD)exrec->ExceptionAddress);943 _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x%p)\n"), 944 prg, exrec->ExceptionCode, exrec->ExceptionAddress); 928 945 fprintf(stderr, errmsg); 929 946 exit(255); … … 931 948 932 949 sprintf(errmsg, 933 _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = %lx\n"),950 _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = 0x%p\n"), 934 951 prg, exrec->ExceptionCode, exrec->ExceptionFlags, 935 (DWORD)exrec->ExceptionAddress);952 exrec->ExceptionAddress); 936 953 937 954 if (exrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION … … 939 956 sprintf(&errmsg[strlen(errmsg)], 940 957 (exrec->ExceptionInformation[0] 941 ? _("Access violation: write operation at address %lx\n")942 : _("Access violation: read operation at address %lx\n")),943 exrec->ExceptionInformation[1]);958 ? _("Access violation: write operation at address 0x%p\n") 959 : _("Access violation: read operation at address 0x%p\n")), 960 (PVOID)exrec->ExceptionInformation[1]); 944 961 945 962 /* turn this on if we want to put stuff in the event log too */ … … 1015 1032 sprintf (sh_path, "%s", search_token); 1016 1033 default_shell = xstrdup (w32ify (sh_path, 0)); 1017 DB (DB_VERBOSE, 1018 (_("find_and_set_shell setting default_shell = %s\n"),default_shell));1034 DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"), 1035 default_shell)); 1019 1036 sh_found = 1; 1020 1037 } else if (!no_default_sh_exe && … … 1026 1043 sprintf (sh_path, "%s", search_token); 1027 1044 default_shell = xstrdup (w32ify (sh_path, 0)); 1028 DB (DB_VERBOSE, 1029 (_("find_and_set_shell setting default_shell = %s\n"),default_shell));1045 DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"), 1046 default_shell)); 1030 1047 sh_found = 1; 1031 1048 } else { … … 1068 1085 if (sh_found) 1069 1086 DB (DB_VERBOSE, 1070 (_("find_and_set_shell path search set default_shell = %s\n"),1087 (_("find_and_set_shell() path search set default_shell = %s\n"), 1071 1088 default_shell)); 1072 1089 } … … 1383 1400 1384 1401 /* Set the stack limit huge so that alloca does not fail. */ 1385 if (getrlimit (RLIMIT_STACK, &rlim) == 0) 1402 if (getrlimit (RLIMIT_STACK, &rlim) == 0 1403 && rlim.rlim_cur > 0 && rlim.rlim_cur < rlim.rlim_max) 1386 1404 { 1405 stack_limit = rlim; 1387 1406 rlim.rlim_cur = rlim.rlim_max; 1388 1407 setrlimit (RLIMIT_STACK, &rlim); 1389 1408 } 1409 else 1410 stack_limit.rlim_cur = 0; 1390 1411 } 1391 1412 #endif … … 1402 1423 #endif 1403 1424 1404 default_goal_file = 0;1405 1425 reading_file = 0; 1406 1426 … … 1419 1439 /* Set up gettext/internationalization support. */ 1420 1440 setlocale (LC_ALL, ""); 1441 /* The cast to void shuts up compiler warnings on systems that 1442 disable NLS. */ 1421 1443 #ifdef LOCALEDIR /* bird */ 1422 bindtextdomain (PACKAGE, LOCALEDIR);1423 textdomain (PACKAGE);1444 (void)bindtextdomain (PACKAGE, LOCALEDIR); 1445 (void)textdomain (PACKAGE); 1424 1446 #endif 1425 1447 … … 1432 1454 #define ADD_SIG(sig) fatal_signal_mask |= sigmask (sig) 1433 1455 #else 1434 #define ADD_SIG(sig) 1456 #define ADD_SIG(sig) (void)sig /* Needed to avoid warnings in MSVC. */ 1435 1457 #endif 1436 1458 #endif … … 1587 1609 1588 1610 /* Initialize the special variables. */ 1589 define_variable (".VARIABLES", 10, "", o_default, 0)->special = 1; 1590 /* define_variable (".TARGETS", 8, "", o_default, 0)->special = 1; */ 1591 define_variable (".RECIPEPREFIX", 13, "", o_default, 0)->special = 1; 1592 1593 /* Set up .FEATURES */ 1594 define_variable (".FEATURES", 9, 1595 "target-specific order-only second-expansion else-if", 1596 o_default, 0); 1611 define_variable_cname (".VARIABLES", "", o_default, 0)->special = 1; 1612 /* define_variable_cname (".TARGETS", "", o_default, 0)->special = 1; */ 1613 define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1; 1614 define_variable_cname (".SHELLFLAGS", "-c", o_default, 0); 1615 1616 /* Set up .FEATURES 1617 We must do this in multiple calls because define_variable_cname() is 1618 a macro and some compilers (MSVC) don't like conditionals in macros. */ 1619 { 1620 const char *features = "target-specific order-only second-expansion" 1621 " else-if shortest-stem undefine" 1597 1622 #ifndef NO_ARCHIVES 1598 do_variable_definition (NILF, ".FEATURES", "archives", 1599 o_default, f_append, 0); 1623 " archives" 1600 1624 #endif 1601 1625 #ifdef MAKE_JOBSERVER 1602 do_variable_definition (NILF, ".FEATURES", "jobserver", 1603 o_default, f_append, 0); 1626 " jobserver" 1604 1627 #endif 1605 1628 #ifdef MAKE_SYMLINKS 1606 do_variable_definition (NILF, ".FEATURES", "check-symlink", 1607 o_default, f_append, 0); 1629 " check-symlink" 1608 1630 #endif 1609 1631 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 1610 do_variable_definition (NILF, ".FEATURES", "explicit-multitarget", 1611 o_default, f_append, 0); 1632 " explicit-multitarget" 1612 1633 #endif 1613 1634 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 1614 do_variable_definition (NILF, ".FEATURES", "prepend-assignment", 1615 o_default, f_append, 0); 1616 #endif 1635 " prepend-assignment" 1636 #endif 1637 ; 1638 1639 define_variable_cname (".FEATURES", features, o_default, 0); 1640 } 1617 1641 1618 1642 #ifdef KMK … … 1675 1699 shell_var.name = v->name; 1676 1700 #endif 1677 shell_var.length = 5; /* bird - gotta set the length too! */1701 shell_var.length = 5; 1678 1702 #ifndef CONFIG_WITH_VALUE_LENGTH 1679 1703 shell_var.value = xstrdup (ep + 1); 1680 1704 #else 1681 shell_var.value = savestring(v->value, v->value_length);1705 shell_var.value = xstrndup (v->value, v->value_length); 1682 1706 shell_var.value_length = v->value_length; 1683 1707 #endif 1684 1685 1708 } 1686 1709 … … 1699 1722 */ 1700 1723 if (!unix_path) 1701 define_variable("PATH", 4, 1702 windows32_path ? windows32_path : "", 1703 o_env, 1)->export = v_export; 1724 define_variable_cname ("PATH", windows32_path ? windows32_path : "", 1725 o_env, 1)->export = v_export; 1704 1726 #endif 1705 1727 #else /* For Amiga, read the ENV: device, ignoring all dirs */ … … 1747 1769 #endif 1748 1770 #endif /* !KMK */ 1771 1749 1772 decode_switches (argc, argv, 0); 1773 1750 1774 #ifdef WINDOWS32 1751 1775 if (suspend_flag) { … … 1815 1839 # endif 1816 1840 ) 1817 argv[0] = xstrdup (concat ( current_directory, "/", argv[0]));1841 argv[0] = xstrdup (concat (3, current_directory, "/", argv[0])); 1818 1842 #else /* !__MSDOS__ */ 1819 1843 if (current_directory[0] != '\0' … … 1824 1848 #endif 1825 1849 ) 1826 argv[0] = xstrdup (concat ( current_directory, "/", argv[0]));1850 argv[0] = xstrdup (concat (3, current_directory, "/", argv[0])); 1827 1851 #endif /* !__MSDOS__ */ 1828 1852 #endif /* WINDOWS32 */ … … 1831 1855 /* The extra indirection through $(MAKE_COMMAND) is done 1832 1856 for hysterical raisins. */ 1833 (void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);1834 (void) define_variable ("MAKE", 4, "$(MAKE_COMMAND)", o_default, 1);1857 define_variable_cname ("MAKE_COMMAND", argv[0], o_default, 0); 1858 define_variable_cname ("MAKE", "$(MAKE_COMMAND)", o_default, 1); 1835 1859 #ifdef KMK 1836 1860 (void) define_variable ("KMK", 3, argv[0], o_default, 1); … … 1873 1897 /* Define an unchangeable variable with a name that no POSIX.2 1874 1898 makefile could validly use for its own variable. */ 1875 (void) define_variable ("-*-command-variables-*-", 23, 1876 value, o_automatic, 0); 1899 define_variable_cname ("-*-command-variables-*-", value, o_automatic, 0); 1877 1900 1878 1901 /* Define the variable; this will not override any user definition. … … 1883 1906 a reference to this hidden variable is written instead. */ 1884 1907 #ifdef KMK 1885 (void) define_variable ("KMK_OVERRIDES", 13,1886 "${-*-command-variables-*-}",o_env, 1);1908 define_variable_cname ("KMK_OVERRIDES", "${-*-command-variables-*-}", 1909 o_env, 1); 1887 1910 #else 1888 (void) define_variable ("MAKEOVERRIDES", 13,1889 "${-*-command-variables-*-}",o_env, 1);1911 define_variable_cname ("MAKEOVERRIDES", "${-*-command-variables-*-}", 1912 o_env, 1); 1890 1913 #endif 1891 1914 } … … 2058 2081 } 2059 2082 2060 (void) define_variable ("CURDIR", 6, current_directory, o_file, 0);2083 define_variable_cname ("CURDIR", current_directory, o_file, 0); 2061 2084 2062 2085 /* Read any stdin makefiles into temporary files. */ … … 2198 2221 default_file = enter_file (strcache_add (".DEFAULT")); 2199 2222 2200 { 2201 struct variable *v = define_variable (".DEFAULT_GOAL", 13, "", o_file, 0); 2202 default_goal_name = &v->value; 2203 } 2223 default_goal_var = define_variable_cname (".DEFAULT_GOAL", "", o_file, 0); 2224 2225 /* Evaluate all strings provided with --eval. 2226 Also set up the $(-*-eval-flags-*-) variable. */ 2227 2228 if (eval_strings) 2229 { 2230 char *p, *value; 2231 unsigned int i; 2232 unsigned int len = sizeof ("--eval=") * eval_strings->idx; 2233 2234 for (i = 0; i < eval_strings->idx; ++i) 2235 { 2236 #ifndef CONFIG_WITH_VALUE_LENGTH 2237 p = xstrdup (eval_strings->list[i]); 2238 len += 2 * strlen (p); 2239 eval_buffer (p); 2240 #else 2241 unsigned int sub_len = strlen(eval_strings->list[i]); 2242 p = xstrndup (eval_strings->list[i], sub_len); 2243 len += 2 * sub_len; 2244 eval_buffer (p, p + sub_len); 2245 #endif 2246 free (p); 2247 } 2248 2249 p = value = alloca (len); 2250 for (i = 0; i < eval_strings->idx; ++i) 2251 { 2252 strcpy (p, "--eval="); 2253 p += strlen (p); 2254 p = quote_for_env (p, eval_strings->list[i]); 2255 *(p++) = ' '; 2256 } 2257 p[-1] = '\0'; 2258 2259 define_variable_cname ("-*-eval-flags-*-", value, o_automatic, 0); 2260 } 2204 2261 2205 2262 /* Read all the makefiles. */ … … 2264 2321 2265 2322 if (jobserver_fds) 2266 { 2267 const char *cp; 2268 unsigned int ui; 2269 2270 for (ui=1; ui < jobserver_fds->idx; ++ui) 2271 if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui])) 2272 fatal (NILF, _("internal error: multiple --jobserver-fds options")); 2273 2274 /* Now parse the fds string and make sure it has the proper format. */ 2275 2276 cp = jobserver_fds->list[0]; 2277 2278 if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2) 2279 fatal (NILF, 2280 _("internal error: invalid --jobserver-fds string `%s'"), cp); 2281 2282 DB (DB_JOBS, 2283 (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1])); 2284 2285 /* The combination of a pipe + !job_slots means we're using the 2286 jobserver. If !job_slots and we don't have a pipe, we can start 2287 infinite jobs. If we see both a pipe and job_slots >0 that means the 2288 user set -j explicitly. This is broken; in this case obey the user 2289 (ignore the jobserver pipe for this make) but print a message. */ 2290 2291 if (job_slots > 0) 2292 error (NILF, 2293 _("warning: -jN forced in submake: disabling jobserver mode.")); 2294 2295 /* Create a duplicate pipe, that will be closed in the SIGCHLD 2296 handler. If this fails with EBADF, the parent has closed the pipe 2297 on us because it didn't think we were a submake. If so, print a 2298 warning then default to -j1. */ 2299 2300 else if ((job_rfd = dup (job_fds[0])) < 0) 2301 { 2302 if (errno != EBADF) 2303 pfatal_with_name (_("dup jobserver")); 2304 2323 { 2324 const char *cp; 2325 unsigned int ui; 2326 2327 for (ui=1; ui < jobserver_fds->idx; ++ui) 2328 if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui])) 2329 fatal (NILF, _("internal error: multiple --jobserver-fds options")); 2330 2331 /* Now parse the fds string and make sure it has the proper format. */ 2332 2333 cp = jobserver_fds->list[0]; 2334 2335 if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2) 2336 fatal (NILF, 2337 _("internal error: invalid --jobserver-fds string `%s'"), cp); 2338 2339 DB (DB_JOBS, 2340 (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1])); 2341 2342 /* The combination of a pipe + !job_slots means we're using the 2343 jobserver. If !job_slots and we don't have a pipe, we can start 2344 infinite jobs. If we see both a pipe and job_slots >0 that means the 2345 user set -j explicitly. This is broken; in this case obey the user 2346 (ignore the jobserver pipe for this make) but print a message. */ 2347 2348 if (job_slots > 0) 2305 2349 error (NILF, 2306 _("warning: jobserver unavailable: using -j1. Add `+' to parent make rule.")); 2307 job_slots = 1; 2308 } 2309 2310 if (job_slots > 0) 2311 { 2312 close (job_fds[0]); 2313 close (job_fds[1]); 2314 job_fds[0] = job_fds[1] = -1; 2315 free (jobserver_fds->list); 2316 free (jobserver_fds); 2317 jobserver_fds = 0; 2318 } 2319 } 2350 _("warning: -jN forced in submake: disabling jobserver mode.")); 2351 2352 /* Create a duplicate pipe, that will be closed in the SIGCHLD 2353 handler. If this fails with EBADF, the parent has closed the pipe 2354 on us because it didn't think we were a submake. If so, print a 2355 warning then default to -j1. */ 2356 2357 else if ((job_rfd = dup (job_fds[0])) < 0) 2358 { 2359 if (errno != EBADF) 2360 pfatal_with_name (_("dup jobserver")); 2361 2362 error (NILF, 2363 _("warning: jobserver unavailable: using -j1. Add `+' to parent make rule.")); 2364 job_slots = 1; 2365 } 2366 2367 if (job_slots > 0) 2368 { 2369 close (job_fds[0]); 2370 close (job_fds[1]); 2371 job_fds[0] = job_fds[1] = -1; 2372 free (jobserver_fds->list); 2373 free (jobserver_fds); 2374 jobserver_fds = 0; 2375 } 2376 } 2320 2377 2321 2378 /* If we have >1 slot but no jobserver-fds, then we're a top-level make. … … 2435 2492 FILE_TIMESTAMP *makefile_mtimes = 0; 2436 2493 unsigned int mm_idx = 0; 2437 char **nargv = argv;2438 int nargc = argc;2494 char **nargv; 2495 int nargc; 2439 2496 int orig_db_level = db_level; 2440 2497 int status; … … 2605 2662 if (strneq (argv[i], "-f", 2)) /* XXX */ 2606 2663 { 2607 char *p = &argv[i][2]; 2608 if (*p == '\0') 2664 if (argv[i][2] == '\0') 2609 2665 /* This cast is OK since we never modify argv. */ 2610 2666 argv[++i] = (char *) makefiles->list[j]; 2611 2667 else 2612 argv[i] = xstrdup (concat ( "-f", makefiles->list[j], ""));2668 argv[i] = xstrdup (concat (2, "-f", makefiles->list[j])); 2613 2669 ++j; 2614 2670 } … … 2616 2672 2617 2673 /* Add -o option for the stdin temporary file, if necessary. */ 2674 nargc = argc; 2618 2675 if (stdin_nm) 2619 2676 { 2620 2677 nargv = xmalloc ((nargc + 2) * sizeof (char *)); 2621 2678 memcpy (nargv, argv, argc * sizeof (char *)); 2622 nargv[nargc++] = xstrdup (concat ( "-o", stdin_nm, ""));2679 nargv[nargc++] = xstrdup (concat (2, "-o", stdin_nm)); 2623 2680 nargv[nargc] = 0; 2624 2681 } 2682 else 2683 nargv = argv; 2625 2684 2626 2685 if (directories != 0 && directories->idx > 0) … … 2639 2698 2640 2699 ++restarts; 2700 2701 /* Reset makeflags in case they were changed. */ 2702 { 2703 const char *pv = define_makeflags (1, 1); 2704 char *p = alloca (sizeof ("MAKEFLAGS=") + strlen (pv) + 1); 2705 sprintf (p, "MAKEFLAGS=%s", pv); 2706 putenv (p); 2707 } 2641 2708 2642 2709 if (ISDB (DB_BASIC)) … … 2758 2825 perror_with_name (_("unlink (temporary file): "), stdin_nm); 2759 2826 2827 /* If there were no command-line goals, use the default. */ 2828 if (goals == 0) 2829 { 2830 char *p; 2831 2832 if (default_goal_var->recursive) 2833 p = variable_expand (default_goal_var->value); 2834 else 2835 { 2836 p = variable_buffer_output (variable_buffer, default_goal_var->value, 2837 strlen (default_goal_var->value)); 2838 *p = '\0'; 2839 p = variable_buffer; 2840 } 2841 2842 if (*p != '\0') 2843 { 2844 struct file *f = lookup_file (p); 2845 2846 /* If .DEFAULT_GOAL is a non-existent target, enter it into the 2847 table and let the standard logic sort it out. */ 2848 if (f == 0) 2849 { 2850 struct nameseq *ns; 2851 ns = PARSE_FILE_SEQ (&p, struct nameseq, '\0', NULL, 0); 2852 if (ns) 2853 { 2854 /* .DEFAULT_GOAL should contain one target. */ 2855 if (ns->next != 0) 2856 fatal (NILF, _(".DEFAULT_GOAL contains more than one target")); 2857 2858 #ifndef CONFIG_WITH_VALUE_LENGTH 2859 f = enter_file (strcache_add (ns->name)); 2860 #else 2861 f = enter_file (ns->name); 2862 #endif 2863 2864 ns->name = 0; /* It was reused by enter_file(). */ 2865 free_ns_chain (ns); 2866 } 2867 } 2868 2869 if (f) 2870 { 2871 goals = alloc_dep (); 2872 goals->file = f; 2873 } 2874 } 2875 } 2876 else 2877 lastgoal->next = 0; 2878 2879 2880 if (!goals) 2881 { 2882 if (read_makefiles == 0) 2883 fatal (NILF, _("No targets specified and no makefile found")); 2884 2885 fatal (NILF, _("No targets")); 2886 } 2887 2888 /* Update the goals. */ 2889 2890 DB (DB_BASIC, (_("Updating goal targets....\n"))); 2891 2760 2892 { 2761 2893 int status; 2762 2763 /* If there were no command-line goals, use the default. */2764 if (goals == 0)2765 {2766 if (**default_goal_name != '\0')2767 {2768 if (default_goal_file == 0 ||2769 strcmp (*default_goal_name, default_goal_file->name) != 0)2770 {2771 default_goal_file = lookup_file (*default_goal_name);2772 2773 /* In case user set .DEFAULT_GOAL to a non-existent target2774 name let's just enter this name into the table and let2775 the standard logic sort it out. */2776 if (default_goal_file == 0)2777 {2778 struct nameseq *ns;2779 char *p = *default_goal_name;2780 2781 #ifndef CONFIG_WITH_ALLOC_CACHES2782 ns = multi_glob (2783 parse_file_seq (&p, '\0', sizeof (struct nameseq), 1),2784 sizeof (struct nameseq));2785 #else2786 ns = multi_glob (2787 parse_file_seq (&p, '\0', &nameseq_cache, 1),2788 &nameseq_cache);2789 #endif2790 2791 /* .DEFAULT_GOAL should contain one target. */2792 if (ns->next != 0)2793 fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));2794 2795 #ifndef CONFIG_WITH_VALUE_LENGTH2796 default_goal_file = enter_file (strcache_add (ns->name));2797 #else2798 default_goal_file = enter_file (ns->name);2799 #endif2800 2801 ns->name = 0; /* It was reused by enter_file(). */2802 free_ns_chain (ns);2803 }2804 }2805 2806 goals = alloc_dep ();2807 goals->file = default_goal_file;2808 }2809 }2810 else2811 lastgoal->next = 0;2812 2813 2814 if (!goals)2815 {2816 if (read_makefiles == 0)2817 fatal (NILF, _("No targets specified and no makefile found"));2818 2819 fatal (NILF, _("No targets"));2820 }2821 2822 /* Update the goals. */2823 2824 DB (DB_BASIC, (_("Updating goal targets....\n")));2825 2894 2826 2895 switch (update_goal_chain (goals)) … … 2933 3002 /* Ignore plain `-' for compatibility. */ 2934 3003 return; 2935 #ifndef CONFIG_WITH_VALUE_LENGTH 2936 v = try_variable_definition (0, arg, o_command, 0); 2937 #else 2938 v = try_variable_definition (0, arg, NULL, o_command, 0); 2939 #endif 3004 v = try_variable_definition (0, arg IF_WITH_VALUE_LENGTH_PARAM(NULL), o_command, 0); 2940 3005 if (v != 0) 2941 3006 { … … 2999 3064 value = vp; 3000 3065 } 3001 define_variable ("MAKECMDGOALS", 12, value, o_default, 0);3066 define_variable_cname ("MAKECMDGOALS", value, o_default, 0); 3002 3067 } 3003 3068 } … … 3110 3175 else if (*optarg == '\0') 3111 3176 { 3112 error (NILF, _("the `-%c' option requires a non-empty string argument"), 3113 cs->c); 3177 char opt[2] = "c"; 3178 const char *op = opt; 3179 3180 if (short_option (cs->c)) 3181 opt[0] = cs->c; 3182 else 3183 op = cs->long_name; 3184 3185 error (NILF, _("the `%s%s' option requires a non-empty string argument"), 3186 short_option (cs->c) ? "-" : "--", op); 3114 3187 bad = 1; 3115 3188 } … … 3128 3201 { 3129 3202 sl->max += 5; 3130 sl->list = xrealloc ((void *)sl->list, /* bird */ 3203 /* MSVC erroneously warns without a cast here. */ 3204 sl->list = xrealloc ((void *)sl->list, 3131 3205 sl->max * sizeof (char *)); 3132 3206 } … … 3275 3349 need permanent storage for this in case decode_switches saves 3276 3350 pointers into the value. */ 3277 argv[1] = xstrdup (concat ( "-", argv[1], ""));3351 argv[1] = xstrdup (concat (2, "-", argv[1])); 3278 3352 3279 3353 /* Parse those words. */ … … 3307 3381 Don't include options with the `no_makefile' flag set if MAKEFILE. */ 3308 3382 3309 static void3383 static const char * 3310 3384 define_makeflags (int all, int makefile) 3311 3385 { … … 3313 3387 static const char ref[] = "$(KMK_OVERRIDES)"; 3314 3388 #else 3315 static const char ref[] = "$(MAKEOVERRIDES)"; 3316 #endif 3317 static const char posixref[] = "$(-*-command-variables-*-)"; 3318 register const struct command_switch *cs; 3389 static /*<- bird*/ const char ref[] = "$(MAKEOVERRIDES)"; 3390 #endif 3391 static /*<- bird*/ const char posixref[] = "$(-*-command-variables-*-)"; 3392 static /*<- bird*/ const char evalref[] = "$(-*-eval-flags-*-)"; 3393 const struct command_switch *cs; 3319 3394 char *flagstring; 3320 3395 register char *p; … … 3337 3412 #define ADD_FLAG(ARG, LEN) \ 3338 3413 do { \ 3339 struct flag *new = alloca (sizeof (struct flag)); 3414 struct flag *new = alloca (sizeof (struct flag)); \ 3340 3415 new->cs = cs; \ 3341 3416 new->arg = (ARG); \ … … 3345 3420 ++flagslen; /* Just a single flag letter. */ \ 3346 3421 else \ 3347 flagslen += 1 + 1 + 1 + 1 + 3 * (LEN); /* " -x foo" */ \ 3422 /* " -x foo", plus space to expand "foo". */ \ 3423 flagslen += 1 + 1 + 1 + 1 + (3 * (LEN)); \ 3348 3424 if (!short_option (cs->c)) \ 3349 3425 /* This switch has no single-letter version, so we use the long. */ \ … … 3434 3510 } 3435 3511 3436 flagslen += 4 + sizeof posixref; /* Four more for the possible " -- ". */ 3512 /* Four more for the possible " -- ". */ 3513 flagslen += 4 + sizeof (posixref) + sizeof (evalref); 3437 3514 3438 3515 #undef ADD_FLAG … … 3507 3584 /* Since MFLAGS is not parsed for flags, there is no reason to 3508 3585 override any makefile redefinition. */ 3509 (void) define_variable ("MFLAGS", 6, flagstring, o_env, 1);3586 define_variable_cname ("MFLAGS", flagstring, o_env, 1); 3510 3587 #endif /* !KMK */ 3588 3589 /* Write a reference to -*-eval-flags-*-, which contains all the --eval 3590 flag options. */ 3591 if (eval_strings) 3592 { 3593 if (p == &flagstring[1]) 3594 /* No flags written, so elide the leading dash already written. */ 3595 p = flagstring; 3596 else 3597 *p++ = ' '; 3598 memcpy (p, evalref, sizeof (evalref) - 1); 3599 p += sizeof (evalref) - 1; 3600 } 3511 3601 3512 3602 if (all && command_variables != 0) … … 3535 3625 if (posix_pedantic) 3536 3626 { 3537 memcpy (p, posixref, sizeof posixref- 1);3538 p += sizeof posixref- 1;3627 memcpy (p, posixref, sizeof (posixref) - 1); 3628 p += sizeof (posixref) - 1; 3539 3629 } 3540 3630 else 3541 3631 { 3542 memcpy (p, ref, sizeof ref- 1);3543 p += sizeof ref- 1;3632 memcpy (p, ref, sizeof (ref) - 1); 3633 p += sizeof (ref) - 1; 3544 3634 } 3545 3635 } … … 3555 3645 *p = '\0'; 3556 3646 3647 /* If there are switches, omit the leading dash unless it is a single long 3648 option with two leading dashes. */ 3649 if (flagstring[0] == '-' && flagstring[1] != '-') 3650 ++flagstring; 3651 3557 3652 #ifdef KMK 3558 v = define_variable ("KMK_FLAGS", 9, 3559 /* If there are switches, omit the leading dash 3560 unless it is a single long option with two 3561 leading dashes. */ 3562 &flagstring[(flagstring[0] == '-' 3563 && flagstring[1] != '-') 3564 ? 1 : 0], 3565 /* This used to use o_env, but that lost when a 3566 makefile defined MAKEFLAGS. Makefiles set 3567 MAKEFLAGS to add switches, but we still want 3568 to redefine its value with the full set of 3569 switches. Of course, an override or command 3570 definition will still take precedence. */ 3571 o_file, 1); 3653 v = define_variable_cname ("KMK_FLAGS", flagstring, 3654 /* This used to use o_env, but that lost when a 3655 makefile defined MAKEFLAGS. Makefiles set 3656 MAKEFLAGS to add switches, but we still want 3657 to redefine its value with the full set of 3658 switches. Of course, an override or command 3659 definition will still take precedence. */ 3660 o_file, 1); 3572 3661 #else 3573 v = define_variable ("MAKEFLAGS", 9, 3574 /* If there are switches, omit the leading dash 3575 unless it is a single long option with two 3576 leading dashes. */ 3577 &flagstring[(flagstring[0] == '-' 3578 && flagstring[1] != '-') 3579 ? 1 : 0], 3580 /* This used to use o_env, but that lost when a 3581 makefile defined MAKEFLAGS. Makefiles set 3582 MAKEFLAGS to add switches, but we still want 3583 to redefine its value with the full set of 3584 switches. Of course, an override or command 3585 definition will still take precedence. */ 3586 o_file, 1); 3587 #endif 3662 v = define_variable_cname ("MAKEFLAGS", flagstring, 3663 /* This used to use o_env, but that lost when a 3664 makefile defined MAKEFLAGS. Makefiles set 3665 MAKEFLAGS to add switches, but we still want 3666 to redefine its value with the full set of 3667 switches. Of course, an override or command 3668 definition will still take precedence. */ 3669 o_file, 1); 3670 #endif 3671 3588 3672 if (! all) 3589 3673 /* The first time we are called, set MAKEFLAGS to always be exported. … … 3597 3681 char val[32]; 3598 3682 sprintf (val, "%u", job_slots); 3599 define_variable ("KMK_OPTS_JOBS", sizeof("KMK_OPTS_JOBS") - 1, 3600 val, o_default, 1); 3601 define_variable ("KMK_OPTS_KEEP_GOING", sizeof("KMK_OPTS_KEEP_GOING") - 1, 3602 keep_going_flag ? "1" : "0", o_default, 1); 3603 define_variable ("KMK_OPTS_JUST_PRINT", sizeof("KMK_OPTS_JUST_PRINT") - 1, 3604 just_print_flag ? "1" : "0", o_default, 1); 3605 define_variable ("KMK_OPTS_PRETTY_COMMAND_PRINTING", sizeof("KMK_OPTS_PRETTY_COMMAND_PRINTING") - 1, 3606 pretty_command_printing ? "1" : "0", o_default, 1); 3683 define_variable_cname ("KMK_OPTS_JOBS", val, o_default, 1); 3684 define_variable_cname ("KMK_OPTS_KEEP_GOING", keep_going_flag ? "1" : "0", o_default, 1); 3685 define_variable_cname ("KMK_OPTS_JUST_PRINT", just_print_flag ? "1" : "0", o_default, 1); 3686 define_variable_cname ("KMK_OPTS_PRETTY_COMMAND_PRINTING", 3687 pretty_command_printing ? "1" : "0", o_default, 1); 3607 3688 sprintf (val, "%u", process_priority); 3608 define_variable ("KMK_OPTS_PRORITY", sizeof("KMK_OPTS_PRORITY") - 1, 3609 val, o_default, 1); 3689 define_variable_cname ("KMK_OPTS_PRORITY", val, o_default, 1); 3610 3690 sprintf (val, "%u", process_affinity); 3611 define_variable ("KMK_OPTS_AFFINITY", sizeof("KMK_OPTS_AFFINITY") - 1, 3612 val, o_default, 1); 3613 #if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS) 3614 define_variable ("KMK_OPTS_STATISTICS", sizeof("KMK_OPTS_STATISTICS") - 1, 3615 make_expensive_statistics ? "1" : "0", o_default, 1); 3691 define_variable_cname ("KMK_OPTS_AFFINITY", val, o_default, 1); 3692 # if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS) 3693 define_variable_cname ("KMK_OPTS_STATISTICS", make_expensive_statistics ? "1" : "0", 3694 o_default, 1); 3616 3695 # endif 3617 # ifdef CONFIG_WITH_PRINT_TIME_SWITCH3696 # ifdef CONFIG_WITH_PRINT_TIME_SWITCH 3618 3697 sprintf (val, "%u", print_time_min); 3619 define_variable ("KMK_OPTS_PRINT_TIME", sizeof("KMK_OPTS_PRINT_TIME") - 1, 3620 val, o_default, 1); 3621 #endif 3698 define_variable_cname ("KMK_OPTS_PRINT_TIME", val, o_default, 1); 3699 # endif 3622 3700 } 3623 3701 #endif 3702 3703 return v->value; 3624 3704 } 3625 3705 … … 3661 3741 word "Copyright", so it hardly seems worth it. */ 3662 3742 3663 printf ("%sCopyright (C) 20 07Free Software Foundation, Inc.\n", precede);3743 printf ("%sCopyright (C) 2010 Free Software Foundation, Inc.\n", precede); 3664 3744 3665 3745 printf (_("%sLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ … … 3818 3898 3819 3899 close (job_fds[0]); 3900 3901 /* Clean out jobserver_fds so we don't pass this information to any 3902 sub-makes. Also reset job_slots since it will be put on the command 3903 line, not in MAKEFLAGS. */ 3904 job_slots = default_job_slots; 3905 if (jobserver_fds) 3906 { 3907 /* MSVC erroneously warns without a cast here. */ 3908 free ((void *)jobserver_fds->list); 3909 free (jobserver_fds); 3910 jobserver_fds = 0; 3911 } 3820 3912 } 3821 3913 } … … 3882 3974 of relative pathnames fail. */ 3883 3975 if (directory_before_chdir != 0) 3884 chdir (directory_before_chdir); 3976 { 3977 /* If it fails we don't care: shut up GCC. */ 3978 int _x; 3979 _x = chdir (directory_before_chdir); 3980 } 3885 3981 3886 3982 #ifdef CONFIG_WITH_PRINT_TIME_SWITCH -
trunk/src/kmk/maintMakefile
r2421 r2591 148 148 && (cd "$$tmppo" \ 149 149 && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) \ 150 && cp "$$tmppo"/*.po po && rm -rf "$$tmppo"150 && cp "$$tmppo"/*.po $(top_srcdir)/po && rm -rf "$$tmppo" 151 151 cd po && $(MAKE) update-po 152 152 $(MAKE) po-check 153 153 154 154 po-update: 155 if test -d "po"; then \ 156 $(MAKE) do-po-update; \ 157 fi 155 [ -d "po" ] && $(MAKE) do-po-update 158 156 159 157 # -------------------------- # … … 165 163 # regularly updated from the specified URL. 166 164 167 savannah-url = http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~ 165 cvs-url = http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~ 166 git-url = http://git.savannah.gnu.org/cgit 168 167 target = $(patsubst get-%,%,$@) 169 168 170 config-url = $( savannah-url)/config/config/$(patsubst get-config/%,%,$@)169 config-url = $(git-url)/config.git/plain/$(patsubst get-config/%,%,$@) 171 170 get-config/config.guess get-config/config.sub: 172 171 @echo $(WGET) $(config-url) -O $(target) \ … … 174 173 && $(move_if_change) 175 174 176 gnulib-url = $( savannah-url)/gnulib/gnulib/build-aux/$(patsubst get-config/%,%,$@)175 gnulib-url = $(git-url)/gnulib.git/plain/build-aux/$(patsubst get-config/%,%,$@) 177 176 get-config/texinfo.tex: 178 177 @echo $(WGET) $(gnulib-url) -O $(target) \ … … 180 179 && $(move_if_change) 181 180 182 gnustandards-url = $( savannah-url)/gnustandards/gnustandards/$(patsubst get-doc/%,%,$@)181 gnustandards-url = $(cvs-url)/gnustandards/gnustandards/$(patsubst get-doc/%,%,$@) 183 182 get-doc/make-stds.texi get-doc/fdl.texi: 184 183 @echo $(WGET) $(gnustandards-url) -O $(target) \ … … 186 185 && $(move_if_change) 187 186 188 .PHONY: cvs-update189 cvs-update: get-config/texinfo.tex get-config/config.guess get-config/config.sub get-doc/make-stds.texi get-doc/fdl.texi187 .PHONY: scm-update 188 scm-update: get-config/texinfo.tex get-config/config.guess get-config/config.sub get-doc/make-stds.texi get-doc/fdl.texi 190 189 191 190 … … 195 194 196 195 .PHONY: update 197 update: po-update cvs-update196 update: po-update scm-update 198 197 199 198 … … 209 208 210 209 changelog-check: 211 if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \210 if head $(top_srcdir)/ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \ 212 211 :; \ 213 212 else \ … … 251 250 @echo "Creating directive file '$@':" 252 251 @( \ 253 echo 'vers tion: 1.1'; \252 echo 'version: 1.1'; \ 254 253 echo 'directory: make'; \ 255 254 echo 'filename: $*'; \ … … 262 261 263 262 FTPPUT = ncftpput 264 gnu-url = ftp-upload.gnu.org /incoming 263 gnu-upload-host = ftp-upload.gnu.org 264 gnu-upload-dir = /incoming 265 265 266 266 267 UPLOADS = upload-alpha upload-ftp 267 268 .PHONY: $(UPLOADS) 268 269 $(UPLOADS): $(DIST_ARCHIVES) $(DIST_ARCHIVES_SIG) $(DIST_ARCHIVES_DIRECTIVE) 269 $(FTPPUT) "$(gnu-u rl)/$(@:upload-%=%)" $^270 $(FTPPUT) "$(gnu-upload-host)" "$(gnu-upload-dir)/$(@:upload-%=%)" $^ 270 271 271 272 272 273 # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 273 # 2007 Free Software Foundation, Inc.274 # 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 274 275 # This file is part of GNU Make. 275 276 # -
trunk/src/kmk/make.1
r1993 r2591 224 224 .TP 0.5i 225 225 .BR \-n , " \-\-just\-print" , " \-\-dry\-run" , " \-\-recon" 226 Print the commands that would be executed, but do not execute them. 226 Print the commands that would be executed, but do not execute them (except in 227 certain circumstances). 227 228 .TP 0.5i 228 229 \fB\-o\fR \fIfile\fR, \fB\-\-old\-file\fR=\fIfile\fR, \fB\-\-assume\-old\fR=\fIfile\fR -
trunk/src/kmk/make.h
r2548 r2591 1 1 /* Miscellaneous global declarations and portability cruft for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 24 24 #define HAVE_CONFIG_H 1 25 25 26 /* Specify we want GNU source code. This must be defined before any 27 system headers are included. */ 28 29 #define _GNU_SOURCE 1 30 26 31 /* AIX requires this to be the first thing in the file. */ 27 #ifndef __GNUC__ 28 # if HAVE_ALLOCA_H 29 # include <alloca.h> 30 # else 31 # ifdef _AIX 32 #if HAVE_ALLOCA_H 33 # include <alloca.h> 34 #else 35 # ifdef _AIX 32 36 #pragma alloca 33 # else 37 # else 38 # if !defined(__GNUC__) && !defined(WINDOWS32) 34 39 # ifndef alloca /* predefined by HP cc +Olibcalls */ 35 40 char *alloca (); … … 37 42 # endif 38 43 # endif 39 #elif defined(__sun__) && defined (HAVE_ALLOCA_H) /* bird: kill warnings. */ 40 # include <alloca.h> 41 #endif 42 43 44 /* Specify we want GNU source code. This must be defined before any 45 system headers are included. */ 46 47 #define _GNU_SOURCE 1 44 #endif 48 45 49 46 … … 240 237 #endif 241 238 239 /* bird - start */ 240 #define COMMA , 241 #ifdef CONFIG_WITH_VALUE_LENGTH 242 # define IF_WITH_VALUE_LENGTH(a_Expr) a_Expr 243 # define IF_WITH_VALUE_LENGTH_PARAM(a_Expr) , a_Expr 244 #else 245 # define IF_WITH_VALUE_LENGTH(a_Expr) 246 # define IF_WITH_VALUE_LENGTH_PARAM(a_Expr) 247 #endif 248 249 #ifdef CONFIG_WITH_ALLOC_CACHES 250 # define IF_WITH_ALLOC_CACHES(a_Expr) a_Expr 251 # define IF_WITH_ALLOC_CACHES_PARAM(a_Expr) , a_Expr 252 #else 253 # define IF_WITH_ALLOC_CACHES(a_Expr) 254 # define IF_WITH_ALLOC_CACHES_PARAM(a_Expr) 255 #endif 256 257 #ifdef CONFIG_WITH_COMMANDS_FUNC 258 # define IF_WITH_COMMANDS_FUNC(a_Expr) a_Expr 259 # define IF_WITH_COMMANDS_FUNC_PARAM(a_Expr) , a_Expr 260 #else 261 # define IF_WITH_COMMANDS_FUNC(a_Expr) 262 # define IF_WITH_COMMANDS_FUNC_PARAM(a_Expr) 263 #endif 264 265 /* bird - end */ 266 242 267 243 268 #ifndef CHAR_BIT … … 363 388 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9) 364 389 365 #ifndef iAPX286 366 # 390 /* Test if two strings are equal. Is this worthwhile? Should be profiled. */ 391 #define streq(a, b) \ 367 392 ((a) == (b) || \ 368 393 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1)))) 369 # ifdef HAVE_CASE_INSENSITIVE_FS 370 # define strieq(a, b) \ 394 395 /* Test if two strings are equal, but match case-insensitively on systems 396 which have case-insensitive filesystems. Should only be used for 397 filenames! */ 398 #ifdef HAVE_CASE_INSENSITIVE_FS 399 # define patheq(a, b) \ 371 400 ((a) == (b) \ 372 401 || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \ 373 402 && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1)))) 374 # else 375 # define strieq(a, b) streq(a, b) 376 # endif 377 #else 378 /* Buggy compiler can't handle this. */ 379 # define streq(a, b) (strcmp ((a), (b)) == 0) 380 # define strieq(a, b) (strcmp ((a), (b)) == 0) 381 #endif 403 #else 404 # define patheq(a, b) streq(a, b) 405 #endif 406 382 407 #define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0) 383 408 … … 425 450 426 451 void sync_Path_environment (void); 427 int w32_kill ( int pid, int sig);452 int w32_kill (pid_t pid, int sig); 428 453 char *end_of_token_w32 (const char *s, char stopchar); 429 454 int find_and_set_default_shell (const char *token); … … 435 460 extern int unixy_shell; 436 461 #endif /* WINDOWS32 */ 462 463 #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) 464 # define SET_STACK_SIZE 465 #endif 466 #ifdef SET_STACK_SIZE 467 # include <sys/resource.h> 468 struct rlimit stack_limit; 469 #endif 437 470 438 471 struct floc … … 475 508 476 509 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H 510 const char *concat (unsigned int, ...); 477 511 void message (int prefix, const char *fmt, ...) 478 512 __attribute__ ((__format__ (__printf__, 2, 3))); … … 482 516 __attribute__ ((noreturn, __format__ (__printf__, 2, 3))); 483 517 #else 518 const char *concat (); 484 519 void message (); 485 520 void error (); … … 491 526 void pfatal_with_name (const char *) __attribute__ ((noreturn)); 492 527 void perror_with_name (const char *, const char *); 493 char *savestring (const char *, unsigned int);494 char *concat (const char *, const char *, const char *);495 528 void *xmalloc (unsigned int); 529 void *xcalloc (unsigned int); 496 530 void *xrealloc (void *, unsigned int); 497 531 char *xstrdup (const char *); 532 char *xstrndup (const char *, unsigned int); 498 533 #ifdef CONFIG_WITH_PRINT_STATS_SWITCH 499 534 void print_heap_stats (void); … … 553 588 void build_vpath_lists (void); 554 589 void construct_vpath_list (char *pattern, char *dirpath); 555 const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr); 590 const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr, 591 unsigned int* vpath_index, unsigned int* path_index); 556 592 int gpath_search (const char *file, unsigned int len); 557 593 … … 696 732 #endif 697 733 734 #if !HAVE_STRNCASECMP 735 # if HAVE_STRNICMP 736 # define strncasecmp strnicmp 737 # elif HAVE_STRNCMPI 738 # define strncasecmp strncmpi 739 # else 740 /* Create our own, in misc.c */ 741 int strncasecmp (const char *s1, const char *s2, int n); 742 # endif 743 #endif 744 698 745 extern const struct floc *reading_file; 699 746 extern const struct floc **expanding_var; … … 709 756 extern int warn_undefined_variables_flag, posix_pedantic, not_parallel; 710 757 extern int second_expansion, clock_skew_detected, rebuilding_makefiles; 758 extern int one_shell; 759 711 760 #ifdef CONFIG_WITH_2ND_TARGET_EXPANSION 712 761 extern int second_target_expansion; -
trunk/src/kmk/makefile.com
r1993 r2591 140 140 $!----------------------------------------------------------------------------- 141 141 $!Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 142 $!2006, 2007 Free Software Foundation, Inc.142 $!2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 143 143 $!This file is part of GNU Make. 144 144 $! -
trunk/src/kmk/makefile.vms
r1993 r2591 2 2 # 3 3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 4 # 2006, 2007 Free Software Foundation, Inc.4 # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 5 5 # This file is part of GNU Make. 6 6 # -
trunk/src/kmk/misc.c
r2548 r2591 1 1 /* Miscellaneous generic support functions for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 166 166 ++in; 167 167 168 /* If the newline is quoted, discard following whitespace 169 and any preceding whitespace; leave just one space. */ 168 /* If the newline is escaped, discard following whitespace leaving just 169 one space. POSIX requires that each backslash/newline/following 170 whitespace sequence be reduced to a single space. */ 170 171 if (backslash) 171 172 { 172 173 in = next_token (in); 174 /* Removing this loop will fix Savannah bug #16670: do we want to? */ 173 175 while (out > line && isblank ((unsigned char)out[-1])) 174 176 --out; … … 218 220 219 221 220 /* Return a string whose contents concatenate th ose of s1, s2, s3.222 /* Return a string whose contents concatenate the NUM strings provided 221 223 This string lives in static, re-used memory. */ 222 224 223 char * 224 concat (const char *s1, const char *s2, const char *s3) 225 { 226 unsigned int len1, len2, len3; 225 const char * 226 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H 227 concat (unsigned int num, ...) 228 #else 229 concat (num, va_alist) 230 unsigned int num; 231 va_dcl 232 #endif 233 { 227 234 static unsigned int rlen = 0; 228 235 static char *result = NULL; 229 230 len1 = (s1 && *s1 != '\0') ? strlen (s1) : 0; 231 len2 = (s2 && *s2 != '\0') ? strlen (s2) : 0; 232 len3 = (s3 && *s3 != '\0') ? strlen (s3) : 0; 233 234 if (len1 + len2 + len3 + 1 > rlen) 235 result = xrealloc (result, (rlen = len1 + len2 + len3 + 10)); 236 237 if (len1) 238 memcpy (result, s1, len1); 239 if (len2) 240 memcpy (result + len1, s2, len2); 241 if (len3) 242 memcpy (result + len1 + len2, s3, len3); 243 244 result[len1+len2+len3] = '\0'; 236 unsigned int ri = 0; /* bird: must be unsigned */ 237 238 #if USE_VARIADIC 239 va_list args; 240 #endif 241 242 VA_START (args, num); 243 244 while (num-- > 0) 245 { 246 const char *s = va_arg (args, const char *); 247 unsigned int l = s ? strlen (s) : 0; 248 249 if (l == 0) 250 continue; 251 252 if (ri + l > rlen) 253 { 254 rlen = ((rlen ? rlen : 60) + l) * 2; 255 result = xrealloc (result, rlen); 256 } 257 258 memcpy (result + ri, s, l); 259 ri += l; 260 } 261 262 VA_END (args); 263 264 /* Get some more memory if we don't have enough space for the 265 terminating '\0'. */ 266 if (ri == rlen) 267 { 268 rlen = (rlen ? rlen : 60) * 2; 269 result = xrealloc (result, rlen); 270 } 271 272 result[ri] = '\0'; 245 273 246 274 return result; … … 397 425 398 426 #undef xmalloc 427 #undef xcalloc 399 428 #undef xrealloc 400 429 #undef xstrdup … … 403 432 xmalloc (unsigned int size) 404 433 { 405 /* Make sure we don't allocate 0, for pre- ANSI libraries. */434 /* Make sure we don't allocate 0, for pre-ISO implementations. */ 406 435 void *result = malloc (size ? size : 1); 407 436 if (result == 0) … … 415 444 make_stats_allocated += size; 416 445 #endif 446 return result; 447 } 448 449 450 void * 451 xcalloc (unsigned int size) 452 { 453 /* Make sure we don't allocate 0, for pre-ISO implementations. */ 454 void *result = calloc (size ? size : 1, 1); 455 if (result == 0) 456 fatal (NILF, _("virtual memory exhausted")); 417 457 return result; 418 458 } … … 432 472 #endif 433 473 434 /* Some older implementations of realloc() don't conform to ANSI. */474 /* Some older implementations of realloc() don't conform to ISO. */ 435 475 if (! size) 436 476 size = 1; … … 480 520 481 521 char * 482 savestring (const char *str, unsigned int length) 483 { 484 char *out = xmalloc (length + 1); 522 xstrndup (const char *str, unsigned int length) 523 { 524 char *result; 525 526 #if defined(HAVE_STRNDUP) && !defined(KMK) 527 result = strndup (str, length); 528 if (result == 0) 529 fatal (NILF, _("virtual memory exhausted")); 530 #else 531 result = xmalloc (length + 1); 485 532 if (length > 0) 486 memcpy (out, str, length); 487 out[length] = '\0'; 488 return out; 533 strncpy (result, str, length); 534 result[length] = '\0'; 535 #endif 536 537 return result; 489 538 } 490 539 … … 786 835 787 836 788 /* Allocate a new `struct dep' with all fields initialized to 0. */ 789 790 struct dep * 791 alloc_dep () 792 { 793 #ifndef CONFIG_WITH_ALLOC_CACHES 794 struct dep *d = xmalloc (sizeof (struct dep)); 795 memset (d, '\0', sizeof (struct dep)); 796 return d; 797 #else 798 return (struct dep *) alloccache_calloc (&dep_cache); 799 #endif 800 } 801 802 803 /* Free `struct dep' along with `name' and `stem'. */ 804 805 void 806 free_dep (struct dep *d) 807 { 808 #ifndef CONFIG_WITH_ALLOC_CACHES 809 free (d); 810 #else 811 alloccache_free (&dep_cache, d); 812 #endif 813 } 814 815 /* Copy a chain of `struct dep', making a new chain 816 with the same contents as the old one. */ 837 /* Copy a chain of `struct dep'. For 2nd expansion deps, dup the name. */ 817 838 818 839 struct dep * … … 827 848 struct dep *c = xmalloc (sizeof (struct dep)); 828 849 #else 829 struct dep *c = (struct dep *) alloccache_alloc(&dep_cache);850 struct dep *c = alloccache_alloc(&dep_cache); 830 851 #endif 831 852 memcpy (c, d, sizeof (struct dep)); 853 854 /** @todo KMK: Check if we need this duplication! */ 855 if (c->need_2nd_expansion) 856 c->name = xstrdup (c->name); 832 857 833 858 c->next = 0; … … 852 877 struct dep *df = d; 853 878 d = d->next; 854 #ifndef CONFIG_WITH_ALLOC_CACHES855 879 free_dep (df); 856 #else857 alloccache_free (&dep_cache, df);858 #endif859 880 } 860 881 } … … 903 924 return (c1 - c2); 904 925 } 926 } 927 #endif 928 929 #if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI 930 931 /* If we don't have strncasecmp() (from POSIX), or anything that can 932 substitute for it, define our own version. */ 933 934 int 935 strncasecmp (const char *s1, const char *s2, int n) 936 { 937 while (n-- > 0) 938 { 939 int c1 = (int) *(s1++); 940 int c2 = (int) *(s2++); 941 942 if (isalpha (c1)) 943 c1 = tolower (c1); 944 if (isalpha (c2)) 945 c2 = tolower (c2); 946 947 if (c1 != '\0' && c1 == c2) 948 continue; 949 950 return (c1 - c2); 951 } 952 953 return 0; 905 954 } 906 955 #endif … … 1234 1283 1235 1284 malloc_zone_statistics (NULL, &s); 1236 printf (_("\n# CRT Heap: %zu bytes in use, in %u blocks, avg %zu bytes/block\n"), 1237 s.size_in_use, s.blocks_in_use, s.size_in_use / s.blocks_in_use); 1238 printf (_("# %zu bytes max in use (high water mark)\n"), 1239 s.max_size_in_use); 1240 printf (_("# %zu bytes reserved, %zu bytes free (estimate)\n"), 1241 s.size_allocated, s.size_allocated - s.size_in_use); 1285 printf (_("\n# CRT Heap: %u bytes in use, in %u blocks, avg %u bytes/block\n"), 1286 (unsigned)s.size_in_use, (unsigned)s.blocks_in_use, 1287 (unsigned)(s.size_in_use / s.blocks_in_use)); 1288 printf (_("# %u bytes max in use (high water mark)\n"), 1289 (unsigned)s.max_size_in_use); 1290 printf (_("# %u bytes reserved, %u bytes free (estimate)\n"), 1291 (unsigned)s.size_allocated, 1292 (unsigned)(s.size_allocated - s.size_in_use)); 1242 1293 # endif /* __APPLE__ */ 1243 1294 … … 1374 1425 format_elapsed_nano (char *buf, size_t size, big_int ts) 1375 1426 { 1376 intsz;1427 unsigned sz; 1377 1428 if (ts < 1000) 1378 1429 sz = sprintf (buf, "%uns", (unsigned)ts); … … 1407 1458 } 1408 1459 if (sz >= size) 1409 fatal (NILF, _("format_elapsed_nano buffer overflow: % d written, %dbuffer"),1410 sz, size);1460 fatal (NILF, _("format_elapsed_nano buffer overflow: %u written, %lu buffer"), 1461 sz, (unsigned long)size); 1411 1462 return sz; 1412 1463 } -
trunk/src/kmk/po
- Property svn:ignore
-
old new 3 3 *.pot 4 4 *.po 5 5 6 Makefile 6 7 Makefile.in 7 8 Makefile.in.in 9 Makevars.template 8 10 Rules-quot 11 stamp-po 9 12 *.sed 10 13 *.sin
-
- Property svn:ignore
-
trunk/src/kmk/po/ChangeLog
r1993 r2591 1 2009-09-16 Paul Smith <[email protected]> 2 3 * LINGUAS: Added new translation for Italian (it). 4 1 5 2008-05-17 Paul Smith <[email protected]> 2 6 … … 63 67 64 68 65 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 69 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software 70 Foundation, Inc. 66 71 This file is part of GNU Make. 67 72 -
trunk/src/kmk/po/LINGUAS
r1993 r2591 1 # Set of available languages: 2 3languages1 # Set of available languages: 24 languages 2 2 3 be da de es fi fr ga gl he hr id ja ko lt nl pl pt_BR ru sv tr uk vi zh_CN3 be da de es fi fr ga gl he hr id it ja ko lt nl pl pt_BR ru sv tr uk vi zh_CN 4 4 5 5 # Can't seem to get en@quot and en@boldquot to build properly? -
trunk/src/kmk/po/Makevars
r1993 r2591 1 1 # This is a -*-Makefile-*- 2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,3 # Inc.2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free 3 # Software Foundation, Inc. 4 4 # This file is part of GNU Make. 5 5 # -
trunk/src/kmk/po/POTFILES.in
r1993 r2591 1 1 # List of source files containing translatable strings. 2 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software3 # Foundation, Inc.2 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 3 # 2010 Free Software Foundation, Inc. 4 4 # This file is part of GNU Make. 5 5 # -
trunk/src/kmk/read.c
r2548 r2591 1 1 /* Reading and parsing of makefiles for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 60 60 FILE *fp; /* File, or NULL if this is an internal buffer. */ 61 61 struct floc floc; /* Info on the file in fp (if any). */ 62 }; 63 64 /* Track the modifiers we can have on variable assignments */ 65 66 struct vmodifiers 67 { 68 unsigned int assign_v:1; 69 unsigned int define_v:1; 70 unsigned int undefine_v:1; 71 unsigned int export_v:1; 72 unsigned int override_v:1; 73 unsigned int private_v:1; 62 74 }; 63 75 … … 149 161 150 162 static int eval_makefile (const char *filename, int flags); 151 static inteval (struct ebuffer *buffer, int flags);163 static void eval (struct ebuffer *buffer, int flags); 152 164 153 165 static long readline (struct ebuffer *ebuf); 154 static void do_define (char *name, unsigned int namelen, 155 enum variable_origin origin, struct ebuffer *ebuf); 166 static void do_undefine (char *name, enum variable_origin origin, 167 struct ebuffer *ebuf); 168 static struct variable *do_define (char *name IF_WITH_VALUE_LENGTH_PARAM(char *eos), 169 enum variable_origin origin, struct ebuffer *ebuf); 156 170 #ifndef CONFIG_WITH_VALUE_LENGTH 157 171 static int conditional_line (char *line, int len, const struct floc *flocp); … … 159 173 static int conditional_line (char *line, char *eol, int len, const struct floc *flocp); 160 174 #endif 161 #ifndef CONFIG_WITH_INCLUDEDEP162 175 static void record_files (struct nameseq *filenames, const char *pattern, 163 const char *pattern_percent, struct dep *deps,176 const char *pattern_percent, char *depstr, 164 177 unsigned int cmds_started, char *commands, 165 178 unsigned int commands_idx, int two_colon, 166 179 const struct floc *flocp); 167 #endif /* !KMK */168 180 static void record_target_var (struct nameseq *filenames, char *defn, 169 enum variable_origin origin, int enabled, 181 enum variable_origin origin, 182 struct vmodifiers *vmod, 170 183 const struct floc *flocp); 171 184 static enum make_word_type get_next_mword (char *buffer, char *delim, … … 198 211 199 212 213 /* Compare a word, both length and contents. 214 P must point to the word to be tested, and WLEN must be the length. 215 */ 216 #define word1eq(s) (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1)) 217 218 219 200 220 /* Read in all the makefiles and return the chain of their names. */ 201 221 … … 208 228 we will be reading. */ 209 229 210 define_variable ("MAKEFILE_LIST", sizeof ("MAKEFILE_LIST")-1, "", o_file, 0);230 define_variable_cname ("MAKEFILE_LIST", "", o_file, 0); 211 231 212 232 DB (DB_BASIC, (_("Reading makefiles...\n"))); … … 320 340 struct dep *d = alloc_dep (); 321 341 d->file = enter_file (strcache_add (*p)); 322 d-> file->dontcare = 1;342 d->dontcare = 1; 323 343 /* Tell update_goal_chain to bail out as soon as this file is 324 344 made, and main not to die if we can't make this file. */ … … 388 408 char *expanded = 0; 389 409 int makefile_errno; 390 int r;391 410 392 411 filename = strcache_add (filename); … … 431 450 for (i = 0; include_directories[i] != 0; ++i) 432 451 { 433 const char *included = concat (include_directories[i], "/", filename); 452 const char *included = concat (3, include_directories[i], 453 "/", filename); 434 454 ebuf.fp = fopen (included, "r"); 435 455 if (ebuf.fp) … … 455 475 deps->changed = flags; 456 476 if (flags & RM_DONTCARE) 457 deps-> file->dontcare = 1;477 deps->dontcare = 1; 458 478 459 479 if (expanded) … … 470 490 return 0; 471 491 } 492 493 /* Set close-on-exec to avoid leaking the makefile to children, such as 494 $(shell ...). */ 495 #ifdef HAVE_FILENO 496 CLOSE_ON_EXEC (fileno (ebuf.fp)); 497 #endif 472 498 473 499 /* Add this makefile to the list. */ … … 506 532 reading_file = &ebuf.floc; 507 533 508 r =eval (&ebuf, !(flags & RM_NO_DEFAULT_GOAL));534 eval (&ebuf, !(flags & RM_NO_DEFAULT_GOAL)); 509 535 510 536 reading_file = curfile; … … 519 545 free (ebuf.bufstart); 520 546 alloca (0); 521 return r; 547 548 return 1; 522 549 } 523 550 524 int 551 void 525 552 #ifndef CONFIG_WITH_VALUE_LENGTH 526 553 eval_buffer (char *buffer) … … 533 560 struct conditionals new; 534 561 const struct floc *curfile; 535 int r;536 562 537 563 /* Evaluate the buffer */ … … 547 573 ebuf.fp = NULL; 548 574 549 ebuf.floc = *reading_file; 575 if (reading_file) 576 ebuf.floc = *reading_file; 577 else 578 ebuf.floc.filenm = NULL; 550 579 551 580 curfile = reading_file; … … 554 583 saved = install_conditionals (&new); 555 584 556 r =eval (&ebuf, 1);585 eval (&ebuf, 1); 557 586 558 587 restore_conditionals (saved); … … 561 590 562 591 alloca (0); 563 return r;564 592 } 565 593 566 594 595 /* Check LINE to see if it's a variable assignment or undefine. 596 597 It might use one of the modifiers "export", "override", "private", or it 598 might be one of the conditional tokens like "ifdef", "include", etc. 599 600 If it's not a variable assignment or undefine, VMOD.V_ASSIGN is 0. 601 Returns LINE. 602 603 Returns a pointer to the first non-modifier character, and sets VMOD 604 based on the modifiers found if any, plus V_ASSIGN is 1. 605 */ 606 static char * 607 parse_var_assignment (const char *line, struct vmodifiers *vmod) 608 { 609 const char *p; 610 memset (vmod, '\0', sizeof (*vmod)); 611 612 /* Find the start of the next token. If there isn't one we're done. */ 613 line = next_token (line); 614 if (*line == '\0') 615 return (char *)line; 616 617 p = line; 618 while (1) 619 { 620 int wlen; 621 const char *p2; 622 enum variable_flavor flavor; 623 624 p2 = parse_variable_definition (p, &flavor); 625 626 /* If this is a variable assignment, we're done. */ 627 if (p2) 628 break; 629 630 /* It's not a variable; see if it's a modifier. */ 631 p2 = end_of_token (p); 632 wlen = p2 - p; 633 634 if (word1eq ("export")) 635 vmod->export_v = 1; 636 else if (word1eq ("override")) 637 vmod->override_v = 1; 638 else if (word1eq ("private")) 639 vmod->private_v = 1; 640 else if (word1eq ("define")) 641 { 642 /* We can't have modifiers after 'define' */ 643 vmod->define_v = 1; 644 p = next_token (p2); 645 break; 646 } 647 else if (word1eq ("undefine")) 648 { 649 /* We can't have modifiers after 'undefine' */ 650 vmod->undefine_v = 1; 651 p = next_token (p2); 652 break; 653 } 654 else 655 /* Not a variable or modifier: this is not a variable assignment. */ 656 return (char *)line; 657 658 /* It was a modifier. Try the next word. */ 659 p = next_token (p2); 660 if (*p == '\0') 661 return (char *)line; 662 } 663 664 /* Found a variable assignment or undefine. */ 665 vmod->assign_v = 1; 666 return (char *)p; 667 } 668 669 567 670 568 671 /* Read file FILENAME as a makefile and add its contents to the data base. … … 570 673 SET_DEFAULT is true if we are allowed to set the default goal. */ 571 674 572 573 static int 675 static void 574 676 eval (struct ebuffer *ebuf, int set_default) 575 677 { … … 583 685 int no_targets = 0; /* Set when reading a rule without targets. */ 584 686 struct nameseq *filenames = 0; 585 struct dep *deps= 0;687 char *depstr = 0; 586 688 long nlines = 0; 587 689 int two_colon = 0; … … 604 706 { \ 605 707 fi.lineno = tgts_started; \ 606 record_files (filenames, pattern, pattern_percent, deps ,\708 record_files (filenames, pattern, pattern_percent, depstr, \ 607 709 cmds_started, commands, commands_idx, two_colon, \ 608 710 &fi); \ 711 filenames = 0; \ 609 712 } \ 610 filenames = 0; \611 713 commands_idx = 0; \ 612 714 no_targets = 0; \ … … 642 744 char *p; 643 745 char *p2; 644 746 struct vmodifiers vmod; 747 748 /* At the top of this loop, we are starting a brand new line. */ 645 749 /* Grab the next line to be evaluated */ 646 750 ebuf->floc.lineno += nlines; … … 672 776 673 777 /* If there is no preceding rule line, don't treat this line 674 as a command, even though it begins with a tab character.778 as a command, even though it begins with a recipe prefix. 675 779 SunOS 4 make appears to behave this way. */ 676 780 … … 711 815 } 712 816 713 /* This line is not a shell command line. Don't worry about tabs.817 /* This line is not a shell command line. Don't worry about whitespace. 714 818 Get more space if we need it; we don't need to preserve the current 715 819 contents of the buffer. */ … … 720 824 if (collapsed) 721 825 free (collapsed); 826 /* Don't need xrealloc: we don't need to preserve the content. */ 722 827 collapsed = xmalloc (collapsed_length); 723 828 } … … 736 841 #endif 737 842 738 /* Compare a word, both length and contents. */ 739 #define word1eq(s) (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1)) 843 /* Get rid if starting space (including formfeed, vtab, etc.) */ 740 844 p = collapsed; 741 845 while (isspace ((unsigned char)*p)) 742 ++p; 743 744 if (*p == '\0') 745 /* This line is completely empty--ignore it. */ 746 continue; 747 748 /* Find the end of the first token. Note we don't need to worry about 749 * ":" here since we compare tokens by length (so "export" will never 750 * be equal to "export:"). 751 */ 752 for (p2 = p+1; *p2 != '\0' && !isspace ((unsigned char)*p2); ++p2) 753 ; 754 wlen = p2 - p; 755 756 /* Find the start of the second token. If it looks like a target or 757 variable definition it can't be a preprocessor token so skip 758 them--this allows variables/targets named `ifdef', `export', etc. */ 759 while (isspace ((unsigned char)*p2)) 760 ++p2; 761 762 if ((p2[0] == ':' || p2[0] == '+' || p2[0] == '=') && p2[1] == '\0') 846 ++p; 847 848 /* See if this is a variable assignment. We need to do this early, to 849 allow variables with names like 'ifdef', 'export', 'private', etc. */ 850 p = parse_var_assignment(p, &vmod); 851 if (vmod.assign_v) 763 852 { 764 /* It can't be a preprocessor token so skip it if we're ignoring */ 765 if (ignoring) 766 continue; 767 768 goto skip_conditionals; 769 } 770 771 /* We must first check for conditional and `define' directives before 772 ignoring anything, since they control what we will do with 773 following lines. */ 774 775 if (!in_ignored_define) 776 { 777 #ifndef CONFIG_WITH_VALUE_LENGTH 778 int i = conditional_line (p, wlen, fstart); 779 #else 780 int i = conditional_line (p, eol, wlen, fstart); 781 #endif 782 if (i != -2) 853 struct variable *v; 854 enum variable_origin origin = vmod.override_v ? o_override : o_file; 855 856 /* If we're ignoring then we're done now. */ 857 if (ignoring) 783 858 { 784 if (i == -1) 785 fatal (fstart, _("invalid syntax in conditional")); 786 787 ignoring = i; 859 if (vmod.define_v) 860 in_ignored_define = 1; 788 861 continue; 789 862 } 790 } 791 792 if (word1eq ("endef")) 863 864 if (vmod.undefine_v) 865 { 866 do_undefine (p, origin, ebuf); 867 868 /* This line has been dealt with. */ 869 goto rule_complete; 870 } 871 else if (vmod.define_v) 872 v = do_define (p IF_WITH_VALUE_LENGTH_PARAM(NULL), origin, ebuf); 873 else 874 v = try_variable_definition (fstart, p IF_WITH_VALUE_LENGTH_PARAM(NULL), origin, 0); 875 876 assert (v != NULL); 877 878 if (vmod.export_v) 879 v->export = v_export; 880 if (vmod.private_v) 881 v->private_var = 1; 882 883 /* This line has been dealt with. */ 884 goto rule_complete; 885 } 886 887 /* If this line is completely empty, ignore it. */ 888 if (*p == '\0') 889 continue; 890 891 p2 = end_of_token (p); 892 wlen = p2 - p; 893 p2 = next_token (p2); 894 895 /* If we're in an ignored define, skip this line (but maybe get out). */ 896 if (in_ignored_define) 793 897 { 794 if (!in_ignored_define) 795 fatal (fstart, _("extraneous `endef'")); 796 in_ignored_define = 0; 898 /* See if this is an endef line (plus optional comment). */ 899 if (word1eq ("endef") && (*p2 == '\0' || *p2 == '#')) 900 in_ignored_define = 0; 901 797 902 continue; 798 903 } 799 904 800 if (word1eq ("define")) 801 { 802 if (ignoring) 803 in_ignored_define = 1; 804 else 805 { 806 if (*p2 == '\0') 807 fatal (fstart, _("empty variable name")); 808 809 /* Let the variable name be the whole rest of the line, 810 with trailing blanks stripped (comments have already been 811 removed), so it could be a complex variable/function 812 reference that might contain blanks. */ 813 p = strchr (p2, '\0'); 814 while (isblank ((unsigned char)p[-1])) 815 --p; 816 do_define (p2, p - p2, o_file, ebuf); 817 } 818 continue; 819 } 820 821 if (word1eq ("override")) 822 { 823 if (*p2 == '\0') 824 error (fstart, _("empty `override' directive")); 825 826 if (strneq (p2, "define", 6) 827 && (isblank ((unsigned char)p2[6]) || p2[6] == '\0')) 828 { 829 if (ignoring) 830 in_ignored_define = 1; 831 else 832 { 833 p2 = next_token (p2 + 6); 834 if (*p2 == '\0') 835 fatal (fstart, _("empty variable name")); 836 837 /* Let the variable name be the whole rest of the line, 838 with trailing blanks stripped (comments have already been 839 removed), so it could be a complex variable/function 840 reference that might contain blanks. */ 841 p = strchr (p2, '\0'); 842 while (isblank ((unsigned char)p[-1])) 843 --p; 844 do_define (p2, p - p2, o_override, ebuf); 845 } 846 } 847 else if (!ignoring 905 /* Check for conditional state changes. */ 906 { 848 907 #ifndef CONFIG_WITH_VALUE_LENGTH 849 && !try_variable_definition (fstart, p2, o_override, 0)) 850 #else 851 && !try_variable_definition (fstart, p2, eol, o_override, 0)) 852 #endif 853 error (fstart, _("invalid `override' directive")); 854 855 continue; 856 } 908 int i = conditional_line (p, wlen, fstart); 909 #else 910 int i = conditional_line (p, eol, wlen, fstart); 911 #endif 912 if (i != -2) 913 { 914 if (i == -1) 915 fatal (fstart, _("invalid syntax in conditional")); 916 917 ignoring = i; 918 continue; 919 } 920 } 921 922 /* Nothing to see here... move along. */ 923 if (ignoring) 924 continue; 925 857 926 #ifdef CONFIG_WITH_LOCAL_VARIABLES 858 859 927 if (word1eq ("local")) 860 928 { … … 880 948 while (isblank ((unsigned char)p[-1])) 881 949 --p; 882 do_define (p2 , p - p2, o_local, ebuf);950 do_define (p2 IF_WITH_VALUE_LENGTH_PARAM(p), o_local, ebuf); 883 951 } 884 952 } 885 953 else if (!ignoring 886 # ifndef CONFIG_WITH_VALUE_LENGTH 887 && !try_variable_definition (fstart, p2, o_local, 0)) 888 # else 889 && !try_variable_definition (fstart, p2, eol, o_local, 0)) 890 # endif 954 && !try_variable_definition (fstart, p2 IF_WITH_VALUE_LENGTH_PARAM(eol), o_local, 0)) 891 955 error (fstart, _("invalid `local' directive")); 892 956 … … 894 958 } 895 959 #endif /* CONFIG_WITH_LOCAL_VARIABLES */ 896 897 if (ignoring)898 /* Ignore the line. We continue here so conditionals899 can appear in the middle of a rule. */900 continue;901 960 902 961 #ifdef KMK … … 918 977 919 978 #endif /* KMK */ 920 if (word1eq ("export")) 979 980 /* Manage the "export" keyword used outside of variable assignment 981 as well as "unexport". */ 982 if (word1eq ("export") || word1eq ("unexport")) 921 983 { 922 /* 'export' by itself causes everything to be exported. */ 984 int exporting = *p == 'u' ? 0 : 1; 985 986 /* (un)export by itself causes everything to be (un)exported. */ 923 987 if (*p2 == '\0') 924 export_all_variables = 1;988 export_all_variables = exporting; 925 989 else 926 990 { 927 struct variable *v; 928 991 unsigned int l; 992 const char *cp; 993 char *ap; 994 995 /* Expand the line so we can use indirect and constructed 996 variable names in an (un)export command. */ 929 997 #ifndef CONFIG_WITH_VALUE_LENGTH 930 v = try_variable_definition (fstart, p2, o_file, 0); 931 #else 932 v = try_variable_definition (fstart, p2, eol, o_file, 0); 933 #endif 934 if (v != 0) 935 v->export = v_export; 936 else 998 cp = ap = allocated_variable_expand (p2); 999 #else 1000 unsigned int buf_len; 1001 cp = ap = allocated_variable_expand_3 (p2, eol - p2, NULL, &buf_len); 1002 #endif 1003 1004 for (p = find_next_token (&cp, &l); p != 0; 1005 p = find_next_token (&cp, &l)) 937 1006 { 938 unsigned int l;939 const char *cp;940 char *ap;941 942 /* Expand the line so we can use indirect and constructed943 variable names in an export command. */ 1007 struct variable *v = lookup_variable (p, l); 1008 if (v == 0) 1009 v = define_variable_loc (p, l, "", o_file, 0, fstart); 1010 v->export = exporting ? v_export : v_noexport; 1011 } 1012 944 1013 #ifndef CONFIG_WITH_VALUE_LENGTH 945 cp = ap = allocated_variable_expand (p2); 946 #else 947 unsigned int buf_len; 948 cp = ap = allocated_variable_expand_3 (p2, eol - p2, NULL, &buf_len); 949 #endif 950 951 for (p = find_next_token (&cp, &l); p != 0; 952 p = find_next_token (&cp, &l)) 953 { 954 v = lookup_variable (p, l); 955 if (v == 0) 956 v = define_variable_loc (p, l, "", o_file, 0, fstart); 957 v->export = v_export; 958 } 959 960 #ifndef CONFIG_WITH_VALUE_LENGTH 961 free (ap); 962 #else 963 recycle_variable_buffer (ap, buf_len); 964 #endif 965 } 1014 free (ap); 1015 #else 1016 recycle_variable_buffer (ap, buf_len); 1017 #endif 966 1018 } 967 1019 goto rule_complete; 968 1020 } 969 1021 970 if (word1eq ("unexport")) 971 { 972 if (*p2 == '\0') 973 export_all_variables = 0; 974 else 975 { 976 unsigned int l; 977 struct variable *v; 978 const char *cp; 979 char *ap; 980 981 /* Expand the line so we can use indirect and constructed 982 variable names in an unexport command. */ 983 #ifndef CONFIG_WITH_VALUE_LENGTH 984 cp = ap = allocated_variable_expand (p2); 985 #else 986 unsigned int buf_len; 987 cp = ap = allocated_variable_expand_3 (p2, eol - p2, NULL, &buf_len); 988 #endif 989 990 for (p = find_next_token (&cp, &l); p != 0; 991 p = find_next_token (&cp, &l)) 992 { 993 v = lookup_variable (p, l); 994 if (v == 0) 995 v = define_variable_loc (p, l, "", o_file, 0, fstart); 996 997 v->export = v_noexport; 998 } 999 1000 #ifndef CONFIG_WITH_VALUE_LENGTH 1001 free (ap); 1002 #else 1003 recycle_variable_buffer (ap, buf_len); 1004 #endif 1005 } 1006 goto rule_complete; 1007 } 1008 1009 skip_conditionals: 1022 /* Handle the special syntax for vpath. */ 1010 1023 if (word1eq ("vpath")) 1011 1024 { … … 1017 1030 if (p != 0) 1018 1031 { 1019 vpat = savestring(p, l);1032 vpat = xstrndup (p, l); 1020 1033 p = find_next_token (&cp, &l); 1021 1034 /* No searchpath means remove all previous … … 1069 1082 #endif /* CONFIG_WITH_INCLUDEDEP */ 1070 1083 1084 /* Handle include and variants. */ 1071 1085 if (word1eq ("include") || word1eq ("-include") || word1eq ("sinclude")) 1072 1086 { … … 1098 1112 } 1099 1113 1100 /* Parse the list of file names. */1114 /* Parse the list of file names. Don't expand archive references! */ 1101 1115 p2 = p; 1102 #ifndef CONFIG_WITH_ALLOC_CACHES 1103 files = multi_glob (parse_file_seq (&p2, '\0', 1104 sizeof (struct nameseq), 1105 1), 1106 sizeof (struct nameseq)); 1107 #else 1108 files = multi_glob (parse_file_seq (&p2, '\0', &nameseq_cache, 1), 1109 &nameseq_cache); 1110 #endif 1116 files = PARSE_FILE_SEQ (&p2, struct nameseq, '\0', NULL, 1117 PARSEFS_NOAR); 1111 1118 #ifndef CONFIG_WITH_VALUE_LENGTH 1112 1119 free (p); … … 1130 1137 int r; 1131 1138 1132 #ifndef CONFIG_WITH_ALLOC_CACHES 1133 free (files); 1134 #else 1135 alloccache_free (&nameseq_cache, files); 1136 #endif 1139 free_ns (files); 1137 1140 files = next; 1138 1141 1139 r = eval_makefile (name, (RM_INCLUDED | RM_NO_TILDE 1140 | (noerror ? RM_DONTCARE : 0))); 1142 r = eval_makefile (name, 1143 (RM_INCLUDED | RM_NO_TILDE 1144 | (noerror ? RM_DONTCARE : 0) 1145 | (set_default ? 0 : RM_NO_DEFAULT_GOAL))); 1141 1146 if (!r && !noerror) 1142 1147 error (fstart, "%s: %s", name, strerror (errno)); … … 1148 1153 goto rule_complete; 1149 1154 } 1150 1151 #ifndef CONFIG_WITH_VALUE_LENGTH1152 if (try_variable_definition (fstart, p, o_file, 0))1153 #else1154 if (try_variable_definition (fstart, p, eol, o_file, 0))1155 #endif1156 /* This line has been dealt with. */1157 goto rule_complete;1158 1155 1159 1156 /* This line starts with a tab but was not caught above because there … … 1175 1172 { 1176 1173 enum make_word_type wtype; 1177 enum variable_origin v_origin;1178 int exported;1179 1174 char *cmdleft, *semip, *lb_next; 1180 1175 unsigned int plen = 0; … … 1347 1342 looking for targets. */ 1348 1343 *colonp = '\0'; 1349 #ifndef CONFIG_WITH_ALLOC_CACHES 1350 filenames = multi_glob (parse_file_seq (&p2, '\0', 1351 sizeof (struct nameseq), 1352 1), 1353 sizeof (struct nameseq)); 1354 #else 1355 filenames = multi_glob (parse_file_seq (&p2, '\0', &nameseq_cache, 1), 1356 &nameseq_cache); 1357 #endif 1344 filenames = PARSE_FILE_SEQ (&p2, struct nameseq, '\0', NULL, 0); 1358 1345 *p2 = ':'; 1359 1346 … … 1386 1373 } 1387 1374 1388 /* See if it's an "override" or "export" keyword; if so see if what 1389 comes after it looks like a variable definition. */ 1390 1391 wtype = get_next_mword (p2, NULL, &p, &wlen); 1392 1393 v_origin = o_file; 1394 exported = 0; 1395 if (wtype == w_static) 1396 { 1397 if (word1eq ("override")) 1398 { 1399 v_origin = o_override; 1400 wtype = get_next_mword (p+wlen, NULL, &p, &wlen); 1401 } 1402 else if (word1eq ("export")) 1403 { 1404 exported = 1; 1405 wtype = get_next_mword (p+wlen, NULL, &p, &wlen); 1406 } 1407 } 1408 1409 if (wtype != w_eol) 1410 wtype = get_next_mword (p+wlen, NULL, NULL, NULL); 1411 1412 if (wtype == w_varassign) 1375 p2 = parse_var_assignment (p2, &vmod); 1376 if (vmod.assign_v) 1413 1377 { 1414 1378 /* If there was a semicolon found, add it back, plus anything … … 1418 1382 unsigned int l = p - variable_buffer; 1419 1383 *(--semip) = ';'; 1384 #ifndef CONFIG_WITH_VALUE_LENGTH 1385 collapse_continuations (semip); 1386 #else 1387 collapse_continuations (semip, strlen(semip)); /** @todo fix this */ 1388 #endif 1420 1389 variable_buffer_output (p2 + strlen (p2), 1421 1390 semip, strlen (semip)+1); 1422 1391 p = variable_buffer + l; 1423 1392 } 1424 record_target_var (filenames, p, v_origin, exported, fstart); 1393 record_target_var (filenames, p2, 1394 vmod.override_v ? o_override : o_file, 1395 &vmod, fstart); 1425 1396 filenames = 0; 1426 1397 continue; … … 1463 1434 while (p != 0 && p[-1] == '\\') 1464 1435 { 1465 registerchar *q = &p[-1];1466 registerint backslash = 0;1436 char *q = &p[-1]; 1437 int backslash = 0; 1467 1438 while (*q-- == '\\') 1468 1439 backslash = !backslash; … … 1507 1478 { 1508 1479 struct nameseq *target; 1509 #ifndef CONFIG_WITH_ALLOC_CACHES 1510 target = parse_file_seq (&p2, ':', sizeof (struct nameseq), 1); 1511 #else 1512 target = parse_file_seq (&p2, ':', &nameseq_cache, 1); 1513 #endif 1480 target = PARSE_FILE_SEQ (&p2, struct nameseq, ':', NULL, 1481 PARSEFS_NOGLOB); 1514 1482 ++p2; 1515 1483 if (target == 0) … … 1521 1489 if (pattern_percent == 0) 1522 1490 fatal (fstart, _("target pattern contains no `%%' (target `%s')"), target->name); /* bird */ 1523 #ifndef CONFIG_WITH_ALLOC_CACHES 1524 free (target); 1525 #else 1526 alloccache_free (&nameseq_cache, target); 1527 #endif 1491 free_ns (target); 1528 1492 } 1529 1493 else … … 1535 1499 strip_whitespace (&beg, &end); 1536 1500 1501 /* Put all the prerequisites here; they'll be parsed later. */ 1537 1502 if (beg <= end && *beg != '\0') 1538 { 1539 /* Put all the prerequisites here; they'll be parsed later. */ 1540 deps = alloc_dep (); 1541 #ifndef CONFIG_WITH_VALUE_LENGTH 1542 deps->name = strcache_add_len (beg, end - beg + 1); 1543 #else /* CONFIG_WITH_VALUE_LENGTH */ 1544 { 1545 /* Make sure the strcache_add_len input is terminated so it 1546 doesn't have to make a temporary copy on the stack. */ 1547 char saved = end[1]; 1548 ((char *)end)[1] = '\0'; 1549 deps->name = strcache_add_len (beg, end - beg + 1); 1550 ((char *)end)[1] = saved; 1551 } 1552 #endif /* CONFIG_WITH_VALUE_LENGTH */ 1553 } 1503 depstr = xstrndup (beg, end - beg + 1); 1554 1504 else 1555 deps = 0;1505 depstr = 0; 1556 1506 1557 1507 commands_idx = 0; … … 1587 1537 Because the target is not recorded until after ifeq directive is 1588 1538 evaluated the .DEFAULT_GOAL does not contain foo yet as one 1589 would expect. Because of this we have to move some of the logic 1590 here. */ 1591 1592 if (**default_goal_name == '\0' && set_default) 1539 would expect. Because of this we have to move the logic here. */ 1540 1541 if (set_default && default_goal_var->value[0] == '\0') 1593 1542 { 1594 1543 const char *name; … … 1680 1629 free (collapsed); 1681 1630 free (commands); 1682 1683 return 1;1684 1631 } 1685 1632 … … 1758 1705 #endif /* CONFIG_WITH_VALUE_LENGTH */ 1759 1706 1707 /* Execute a `undefine' directive. 1708 The undefine line has already been read, and NAME is the name of 1709 the variable to be undefined. */ 1710 1711 static void 1712 do_undefine (char *name, enum variable_origin origin, struct ebuffer *ebuf) 1713 { 1714 char *p, *var; 1715 1716 /* Expand the variable name and find the beginning (NAME) and end. */ 1717 var = allocated_variable_expand (name); 1718 name = next_token (var); 1719 if (*name == '\0') 1720 fatal (&ebuf->floc, _("empty variable name")); 1721 p = name + strlen (name) - 1; 1722 while (p > name && isblank ((unsigned char)*p)) 1723 --p; 1724 p[1] = '\0'; 1725 1726 undefine_variable_global (name, p - name + 1, origin); 1727 free (var); 1728 } 1729 1760 1730 /* Execute a `define' directive. 1761 1731 The first line has already been read, and NAME is the name of 1762 1732 the variable to be defined. The following lines remain to be read. */ 1763 1733 1764 static void1765 do_define (char *name , unsigned int namelen,1734 static struct variable * 1735 do_define (char *name IF_WITH_VALUE_LENGTH_PARAM(char *eos), 1766 1736 enum variable_origin origin, struct ebuffer *ebuf) 1767 1737 { 1738 struct variable *v; 1739 enum variable_flavor flavor; 1768 1740 struct floc defstart; 1769 long nlines = 0;1770 1741 int nlevels = 1; 1771 1742 unsigned int length = 100; 1772 1743 char *definition = xmalloc (length); 1773 1744 unsigned int idx = 0; 1774 char *p; 1775 1776 /* Expand the variable name. */ 1777 char *var = alloca (namelen + 1); 1778 memcpy (var, name, namelen); 1779 var[namelen] = '\0'; 1780 var = variable_expand (var); 1745 char *p, *var; 1781 1746 1782 1747 defstart = ebuf->floc; 1783 1748 1749 p = parse_variable_definition (name, &flavor); 1750 if (p == NULL) 1751 /* No assignment token, so assume recursive. */ 1752 flavor = f_recursive; 1753 else 1754 { 1755 if (*(next_token (p)) != '\0') 1756 error (&defstart, _("extraneous text after `define' directive")); 1757 1758 /* Chop the string before the assignment token to get the name. */ 1759 p[flavor == f_recursive ? -1 : -2] = '\0'; 1760 } 1761 1762 /* Expand the variable name and find the beginning (NAME) and end. */ 1763 var = allocated_variable_expand (name); 1764 name = next_token (var); 1765 if (*name == '\0') 1766 fatal (&defstart, _("empty variable name")); 1767 p = name + strlen (name) - 1; 1768 while (p > name && isblank ((unsigned char)*p)) 1769 --p; 1770 p[1] = '\0'; 1771 1772 /* Now read the value of the variable. */ 1784 1773 while (1) 1785 1774 { 1786 1775 unsigned int len; 1787 1776 char *line; 1788 1789 nlines = readline (ebuf); 1777 long nlines = readline (ebuf); 1778 1779 /* If there is nothing left to be eval'd, there's no 'endef'!! */ 1780 if (nlines < 0) 1781 fatal (&defstart, _("missing `endef', unterminated `define'")); 1782 1790 1783 ebuf->floc.lineno += nlines; 1791 1792 /* If there is nothing left to eval, we're done. */1793 if (nlines < 0)1794 break;1795 1796 1784 line = ebuf->buffer; 1797 1785 … … 1803 1791 1804 1792 /* If the line doesn't begin with a tab, test to see if it introduces 1805 another define, or ends one. */ 1806 1807 /* Stop if we find an 'endef' */ 1793 another define, or ends one. Stop if we find an 'endef' */ 1808 1794 if (line[0] != cmd_prefix) 1809 1795 { … … 1832 1818 ebuf->eol = remove_comments (p, ebuf->eol); 1833 1819 #endif 1834 if (* next_token (p) != '\0')1820 if (*(next_token (p)) != '\0') 1835 1821 error (&ebuf->floc, 1836 _(" Extraneous text after `endef' directive"));1822 _("extraneous text after `endef' directive")); 1837 1823 1838 1824 if (--nlevels == 0) 1839 { 1840 /* Define the variable. */ 1841 if (idx == 0) 1842 definition[0] = '\0'; 1843 else 1844 definition[idx - 1] = '\0'; 1845 1846 /* Always define these variables in the global set. */ 1847 define_variable_global (var, strlen (var), definition, 1848 origin, 1, &defstart); 1849 free (definition); 1850 return; 1851 } 1825 break; 1852 1826 } 1853 1827 } 1854 1828 1855 /* Otherwise add this line to the variable definition. */1829 /* Add this line to the variable definition. */ 1856 1830 #ifndef CONFIG_WITH_VALUE_LENGTH 1857 1831 len = strlen (line); … … 1872 1846 } 1873 1847 1874 /* No `endef'!! */ 1875 fatal (&defstart, _("missing `endef', unterminated `define'")); 1876 1877 /* NOTREACHED */ 1878 return; 1848 /* We've got what we need; define the variable. */ 1849 if (idx == 0) 1850 definition[0] = '\0'; 1851 else 1852 definition[idx - 1] = '\0'; 1853 1854 v = do_variable_definition (&defstart, name, definition, origin, flavor, 0); 1855 free (definition); 1856 free (var); 1857 return (v); 1879 1858 } 1880 1859 … … 2267 2246 2268 2247 2269 /* Remove duplicate dependencies in CHAIN. */2270 #ifndef CONFIG_WITH_STRCACHE22271 2272 static unsigned long2273 dep_hash_1 (const void *key)2274 {2275 return_STRING_HASH_1 (dep_name ((struct dep const *) key));2276 }2277 2278 static unsigned long2279 dep_hash_2 (const void *key)2280 {2281 return_STRING_HASH_2 (dep_name ((struct dep const *) key));2282 }2283 2284 static int2285 dep_hash_cmp (const void *x, const void *y)2286 {2287 struct dep *dx = (struct dep *) x;2288 struct dep *dy = (struct dep *) y;2289 int cmp = strcmp (dep_name (dx), dep_name (dy));2290 2291 /* If the names are the same but ignore_mtimes are not equal, one of these2292 is an order-only prerequisite and one isn't. That means that we should2293 remove the one that isn't and keep the one that is. */2294 2295 if (!cmp && dx->ignore_mtime != dy->ignore_mtime)2296 dx->ignore_mtime = dy->ignore_mtime = 0;2297 2298 return cmp;2299 }2300 2301 #else /* CONFIG_WITH_STRCACHE2 */2302 2303 /* Exploit the fact that all names are in the string cache. This means equal2304 names shall have the same storage and there is no need for hashing or2305 comparing. Use the address as the first hash, avoiding any touching of2306 the name, and the length as the second. */2307 2308 static unsigned long2309 dep_hash_1 (const void *key)2310 {2311 const char *name = dep_name ((struct dep const *) key);2312 assert (strcache2_is_cached (&file_strcache, name));2313 return (size_t) name / sizeof(void *);2314 }2315 2316 static unsigned long2317 dep_hash_2 (const void *key)2318 {2319 const char *name = dep_name ((struct dep const *) key);2320 return strcache2_get_len (&file_strcache, name);2321 }2322 2323 static int2324 dep_hash_cmp (const void *x, const void *y)2325 {2326 struct dep *dx = (struct dep *) x;2327 struct dep *dy = (struct dep *) y;2328 const char *dxname = dep_name (dx);2329 const char *dyname = dep_name (dy);2330 int cmp = dxname == dyname ? 0 : 1;2331 2332 /* check preconds: both cached and the cache contains no duplicates. */2333 assert (strcache2_is_cached (&file_strcache, dxname));2334 assert (strcache2_is_cached (&file_strcache, dyname));2335 assert (cmp == 0 || strcmp (dxname, dyname) != 0);2336 2337 /* If the names are the same but ignore_mtimes are not equal, one of these2338 is an order-only prerequisite and one isn't. That means that we should2339 remove the one that isn't and keep the one that is. */2340 2341 if (!cmp && dx->ignore_mtime != dy->ignore_mtime)2342 dx->ignore_mtime = dy->ignore_mtime = 0;2343 2344 return cmp;2345 }2346 2347 #endif /* CONFIG_WITH_STRCACHE2 */2348 2349 void2350 uniquize_deps (struct dep *chain)2351 {2352 struct hash_table deps;2353 register struct dep **depp;2354 2355 hash_init (&deps, 500, dep_hash_1, dep_hash_2, dep_hash_cmp);2356 2357 /* Make sure that no dependencies are repeated. This does not2358 really matter for the purpose of updating targets, but it2359 might make some names be listed twice for $^ and $?. */2360 2361 depp = &chain;2362 while (*depp)2363 {2364 struct dep *dep = *depp;2365 struct dep **dep_slot = (struct dep **) hash_find_slot (&deps, dep);2366 if (HASH_VACANT (*dep_slot))2367 {2368 hash_insert_at (&deps, dep, dep_slot);2369 depp = &dep->next;2370 }2371 else2372 {2373 /* Don't bother freeing duplicates.2374 It's dangerous and little benefit accrues. */2375 *depp = dep->next;2376 }2377 }2378 2379 hash_free (&deps, 0);2380 }2381 2382 2383 2248 /* Record target-specific variable values for files FILENAMES. 2384 2249 TWO_COLON is nonzero if a double colon was used. … … 2392 2257 static void 2393 2258 record_target_var (struct nameseq *filenames, char *defn, 2394 enum variable_origin origin, int exported,2259 enum variable_origin origin, struct vmodifiers *vmod, 2395 2260 const struct floc *flocp) 2396 2261 { … … 2412 2277 2413 2278 nextf = filenames->next; 2414 #ifndef CONFIG_WITH_ALLOC_CACHES 2415 free (filenames); 2416 #else 2417 alloccache_free (&nameseq_cache, filenames); 2418 #endif 2279 free_ns (filenames); 2419 2280 2420 2281 /* If it's a pattern target, then add it to the pattern-specific … … 2428 2289 /* I don't think this can fail since we already determined it was a 2429 2290 variable definition. */ 2430 #ifndef CONFIG_WITH_VALUE_LENGTH 2431 v = parse_variable_definition (&p->variable, defn); 2432 #else 2433 v = parse_variable_definition (&p->variable, defn, NULL); 2434 #endif 2291 v = assign_variable_definition (&p->variable, defn IF_WITH_VALUE_LENGTH_PARAM(NULL)); 2435 2292 assert (v != 0); 2436 2293 2294 v->origin = origin; 2437 2295 if (v->flavor == f_simple) 2438 2296 v->value = allocated_variable_expand (v->value); … … 2468 2326 2469 2327 current_variable_set_list = f->variables; 2470 #ifndef CONFIG_WITH_VALUE_LENGTH 2471 v = try_variable_definition (flocp, defn, origin, 1); 2472 #else 2473 v = try_variable_definition (flocp, defn, NULL, origin, 1); 2474 #endif 2328 v = try_variable_definition (flocp, defn IF_WITH_VALUE_LENGTH_PARAM(NULL), origin, 1); 2475 2329 if (!v) 2476 error(flocp, _("Malformed target-specific variable definition"));2330 fatal (flocp, _("Malformed target-specific variable definition")); 2477 2331 current_variable_set_list = global; 2478 2332 } 2479 2333 2480 2334 /* Set up the variable to be *-specific. */ 2481 v->origin = origin;2482 2335 v->per_target = 1; 2483 v->export = exported ? v_export : v_default; 2336 v->private_var = vmod->private_v; 2337 v->export = vmod->export_v ? v_export : v_default; 2484 2338 2485 2339 /* If it's not an override, check to see if there was a command-line 2486 2340 setting. If so, reset the value. */ 2487 if ( origin != o_override)2341 if (v->origin != o_override) 2488 2342 { 2489 2343 struct variable *gv; … … 2507 2361 v->value = xstrdup (gv->value); 2508 2362 #else 2509 v->value = savestring(gv->value, gv->value_length);2363 v->value = xstrndup (gv->value, gv->value_length); 2510 2364 v->value_length = gv->value_length; 2511 2365 #endif … … 2530 2384 that are not incorporated into other data structures. */ 2531 2385 2532 #ifndef CONFIG_WITH_INCLUDEDEP2533 2386 static void 2534 #else2535 void2536 #endif2537 2387 record_files (struct nameseq *filenames, const char *pattern, 2538 const char *pattern_percent, struct dep *deps,2388 const char *pattern_percent, char *depstr, 2539 2389 unsigned int cmds_started, char *commands, 2540 2390 unsigned int commands_idx, int two_colon, 2541 2391 const struct floc *flocp) 2542 2392 { 2543 struct nameseq *nextf;2544 int implicit = 0;2545 unsigned int max_targets = 0, target_idx = 0;2546 const char **targets = 0, **target_percents = 0;2547 struct commands *cmds;2548 2393 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 2549 2394 struct file *prev_file = 0; … … 2551 2396 multi_mode = !two_colon && !pattern ? m_unsettled : m_no; 2552 2397 #endif 2398 struct commands *cmds; 2399 struct dep *deps; 2400 const char *implicit_percent; 2401 const char *name; 2553 2402 2554 2403 /* If we've already snapped deps, that means we're in an eval being … … 2559 2408 fatal (flocp, _("prerequisites cannot be defined in recipes")); 2560 2409 2410 /* Determine if this is a pattern rule or not. */ 2411 name = filenames->name; 2412 implicit_percent = find_percent_cached (&name); 2413 2414 /* If there's a recipe, set up a struct for it. */ 2561 2415 if (commands_idx > 0) 2562 2416 { … … 2568 2422 cmds->fileinfo.filenm = flocp->filenm; 2569 2423 cmds->fileinfo.lineno = cmds_started; 2570 cmds->commands = savestring(commands, commands_idx);2424 cmds->commands = xstrndup (commands, commands_idx); 2571 2425 cmds->command_lines = 0; 2572 2426 #ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS … … 2575 2429 } 2576 2430 else 2577 cmds = 0; 2578 2579 for (; filenames != 0; filenames = nextf) 2431 cmds = 0; 2432 2433 /* If there's a prereq string then parse it--unless it's eligible for 2nd 2434 expansion: if so, snap_deps() will do it. */ 2435 if (depstr == 0) 2436 deps = 0; 2437 else if (second_expansion && strchr (depstr, '$')) 2580 2438 { 2581 const char *name = filenames->name; 2439 deps = alloc_dep (); 2440 deps->name = depstr; 2441 deps->need_2nd_expansion = 1; 2442 deps->staticpattern = pattern != 0; 2443 } 2444 else 2445 { 2446 deps = split_prereqs (depstr); 2447 free (depstr); 2448 2449 /* We'll enter static pattern prereqs later when we have the stem. We 2450 don't want to enter pattern rules at all so that we don't think that 2451 they ought to exist (make manual "Implicit Rule Search Algorithm", 2452 item 5c). */ 2453 if (! pattern && ! implicit_percent) 2454 deps = enter_prereqs (deps, NULL); 2455 } 2456 2457 /* For implicit rules, _all_ the targets must have a pattern. That means we 2458 can test the first one to see if we're working with an implicit rule; if 2459 so we handle it specially. */ 2460 2461 if (implicit_percent) 2462 { 2463 struct nameseq *nextf; 2464 const char **targets, **target_pats; 2465 unsigned int c; 2466 2467 if (pattern != 0) 2468 fatal (flocp, _("mixed implicit and static pattern rules")); 2469 2470 /* Count the targets to create an array of target names. 2471 We already have the first one. */ 2472 nextf = filenames->next; 2473 free_ns (filenames); 2474 filenames = nextf; 2475 2476 for (c = 1; nextf; ++c, nextf = nextf->next) 2477 ; 2478 targets = xmalloc (c * sizeof (const char *)); 2479 target_pats = xmalloc (c * sizeof (const char *)); 2480 2481 targets[0] = name; 2482 target_pats[0] = implicit_percent; 2483 2484 c = 1; 2485 while (filenames) 2486 { 2487 name = filenames->name; 2488 implicit_percent = find_percent_cached (&name); 2489 2490 if (implicit_percent == 0) 2491 fatal (flocp, _("mixed implicit and normal rules")); 2492 2493 targets[c] = name; 2494 target_pats[c] = implicit_percent; 2495 ++c; 2496 2497 nextf = filenames->next; 2498 free_ns (filenames); 2499 filenames = nextf; 2500 } 2501 2502 create_pattern_rule (targets, target_pats, c, two_colon, deps, cmds, 1); 2503 2504 return; 2505 } 2506 2507 2508 /* Walk through each target and create it in the database. 2509 We already set up the first target, above. */ 2510 while (1) 2511 { 2512 struct nameseq *nextf = filenames->next; 2582 2513 struct file *f; 2583 2514 struct dep *this = 0; 2584 const char *implicit_percent; 2585 2586 nextf = filenames->next; 2587 #ifndef CONFIG_WITH_ALLOC_CACHES 2588 free (filenames); 2589 #else 2590 alloccache_free (&nameseq_cache, filenames); 2591 #endif 2515 2516 free_ns (filenames); 2592 2517 2593 2518 /* Check for special targets. Do it here instead of, say, snap_deps() 2594 2519 so that we can immediately use the value. */ 2595 2596 2520 if (streq (name, ".POSIX")) 2597 posix_pedantic = 1; 2521 { 2522 posix_pedantic = 1; 2523 define_variable_cname (".SHELLFLAGS", "-ec", o_default, 0); 2524 } 2598 2525 else if (streq (name, ".SECONDEXPANSION")) 2599 2526 second_expansion = 1; … … 2602 2529 second_target_expansion = 1; 2603 2530 #endif 2604 2605 implicit_percent = find_percent_cached (&name); 2606 implicit |= implicit_percent != 0; 2607 2608 if (implicit) 2609 { 2610 if (pattern != 0) 2611 fatal (flocp, _("mixed implicit and static pattern rules")); 2612 2613 if (implicit_percent == 0) 2614 fatal (flocp, _("mixed implicit and normal rules")); 2615 2616 if (targets == 0) 2617 { 2618 max_targets = 5; 2619 targets = xmalloc (5 * sizeof (char *)); 2620 target_percents = xmalloc (5 * sizeof (char *)); 2621 target_idx = 0; 2622 } 2623 else if (target_idx == max_targets - 1) 2624 { 2625 max_targets += 5; 2626 targets = xrealloc ((void *)targets, max_targets * sizeof (char *)); 2627 target_percents = xrealloc ((void *)target_percents, 2628 max_targets * sizeof (char *)); 2629 } 2630 targets[target_idx] = name; 2631 target_percents[target_idx] = implicit_percent; 2632 ++target_idx; 2633 continue; 2634 } 2531 #if !defined(WINDOWS32) && !defined (__MSDOS__) && !defined (__EMX__) 2532 else if (streq (name, ".ONESHELL")) 2533 one_shell = 1; 2534 #endif 2635 2535 2636 2536 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET … … 2670 2570 } 2671 2571 multi_mode = name[1] == '\0' ? m_yes : m_yes_maybe; 2672 continue;2572 goto l_next; 2673 2573 } 2674 2574 } … … 2678 2578 2679 2579 /* If this is a static pattern rule: 2680 `targets: target%pattern: dep%pattern; cmds',2580 `targets: target%pattern: prereq%pattern; recipe', 2681 2581 make sure the pattern matches this target name. */ 2682 2582 if (pattern && !pattern_matches (pattern, pattern_percent, name)) 2683 2583 error (flocp, _("target `%s' doesn't match the target pattern"), name); 2684 2584 else if (deps) 2685 { 2686 /* If there are multiple filenames, copy the chain DEPS for all but 2687 the last one. It is not safe for the same deps to go in more 2688 than one place in the database. */ 2689 this = nextf != 0 ? copy_dep_chain (deps) : deps; 2690 this->need_2nd_expansion = (second_expansion 2691 && strchr (this->name, '$')); 2692 } 2693 2585 /* If there are multiple targets, copy the chain DEPS for all but the 2586 last one. It is not safe for the same deps to go in more than one 2587 place in the database. */ 2588 this = nextf != 0 ? copy_dep_chain (deps) : deps; 2589 2590 /* Find or create an entry in the file database for this target. */ 2694 2591 if (!two_colon) 2695 2592 { 2696 /* Single-colon. Combine th ese dependencies2697 with others in file's existing record,if any. */2593 /* Single-colon. Combine this rule with the file's existing record, 2594 if any. */ 2698 2595 #ifndef KMK 2699 2596 f = enter_file (strcache_add (name)); … … 2701 2598 f = enter_file (name); 2702 2599 #endif 2703 2704 2600 if (f->double_colon) 2705 2601 fatal (flocp, … … 2726 2622 } 2727 2623 2728 f->is_target = 1;2729 2730 2624 /* Defining .DEFAULT with no deps or cmds clears it. */ 2731 2625 if (f == default_file && this == 0 && cmds == 0) … … 2759 2653 free_dep_chain (f->deps); 2760 2654 f->deps = 0; 2761 }2762 else if (this != 0)2763 {2764 /* Add the file's old deps and the new ones in THIS together. */2765 2766 if (f->deps != 0)2767 {2768 struct dep **d_ptr = &f->deps;2769 2770 while ((*d_ptr)->next != 0)2771 d_ptr = &(*d_ptr)->next;2772 2773 if (cmds != 0)2774 /* This is the rule with commands, so put its deps2775 last. The rationale behind this is that $< expands to2776 the first dep in the chain, and commands use $<2777 expecting to get the dep that rule specifies. However2778 the second expansion algorithm reverses the order thus2779 we need to make it last here. */2780 (*d_ptr)->next = this;2781 else2782 {2783 /* This is the rule without commands. Put its2784 dependencies at the end but before dependencies from2785 the rule with commands (if any). This way everything2786 appears in makefile order. */2787 2788 if (f->cmds != 0)2789 {2790 #ifndef KMK /* bugfix: Don't chop the chain! */2791 this->next = *d_ptr;2792 *d_ptr = this;2793 #else /* KMK */2794 struct dep *this_last = this;2795 while (this_last->next)2796 this_last = this_last->next;2797 this_last->next = *d_ptr;2798 *d_ptr = this;2799 #endif /* KMK */2800 }2801 else2802 (*d_ptr)->next = this;2803 }2804 }2805 else2806 f->deps = this;2807 2808 /* This is a hack. I need a way to communicate to snap_deps()2809 that the last dependency line in this file came with commands2810 (so that logic in snap_deps() can put it in front and all2811 this $< -logic works). I cannot simply rely on file->cmds2812 being not 0 because of the cases like the following:2813 2814 foo: bar2815 foo:2816 ...2817 2818 I am going to temporarily "borrow" UPDATING member in2819 `struct file' for this. */2820 2821 if (cmds != 0)2822 f->updating = 1;2823 2655 } 2824 2656 } … … 2832 2664 #endif /* CONFIG_WITH_STRCACHE2 */ 2833 2665 2834 /* Check for both : and :: rules. Check is_target so 2835 we don't loseon default suffix rules or makefiles. */2666 /* Check for both : and :: rules. Check is_target so we don't lose 2667 on default suffix rules or makefiles. */ 2836 2668 if (f != 0 && f->is_target && !f->double_colon) 2837 2669 fatal (flocp, 2838 2670 _("target file `%s' has both : and :: entries"), f->name); 2671 2839 2672 #ifndef KMK 2840 2673 f = enter_file (strcache_add (name)); … … 2850 2683 double_colon pointer to itself. */ 2851 2684 f->double_colon = f; 2852 f->is_target = 1; 2853 f->deps = this; 2685 2854 2686 f->cmds = cmds; 2855 2687 } 2856 2688 2689 f->is_target = 1; 2690 2857 2691 /* If this is a static pattern rule, set the stem to the part of its 2858 2692 name that matched the `%' in the pattern, so you can use $* in the 2859 commands. */2693 commands. If we didn't do it before, enter the prereqs now. */ 2860 2694 if (pattern) 2861 2695 { … … 2869 2703 if (this) 2870 2704 { 2871 this->staticpattern = 1; 2872 this->stem = f->stem; 2705 if (! this->need_2nd_expansion) 2706 this = enter_prereqs (this, f->stem); 2707 else 2708 this->stem = f->stem; 2873 2709 } 2874 2710 } 2875 2711 2712 /* Add the dependencies to this file entry. */ 2713 if (this != 0) 2714 { 2715 /* Add the file's old deps and the new ones in THIS together. */ 2716 if (f->deps == 0) 2717 f->deps = this; 2718 else if (cmds != 0) 2719 { 2720 struct dep *d = this; 2721 2722 /* If this rule has commands, put these deps first. */ 2723 while (d->next != 0) 2724 d = d->next; 2725 2726 d->next = f->deps; 2727 f->deps = this; 2728 } 2729 else 2730 { 2731 struct dep *d = f->deps; 2732 2733 /* A rule without commands: put its prereqs at the end. */ 2734 while (d->next != 0) 2735 d = d->next; 2736 2737 d->next = this; 2738 } 2739 } 2740 2876 2741 name = f->name; 2877 2742 2878 /* If this target is a default target, update DEFAULT_GOAL_FILE. */ 2879 if (streq (*default_goal_name, name) 2880 && (default_goal_file == 0 2881 || ! streq (default_goal_file->name, name)))2882 default_goal_file = f;2883 }2884 2885 if (implicit)2886 { 2887 if (deps)2888 deps->need_2nd_expansion = second_expansion;2889 create_pattern_rule (targets, target_percents, target_idx,2890 two_colon, deps, cmds, 1);2743 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 2744 l_next: 2745 #endif 2746 /* All done! Set up for the next one. */ 2747 if (nextf == 0) 2748 break; 2749 2750 filenames = nextf; 2751 2752 /* Reduce escaped percents. If there are any unescaped it's an error */ 2753 name = filenames->name; 2754 if (find_percent_cached (&name)) 2755 fatal (flocp, _("mixed implicit and normal rules")); 2891 2756 } 2892 2757 } … … 3111 2976 3112 2977 3113 /* Parse a string into a sequence of filenames represented as a3114 chain of struct nameseq's in reverse order and return that chain.3115 3116 The string is passed as STRINGP, the address of a string pointer.3117 The string pointer is updated to point at the first character3118 not parsed, which either is a null char or equals STOPCHAR.3119 3120 SIZE is how big to construct chain elements.3121 This is useful if we want them actually to be other structures3122 that have room for additional info.3123 3124 If STRIP is nonzero, strip `./'s off the beginning. */3125 3126 #ifndef CONFIG_WITH_ALLOC_CACHES3127 struct nameseq *3128 parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip)3129 #else3130 struct nameseq *3131 parse_file_seq (char **stringp, int stopchar, struct alloccache *cache, int strip)3132 #endif3133 {3134 struct nameseq *new = 0;3135 struct nameseq *new1;3136 #ifndef NO_ARCHIVES /* bird: MSC warning */3137 struct nameseq *lastnew1;3138 #endif3139 char *p = *stringp;3140 3141 #ifdef VMS3142 # define VMS_COMMA ','3143 #else3144 # define VMS_COMMA 03145 #endif3146 3147 while (1)3148 {3149 const char *name;3150 char *q;3151 3152 /* Skip whitespace; see if any more names are left. */3153 p = next_token (p);3154 if (*p == '\0')3155 break;3156 if (*p == stopchar)3157 break;3158 3159 /* There are, so find the end of the next name. */3160 q = p;3161 p = find_char_unquote (q, stopchar, VMS_COMMA, 1, 0);3162 #ifdef VMS3163 /* convert comma separated list to space separated */3164 if (p && *p == ',')3165 *p =' ';3166 #endif3167 #ifdef _AMIGA3168 if (stopchar == ':' && p && *p == ':'3169 && !(isspace ((unsigned char)p[1]) || !p[1]3170 || isspace ((unsigned char)p[-1])))3171 p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0);3172 #endif3173 #ifdef HAVE_DOS_PATHS3174 /* For DOS paths, skip a "C:\..." or a "C:/..." until we find the3175 first colon which isn't followed by a slash or a backslash.3176 Note that tokens separated by spaces should be treated as separate3177 tokens since make doesn't allow path names with spaces */3178 if (stopchar == ':')3179 while (p != 0 && !isspace ((unsigned char)*p) &&3180 (p[1] == '\\' || p[1] == '/') && isalpha ((unsigned char)p[-1]))3181 p = find_char_unquote (p + 1, stopchar, VMS_COMMA, 1, 0);3182 #endif3183 if (p == 0)3184 p = q + strlen (q);3185 3186 if (strip)3187 #ifdef VMS3188 /* Skip leading `[]'s. */3189 while (p - q > 2 && q[0] == '[' && q[1] == ']')3190 #else3191 /* Skip leading `./'s. */3192 while (p - q > 2 && q[0] == '.' && q[1] == '/')3193 #endif3194 {3195 q += 2; /* Skip "./". */3196 while (q < p && *q == '/')3197 /* Skip following slashes: ".//foo" is "foo", not "/foo". */3198 ++q;3199 }3200 3201 /* Extract the filename just found, and skip it. */3202 3203 if (q == p)3204 /* ".///" was stripped to "". */3205 #if defined(VMS)3206 continue;3207 #elif defined(_AMIGA)3208 name = "";3209 #else3210 name = "./";3211 #endif3212 else3213 #ifdef VMS3214 /* VMS filenames can have a ':' in them but they have to be '\'ed but we need3215 * to remove this '\' before we can use the filename.3216 * Savestring called because q may be read-only string constant.3217 */3218 {3219 char *qbase = xstrdup (q);3220 char *pbase = qbase + (p-q);3221 char *q1 = qbase;3222 char *q2 = q1;3223 char *p1 = pbase;3224 3225 while (q1 != pbase)3226 {3227 if (*q1 == '\\' && *(q1+1) == ':')3228 {3229 q1++;3230 p1--;3231 }3232 *q2++ = *q1++;3233 }3234 name = strcache_add_len (qbase, p1 - qbase);3235 free (qbase);3236 }3237 #elif !defined (CONFIG_WITH_VALUE_LENGTH) || defined (CONFIG_WITH_STRCACHE2)3238 name = strcache_add_len (q, p - q);3239 #else /* CONFIG_WITH_VALUE_LENGTH */3240 {3241 /* Make sure it's terminated, strcache_add_len has to make a3242 temp copy on the stack otherwise. */3243 char saved = *p;3244 if (!saved)3245 *p = '\0';3246 name = strcache_add_len (q, p - q);3247 if (saved)3248 *p = saved;3249 }3250 #endif /* CONFIG_WITH_VALUE_LENGTH */3251 3252 /* Add it to the front of the chain. */3253 #ifndef CONFIG_WITH_ALLOC_CACHES3254 new1 = xmalloc (size);3255 memset (new1, '\0', size);3256 #else3257 new1 = (struct nameseq *) alloccache_calloc (cache);3258 #endif3259 new1->name = name;3260 new1->next = new;3261 new = new1;3262 }3263 3264 #ifndef NO_ARCHIVES3265 3266 /* Look for multi-word archive references.3267 They are indicated by a elt ending with an unmatched `)' and3268 an elt further down the chain (i.e., previous in the file list)3269 with an unmatched `(' (e.g., "lib(mem"). */3270 3271 new1 = new;3272 lastnew1 = 0;3273 while (new1 != 0)3274 if (new1->name[0] != '(' /* Don't catch "(%)" and suchlike. */3275 && new1->name[strlen (new1->name) - 1] == ')'3276 && strchr (new1->name, '(') == 0)3277 {3278 /* NEW1 ends with a `)' but does not contain a `('.3279 Look back for an elt with an opening `(' but no closing `)'. */3280 3281 struct nameseq *n = new1->next, *lastn = new1;3282 char *paren = 0;3283 while (n != 0 && (paren = strchr (n->name, '(')) == 0)3284 {3285 lastn = n;3286 n = n->next;3287 }3288 if (n != 03289 /* Ignore something starting with `(', as that cannot actually3290 be an archive-member reference (and treating it as such3291 results in an empty file name, which causes much lossage). */3292 && n->name[0] != '(')3293 {3294 /* N is the first element in the archive group.3295 Its name looks like "lib(mem" (with no closing `)'). */3296 3297 char *libname;3298 3299 /* Copy "lib(" into LIBNAME. */3300 ++paren;3301 libname = alloca (paren - n->name + 1);3302 memcpy (libname, n->name, paren - n->name);3303 libname[paren - n->name] = '\0';3304 3305 if (*paren == '\0')3306 {3307 /* N was just "lib(", part of something like "lib( a b)".3308 Edit it out of the chain and free its storage. */3309 lastn->next = n->next;3310 #ifndef CONFIG_WITH_ALLOC_CACHES3311 free (n);3312 #else3313 alloccache_free (cache, n);3314 #endif3315 /* LASTN->next is the new stopping elt for the loop below. */3316 n = lastn->next;3317 }3318 else3319 {3320 /* Replace N's name with the full archive reference. */3321 n->name = strcache_add (concat (libname, paren, ")"));3322 }3323 3324 if (new1->name[1] == '\0')3325 {3326 /* NEW1 is just ")", part of something like "lib(a b )".3327 Omit it from the chain and free its storage. */3328 if (lastnew1 == 0)3329 new = new1->next;3330 else3331 lastnew1->next = new1->next;3332 lastn = new1;3333 new1 = new1->next;3334 #ifndef CONFIG_WITH_ALLOC_CACHES3335 free (lastn);3336 #else3337 alloccache_free (cache, lastn);3338 #endif3339 }3340 else3341 {3342 /* Replace also NEW1->name, which already has closing `)'. */3343 new1->name = strcache_add (concat (libname, new1->name, ""));3344 new1 = new1->next;3345 }3346 3347 /* Trace back from NEW1 (the end of the list) until N3348 (the beginning of the list), rewriting each name3349 with the full archive reference. */3350 3351 while (new1 != n)3352 {3353 new1->name = strcache_add (concat (libname, new1->name, ")"));3354 lastnew1 = new1;3355 new1 = new1->next;3356 }3357 }3358 else3359 {3360 /* No frobnication happening. Just step down the list. */3361 lastnew1 = new1;3362 new1 = new1->next;3363 }3364 }3365 else3366 {3367 lastnew1 = new1;3368 new1 = new1->next;3369 }3370 3371 #endif3372 3373 *stringp = p;3374 return new;3375 }3376 3377 3378 2978 /* Find the next line of text in an eval buffer, combining continuation lines 3379 2979 into one line. … … 3412 3012 { 3413 3013 int backslash = 0; 3414 c har *bol = eol;3415 c har *p;3014 const char *bol = eol; 3015 const char *p; 3416 3016 3417 3017 /* Find the next newline. At EOS, stop. */ 3418 3018 #ifndef CONFIG_WITH_VALUE_LENGTH 3419 eol = p= strchr (eol , '\n');3019 p = eol = strchr (eol , '\n'); 3420 3020 #else 3421 3021 p = (char *)memchr (eol, '\n', end - eol); 3422 3022 assert (!memchr (eol, '\0', p != 0 ? p - eol : end - eol)); 3423 eol = p;3023 eol = (char *)p; 3424 3024 #endif 3425 3025 if (!eol) … … 3933 3533 if (home_dir != 0) 3934 3534 { 3935 char *new = xstrdup (concat ( home_dir, "", name + 1));3535 char *new = xstrdup (concat (2, home_dir, name + 1)); 3936 3536 if (is_variable) 3937 3537 free (home_dir); … … 3952 3552 return xstrdup (pwent->pw_dir); 3953 3553 else 3954 return xstrdup (concat ( pwent->pw_dir, "/", userend + 1));3554 return xstrdup (concat (3, pwent->pw_dir, "/", userend + 1)); 3955 3555 } 3956 3556 else if (userend != 0) … … 3962 3562 } 3963 3563 3964 /* Given a chain of struct nameseq's describing a sequence of filenames, 3965 in reverse of the intended order, return a new chain describing the 3966 result of globbing the filenames. The new chain is in forward order. 3967 The links of the old chain are freed or used in the new chain. 3968 Likewise for the names in the old chain. 3564 3565 /* Parse a string into a sequence of filenames represented as a chain of 3566 struct nameseq's and return that chain. Optionally expand the strings via 3567 glob(). 3568 3569 The string is passed as STRINGP, the address of a string pointer. 3570 The string pointer is updated to point at the first character 3571 not parsed, which either is a null char or equals STOPCHAR. 3969 3572 3970 3573 SIZE is how big to construct chain elements. 3971 3574 This is useful if we want them actually to be other structures 3972 that have room for additional info. */ 3973 3575 that have room for additional info. 3576 3577 PREFIX, if non-null, is added to the beginning of each filename. 3578 3579 FLAGS allows one or more of the following bitflags to be set: 3580 PARSEFS_NOSTRIP - Do no strip './'s off the beginning 3581 PARSEFS_NOAR - Do not check filenames for archive references 3582 PARSEFS_NOGLOB - Do not expand globbing characters 3583 PARSEFS_EXISTS - Only return globbed files that actually exist 3584 (cannot also set NOGLOB) 3585 PARSEFS_NOCACHE - Do not add filenames to the strcache (caller frees) 3586 */ 3587 3588 void * 3589 parse_file_seq (char **stringp, unsigned int size, int stopchar, 3590 const char *prefix, int flags 3591 IF_WITH_ALLOC_CACHES_PARAM(struct alloccache *alloc_cache) ) 3592 { 3593 extern void dir_setup_glob (glob_t *glob); 3594 3595 /* tmp points to tmpbuf after the prefix, if any. 3596 tp is the end of the buffer. */ 3597 static char *tmpbuf = NULL; 3598 static int tmpbuf_len = 0; 3599 3600 int cachep = (! (flags & PARSEFS_NOCACHE)); 3601 3602 struct nameseq *new = 0; 3603 struct nameseq **newp = &new; 3974 3604 #ifndef CONFIG_WITH_ALLOC_CACHES 3975 struct nameseq * 3976 multi_glob (struct nameseq *chain, unsigned int size) 3977 #else 3978 struct nameseq * 3979 multi_glob (struct nameseq *chain, struct alloccache *cache) 3980 #endif 3981 { 3982 void dir_setup_glob (glob_t *); 3983 struct nameseq *new = 0; 3984 struct nameseq *old; 3985 struct nameseq *nexto; 3605 #define NEWELT(_n) do { \ 3606 const char *__n = (_n); \ 3607 *newp = xcalloc (size); \ 3608 (*newp)->name = (cachep ? strcache_add (__n) : xstrdup (__n)); \ 3609 newp = &(*newp)->next; \ 3610 } while(0) 3611 #else 3612 # define NEWELT(_n) do { \ 3613 const char *__n = (_n); \ 3614 *newp = alloccache_calloc (alloc_cache); \ 3615 (*newp)->name = (cachep ? strcache_add (__n) : xstrdup (__n)); \ 3616 newp = &(*newp)->next; \ 3617 } while(0) 3618 #endif 3619 3620 char *p; 3986 3621 glob_t gl; 3987 #if defined(KMK) || defined(__EMX__) /* speed optimization */ 3988 int rc; 3989 #endif 3990 3991 dir_setup_glob (&gl); 3992 3993 for (old = chain; old != 0; old = nexto) 3622 char *tp; 3623 3624 #ifdef VMS 3625 # define VMS_COMMA ',' 3626 #else 3627 # define VMS_COMMA 0 3628 #endif 3629 3630 if (size < sizeof (struct nameseq)) 3631 size = sizeof (struct nameseq); 3632 3633 if (! (flags & PARSEFS_NOGLOB)) 3634 dir_setup_glob (&gl); 3635 3636 /* Get enough temporary space to construct the largest possible target. */ 3637 { 3638 int l = strlen (*stringp) + 1; 3639 if (l > tmpbuf_len) 3640 { 3641 tmpbuf = xrealloc (tmpbuf, l); 3642 tmpbuf_len = l; 3643 } 3644 } 3645 tp = tmpbuf; 3646 3647 /* Parse STRING. P will always point to the end of the parsed content. */ 3648 p = *stringp; 3649 while (1) 3994 3650 { 3995 const char *gname; 3651 const char *name; 3652 const char **nlist = 0; 3653 char *tildep = 0; 3996 3654 #ifndef NO_ARCHIVES 3997 3655 char *arname = 0; 3998 3656 char *memname = 0; 3999 3657 #endif 4000 nexto = old->next; 4001 gname = old->name; 4002 4003 if (gname[0] == '~') 3658 char *s; 3659 int nlen; 3660 int i; 3661 3662 /* Skip whitespace; at the end of the string or STOPCHAR we're done. */ 3663 p = next_token (p); 3664 if (*p == '\0' || *p == stopchar) 3665 break; 3666 3667 /* There are names left, so find the end of the next name. 3668 Throughout this iteration S points to the start. */ 3669 s = p; 3670 p = find_char_unquote (p, stopchar, VMS_COMMA, 1, 0); 3671 #ifdef VMS 3672 /* convert comma separated list to space separated */ 3673 if (p && *p == ',') 3674 *p =' '; 3675 #endif 3676 #ifdef _AMIGA 3677 if (stopchar == ':' && p && *p == ':' 3678 && !(isspace ((unsigned char)p[1]) || !p[1] 3679 || isspace ((unsigned char)p[-1]))) 3680 p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0); 3681 #endif 3682 #ifdef HAVE_DOS_PATHS 3683 /* For DOS paths, skip a "C:\..." or a "C:/..." until we find the 3684 first colon which isn't followed by a slash or a backslash. 3685 Note that tokens separated by spaces should be treated as separate 3686 tokens since make doesn't allow path names with spaces */ 3687 if (stopchar == ':') 3688 while (p != 0 && !isspace ((unsigned char)*p) && 3689 (p[1] == '\\' || p[1] == '/') && isalpha ((unsigned char)p[-1])) 3690 p = find_char_unquote (p + 1, stopchar, VMS_COMMA, 1, 0); 3691 #endif 3692 if (p == 0) 3693 p = s + strlen (s); 3694 3695 /* Strip leading "this directory" references. */ 3696 if (! (flags & PARSEFS_NOSTRIP)) 3697 #ifdef VMS 3698 /* Skip leading `[]'s. */ 3699 while (p - s > 2 && s[0] == '[' && s[1] == ']') 3700 #else 3701 /* Skip leading `./'s. */ 3702 while (p - s > 2 && s[0] == '.' && s[1] == '/') 3703 #endif 3704 { 3705 /* Skip "./" and all following slashes. */ 3706 s += 2; 3707 while (*s == '/') 3708 ++s; 3709 } 3710 3711 /* Extract the filename just found, and skip it. 3712 Set NAME to the string, and NLEN to its length. */ 3713 3714 if (s == p) 3715 { 3716 /* The name was stripped to empty ("./"). */ 3717 #if defined(VMS) 3718 continue; 3719 #elif defined(_AMIGA) 3720 /* PDS-- This cannot be right!! */ 3721 tp[0] = '\0'; 3722 nlen = 0; 3723 #else 3724 tp[0] = '.'; 3725 tp[1] = '/'; 3726 tp[2] = '\0'; 3727 nlen = 2; 3728 #endif 3729 } 3730 else 4004 3731 { 4005 char *newname = tilde_expand (old->name); 4006 if (newname != 0) 4007 gname = newname; 3732 #ifdef VMS 3733 /* VMS filenames can have a ':' in them but they have to be '\'ed but we need 3734 * to remove this '\' before we can use the filename. 3735 * xstrdup called because S may be read-only string constant. 3736 */ 3737 char *n = tp; 3738 while (s < p) 3739 { 3740 if (s[0] == '\\' && s[1] == ':') 3741 ++s; 3742 *(n++) = *(s++); 3743 } 3744 n[0] = '\0'; 3745 nlen = strlen (tp); 3746 #else 3747 nlen = p - s; 3748 memcpy (tp, s, nlen); 3749 tp[nlen] = '\0'; 3750 #endif 3751 } 3752 3753 /* At this point, TP points to the element and NLEN is its length. */ 3754 3755 #ifndef NO_ARCHIVES 3756 /* If this is the start of an archive group that isn't complete, set up 3757 to add the archive prefix for future files. A file list like: 3758 "libf.a(x.o y.o z.o)" needs to be expanded as: 3759 "libf.a(x.o) libf.a(y.o) libf.a(z.o)" 3760 3761 TP == TMP means we're not already in an archive group. Ignore 3762 something starting with `(', as that cannot actually be an 3763 archive-member reference (and treating it as such results in an empty 3764 file name, which causes much lossage). Also if it ends in ")" then 3765 it's a complete reference so we don't need to treat it specially. 3766 3767 Finally, note that archive groups must end with ')' as the last 3768 character, so ensure there's some word ending like that before 3769 considering this an archive group. */ 3770 if (! (flags & PARSEFS_NOAR) 3771 && tp == tmpbuf && tp[0] != '(' && tp[nlen-1] != ')') 3772 { 3773 char *n = strchr (tp, '('); 3774 if (n) 3775 { 3776 /* This looks like the first element in an open archive group. 3777 A valid group MUST have ')' as the last character. */ 3778 const char *e = p + nlen; 3779 do 3780 { 3781 e = next_token (e); 3782 /* Find the end of this word. We don't want to unquote and 3783 we don't care about quoting since we're looking for the 3784 last char in the word. */ 3785 while (*e != '\0' && *e != stopchar && *e != VMS_COMMA 3786 && ! isblank ((unsigned char) *e)) 3787 ++e; 3788 if (e[-1] == ')') 3789 { 3790 /* Found the end, so this is the first element in an 3791 open archive group. It looks like "lib(mem". 3792 Reset TP past the open paren. */ 3793 nlen -= (n + 1) - tp; 3794 tp = n + 1; 3795 3796 /* If we have just "lib(", part of something like 3797 "lib( a b)", go to the next item. */ 3798 if (! nlen) 3799 continue; 3800 3801 /* We can stop looking now. */ 3802 break; 3803 } 3804 } 3805 while (*e != '\0'); 3806 } 3807 } 3808 3809 /* If we are inside an archive group, make sure it has an end. */ 3810 if (tp > tmpbuf) 3811 { 3812 if (tp[nlen-1] == ')') 3813 { 3814 /* This is the natural end; reset TP. */ 3815 tp = tmpbuf; 3816 3817 /* This is just ")", something like "lib(a b )": skip it. */ 3818 if (nlen == 1) 3819 continue; 3820 } 3821 else 3822 { 3823 /* Not the end, so add a "fake" end. */ 3824 tp[nlen++] = ')'; 3825 tp[nlen] = '\0'; 3826 } 3827 } 3828 #endif 3829 3830 /* If we're not globbing we're done: add it to the end of the chain. 3831 Go to the next item in the string. */ 3832 if (flags & PARSEFS_NOGLOB) 3833 { 3834 NEWELT (concat (2, prefix, tp)); 3835 continue; 3836 } 3837 3838 /* If we get here we know we're doing glob expansion. 3839 TP is a string in tmpbuf. NLEN is no longer used. 3840 We may need to do more work: after this NAME will be set. */ 3841 name = tp; 3842 3843 /* Expand tilde if applicable. */ 3844 if (tp[0] == '~') 3845 { 3846 tildep = tilde_expand (tp); 3847 if (tildep != 0) 3848 name = tildep; 4008 3849 } 4009 3850 4010 3851 #ifndef NO_ARCHIVES 4011 if (ar_name (gname)) 3852 /* If NAME is an archive member reference replace it with the archive 3853 file name, and save the member name in MEMNAME. We will glob on the 3854 archive name and then reattach MEMNAME later. */ 3855 if (! (flags & PARSEFS_NOAR) && ar_name (name)) 4012 3856 { 4013 /* OLD->name is an archive member reference. Replace it with the 4014 archive file name, and save the member name in MEMNAME. We will 4015 glob on the archive name and then reattach MEMNAME later. */ 4016 ar_parse_name (gname, &arname, &memname); 4017 gname = arname; 3857 ar_parse_name (name, &arname, &memname); 3858 name = arname; 4018 3859 } 4019 3860 #endif /* !NO_ARCHIVES */ 4020 3861 4021 #if defined(KMK) || defined(__EMX__) /* speed optimization */ 4022 if (!strpbrk(gname, "*?[")) 4023 { 4024 gl.gl_pathc = 1; 4025 gl.gl_pathv = (char **)&gname; 4026 rc = 0; 4027 } 4028 else 4029 rc = glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl); 4030 switch (rc) 4031 #else 4032 switch (glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl)) 4033 #endif 3862 switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl)) 4034 3863 { 4035 case 0: /* Success. */4036 {4037 int i = gl.gl_pathc;4038 while (i-- > 0)4039 {4040 #ifndef NO_ARCHIVES4041 if (memname != 0)4042 {4043 /* Try to glob on MEMNAME within the archive. */4044 struct nameseq *found4045 = ar_glob (gl.gl_pathv[i], memname, size);4046 if (! found)4047 {4048 /* No matches. Use MEMNAME as-is. */4049 unsigned int alen = strlen (gl.gl_pathv[i]);4050 unsigned int mlen = strlen (memname);4051 char *name;4052 struct nameseq *elt = xmalloc (size);4053 memset (elt, '\0', size);4054 4055 name = alloca (alen + 1 + mlen + 2);4056 memcpy (name, gl.gl_pathv[i], alen);4057 name[alen] = '(';4058 memcpy (name+alen+1, memname, mlen);4059 name[alen + 1 + mlen] = ')';4060 name[alen + 1 + mlen + 1] = '\0';4061 elt->name = strcache_add (name);4062 elt->next = new;4063 new = elt;4064 }4065 else4066 {4067 /* Find the end of the FOUND chain. */4068 struct nameseq *f = found;4069 while (f->next != 0)4070 f = f->next;4071 4072 /* Attach the chain being built to the end of the FOUND4073 chain, and make FOUND the new NEW chain. */4074 f->next = new;4075 new = found;4076 }4077 }4078 else4079 #endif /* !NO_ARCHIVES */4080 {4081 #ifndef CONFIG_WITH_ALLOC_CACHES4082 struct nameseq *elt = xmalloc (size);4083 memset (elt, '\0', size);4084 #else4085 struct nameseq *elt = alloccache_calloc (cache);4086 #endif4087 elt->name = strcache_add (gl.gl_pathv[i]);4088 elt->next = new;4089 new = elt;4090 }4091 }4092 #if defined(KMK) || defined(__EMX__) /* speed optimization */4093 if (gl.gl_pathv != (char **)&gname)4094 #endif4095 globfree (&gl);4096 #ifndef CONFIG_WITH_ALLOC_CACHES4097 free (old);4098 #else4099 alloccache_free (cache, old);4100 #endif4101 break;4102 }4103 4104 3864 case GLOB_NOSPACE: 4105 3865 fatal (NILF, _("virtual memory exhausted")); 4106 break; 3866 3867 case 0: 3868 /* Success. */ 3869 i = gl.gl_pathc; 3870 nlist = (const char **)gl.gl_pathv; 3871 break; 3872 3873 case GLOB_NOMATCH: 3874 /* If we want only existing items, skip this one. */ 3875 if (flags & PARSEFS_EXISTS) 3876 { 3877 i = 0; 3878 break; 3879 } 3880 /* FALLTHROUGH */ 4107 3881 4108 3882 default: 4109 old->next = new; 4110 new = old; 4111 break; 3883 /* By default keep this name. */ 3884 i = 1; 3885 nlist = &name; 3886 break; 4112 3887 } 3888 3889 /* For each matched element, add it to the list. */ 3890 while (i-- > 0) 3891 #ifndef NO_ARCHIVES 3892 if (memname != 0) 3893 { 3894 /* Try to glob on MEMNAME within the archive. */ 3895 struct nameseq *found = ar_glob (nlist[i], memname, size); 3896 if (! found) 3897 /* No matches. Use MEMNAME as-is. */ 3898 NEWELT (concat (5, prefix, nlist[i], "(", memname, ")")); 3899 else 3900 { 3901 /* We got a chain of items. Attach them. */ 3902 (*newp)->next = found; 3903 3904 /* Find and set the new end. Massage names if necessary. */ 3905 while (1) 3906 { 3907 if (! cachep) 3908 found->name = xstrdup (concat (2, prefix, name)); 3909 else if (prefix) 3910 found->name = strcache_add (concat (2, prefix, name)); 3911 3912 if (found->next == 0) 3913 break; 3914 3915 found = found->next; 3916 } 3917 newp = &found->next; 3918 } 3919 } 3920 else 3921 #endif /* !NO_ARCHIVES */ 3922 NEWELT (concat (2, prefix, nlist[i])); 3923 3924 globfree (&gl); 4113 3925 4114 3926 #ifndef NO_ARCHIVES … … 4116 3928 free (arname); 4117 3929 #endif 3930 3931 if (tildep) 3932 free (tildep); 4118 3933 } 4119 3934 3935 *stringp = p; 4120 3936 return new; 4121 3937 } -
trunk/src/kmk/readme.vms
r1993 r2591 1 1 This is the VMS version of GNU Make, updated by Hartmut Becker 2 2 3 Changes are based on GNU make 3.80. Latest changes are for OpenVMS/I64 4 and new VMS CRTLs. 5 6 This version was tested on OpenVMS/I64 V8.2 (field test) with hp C 7 X7.1-024 OpenVMS/Alpha V7.3-2 with Compaq C V6.5-001 and OpenVMS/VAX 7.1 8 with Compaq C V6.2-003 There are still some warning and informational 9 message issued by the compilers. 3 Changes are based on GNU make 3.82. 4 5 This version was built and tested on OpenVMS V7.3 (VAX), V7.3-2 (Alpha) and 6 V8.3-1H1 (I64). 10 7 11 8 Build instructions 12 9 Make a 1st version 13 $ @makefile.com 10 $ @makefile.com ! ignore any compiler and/or linker warning 14 11 $ rena make.exe 1st-make.exe 15 12 Use the 1st version to generate a 2nd version … … 21 18 $ mc sys$disk:[]2nd-make 22 19 23 Changes: 20 Changes (3.81.90) 21 22 Michael Gehre (at VISTEC-SEMI dot COM) supplied a fix for a problem with 23 timestamps of object modules in OLBs. The timestamps were not correctly 24 adjusted to GMT based time, if the local VMS time was using a daylight saving 25 algorithm and if daylight saving was switched off. 26 27 John Eisenbraun (at HP dot COM) supplied fixes and and an enhancement to append 28 output redirection in action lines. 29 30 Rework of ctrl+c and ctrl+y handling. 31 32 Fix a problem with cached strings, which showed on case-insensitive file 33 systems. 34 35 Build fixes for const-ified code in VMS specific sources. 36 37 Build notes: 38 - Try to avoid HP C V7.2-001, which has an incompatible change 39 how __STDC__ is defined. This results at least in compile time warnings. 40 41 - On V8.3-1H1, if you press Ctrl+C you may see a traceback, starting with 42 %SYSTEM-F-CONTROLC, operation completed under CTRL/C 43 %TRACE-F-TRACEBACK, symbolic stack dump follows 44 image module routine line rel PC abs PC 45 46 DECC$SHR C$SIGNAL gsignal 27991 0000000000001180 47 FFFFFFFF84AB2DA0 48 DECC$SHR C$SIGNAL raise 28048 0000000000001280 49 FFFFFFFF84AB2EA0 50 DECC$SHR C$SIGPENDING decc$$deliver_signals 51 12475 0000000000000890 52 FFFFFFFF84C13690 53 ... 54 This looks like an incompatibility to the Alpha and VAX behavior, so it looks 55 like a problem in I64 VMS version(s). 56 57 - There is no clean build on VAX. In the environment I tested, I had to use GNU 58 make's alloca which produced a couple of compile time warnings. It seems too 59 much effort to work on a clean build on VAX. 60 61 A note on appending the redirected output. With this change, a simple mechanism 62 is implemented to make ">>" work in action lines. In VMS there is no simple 63 feature like ">>" to have DCL command or program output redirected and appended 64 to a file. GNU make for VMS already implements the redirection of output. If 65 such a redirection is detected, an ">" on the action line, GNU make creates a 66 DCL command procedure to execute the action and to redirect its output. Based 67 on that, now ">>" is also recognized and a similar but different command 68 procedure is created to implement the append. The main idea here is to create a 69 temporary file which collects the output and which is appended to the wanted 70 output file. Then the temporary file is deleted. This is all done in the 71 command procedure to keep changes in make small and simple. This obviously has 72 some limitations but it seems good enough compared with the current ">" 73 implementation. (And in my opinion, redirection is not really what GNU make has 74 to do.) With this approach, it may happen that the temporary file is not yet 75 appended and is left in SYS$SCRATCH. The temporary file names look like 76 "CMDxxxxx.". Any time the created command procedure can not complete, this 77 happens. Pressing Ctrl+Y to abort make is one case. In case of Ctrl+Y the 78 associated command procedure is left in SYS$SCRATCH as well. Its name is 79 CMDxxxxx.COM. 80 81 Change in the Ctrl+Y handling 82 83 Ctrl+Y was: The CtrlY handler called $forcex for the current child. 84 85 Ctrl+Y changed: The CtrlY handler uses $delprc to delete all children. This way 86 also actions with DCL commands will be stopped. As before Ctrl+Y then sends 87 SIGQUIT to itself, which is handled in common code. 88 89 Change in deleteing temporary command files 90 91 Temporary command files were deleted in the main line, after returning from the 92 vms child termination handler. If Ctrl+C was pressed, the handler is called but 93 did not return to main line. 94 95 Now, temporary command files are deleted in the vms child termination 96 handler. That deletes the them even if a Ctrl+C was pressed. 97 98 The behavior of pressing Ctrl+C is not changed. It still has only an effect, 99 after the current action is terminated. If that doesn't happen or takes too 100 long, Ctrl+Y should be used instead. 101 102 103 Changes (3.80) 24 104 25 105 . In default.c define variable ARCH as IA64 for VMS on Itanium systems. … … 300 380 ------------------------------------------------------------------------------- 301 381 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 302 2006, 2007 Free Software Foundation, Inc.382 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 303 383 This file is part of GNU Make. 304 384 -
trunk/src/kmk/remake.c
r2100 r2591 1 1 /* Basic dependency engine for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 90 90 { 91 91 int t = touch_flag, q = question_flag, n = just_print_flag; 92 unsigned int j = job_slots;93 92 int status = -1; 94 93 … … 142 141 unsigned int ocommands_started; 143 142 int x; 143 144 file->dontcare = g->dontcare; 145 144 146 check_renamed (file); 145 147 if (rebuilding_makefiles) … … 215 217 any_not_updated |= !file->updated; 216 218 219 file->dontcare = 0; 220 217 221 if (stop) 218 222 break; … … 275 279 question_flag = q; 276 280 just_print_flag = n; 277 job_slots = j;278 281 } 279 282 … … 308 311 if (f->considered == considered) 309 312 { 310 DBF (DB_VERBOSE, _("Pruning file `%s'.\n")); 311 return f->command_state == cs_finished ? f->update_status : 0; 313 /* Check for the case where a target has been tried and failed but 314 the diagnostics hasn't been issued. If we need the diagnostics 315 then we will have to continue. */ 316 if (!(f->updated && f->update_status > 0 && !f->dontcare && f->no_diag)) 317 { 318 DBF (DB_VERBOSE, _("Pruning file `%s'.\n")); 319 return f->command_state == cs_finished ? f->update_status : 0; 320 } 312 321 } 313 322 … … 326 335 /* If we got an error, don't bother with double_colon etc. */ 327 336 if (status != 0 && !keep_going_flag) 328 337 return status; 329 338 330 339 if (f->command_state == cs_running … … 358 367 359 368 static void 360 complain ( conststruct file *file)369 complain (struct file *file) 361 370 { 362 371 const char *msg_noparent … … 365 374 = _("%sNo rule to make target `%s', needed by `%s'%s"); 366 375 376 /* If this file has no_diag set then it means we tried to update it 377 before in the dontcare mode and failed. The target that actually 378 failed is not necessarily this file but could be one of its direct 379 or indirect dependencies. So traverse this file's dependencies and 380 find the one that actually caused the failure. */ 381 382 struct dep *d; 383 384 for (d = file->deps; d != 0; d = d->next) 385 { 386 if (d->file->updated && d->file->update_status > 0 && file->no_diag) 387 { 388 complain (d->file); 389 break; 390 } 391 } 392 393 if (d == 0) 394 { 395 /* Didn't find any dependencies to complain about. */ 396 367 397 #ifdef KMK 368 /* jokes */369 if (!keep_going_flag && file->parent == 0)370 {371 const char *msg_joke = 0;372 extern struct dep *goals;373 374 /* classics */375 if (!strcmp (file->name, "fire")376 || !strcmp (file->name, "Fire"))377 msg_joke = "No matches.\n";378 else if (!strcmp (file->name, "love")379 || !strcmp (file->name, "Love")380 || !strcmp (file->name, "peace")381 || !strcmp (file->name, "Peace"))382 msg_joke = "Not war.\n";383 else if (!strcmp (file->name, "war"))384 msg_joke = "Don't know how to make war.\n";385 386 /* http://xkcd.com/149/ - GNU Make bug #23273. */387 else if (( !strcmp (file->name, "me")388 && goals != 0389 && !strcmp (dep_name(goals), "me")390 && goals->next != 0391 && !strcmp (dep_name(goals->next), "a")392 && goals->next->next != 0)393 || !strncmp (file->name, "me a ", 5))394 msg_joke =398 /* jokes */ 399 if (!keep_going_flag && file->parent == 0) 400 { 401 const char *msg_joke = 0; 402 extern struct dep *goals; 403 404 /* classics */ 405 if (!strcmp (file->name, "fire") 406 || !strcmp (file->name, "Fire")) 407 msg_joke = "No matches.\n"; 408 else if (!strcmp (file->name, "love") 409 || !strcmp (file->name, "Love") 410 || !strcmp (file->name, "peace") 411 || !strcmp (file->name, "Peace")) 412 msg_joke = "Not war.\n"; 413 else if (!strcmp (file->name, "war")) 414 msg_joke = "Don't know how to make war.\n"; 415 416 /* http://xkcd.com/149/ - GNU Make bug #23273. */ 417 else if (( !strcmp (file->name, "me") 418 && goals != 0 419 && !strcmp (dep_name(goals), "me") 420 && goals->next != 0 421 && !strcmp (dep_name(goals->next), "a") 422 && goals->next->next != 0) 423 || !strncmp (file->name, "me a ", 5)) 424 msg_joke = 395 425 # ifdef HAVE_UNISTD_H 396 426 getuid () == 0 ? "Okay.\n" : 397 427 # endif 398 "What? Make it yourself!\n"; 399 if (msg_joke) 428 "What? Make it yourself!\n"; 429 if (msg_joke) 430 { 431 fputs (msg_joke, stderr); 432 die (2); 433 } 434 } 435 #endif /* KMK */ 436 437 if (!keep_going_flag) 400 438 { 401 fputs (msg_joke, stderr); 402 die (2); 439 if (file->parent == 0) 440 fatal (NILF, msg_noparent, "", file->name, ""); 441 442 fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); 403 443 } 404 } 405 #endif /* KMK */ 406 407 if (!keep_going_flag) 408 { 444 409 445 if (file->parent == 0) 410 fatal (NILF, msg_noparent, "", file->name, ""); 411 412 fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); 413 } 414 415 if (file->parent == 0) 416 error (NILF, msg_noparent, "*** ", file->name, "."); 417 else 418 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 446 error (NILF, msg_noparent, "*** ", file->name, "."); 447 else 448 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 449 450 file->no_diag = 0; 451 } 419 452 } 420 453 … … 424 457 update_file_1 (struct file *file, unsigned int depth) 425 458 { 426 registerFILE_TIMESTAMP this_mtime;459 FILE_TIMESTAMP this_mtime; 427 460 int noexist, must_make, deps_changed; 428 461 int dep_status = 0; 429 register struct dep *d, *lastd; 462 struct file *ofile; 463 struct dep *d, *ad; 464 struct dep amake; 430 465 int running = 0; 431 466 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 467 struct file *org_file = file; 432 468 struct file *f2, *f3; 433 469 … … 438 474 DBS (DB_VERBOSE, (_("Considering target file `%s' -> multi head `%s'.\n"), 439 475 file->name, file->multi_head->name)); 440 file = file->multi_head;476 org_file = file = file->multi_head; 441 477 } 442 478 else … … 451 487 _("Recently tried and failed to update file `%s'.\n")); 452 488 453 /* If the file we tried to make is marked dontcarethen no message489 /* If the file we tried to make is marked no_diag then no message 454 490 was printed about it when it failed during the makefile rebuild. 455 491 If we're trying to build it again in the normal rebuild, print a 456 492 message now. */ 457 if (file->dontcare && !rebuilding_makefiles) 458 { 459 file->dontcare = 0; 493 if (file->no_diag && !file->dontcare) 460 494 complain (file); 461 }462 495 463 496 return file->update_status; … … 483 516 } 484 517 518 /* Determine whether the diagnostics will be issued should this update 519 fail. */ 520 file->no_diag = file->dontcare; 521 485 522 ++depth; 486 523 487 524 /* Notice recursive update of the same file. */ 488 525 start_updating (file); 526 527 /* We might change file if we find a different one via vpath; 528 remember this one to turn off updating. */ 529 ofile = file; 489 530 490 531 /* Looking at the file's modtime beforehand allows the possibility … … 554 595 } 555 596 556 /* Update all non-intermediate files we depend on, if necessary, 557 and see whether any of them is more recent than this file. 558 For explicit multitarget rules we must iterate all the output 597 /* Update all non-intermediate files we depend on, if necessary, and see 598 whether any of them is more recent than this file. We need to walk our 599 deps, AND the deps of any also_make targets to ensure everything happens 600 in the correct order. 601 602 bird: For explicit multitarget rules we must iterate all the output 559 603 files to get the correct picture. The special .MUST_MAKE 560 target variable call is also done from this context. 604 target variable call is also done from this context. */ 561 605 562 606 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 563 for (f2 = file; f2; f2 = f2->multi_next) 564 { 565 lastd = 0; 566 d = f2->deps; 567 #else 568 lastd = 0; 569 d = file->deps; 570 #endif 571 while (d != 0) 607 assert (file == org_file); 608 for (f2 = file; f2; file = f2 = f2->multi_next) 609 { 610 #endif 611 amake.file = file; 612 amake.next = file->also_make; 613 ad = &amake; 614 while (ad) 615 { 616 struct dep *lastd = 0; 617 618 /* Find the deps we're scanning */ 619 d = ad->file->deps; 620 ad = ad->next; 621 622 while (d) 572 623 { 573 624 FILE_TIMESTAMP mtime; … … 584 635 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 585 636 /* silently ignore the order-only dep hack. */ 586 if (f 2->multi_maybe && d->file ==file)637 if (file->multi_maybe && d->file == org_file) 587 638 { 588 639 lastd = d; … … 593 644 594 645 error (NILF, _("Circular %s <- %s dependency dropped."), 595 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET596 f2->name, d->file->name);597 #else598 646 file->name, d->file->name); 599 #endif600 647 /* We cannot free D here because our the caller will still have 601 648 a reference to it when we were called recursively via 602 649 check_dep below. */ 603 650 if (lastd == 0) 604 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET605 f2->deps = d->next;606 #else607 651 file->deps = d->next; 608 #endif609 652 else 610 653 lastd->next = d->next; … … 613 656 } 614 657 615 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET616 d->file->parent = f2;617 #else618 658 d->file->parent = file; 619 #endif620 659 maybe_make = must_make; 621 660 … … 626 665 d->file->dontcare = file->dontcare; 627 666 } 628 629 667 630 668 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); … … 664 702 d = d->next; 665 703 } 704 } 666 705 667 706 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 668 if (dep_status != 0 && !keep_going_flag) 669 break; 670 } 707 if (dep_status != 0 && !keep_going_flag) 708 break; 709 } 710 file = org_file; 671 711 #endif 672 712 … … 677 717 # ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 678 718 if (!must_make) 679 for (f2 = file; f2 && !must_make; f2 = f2->multi_next)719 for (f2 = org_file; f2 && !must_make; f2 = f2->multi_next) 680 720 must_make = call_must_make_target_var (f2, depth); 681 721 # else … … 691 731 { 692 732 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 693 for (f2 = file; f2; f2 = f2->multi_next) 694 for (d = f2->deps; d != 0; d = d->next) 695 #else 733 for (file = f2 = org_file; f2; file = f2 = f2->multi_next) 734 #endif 696 735 for (d = file->deps; d != 0; d = d->next) 697 #endif698 736 if (d->file->intermediate) 699 737 { … … 702 740 FILE_TIMESTAMP mtime = file_mtime (d->file); 703 741 check_renamed (d->file); 704 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET705 d->file->parent = f2;706 #else707 742 d->file->parent = file; 708 #endif709 743 710 744 /* Inherit dontcare flag from our parent. */ … … 741 775 742 776 if (!running) 743 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET744 d->changed = ((f2->phony && f2->cmds != 0)745 #else746 777 d->changed = ((file->phony && file->cmds != 0) 747 #endif748 778 || file_mtime (d->file) != mtime); 749 779 } 780 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 781 file = org_file; 782 #endif 750 783 } 751 784 752 785 finish_updating (file); 786 finish_updating (ofile); 753 787 754 788 DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n")); … … 797 831 deps_changed = 0; 798 832 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 799 for (f 2 = file; f2;f2 = f2->multi_next)833 for (file = f2 = org_file; f2; file = f2 = f2->multi_next) 800 834 #endif 801 835 for (d = file->deps; d != 0; d = d->next) … … 803 837 FILE_TIMESTAMP d_mtime = file_mtime (d->file); 804 838 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 805 if (d->file == file && f 2->multi_maybe)839 if (d->file == file && file->multi_maybe) 806 840 continue; 807 841 #endif … … 858 892 } 859 893 } 894 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 895 file = org_file; 896 #endif 860 897 861 898 /* Here depth returns to the value it had when we were called. */ … … 1170 1207 would have been updated. */ 1171 1208 1172 if ( question_flag || just_print_flag || touch_flag)1209 if ((question_flag || just_print_flag || touch_flag) && file->cmds) 1173 1210 { 1174 1211 for (i = file->cmds->ncommand_lines; i > 0; --i) … … 1278 1315 FILE_TIMESTAMP this_mtime, int *must_make_ptr) 1279 1316 { 1317 struct file *ofile; 1280 1318 struct dep *d; 1281 1319 int dep_status = 0; … … 1283 1321 ++depth; 1284 1322 start_updating (file); 1323 1324 /* We might change file if we find a different one via vpath; 1325 remember this one to turn off updating. */ 1326 ofile = file; 1285 1327 1286 1328 if (file->phony || !file->intermediate) … … 1333 1375 necessary, and see whether any of them is more recent than the 1334 1376 file on whose behalf we are checking. */ 1335 struct dep *l astd;1377 struct dep *ld; 1336 1378 int deps_running = 0; 1337 1379 1338 /* Reset this target's state so that we check it fresh. It could be 1339 that it's already been checked as part of an order-only 1340 prerequisite and so wasn't rebuilt then, but should be now. 1341 1342 bird: What if we're already running the recipe? We don't wish 1343 it to be started once again do we? This happens with the 1344 SECONDARY Test #9 here now... If the idea is to re-evaluate 1345 the target regardless of whether it's running or no, then 1346 perhaps saving and restoring is a better idea? 1347 See bug #15919. */ 1348 if (file->command_state != cs_running) /* bird */ 1380 /* If this target is not running, set it's state so that we check it 1381 fresh. It could be it was checked as part of an order-only 1382 prerequisite and so wasn't rebuilt then, but should be now. */ 1383 if (file->command_state != cs_running) 1349 1384 set_command_state (file, cs_not_started); 1350 1385 1351 l astd = 0;1386 ld = 0; 1352 1387 d = file->deps; 1353 1388 while (d != 0) … … 1359 1394 error (NILF, _("Circular %s <- %s dependency dropped."), 1360 1395 file->name, d->file->name); 1361 if (l astd == 0)1396 if (ld == 0) 1362 1397 { 1363 1398 file->deps = d->next; … … 1367 1402 else 1368 1403 { 1369 l astd->next = d->next;1404 ld->next = d->next; 1370 1405 free_dep (d); 1371 d = l astd->next;1406 d = ld->next; 1372 1407 } 1373 1408 continue; … … 1388 1423 deps_running = 1; 1389 1424 1390 l astd = d;1425 ld = d; 1391 1426 d = d->next; 1392 1427 } … … 1401 1436 1402 1437 finish_updating (file); 1438 finish_updating (ofile); 1439 1403 1440 return dep_status; 1404 1441 } … … 1588 1625 { 1589 1626 /* If name_mtime failed, search VPATH. */ 1590 const char *name = vpath_search (file->name, &mtime );1627 const char *name = vpath_search (file->name, &mtime, NULL, NULL); 1591 1628 if (name 1592 1629 /* Last resort, is it a library (-lxxx)? */ … … 1839 1876 }; 1840 1877 1841 static char *libpatterns = NULL; 1842 1843 const char *libname = lib+2; /* Name without the '-l'. */ 1878 const char *file = 0; 1879 char *libpatterns; 1844 1880 FILE_TIMESTAMP mtime; 1845 1881 … … 1848 1884 const char *p2; 1849 1885 unsigned int len; 1886 unsigned int liblen; 1887 1888 /* Information about the earliest (in the vpath sequence) match. */ 1889 unsigned int best_vpath = 0, best_path = 0; /* bird: gcc maybe used uninitialized (both) */ 1890 unsigned int std_dirs = 0; 1850 1891 1851 1892 char **dp; 1852 1893 1853 /* If we don't have libpatterns, get it. */ 1854 if (!libpatterns) 1855 { 1856 int save = warn_undefined_variables_flag; 1857 warn_undefined_variables_flag = 0; 1858 1859 libpatterns = xstrdup (variable_expand ("$(strip $(.LIBPATTERNS))")); 1860 1861 warn_undefined_variables_flag = save; 1862 } 1863 1864 /* Loop through all the patterns in .LIBPATTERNS, and search on each one. */ 1894 libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)")); 1895 1896 /* Skip the '-l'. */ 1897 lib += 2; 1898 liblen = strlen (lib); 1899 1900 /* Loop through all the patterns in .LIBPATTERNS, and search on each one. 1901 To implement the linker-compatible behavior we have to search through 1902 all entries in .LIBPATTERNS and choose the "earliest" one. */ 1865 1903 p2 = libpatterns; 1866 1904 while ((p = find_next_token (&p2, &len)) != 0) … … 1872 1910 const size_t libbuf_offset = libbuf - variable_buffer; /* bird */ 1873 1911 1874 /* Expand the pattern using LIB NAMEas a replacement. */1912 /* Expand the pattern using LIB as a replacement. */ 1875 1913 { 1876 1914 char c = p[len]; … … 1881 1919 if (!p3) 1882 1920 { 1883 /* Give a warning if there is no pattern, then remove the 1884 pattern so it's ignored next time. */ 1921 /* Give a warning if there is no pattern. */ 1885 1922 error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p); 1886 for (; len; --len, ++p) 1887 *p = ' '; 1888 *p = c; 1923 p[len] = c; 1889 1924 continue; 1890 1925 } 1891 1926 p4 = variable_buffer_output (libbuf, p, p3-p); 1892 p4 = variable_buffer_output (p4, lib name, strlen (libname));1927 p4 = variable_buffer_output (p4, lib, liblen); 1893 1928 p4 = variable_buffer_output (p4, p3+1, len - (p3-p)); 1894 1929 p[len] = c; … … 1902 1937 if (mtime_ptr != 0) 1903 1938 *mtime_ptr = mtime; 1904 return strcache_add (libbuf); 1939 file = strcache_add (libbuf); 1940 /* This by definition will have the best index, so stop now. */ 1941 break; 1905 1942 } 1906 1943 … … 1908 1945 1909 1946 { 1910 const char *file = vpath_search (libbuf, mtime_ptr); 1911 if (file) 1912 return file; 1947 unsigned int vpath_index, path_index; 1948 const char* f = vpath_search (libbuf, mtime_ptr ? &mtime : NULL, 1949 &vpath_index, &path_index); 1950 if (f) 1951 { 1952 /* If we have a better match, record it. */ 1953 if (file == 0 || 1954 vpath_index < best_vpath || 1955 (vpath_index == best_vpath && path_index < best_path)) 1956 { 1957 file = f; 1958 best_vpath = vpath_index; 1959 best_path = path_index; 1960 1961 if (mtime_ptr != 0) 1962 *mtime_ptr = mtime; 1963 } 1964 } 1913 1965 } 1914 1966 … … 1916 1968 1917 1969 if (!buflen) 1918 { 1919 for (dp = dirs; *dp != 0; ++dp) 1920 { 1921 int l = strlen (*dp); 1922 if (l > libdir_maxlen) 1923 libdir_maxlen = l; 1924 } 1925 buflen = strlen (libbuf); 1926 buf = xmalloc(libdir_maxlen + buflen + 2); 1927 } 1970 { 1971 for (dp = dirs; *dp != 0; ++dp) 1972 { 1973 int l = strlen (*dp); 1974 if (l > libdir_maxlen) 1975 libdir_maxlen = l; 1976 std_dirs++; 1977 } 1978 buflen = strlen (libbuf); 1979 buf = xmalloc(libdir_maxlen + buflen + 2); 1980 } 1928 1981 else if (buflen < strlen (libbuf)) 1929 { 1930 buflen = strlen (libbuf); 1931 buf = xrealloc (buf, libdir_maxlen + buflen + 2); 1932 } 1933 1934 for (dp = dirs; *dp != 0; ++dp) 1935 { 1936 sprintf (buf, "%s/%s", *dp, libbuf); 1937 mtime = name_mtime (buf); 1938 if (mtime != NONEXISTENT_MTIME) 1939 { 1940 if (mtime_ptr != 0) 1941 *mtime_ptr = mtime; 1942 return strcache_add (buf); 1943 } 1944 } 1945 } 1946 1947 return 0; 1982 { 1983 buflen = strlen (libbuf); 1984 buf = xrealloc (buf, libdir_maxlen + buflen + 2); 1985 } 1986 1987 { 1988 /* Use the last std_dirs index for standard directories. This 1989 was it will always be greater than the VPATH index. */ 1990 unsigned int vpath_index = ~((unsigned int)0) - std_dirs; 1991 1992 for (dp = dirs; *dp != 0; ++dp) 1993 { 1994 sprintf (buf, "%s/%s", *dp, libbuf); 1995 mtime = name_mtime (buf); 1996 if (mtime != NONEXISTENT_MTIME) 1997 { 1998 if (file == 0 || vpath_index < best_vpath) 1999 { 2000 file = strcache_add (buf); 2001 best_vpath = vpath_index; 2002 2003 if (mtime_ptr != 0) 2004 *mtime_ptr = mtime; 2005 } 2006 } 2007 2008 vpath_index++; 2009 } 2010 } 2011 2012 } 2013 2014 free (libpatterns); 2015 return file; 1948 2016 } -
trunk/src/kmk/remote-cstms.c
r1993 r2591 5 5 6 6 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 7 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software8 Foundation, Inc.7 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 8 2010 Free Software Foundation, Inc. 9 9 This file is part of GNU Make. 10 10 -
trunk/src/kmk/remote-stub.c
r1993 r2591 1 1 /* Template for the remote job exportation interface to GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 -
trunk/src/kmk/rule.c
r2137 r2591 1 1 /* Pattern and suffix rule internals for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 97 97 for (dep = rule->deps; dep != 0; dep = dep->next) 98 98 { 99 unsigned int len = strlen (dep->name); 99 const char *dname = dep_name (dep); 100 unsigned int len = strlen (dname); 100 101 101 102 #ifdef VMS 102 const char *p = strrchr (dep->name, ']');103 const char *p = strrchr (dname, ']'); 103 104 const char *p2; 104 105 if (p == 0) 105 p = strrchr (d ep->name, ':');106 p2 = p != 0 ? strchr (d ep->name, '%') : 0;106 p = strrchr (dname, ':'); 107 p2 = p != 0 ? strchr (dname, '%') : 0; 107 108 #else 108 const char *p = strrchr (dep->name, '/');109 const char *p2 = p != 0 ? strchr (dep->name, '%') : 0;109 const char *p = strrchr (dname, '/'); 110 const char *p2 = p != 0 ? strchr (dname, '%') : 0; 110 111 #endif 111 112 ndeps++; 112 113 113 114 if (len > max_pattern_dep_length) … … 118 119 /* There is a slash before the % in the dep name. 119 120 Extract the directory name. */ 120 if (p == d ep->name)121 if (p == dname) 121 122 ++p; 122 if (p - d ep->name > namelen)123 if (p - dname > namelen) 123 124 { 124 namelen = p - d ep->name;125 namelen = p - dname; 125 126 name = xrealloc (name, namelen + 1); 126 127 } 127 memcpy (name, d ep->name, p - dep->name);128 name[p - d ep->name] = '\0';128 memcpy (name, dname, p - dname); 129 name[p - dname] = '\0'; 129 130 130 131 /* In the deps of an implicit rule the `changed' flag … … 380 381 381 382 ptr = p->dep; 382 #ifndef CONFIG_WITH_ALLOC_CACHES 383 r->deps = (struct dep *) multi_glob (parse_file_seq (&ptr, '\0', 384 sizeof (struct dep), 1), 385 sizeof (struct dep)); 386 #else 387 r->deps = (struct dep *) multi_glob (parse_file_seq (&ptr, '\0', 388 &dep_cache, 1), 389 &dep_cache); 390 #endif 383 r->deps = PARSE_FILE_SEQ (&ptr, struct dep, '\0', NULL, 0); 391 384 392 385 if (new_pattern_rule (r, 0)) … … 419 412 { 420 413 struct rule *next = rule->next; 421 struct dep *dep; 422 423 dep = rule->deps; 424 while (dep) 425 { 426 struct dep *t = dep->next; 427 free_dep (dep); 428 dep = t; 429 } 430 431 free (rule->targets); 432 free (rule->suffixes); 414 415 free_dep_chain (rule->deps); 416 417 /* MSVC erroneously warns without a cast here. */ 418 free ((void *)rule->targets); 419 free ((void *)rule->suffixes); 433 420 free (rule->lens); 434 421 … … 505 492 { 506 493 unsigned int i; 507 struct dep *d;508 494 509 495 for (i = 0; i < r->num; ++i) … … 515 501 putchar (':'); 516 502 517 for (d = r->deps; d != 0; d = d->next) 518 printf (" %s", dep_name (d)); 519 putchar ('\n'); 503 print_prereqs (r->deps); 520 504 521 505 if (r->cmds != 0) … … 564 548 makefiles and thus count_implicit_rule_limits wasn't called yet. */ 565 549 if (num_pattern_rules != 0) 566 fatal (NILF, _("BUG: num_pattern_rules wrong! %u != %u"),550 fatal (NILF, _("BUG: num_pattern_rules is wrong! %u != %u"), 567 551 num_pattern_rules, rules); 568 552 } -
trunk/src/kmk/rule.h
r1993 r2591 1 1 /* Definitions for using pattern rules in GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 -
trunk/src/kmk/signame.c
r1993 r2591 1 1 /* Convert between signal names and numbers. 2 2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 4 Foundation, Inc. 4 5 This file is part of GNU Make. 5 6 … … 229 230 230 231 char * 231 strsignal (int sig nal)232 strsignal (int sig) 232 233 { 233 234 static char buf[] = "Signal 12345678901234567890"; … … 246 247 #endif 247 248 248 if (sig nal > 0 || signal< NSIG)249 return (char *) sys_siglist[sig nal];250 251 sprintf (buf, "Signal %d", sig nal);249 if (sig > 0 || sig < NSIG) 250 return (char *) sys_siglist[sig]; 251 252 sprintf (buf, "Signal %d", sig); 252 253 return buf; 253 254 } -
trunk/src/kmk/strcache.c
r1993 r2591 1 1 /* Constant string caching for GNU Make. 2 Copyright (C) 2006, 2007 Free Software Foundation, Inc.2 Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 3 3 This file is part of GNU Make. 4 4 -
trunk/src/kmk/subproc.bat
r1993 r2591 1 1 @echo off 2 2 rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 rem 2005, 2006, 2007 Free Software Foundation, Inc.3 rem 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 rem This file is part of GNU Make. 5 5 rem -
trunk/src/kmk/tests
- Property svn:ignore
--- +++
- Property svn:ignore
-
trunk/src/kmk/tests/ChangeLog
r1993 r2591 1 2010-07-28 Paul Smith <[email protected]> 2 3 * scripts/targets/POSIX: Compatibility issues with Solaris (and 4 Tru64?); "false" returns different exit codes, and set -x shows 5 output with extra whitespace. Run the commands by hand first to 6 find out what the real shell would do, then compare what make does. 7 * scripts/variables/SHELL: Ditto. 8 9 2010-07-12 Paul Smith <[email protected]> 10 11 * test_driver.pl: Add a new $perl_name containing the path to Perl. 12 * run_make_tests.pl (run_make_test): Replace the special string 13 #PERL# in a makefile etc. with the path the Perl executable so 14 makefiles can use it. 15 16 * scripts/targets/ONESHELL: Add a new set of regression tests for 17 the .ONESHELL feature. 18 19 2010-07-06 Paul Smith <[email protected]> 20 21 * scripts/variables/SHELL: Test the new .SHELLFLAGS variable. 22 23 * scripts/targets/POSIX: New file. Test the .POSIX special target. 24 Verify that enabling .POSIX changes the shell flags to set -e. 25 26 2010-07-01 Paul Smith <[email protected]> 27 28 * scripts/features/recursion: Add a space to separate command-line 29 args. Fixes Savannah bug #29968. 30 31 2009-11-12 Boris Kolpackov <[email protected]> 32 33 * scripts/features/vpath3: Test for the new library search 34 behavior. 35 36 2009-10-06 Boris Kolpackov <[email protected]> 37 38 * scripts/features/se_explicit: Enable the test for now fixed 39 Savannah bug 25780. 40 41 2009-10-06 Boris Kolpackov <[email protected]> 42 43 * scripts/variables/undefine: Tests for the new undefine feature. 44 45 2009-10-03 Paul Smith <[email protected]> 46 47 * scripts/features/parallelism: Test for open Savannah bug #26846. 48 49 * scripts/variables/MAKE: Rewrite for new run_make_test() format. 50 51 * scripts/variables/MAKEFLAGS: Created. 52 Add test for Savannah bug #2216 (still open). 53 54 * scripts/features/include: Test for Savannah bug #102 (still open). 55 56 2009-09-30 Boris Kolpackov <[email protected]> 57 58 * scripts/features/include: Add diagnostics issuing tests for 59 cases where targets have been updated and failed with the 60 dontcare flag. Savannah bugs #15110, #25493, #12686, #17740. 61 62 2009-09-28 Paul Smith <[email protected]> 63 64 * scripts/functions/shell: Add regression test for Savannah bug 65 #20513 (still open). 66 67 * scripts/features/se_explicit: Add regression tests for Savannah 68 bug #25780 (still open). 69 70 * run_make_tests.pl (valid_option): Add a new flag, -all([-_]?tests)? 71 that runs tests we know will fail. This allows us to add 72 regression tests to the test suite for bugs that haven't been 73 fixed yet. 74 75 2009-09-28 Boris Kolpackov <[email protected]> 76 77 * scripts/features/patspecific_vars: Add a test for the shortest 78 stem first order. 79 80 * scripts/features/patternrules: Add a test for the shortest stem 81 first order. 82 83 2009-09-24 Paul Smith <[email protected]> 84 85 * scripts/features/se_implicit: Add a test for order-only 86 secondary expansion prerequisites. 87 88 2009-09-23 Paul Smith <[email protected]> 89 90 * scripts/features/patternrules: Test that we can remove pattern 91 rules, both single and multiple prerequisites. Savannah bug #18622. 92 93 * scripts/features/echoing: Rework for run_make_test(). 94 95 2009-06-14 Paul Smith <[email protected]> 96 97 * scripts/features/vpath: Verify we don't get bogus circular 98 dependency warnings if we choose a different file via vpath during 99 update. Savannah bug #13529. 100 101 2009-06-13 Paul Smith <[email protected]> 102 103 * scripts/variables/MAKEFILES: Verify that MAKEFILES included 104 files (and files included by them) don't set the default goal. 105 Savannah bug #13401. 106 107 * scripts/functions/wildcard: Test that wildcards with 108 non-existent glob matchers return empty. 109 110 2009-06-09 Paul Smith <[email protected]> 111 112 * scripts/options/dash-B: Test the $? works correctly with -B. 113 Savannah bug #17825. 114 115 * scripts/features/patternrules: Test that dependencies of 116 "also_make" targets are created properly. Savannah bug #19108. 117 118 * test_driver.pl (compare_output): Create a "run" file for failed 119 tests containing the command that was run. 120 (get_runfile): New function. 121 122 * run_make_tests.pl (valid_option): Enhanced support for valgrind: 123 allow memcheck and massif tools. 124 125 * scripts/features/patternrules: Have to comment out a line in the 126 first test due to backing out a change that broke the implicit 127 rule search algorithm. Savannah bug #17752. 128 * scripts/misc/general4: Remove a test that is redundant with 129 patternrules. 130 131 * scripts/features/parallelism: Add a test for re-exec with 132 jobserver master override. Savannah bug #18124. 133 134 2009-06-08 Paul Smith <[email protected]> 135 136 * scripts/features/targetvars: Add a test for continued target 137 vars after a semicolon. Savannah bug #17521. 138 139 2009-06-07 Paul Smith <[email protected]> 140 141 * scripts/features/se_explicit: Make sure we catch defining 142 prereqs during snap_deps(). Savannah bug #24622. 143 144 * scripts/variables/automatic: Check prereq ordering when the 145 target with the recipe has no prereqs. Savannah bug #21198. 146 147 * scripts/variables/LIBPATTERNS: Add a new set of test for 148 $(.LIBPATTERNS) (previously untested!) 149 150 2009-06-04 Paul Smith <[email protected]> 151 152 * scripts/variables/SHELL: The export target-specific SHELL test 153 has an incorrect known-good-value. 154 155 * scripts/misc/general4: Check for whitespace (ffeed, vtab, etc.) 156 157 * scripts/features/se_explicit: Add tests for Savannah bug #24588. 158 159 2009-05-31 Paul Smith <[email protected]> 160 161 * scripts/variables/DEFAULT_GOAL: Add tests for Savannah bug #25697. 162 163 * scripts/features/targetvars: Add tests of overrides for Savannah 164 bug #26207. 165 * scripts/features/patspecific_vars: Ditto. 166 167 * scripts/features/patternrules: Add a test for Savannah bug #26593. 168 169 2009-05-30 Paul Smith <[email protected]> 170 171 * scripts/variables/flavors: Update with new variable flavor tests. 172 * scripts/variables/define: Create a new set of tests for 173 define/endef and move those aspects of the flavors suite here. 174 175 2009-05-25 Paul Smith <[email protected]> 176 177 * scripts/features/targetvars: Ditto. 178 179 * scripts/features/export: Test new variable parsing abilities. 180 181 2009-02-23 Ramon Garcia <[email protected]> 182 183 * scripts/variables/private: Create a new suite of tests for 'private'. 184 1 185 2007-11-04 Paul Smith <[email protected]> 2 186 … … 881 1065 882 1066 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 883 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.1067 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 884 1068 This file is part of GNU Make. 885 1069 -
trunk/src/kmk/tests/NEWS
r1993 r2591 165 165 ------------------------------------------------------------------------------- 166 166 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 167 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.167 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 168 168 This file is part of GNU Make. 169 169 -
trunk/src/kmk/tests/README
r1993 r2591 9 9 ----------------------------------------------------------------------------- 10 10 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 11 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.11 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 12 12 This file is part of GNU Make. 13 13 -
trunk/src/kmk/tests/mkshadow
r1993 r2591 5 5 # 6 6 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 7 # 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 7 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 8 # Foundation, Inc. 8 9 # This file is part of GNU Make. 9 10 # -
trunk/src/kmk/tests/run_make_tests.pl
r1993 r2591 13 13 14 14 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 15 # 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 15 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 16 # Foundation, Inc. 16 17 # This file is part of GNU Make. 17 18 # … … 29 30 # this program. If not, see <http://www.gnu.org/licenses/>. 30 31 32 31 33 $valgrind = 0; # invoke make with valgrind 32 $valgrind_args = '--num-callers=15 --tool=memcheck --leak-check=full'; 34 $valgrind_args = ''; 35 $memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full'; 36 $massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup'; 33 37 $pure_log = undef; 38 39 $command_string = ''; 40 41 $all_tests = 0; 34 42 35 43 require "test_driver.pl"; … … 44 52 local($option) = @_; 45 53 46 if ($option =~ /^-make([-_]?path)?$/) 47 { 48 $make_path = shift @argv; 49 if (!-f $make_path) 50 { 51 print "$option $make_path: Not found.\n"; 52 exit 0; 53 } 54 return 1; 55 } 56 57 if ($option =~ /^-valgrind$/i) { 58 $valgrind = 1; 59 return 1; 54 if ($option =~ /^-make([-_]?path)?$/i) { 55 $make_path = shift @argv; 56 if (!-f $make_path) { 57 print "$option $make_path: Not found.\n"; 58 exit 0; 59 } 60 return 1; 61 } 62 63 if ($option =~ /^-all([-_]?tests)?$/i) { 64 $all_tests = 1; 65 return 1; 66 } 67 68 if ($option =~ /^-(valgrind|memcheck)$/i) { 69 $valgrind = 1; 70 $valgrind_args = $memcheck_args; 71 return 1; 72 } 73 74 if ($option =~ /^-massif$/i) { 75 $valgrind = 1; 76 $valgrind_args = $massif_args; 77 return 1; 60 78 } 61 79 … … 106 124 $makestring =~ s/#MAKEPATH#/$mkpath/g; 107 125 $makestring =~ s/#MAKE#/$make_name/g; 126 $makestring =~ s/#PERL#/$perl_name/g; 108 127 $makestring =~ s/#PWD#/$pwd/g; 109 128 … … 120 139 $answer =~ s/#MAKEPATH#/$mkpath/g; 121 140 $answer =~ s/#MAKE#/$make_name/g; 141 $answer =~ s/#PERL#/$perl_name/g; 122 142 $answer =~ s/#PWD#/$pwd/g; 123 143 … … 149 169 } 150 170 171 $command_string = "$command\n"; 172 151 173 if ($valgrind) { 152 174 print VALGRIND "\n\nExecuting: $command\n"; … … 156 178 { 157 179 my $old_timeout = $test_timeout; 158 $test_timeout = $timeout if $timeout; 180 $timeout and $test_timeout = $timeout; 181 182 # If valgrind is enabled, turn off the timeout check 183 $valgrind and $test_timeout = 0; 159 184 160 185 $code = &run_command_with_output($logname,$command); … … 184 209 print "Error running $make_path (expected $expected_code; got $code): $command\n"; 185 210 $test_passed = 0; 211 $runf = &get_runfile; 212 &create_file (&get_runfile, $command_string); 186 213 # If it's a SIGINT, stop here 187 214 if ($code & 127) { 188 215 print STDERR "\nCaught signal ".($code & 127)."!\n"; 189 exit($code);216 ($code & 127) == 2 and exit($code); 190 217 } 191 218 return 0; … … 196 223 } 197 224 198 1;225 return 1; 199 226 } 200 227 … … 202 229 { 203 230 &print_standard_usage ("run_make_tests", 204 "[-make_path make_pathname] [- valgrind]",);231 "[-make_path make_pathname] [-memcheck] [-massif]",); 205 232 } 206 233 207 234 sub print_help 208 235 { 209 &print_standard_help ("-make_path", 210 "\tYou may specify the pathname of the copy of make to run."); 236 &print_standard_help ( 237 "-make_path", 238 "\tYou may specify the pathname of the copy of make to run.", 239 "-valgrind", 240 "-memcheck", 241 "\tRun the test suite under valgrind's memcheck tool.", 242 "\tChange the default valgrind args with the VALGRIND_ARGS env var.", 243 "-massif", 244 "\tRun the test suite under valgrind's massif toool.", 245 "\tChange the default valgrind args with the VALGRIND_ARGS env var." 246 ); 211 247 } 212 248 … … 336 372 337 373 if ($valgrind) { 374 my $args = $valgrind_args; 338 375 open(VALGRIND, "> valgrind.out") 339 376 || die "Cannot open valgrind.out: $!\n"; 340 377 # -q --leak-check=yes 341 exists $ENV{VALGRIND_ARGS} and $ valgrind_args = $ENV{VALGRIND_ARGS};342 $make_path = "valgrind --log-fd=".fileno(VALGRIND)." $ valgrind_args $make_path";378 exists $ENV{VALGRIND_ARGS} and $args = $ENV{VALGRIND_ARGS}; 379 $make_path = "valgrind --log-fd=".fileno(VALGRIND)." $args $make_path"; 343 380 # F_SETFD is 2 344 381 fcntl(VALGRIND, 2, 0) or die "fcntl(setfd) failed: $!\n"; -
trunk/src/kmk/tests/scripts/features/echoing
r969 r2591 1 $description = "The following test creates a makefile to test command \n" 2 ."echoing. It tests that when a command line starts with \n" 3 ."a '\@', the echoing of that line is suppressed. It also \n" 4 ."tests the -n option which tells make to ONLY echo the \n" 5 ."commands and no execution happens. In this case, even \n" 6 ."the commands with '\@' are printed. Lastly, it tests the \n" 7 ."-s flag which tells make to prevent all echoing, as if \n" 8 ."all commands started with a '\@'."; 1 # -*-perl-*- 2 $description = "The following test creates a makefile to test command 3 echoing. It tests that when a command line starts with 4 a '\@', the echoing of that line is suppressed. It also 5 tests the -n option which tells make to ONLY echo the 6 commands and no execution happens. In this case, even 7 the commands with '\@' are printed. Lastly, it tests the 8 -s flag which tells make to prevent all echoing, as if 9 all commands started with a '\@'."; 9 10 10 $details = "This test is similar to the 'clean' test except that a '\@' has \n"11 ."been placed in front of the delete command line. Four tests \n" 12 ."are run here. First, make is run normally and the first echo\n" 13 ."command should be executed. In this case there is no '\@' so \n" 14 ."we should expect make to display the command AND display the \n" 15 ."echoed message. Secondly, make is run with the clean target, \n" 16 ."but since there is a '\@' at the beginning of the command, we\n" 17 ."expect no output; just the deletion of a file which we check \n" 18 ."for. Third, we give the clean target again except this time\n" 19 ."we give make the -n option. We now expect the command to be \n" 20 ."displayed but not to be executed. In this case we need only \n" 21 ."to check the output since an error message would be displayed\n" 22 ."if it actually tried to run the delete command again and the \n" 23 ."file didn't exist. Lastly, we run the first test again with \n" 24 ."the -s option and check that make did not echo the echo \n" 25 ."command before printing the message.";11 $details = "This test is similar to the 'clean' test except that a '\@' has 12 been placed in front of the delete command line. Four tests 13 are run here. First, make is run normally and the first echo 14 command should be executed. In this case there is no '\@' so 15 we should expect make to display the command AND display the 16 echoed message. Secondly, make is run with the clean target, 17 but since there is a '\@' at the beginning of the command, we 18 expect no output; just the deletion of a file which we check 19 for. Third, we give the clean target again except this time 20 we give make the -n option. We now expect the command to be 21 displayed but not to be executed. In this case we need only 22 to check the output since an error message would be displayed 23 if it actually tried to run the delete command again and the 24 file didn't exist. Lastly, we run the first test again with 25 the -s option and check that make did not echo the echo 26 command before printing the message.\n"; 26 27 27 28 $example = "EXAMPLE_FILE"; 28 29 29 open(MAKEFILE,"> $makefile"); 30 31 # The Contents of the MAKEFILE ... 32 33 print MAKEFILE "all: \n"; 34 print MAKEFILE "\techo This makefile did not clean the dir... good\n"; 35 print MAKEFILE "clean: \n"; 36 print MAKEFILE "\t\@$delete_command $example\n"; 37 38 # END of Contents of MAKEFILE 39 40 close(MAKEFILE); 41 42 &touch($example); 30 touch($example); 43 31 44 32 # TEST #1 45 33 # ------- 46 34 47 &run_make_with_options($makefile,"",&get_logfile,0); 48 $answer = "echo This makefile did not clean the dir... good\n" 49 ."This makefile did not clean the dir... good\n"; 50 &compare_output($answer,&get_logfile(1)); 51 35 run_make_test(" 36 all: 37 \techo This makefile did not clean the dir... good 38 clean: 39 \t\@$delete_command $example\n", 40 '', 'echo This makefile did not clean the dir... good 41 This makefile did not clean the dir... good'); 52 42 53 43 # TEST #2 54 44 # ------- 55 45 56 &run_make_with_options($makefile,"clean",&get_logfile,0);46 run_make_test(undef, 'clean', ''); 57 47 if (-f $example) { 58 48 $test_passed = 0; 49 unlink($example); 59 50 } 60 &compare_output('',&get_logfile(1));61 51 62 52 # TEST #3 63 53 # ------- 64 54 65 &run_make_with_options($makefile,"-n clean",&get_logfile,0); 66 $answer = "$delete_command $example\n"; 67 &compare_output($answer,&get_logfile(1)); 55 run_make_test(undef, '-n clean', "$delete_command $example\n"); 68 56 69 57 … … 71 59 # ------- 72 60 73 &run_make_with_options($makefile,"-s",&get_logfile,0); 74 $answer = "This makefile did not clean the dir... good\n"; 75 &compare_output($answer,&get_logfile(1)); 61 run_make_test(undef, '-s', "This makefile did not clean the dir... good\n"); 76 62 77 63 78 64 1; 79 80 81 82 83 84 85 86 87 -
trunk/src/kmk/tests/scripts/features/export
r969 r2591 7 7 # about that here. 8 8 9 open(MAKEFILE,"> $makefile"); 10 11 # The Contents of the MAKEFILE ... 12 13 print MAKEFILE <<'EOMAKE'; 14 9 &run_make_test(' 15 10 FOO = foo 16 11 BAR = bar … … 41 36 @echo "FOO=$(FOO) BAR=$(BAR) BAZ=$(BAZ) BOZ=$(BOZ) BITZ=$(BITZ) BOTZ=$(BOTZ)" 42 37 @echo "FOO=$$FOO BAR=$$BAR BAZ=$$BAZ BOZ=$$BOZ BITZ=$$BITZ BOTZ=$$BOTZ" 43 44 EOMAKE 45 46 close(MAKEFILE); 47 48 # TEST 0: basics 49 50 &run_make_with_options($makefile,"",&get_logfile,0); 51 52 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 53 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"; 54 55 &compare_output($answer,&get_logfile(1)); 38 ', 39 '', "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 40 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"); 56 41 57 42 # TEST 1: make sure vars inherited from the parent are exported … … 59 44 $extraENV{FOO} = 1; 60 45 61 &run_make_with_options($makefile,"",&get_logfile,0); 62 63 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 64 FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"; 65 66 &compare_output($answer,&get_logfile(1)); 46 &run_make_test(undef, '', "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 47 FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"); 67 48 68 49 # TEST 2: global export. Explicit unexport takes precedence. 69 50 70 &run_make_with_options($makefile,"EXPORT_ALL=1",&get_logfile,0); 71 72 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 73 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"; 74 75 &compare_output($answer,&get_logfile(1)); 51 run_make_test(undef, "EXPORT_ALL=1" , 52 "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 53 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"); 76 54 77 55 # TEST 3: global unexport. Explicit export takes precedence. 78 56 79 &run_make_with_options($makefile,"UNEXPORT_ALL=1",&get_logfile,0); 80 81 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 82 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"; 83 84 &compare_output($answer,&get_logfile(1)); 57 &run_make_test(undef, "UNEXPORT_ALL=1", 58 "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 59 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"); 85 60 86 61 # TEST 4: both: in the above makefile the unexport comes last so that rules. 87 62 88 &run_make_with_options($makefile,"EXPORT_ALL=1 UNEXPORT_ALL=1",&get_logfile,0); 89 90 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 91 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"; 92 93 &compare_output($answer,&get_logfile(1)); 63 &run_make_test(undef, "EXPORT_ALL=1 UNEXPORT_ALL=1", 64 "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 65 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"); 94 66 95 67 # TEST 5: test the pseudo target. 96 68 97 &run_make_with_options($makefile,"EXPORT_ALL_PSEUDO=1",&get_logfile,0); 98 99 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 100 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"; 101 102 &compare_output($answer,&get_logfile(1)); 103 69 &run_make_test(undef, "EXPORT_ALL_PSEUDO=1", 70 "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz 71 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n"); 104 72 105 73 # TEST 6: Test the expansion of variables inside export 106 74 107 $makefile2 = &get_tmpfile; 108 109 open(MAKEFILE, "> $makefile2"); 110 111 print MAKEFILE <<'EOF'; 112 75 &run_make_test(' 113 76 foo = f-ok 114 77 bar = b-ok … … 126 89 @echo foo=$(foo) bar=$(bar) 127 90 @echo foo=$$foo bar=$$bar 128 129 EOF 130 131 close(MAKEFILE); 132 133 &run_make_with_options($makefile2,"",&get_logfile,0); 134 $answer = "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n"; 135 &compare_output($answer,&get_logfile(1)); 136 91 ', 92 "", "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n"); 137 93 138 94 # TEST 7: Test the expansion of variables inside unexport 139 95 140 $makefile3 = &get_tmpfile; 141 142 open(MAKEFILE, "> $makefile3"); 143 144 print MAKEFILE <<'EOF'; 145 96 &run_make_test(' 146 97 foo = f-ok 147 98 bar = b-ok … … 161 112 @echo foo=$(foo) bar=$(bar) 162 113 @echo foo=$$foo bar=$$bar 163 164 EOF 165 166 close(MAKEFILE); 167 168 &run_make_with_options($makefile3,"",&get_logfile,0); 169 $answer = "foo=f-ok bar=b-ok\nfoo= bar=\n"; 170 &compare_output($answer,&get_logfile(1)); 171 114 ', 115 '', "foo=f-ok bar=b-ok\nfoo= bar=\n"); 172 116 173 117 # TEST 7: Test exporting multiple variables on the same line 174 118 175 $makefile4 = &get_tmpfile; 176 177 open(MAKEFILE, "> $makefile4"); 178 179 print MAKEFILE <<'EOF'; 180 119 &run_make_test(' 181 120 A = a 182 121 B = b … … 197 136 198 137 all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J 199 EOF 200 201 close(MAKEFILE); 202 203 &run_make_with_options($makefile4,"",&get_logfile,0); 204 $answer = "A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j\n"; 205 &compare_output($answer,&get_logfile(1)); 206 138 ', 139 '', "A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j\n"); 207 140 208 141 # TEST 8: Test unexporting multiple variables on the same line 209 142 210 $makefile5 = &get_tmpfile;143 @extraENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10); 211 144 212 open(MAKEFILE, "> $makefile5"); 213 214 print MAKEFILE <<'EOF'; 215 145 &run_make_test(' 216 146 A = a 217 147 B = b … … 232 162 233 163 all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J 234 EOF 164 ', 165 '', "A= B= C= D= E= F= G= H= I= J=\n"); 235 166 236 close(MAKEFILE); 167 # TEST 9: Check setting a variable named "export" 237 168 238 @extraENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10); 169 &run_make_test(' 170 export = 123 171 export export 172 export export = 456 173 a: ; @echo "\$$(export)=$(export) / \$$export=$$export" 174 ', 175 '', "\$(export)=456 / \$export=456\n"); 239 176 240 &run_make_with_options($makefile5,"",&get_logfile,0); 241 $answer = "A= B= C= D= E= F= G= H= I= J=\n"; 242 &compare_output($answer,&get_logfile(1)); 177 # TEST 9: Check "export" as a target 243 178 179 &run_make_test(' 180 a: export 181 export: ; @echo "$@" 182 ', 183 '', "export\n"); 244 184 245 185 # This tells the test driver that the perl test script executed properly. -
trunk/src/kmk/tests/scripts/features/include
r969 r2591 91 91 ', '', ''); 92 92 93 1;94 95 93 96 94 # Make sure that we don't die when the command fails but we dontcare. … … 118 116 sinclude', '', ''); 119 117 118 119 # Test that the diagnostics is issued even if the target has been 120 # tried before with the dontcare flag (direct dependency case). 121 # 122 run_make_test(' 123 -include foo 124 125 all: bar 126 127 foo: baz 128 bar: baz 129 ', 130 '', 131 "#MAKE#: *** No rule to make target `baz', needed by `bar'. Stop.\n", 132 512); 133 134 # Test that the diagnostics is issued even if the target has been 135 # tried before with the dontcare flag (indirect dependency case). 136 # 137 run_make_test(' 138 -include foo 139 140 all: bar 141 142 foo: baz 143 bar: baz 144 baz: end 145 ', 146 '', 147 "#MAKE#: *** No rule to make target `end', needed by `baz'. Stop.\n", 148 512); 149 150 # Test that the diagnostics is issued even if the target has been 151 # tried before with the dontcare flag (include/-include case). 152 # 153 run_make_test(' 154 include bar 155 -include foo 156 157 all: 158 159 foo: baz 160 bar: baz 161 baz: end 162 ', 163 '', 164 "#MAKEFILE#:2: bar: No such file or directory 165 #MAKE#: *** No rule to make target `end', needed by `baz'. Stop.\n", 166 512); 167 168 if ($all_tests) { 169 # Test that include of a rebuild-able file doesn't show a warning 170 # Savannah bug #102 171 run_make_test(q! 172 include foo 173 foo: ; @echo foo = bar > $@ 174 !, 175 '', "#MAKE#: `foo' is up to date.\n"); 176 rmfiles('foo'); 177 } 178 120 179 1; -
trunk/src/kmk/tests/scripts/features/override
r969 r2591 1 $description = "The following test creates a makefile to ..."; 1 # -*-perl-*- 2 3 $description = "Test the override directive on variable assignments."; 2 4 3 5 $details = ""; 4 6 5 open(MAKEFILE,"> $makefile"); 7 # TEST 0: Basic override 6 8 7 # The Contents of the MAKEFILE ... 9 run_make_test(' 10 X = start 11 override recur = $(X) 12 override simple := $(X) 13 X = end 14 all: ; @echo "$(recur) $(simple)" 15 ', 16 'recur=I simple=J', "end start\n"); 8 17 9 print MAKEFILE "override define foo\n" 10 ."\@echo First comes the definition.\n" 11 ."\@echo Then comes the override.\n" 12 ."endef\n" 13 ."all: \n" 14 ."\t\$(foo)\n"; 18 # TEST 1: Override with append 15 19 16 # END of Contents of MAKEFILE 20 run_make_test(' 21 X += X1 22 override X += X2 23 override Y += Y1 24 Y += Y2 25 all: ; @echo "$(X) $(Y)" 26 ', 27 '', "X1 X2 Y1\n"); 17 28 18 close(MAKEFILE); 29 # TEST 2: Override with append to the command line 19 30 20 &run_make_with_options($makefile,"foo=Hello",&get_logfile);31 run_make_test(undef, 'X=C Y=C', "C X2 C Y1\n"); 21 32 22 # Create the answer to what should be produced by this Makefile 23 $answer = "First comes the definition.\n" 24 ."Then comes the override.\n"; 33 # Test override of define/endef 25 34 26 &compare_output($answer,&get_logfile(1)); 35 run_make_test(' 36 override define foo 37 @echo First comes the definition. 38 @echo Then comes the override. 39 endef 40 all: ; $(foo) 41 ', 42 'foo=Hello', "First comes the definition.\nThen comes the override.\n"); 43 27 44 28 45 1; 29 30 31 32 33 34 -
trunk/src/kmk/tests/scripts/features/parallelism
r2186 r2591 44 44 "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n"); 45 45 46 unlink('1.inc', '2.inc');46 rmfiles(qw(1.inc 2.inc)); 47 47 48 48 … … 63 63 "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n"); 64 64 65 unlink('1.inc', '2.inc');65 rmfiles(qw(1.inc 2.inc)); 66 66 67 67 # Grant Taylor reports a problem where tokens can be lost (not written back … … 153 153 .PHONY: phony 154 154 phony: ; : phony', '-rR -j', ': phony'); 155 unlink('target'); 156 155 rmfiles('target'); 156 157 # TEST #10: Don't put --jobserver-fds into a re-exec'd MAKEFLAGS. 158 # We can't test this directly because there's no way a makefile can 159 # show the value of MAKEFLAGS we were re-exec'd with. We can intuit it 160 # by looking for "disabling jobserver mode" warnings; we should only 161 # get one from the original invocation and none from the re-exec. 162 # See Savannah bug #18124 163 164 run_make_test(q! 165 -include inc.mk 166 recur: 167 # @echo 'MAKEFLAGS = $(MAKEFLAGS)' 168 @rm -f inc.mk 169 @$(MAKE) -j2 -f #MAKEFILE# all 170 all: 171 # @echo 'MAKEFLAGS = $(MAKEFLAGS)' 172 @echo $@ 173 inc.mk: 174 # @echo 'MAKEFLAGS = $(MAKEFLAGS)' 175 @echo 'FOO = bar' > $@ 176 !, 177 '--no-print-directory -j2', "#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.\nall\n"); 178 179 rmfiles('inc.mk'); 180 181 if ($all_tests) { 182 # Implicit files aren't properly recreated during parallel builds 183 # Savannah bug #26864 184 185 # The first run works fine 186 run_make_test(q! 187 %.bar: %.x foo.y ; cat $^ > $@ 188 %.x: ; touch $@ 189 foo.y: foo.y.in ; cp $< $@ 190 foo.y.in: ; touch $@ 191 !, 192 '-j2 main.bar', 193 "touch foo.y.in 194 touch main.x 195 cp foo.y.in foo.y 196 cat main.x foo.y > main.bar 197 rm main.x"); 198 199 # Now we touch the .in file and make sure it still works 200 touch('foo.y.in'); 201 202 run_make_test(undef, '-j2 main.bar', "cp foo.y.in foo.y 203 touch main.x 204 cat main.x foo.y > main.bar 205 rm main.x"); 206 207 # Clean up 208 rmfiles(qw(foo.y foo.y.in main.bar)); 209 } 210 211 if ($all_tests) { 212 # Jobserver FD handling is messed up in some way. 213 # Savannah bug #28189 214 # It doesn't look like that bug anymore but this is the code it runs 215 216 run_make_test(q! 217 ifdef EXTRA 218 vpath %.dst / 219 xxx.dst: ; true 220 yyy.dst: ; true 221 endif 222 223 M := $(MAKE) 224 xx: ; $M --no-print-directory -j2 -f $(MAKEFILE_LIST) xxx.dst yyy.dst EXTRA=1 225 !, 226 '-j2', 227 '#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode. 228 true 229 true 230 '); 231 } 157 232 158 233 # Make sure that all jobserver FDs are closed if we need to re-exec the … … 183 258 # 'bar'); 184 259 185 # unlink('dependfile', 'output');260 # rmfiles(qw(dependfile output)); 186 261 187 262 … … 189 264 # run_make_test(undef, '-j2 recurse INCL=false', 'bar'); 190 265 191 # unlink('dependfile', 'output');266 # rmfiles(qw(dependfile output)); 192 267 193 268 1; -
trunk/src/kmk/tests/scripts/features/patspecific_vars
r2173 r2591 121 121 pattrn: global: new $t pattern: good $t inherit: good $t;'); 122 122 123 # TEST #8: override in pattern-specific variables 124 125 run_make_test(' 126 a%: override FOO += f1 127 a%: FOO += f2 128 ab: ; @echo "$(FOO)" 129 ', 130 '', "f1\n"); 131 132 run_make_test(undef, 'FOO=C', "C f1\n"); 133 134 # TEST #9: Test shortest stem selection in pattern-specific variables. 135 136 run_make_test(' 137 %-mt.x: x := two 138 %.x: x := one 139 140 all: foo.x foo-mt.x 141 142 foo.x: ;@echo $x 143 foo-mt.x: ;@echo $x 144 ', 145 '', 146 "one\ntwo"); 123 147 124 148 1; -
trunk/src/kmk/tests/scripts/features/patternrules
- Property svn:keywords deleted
r1952 r2591 16 16 # 17 17 18 run_make_test( '18 run_make_test(q! 19 19 .PHONY: all 20 20 21 21 all: case.1 case.2 case.3 22 a: void 22 23 # We can't have this, due to "Implicit Rule Search Algorithm" step 5c 24 #xxx: void 23 25 24 26 # 1 - existing file … … 42 44 43 45 3.implicit-phony: 44 ', 45 '', 46 ''); 46 !, '', ''); 47 47 48 48 # TEST #1: make sure files that are built via implicit rules are marked … … 150 150 unlink('foo.in', 'foo.h', 'foo.c', 'foo.o'); 151 151 152 # TEST #5: make sure both prefix and suffix patterns work with multiple 153 # target patterns (Savannah bug #26593). 154 # 155 run_make_test(' 156 all: foo.s1 foo.s2 p1.foo p2.foo 157 158 p1.% p2.%: %.orig 159 @echo $@ 160 %.s1 %.s2: %.orig 161 @echo $@ 162 163 .PHONY: foo.orig 164 ', 165 '', "foo.s1\np1.foo\n"); 166 167 # TEST 6: Make sure that non-target files are still eligible to be created 168 # as part of implicit rule chaining. Savannah bug #17752. 169 170 run_make_test(q! 171 BIN = xyz 172 COPY = $(BIN).cp 173 SRC = $(BIN).c 174 allbroken: $(COPY) $(BIN) ; @echo ok 175 $(SRC): ; @echo 'main(){}' > $@ 176 %.cp: % ; @cp $< $@ 177 % : %.c ; @cp $< $@ 178 clean: ; @rm -rf $(SRC) $(COPY) $(BIN) 179 !, 180 '', "ok\n"); 181 182 unlink(qw(xyz xyz.cp xyz.c)); 183 184 # TEST 7: Make sure that all prereqs of all "also_make" targets get created 185 # before any of the things that depend on any of them. Savannah bug #19108. 186 187 run_make_test(q! 188 final: x ; @echo $@ 189 x: x.t1 x.t2 ; @echo $@ 190 x.t2: dep 191 dep: ; @echo $@ 192 %.t1 %.t2: ; @echo $*.t1 ; echo $*.t2 193 !, 194 '', "dep\nx.t1\nx.t2\nx\nfinal\n"); 195 196 197 # TEST 8: Verify we can remove pattern rules. Savannah bug #18622. 198 199 my @f = (qw(foo.w foo.ch)); 200 touch(@f); 201 202 run_make_test(q! 203 CWEAVE := : 204 205 # Disable builtin rules 206 %.tex : %.w 207 %.tex : %.w %.ch 208 !, 209 'foo.tex', 210 "#MAKE#: *** No rule to make target `foo.tex'. Stop.", 512); 211 212 unlink(@f); 213 214 # TEST #9: Test shortest stem selection in pattern rules. 215 216 run_make_test(' 217 %.x: ;@echo one 218 %-mt.x: ;@echo two 219 220 all: foo.x foo-mt.x 221 ', 222 '', 223 "one\ntwo"); 224 225 1; 226 152 227 # This tells the test driver that the perl test script executed properly. 153 228 1; -
trunk/src/kmk/tests/scripts/features/recursion
r1956 r2591 17 17 @echo THE END 18 18 ', 19 ('CFLAGS=-O -w' . ($parallel_jobs ? ' -j 2' : '')),19 ('CFLAGS=-O -w' . ($parallel_jobs ? ' -j 2' : '')), 20 20 ($vos 21 21 ? "#MAKE#: Entering directory `#PWD#' -
trunk/src/kmk/tests/scripts/features/se_explicit
- Property svn:keywords deleted
r1981 r2591 27 27 # TEST #1: automatic variables. 28 28 # 29 run_make_test( '29 run_make_test(q! 30 30 .SECONDEXPANSION: 31 .DEFAULT: ; @echo $@31 .DEFAULT: ; @echo '$@' 32 32 33 33 foo: bar baz … … 42 42 $$*.6 43 43 44 ',44 !, 45 45 '-j1', 46 46 'bar … … 63 63 # Test #2: target/pattern -specific variables. 64 64 # 65 run_make_test( '65 run_make_test(q! 66 66 .SECONDEXPANSION: 67 .DEFAULT: ; @echo $@67 .DEFAULT: ; @echo '$@' 68 68 69 69 foo.x: $$a $$b … … 72 72 73 73 %.x: b := baz 74 75 ', 74 !, 76 75 '', 77 76 'bar … … 82 81 # Test #3: order of prerequisites. 83 82 # 84 run_make_test( '83 run_make_test(q! 85 84 .SECONDEXPANSION: 86 .DEFAULT: ; @echo $@85 .DEFAULT: ; @echo '$@' 87 86 88 87 all: foo bar baz 89 88 90 89 # Subtest #1 91 #92 90 foo: foo.1; @: 93 94 91 foo: foo.2 95 96 92 foo: foo.3 97 93 98 99 94 # Subtest #2 100 #101 95 bar: bar.2 102 103 96 bar: bar.1; @: 104 105 97 bar: bar.3 106 98 107 108 99 # Subtest #3 109 #110 100 baz: baz.1 111 112 101 baz: baz.2 113 114 102 baz: ; @: 115 116 ', 103 !, 117 104 '-j1', 118 105 'foo.1 … … 126 113 '); 127 114 115 # TEST #4: eval in a context where there is no reading_file 116 run_make_test(q! 117 .SECONDEXPANSION: 118 all : $$(eval $$(info test)) 119 !, 120 '', "test\n#MAKE#: Nothing to be done for `all'.\n"); 121 122 # TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new 123 # target/prereq relationships. 124 125 run_make_test(q! 126 .SECONDEXPANSION: 127 proj1.exe : proj1.o $$(eval $$(test)) 128 define test 129 proj1.o : proj1.c 130 proj1.c: proj1.h 131 endef 132 !, 133 '', "#MAKE#: *** prerequisites cannot be defined in recipes. Stop.\n", 512); 134 135 136 # Automatic $$+ variable expansion issue. Savannah bug #25780 137 run_make_test(q! 138 all : foo foo 139 .SECONDEXPANSION: 140 all : $$+ ; @echo '$+' 141 foo : ; 142 !, 143 '', "foo foo foo foo\n"); 144 145 146 # Automatic $$+ variable expansion issue. Savannah bug #25780 147 run_make_test(q! 148 all : bar bar 149 bar : ; 150 q%x : ; 151 .SECONDEXPANSION: 152 a%l: q1x $$+ q2x ; @echo '$+' 153 !, 154 '', "q1x bar bar q2x bar bar\n"); 155 156 128 157 # This tells the test driver that the perl test script executed properly. 129 158 1; -
trunk/src/kmk/tests/scripts/features/se_implicit
- Property svn:keywords deleted
r1982 r2591 12 12 # Test #1: automatic variables. 13 13 # 14 run_make_test( '15 .SECONDEXPANSION: 16 .DEFAULT: ; @echo $@14 run_make_test(q! 15 .SECONDEXPANSION: 16 .DEFAULT: ; @echo '$@' 17 17 18 18 foo.a: bar baz … … 38 38 5.buz \ 39 39 6.a: 40 @echo $@41 42 ',40 @echo '$@' 41 42 !, 43 43 '-j1', 44 44 '1.foo.a … … 61 61 # Test #2: target/pattern -specific variables. 62 62 # 63 run_make_test( '63 run_make_test(q! 64 64 .SECONDEXPANSION: 65 65 foo.x: … … 72 72 %.x: x_b := baz 73 73 74 bar baz: ; @echo $@ 75 76 ', 77 '', 78 'bar 79 baz 80 '); 74 bar baz: ; @echo '$@' 75 !, 76 '', "bar\nbaz\n"); 81 77 82 78 83 79 # Test #3: order of prerequisites. 84 80 # 85 run_make_test( '86 .SECONDEXPANSION: 87 .DEFAULT: ; @echo $@81 run_make_test(q! 82 .SECONDEXPANSION: 83 .DEFAULT: ; @echo '$@' 88 84 89 85 all: foo bar baz … … 98 94 foo: foo.3 99 95 100 foo.1: ; @echo $@96 foo.1: ; @echo '$@' 101 97 102 98 … … 109 105 bar: bar.3 110 106 111 bar.1: ; @echo $@107 bar.1: ; @echo '$@' 112 108 113 109 … … 119 115 120 116 %az: ; @: 121 122 ', 123 '-j1', 117 !, 118 '-j1', 124 119 'foo.1 125 120 foo.2 … … 135 130 # Test #4: stem splitting logic. 136 131 # 137 run_make_test( '132 run_make_test(q! 138 133 .SECONDEXPANSION: 139 134 $(dir)/tmp/bar.o: 140 135 141 $(dir)/tmp/foo/bar.c: ; @echo $@142 $(dir)/tmp/bar/bar.c: ; @echo $@143 foo.h: ; @echo $@136 $(dir)/tmp/foo/bar.c: ; @echo '$@' 137 $(dir)/tmp/bar/bar.c: ; @echo '$@' 138 foo.h: ; @echo '$@' 144 139 145 140 %.o: $$(addsuffix /%.c,foo bar) foo.h 146 @echo $@: {$<} $^ 147 148 ', 149 "dir=$dir", 150 "$dir/tmp/foo/bar.c 141 @echo '$@: {$<} $^' 142 !, 143 "dir=$dir", "$dir/tmp/foo/bar.c 151 144 $dir/tmp/bar/bar.c 152 145 foo.h … … 157 150 # Test #5: stem splitting logic and order-only prerequisites. 158 151 # 159 run_make_test( '152 run_make_test(q! 160 153 .SECONDEXPANSION: 161 154 $(dir)/tmp/foo.o: $(dir)/tmp/foo.c 162 $(dir)/tmp/foo.c: ; @echo $@163 bar.h: ; @echo $@155 $(dir)/tmp/foo.c: ; @echo '$@' 156 bar.h: ; @echo '$@' 164 157 165 158 %.o: %.c|bar.h 166 @echo $@: {$<} {$|} $^ 167 168 ', 169 "dir=$dir", 170 "$dir/tmp/foo.c 159 @echo '$@: {$<} {$|} $^' 160 161 !, 162 "dir=$dir", "$dir/tmp/foo.c 171 163 bar.h 172 164 $dir/tmp/foo.o: {$dir/tmp/foo.c} {bar.h} $dir/tmp/foo.c … … 176 168 # Test #6: lack of implicit prerequisites. 177 169 # 178 run_make_test( '170 run_make_test(q! 179 171 .SECONDEXPANSION: 180 172 foo.o: foo.c 181 foo.c: ; @echo $@173 foo.c: ; @echo '$@' 182 174 183 175 %.o: 184 @echo $@: {$<} $^ 185 186 ', 187 '', 188 'foo.c 189 foo.o: {foo.c} foo.c 190 '); 176 @echo '$@: {$<} $^' 177 !, 178 '', "foo.c\nfoo.o: {foo.c} foo.c\n"); 179 191 180 192 181 # Test #7: Test stem from the middle of the name. 193 182 # 194 run_make_test( '183 run_make_test(q! 195 184 .SECONDEXPANSION: 196 185 foobarbaz: 197 186 198 187 foo%baz: % $$*.1 199 @echo $*188 @echo '$*' 200 189 201 190 bar bar.1: 202 @echo $@ 203 204 ', 205 '', 206 'bar 207 bar.1 208 bar 209 '); 191 @echo '$@' 192 !, 193 '', "bar\nbar.1\nbar\n"); 194 210 195 211 196 # Test #8: Make sure stem triple-expansion does not happen. 212 197 # 213 run_make_test( '198 run_make_test(q! 214 199 .SECONDEXPANSION: 215 200 foo$$bar: 216 201 217 202 f%r: % $$*.1 218 @echo \'$*\'203 @echo '$*' 219 204 220 205 oo$$ba oo$$ba.1: 221 @echo \'$@\' 222 223 ', 224 '', 225 'oo$ba 206 @echo '$@' 207 !, 208 '', 'oo$ba 226 209 oo$ba.1 227 210 oo$ba 228 211 '); 229 212 213 # Test #9: Check the value of $^ 214 run_make_test(q! 215 .SECONDEXPANSION: 216 217 %.so: | $$(extra) ; @echo $^ 218 219 foo.so: extra := foo.o 220 foo.so: 221 foo.o: 222 !, 223 '', "\n"); 230 224 231 225 # This tells the test driver that the perl test script executed properly. -
trunk/src/kmk/tests/scripts/features/se_statpat
- Property svn:keywords deleted
r1983 r2591 6 6 # Test #1: automatic variables. 7 7 # 8 run_make_test(' 8 # bird: Had to add -j1 here earlier... 9 run_make_test(q! 9 10 .SECONDEXPANSION: 10 .DEFAULT: ; @echo $@11 .DEFAULT: ; @echo '$@' 11 12 12 13 foo.a foo.b: foo.%: bar.% baz.% 13 14 14 foo.a foo.b: foo.%: biz.% | buz.% 15 15 … … 20 20 $$|.5 \ 21 21 $$*.6 22 23 ', 24 '-j1', 25 'bar.a 22 !, 23 '', 'bar.a 26 24 baz.a 27 25 biz.a … … 42 40 # Test #2: target/pattern -specific variables. 43 41 # 44 run_make_test( '42 run_make_test(q! 45 43 .SECONDEXPANSION: 46 .DEFAULT: ; @echo $@44 .DEFAULT: ; @echo '$@' 47 45 48 46 foo.x foo.y: foo.%: $$(%_a) $$($$*_b) … … 51 49 52 50 %.x: x_b := baz 53 54 55 ', 56 '', 57 'bar 58 baz 59 '); 51 !, 52 '', "bar\nbaz\n"); 60 53 61 54 62 55 # Test #3: order of prerequisites. 63 56 # 64 run_make_test(' 57 # bird: Had to add -j1 here earlier... 58 run_make_test(q! 65 59 .SECONDEXPANSION: 66 .DEFAULT: ; @echo $@60 .DEFAULT: ; @echo '$@' 67 61 68 62 all: foo.a bar.a baz.a 69 63 70 64 # Subtest #1 71 #72 65 foo.a foo.b: foo.%: foo.%.1; @: 73 74 66 foo.a foo.b: foo.%: foo.%.2 75 76 67 foo.a foo.b: foo.%: foo.%.3 77 68 78 69 79 70 # Subtest #2 80 #81 71 bar.a bar.b: bar.%: bar.%.2 82 83 72 bar.a bar.b: bar.%: bar.%.1; @: 84 85 73 bar.a bar.b: bar.%: bar.%.3 86 74 87 75 88 76 # Subtest #3 89 #90 77 baz.a baz.b: baz.%: baz.%.1 91 92 78 baz.a baz.b: baz.%: baz.%.2 93 94 79 baz.a baz.b: ; @: 95 96 ', 97 '-j1', 98 'foo.a.1 80 !, 81 '', 'foo.a.1 99 82 foo.a.2 100 83 foo.a.3 … … 109 92 # Test #4: Make sure stem triple-expansion does not happen. 110 93 # 111 run_make_test( '94 run_make_test(q! 112 95 .SECONDEXPANSION: 113 96 foo$$bar: f%r: % $$*.1 114 @echo \'$*\'97 @echo '$*' 115 98 116 99 oo$$ba oo$$ba.1: 117 @echo \'$@\' 118 119 ', 120 '', 121 'oo$ba 100 @echo '$@' 101 !, 102 '', 'oo$ba 122 103 oo$ba.1 123 104 oo$ba -
trunk/src/kmk/tests/scripts/features/targetvars
r2165 r2591 7 7 rules, semicolon interference, etc."; 8 8 9 open(MAKEFILE,"> $makefile"); 10 11 print MAKEFILE <<'EOF'; 9 run_make_test(' 12 10 SHELL = /bin/sh 13 11 export FOO = foo … … 18 16 three: ; BAR=1000 19 17 @echo $(FOO) $(BAR) 20 # Some things that shouldn 't be target vars18 # Some things that shouldn not be target vars 21 19 funk : override 22 20 funk : override adelic … … 25 23 four:FOO=x 26 24 four:VAR$(FOO)=ok 27 four: ; @echo '$(FOO) $(VAR$(FOO)) $(VAR) $(VARx)'25 four: ; @echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx)" 28 26 five:FOO=x 29 27 five six : VAR$(FOO)=good 30 five six: ;@echo '$(FOO) $(VAR$(FOO)) $(VAR) $(VARx) $(VARfoo)'28 five six: ;@echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx) $(VARfoo)" 31 29 # Test per-target variable inheritance 32 30 seven: eight … … 42 40 # Test = escaping 43 41 EQ = = 44 ten: one \=two45 ten: one \=two42 ten: one$(EQ)two 43 ten: one $(EQ) two 46 44 ten one$(EQ)two $(EQ):;@echo $@ 47 45 .PHONY: one two three four five six seven eight nine ten $(EQ) one$(EQ)two … … 55 53 foo.r : RVAR += rvar 56 54 foo.t : TVAR := $(QVAR) 57 EOF 58 59 close(MAKEFILE); 60 61 # TEST #1 62 63 &run_make_with_options($makefile, "-j1 one two three", &get_logfile); 64 $answer = "one bar\nfoo two\nBAR=1000\nfoo bar\n"; 65 &compare_output($answer,&get_logfile(1)); 55 ', 56 "one two three", "one bar\nfoo two\nBAR=1000\nfoo bar\n"); 66 57 67 58 # TEST #2 68 59 69 &run_make_with_options($makefile, "-j1 one two FOO=1 BAR=2", &get_logfile); 70 $answer = "one 2\n1 2\n"; 71 &compare_output($answer,&get_logfile(1)); 60 run_make_test(undef, "one two FOO=1 BAR=2", "one 2\n1 2\n"); 72 61 73 62 # TEST #3 74 63 75 &run_make_with_options($makefile, "-j1 four", &get_logfile); 76 $answer = "x ok ok\n"; 77 &compare_output($answer,&get_logfile(1)); 64 run_make_test(undef, "four", "x ok ok\n"); 78 65 79 66 # TEST #4 80 67 81 &run_make_with_options($makefile, "-j1 seven", &get_logfile); 82 $answer = "eight: seven eight\nseven: seven seven\n"; 83 &compare_output($answer,&get_logfile(1)); 68 run_make_test(undef, "seven", "eight: seven eight\nseven: seven seven\n"); 84 69 85 70 # TEST #5 86 71 87 &run_make_with_options($makefile, "-j1 nine", &get_logfile); 88 $answer = "wallace bar wallace bar\n"; 89 &compare_output($answer,&get_logfile(1)); 72 run_make_test(undef, "nine", "wallace bar wallace bar\n"); 90 73 91 74 # TEST #5-a 92 75 93 &run_make_with_options($makefile, "-j1 nine-a", &get_logfile); 94 $answer = "baz\n"; 95 &compare_output($answer,&get_logfile(1)); 76 run_make_test(undef, "nine-a", "baz\n"); 96 77 97 78 # TEST #6 98 79 99 &run_make_with_options($makefile, "-j1 ten", &get_logfile); 100 $answer = "one=two\none bar\n=\nfoo two\nten\n"; 101 &compare_output($answer,&get_logfile(1)); 80 run_make_test(undef, "ten", "one=two\none bar\n=\nfoo two\nten\n"); 102 81 103 82 # TEST #6 104 83 105 &run_make_with_options($makefile, "-j1 foo.q bar.q", &get_logfile); 106 $answer = "qvar = rvar\nqvar =\n"; 107 &compare_output($answer,&get_logfile(1)); 84 run_make_test(undef, "foo.q bar.q", "qvar = rvar\nqvar =\n"); 108 85 109 86 # TEST #7 110 87 111 &run_make_with_options($makefile, "-j1 foo.t bar.s", &get_logfile); 112 $answer = "qvar = qvar\nqvar =\n"; 113 &compare_output($answer,&get_logfile(1)); 88 run_make_test(undef, "foo.t bar.s", "qvar = qvar\nqvar =\n"); 114 89 115 90 … … 117 92 # For PR/1378: Target-specific vars don't inherit correctly 118 93 119 $makefile2 = &get_tmpfile; 120 121 open(MAKEFILE,"> $makefile2"); 122 print MAKEFILE <<'EOF'; 94 run_make_test(' 123 95 foo: FOO = foo 124 96 bar: BAR = bar … … 126 98 bar: baz 127 99 baz: ; @echo $(FOO) $(BAR) 128 EOF 129 close(MAKEFILE); 130 131 &run_make_with_options("$makefile2", "", &get_logfile); 132 $answer = "foo bar\n"; 133 &compare_output($answer, &get_logfile(1)); 100 ', "", "foo bar\n"); 134 101 135 102 # TEST #9 … … 137 104 # Also PR/1831 138 105 139 $makefile3 = &get_tmpfile; 140 141 open(MAKEFILE,"> $makefile3"); 142 print MAKEFILE <<'EOF'; 106 run_make_test(' 143 107 .PHONY: all one 144 108 all: FOO += baz … … 150 114 one: FOO += boz 151 115 one: ; @echo $(FOO) 152 EOF 153 close(MAKEFILE); 154 155 &run_make_with_options("$makefile3", "", &get_logfile); 156 $answer = "bar baz biz boz\nbar baz\n"; 157 &compare_output($answer, &get_logfile(1)); 116 ', 117 '', "bar baz biz boz\nbar baz\n"); 158 118 159 119 # Test #10 160 120 161 &run_make_with_options("$makefile3", "one", &get_logfile); 162 $answer = "bar biz boz\n"; 163 &compare_output($answer, &get_logfile(1)); 121 run_make_test(undef, 'one', "bar biz boz\n"); 164 122 165 123 # Test #11 166 124 # PR/1709: Test semicolons in target-specific variable values 167 125 168 $makefile4 = &get_tmpfile; 169 170 open(MAKEFILE, "> $makefile4"); 171 print MAKEFILE <<'EOF'; 126 run_make_test(' 172 127 foo : FOO = ; ok 173 foo : ; @echo '$(FOO)' 174 EOF 175 close(MAKEFILE); 176 177 &run_make_with_options("$makefile4", "", &get_logfile); 178 $answer = "; ok\n"; 179 &compare_output($answer, &get_logfile(1)); 128 foo : ; @echo "$(FOO)" 129 ', 130 '', "; ok\n"); 180 131 181 132 # Test #12 … … 183 134 # I nailed it this time :-/. 184 135 185 $makefile5 = &get_tmpfile; 186 187 open(MAKEFILE, "> $makefile5"); 188 print MAKEFILE <<'EOF'; 136 run_make_test(' 189 137 .PHONY: a 190 138 … … 196 144 a: BLAH := bar 197 145 a: COMMAND += snafu $(BLAH) 198 EOF 199 close(MAKEFILE); 200 201 &run_make_with_options("$makefile5", "", &get_logfile); 202 $answer = "bar snafu bar\n"; 203 &compare_output($answer, &get_logfile(1)); 146 ', 147 '', "bar snafu bar\n"); 204 148 205 149 # Test #13 206 150 # Test double-colon rules with target-specific variable values 207 151 208 $makefile6 = &get_tmpfile; 209 210 open(MAKEFILE, "> $makefile6"); 211 print MAKEFILE <<'EOF'; 152 run_make_test(' 212 153 W = bad 213 154 X = bad … … 225 166 fo% : Z = pat 226 167 endif 227 228 EOF 229 close(MAKEFILE); 230 231 &run_make_with_options("$makefile6", "foo", &get_logfile); 232 $answer = "ok ok foo nopat\nok ok foo nopat\n"; 233 &compare_output($answer, &get_logfile(1)); 168 ', 169 'foo', "ok ok foo nopat\nok ok foo nopat\n"); 234 170 235 171 # Test #14 … … 237 173 # inheritance 238 174 239 &run_make_with_options("$makefile6", "bar", &get_logfile); 240 $answer = "ok ok bar nopat\nok ok bar nopat\n"; 241 &compare_output($answer, &get_logfile(1)); 175 run_make_test(undef, 'bar', "ok ok bar nopat\nok ok bar nopat\n"); 242 176 243 177 # Test #15 244 178 # Test double-colon rules with pattern-specific variable values 245 179 246 &run_make_with_options("$makefile6", "foo PATTERN=yes", &get_logfile); 247 $answer = "ok ok foo pat\nok ok foo pat\n"; 248 &compare_output($answer, &get_logfile(1)); 249 180 run_make_test(undef, 'foo PATTERN=yes', "ok ok foo pat\nok ok foo pat\n"); 250 181 251 182 # Test #16 … … 253 184 # (> make default buffer length) 254 185 255 $makefile7 = &get_tmpfile; 256 257 open(MAKEFILE, "> $makefile7"); 258 print MAKEFILE <<'EOF'; 186 run_make_test(' 259 187 base_metals_fmd_reports.sun5 base_metals_fmd_reports CreateRealPositions CreateMarginFunds deals_changed_since : BUILD_OBJ=$(shell if [ -f "build_information.generate" ]; then echo "$(OBJ_DIR)/build_information.o"; else echo "no build information"; fi ) 260 188 261 189 deals_changed_since: ; @echo $(BUILD_OBJ) 262 263 EOF 264 close(MAKEFILE); 265 266 &run_make_with_options("$makefile7", '', &get_logfile); 267 $answer = "no build information\n"; 268 &compare_output($answer, &get_logfile(1)); 190 ', 191 '', "no build information\n"); 269 192 270 193 # TEST #17 … … 287 210 .INTERMEDIATE: foo.x rules.mk 288 211 ', 289 '-I t1', 290 'MYVAR= FOOVAR=bar ALLVAR=xxx'); 212 '-I t1', 'MYVAR= FOOVAR=bar ALLVAR=xxx'); 291 213 292 214 rmfiles('t1/rules.mk'); … … 298 220 # double-expansion. See Savannah bug #15913. 299 221 300 run_make_test( "301 VAR := \$\$FOO222 run_make_test(' 223 VAR := $$FOO 302 224 foo: VAR += BAR 303 foo: ; \@echo '\$(VAR)'", 304 '', 305 '$FOO BAR'); 225 foo: ; @echo '."'".'$(VAR)'."'".' 226 ', 227 '', '$FOO BAR'); 228 229 # TEST #19: Override with append variables 230 231 run_make_test(' 232 a: override FOO += f1 233 a: FOO += f2 234 a: ; @echo "$(FOO)" 235 ', 236 '', "f1\n"); 237 238 run_make_test(undef, 'FOO=C', "C f1\n"); 239 240 # TEST #20: Check for continuation after semicolons 241 242 run_make_test(q! 243 a: A = 'hello; \ 244 world' 245 a: ; @echo $(A) 246 !, 247 '', "hello; world\n"); 248 249 # TEST #19: Test define/endef variables as target-specific vars 250 251 # run_make_test(' 252 # define b 253 # @echo global 254 # endef 255 # a: define b 256 # @echo local 257 # endef 258 259 # a: ; $(b) 260 # ', 261 # '', "local\n"); 306 262 307 263 1; -
trunk/src/kmk/tests/scripts/features/vpath
r2162 r2591 1 # -*-perl-*- 2 1 3 $description = "The following test creates a makefile to test the \n" 2 4 ."vpath directive which allows you to specify a search \n" … … 61 63 } 62 64 65 # TEST 2: after vpath lookup ensure we don't get incorrect circular dependency 66 # warnings due to change of struct file ptr. Savannah bug #13529. 67 68 mkdir('vpath-d', 0777); 69 70 run_make_test(q! 71 vpath %.te vpath-d/ 72 .SECONDARY: 73 default: vpath-d/a vpath-d/b 74 vpath-d/a: fail.te 75 vpath-d/b : fail.te 76 vpath-d/fail.te: 77 !, 78 '', "#MAKE#: Nothing to be done for `default'.\n"); 79 80 rmdir('vpath-d'); 81 63 82 1; -
trunk/src/kmk/tests/scripts/functions/abspath
- Property svn:keywords deleted
-
trunk/src/kmk/tests/scripts/functions/realpath
- Property svn:keywords deleted
-
trunk/src/kmk/tests/scripts/functions/shell
r969 r2591 12 12 13 13 14 # Test unescaped comment characters in shells. Savannah bug #20513 15 if ($all_tests) { 16 run_make_test(q! 17 FOO := $(shell echo '#') 18 foo: ; echo '$(FOO)' 19 !, 20 '', "#\n"); 21 } 22 14 23 # Test shells inside exported environment variables. 15 24 # This is the test that fails if we try to put make exported variables into -
trunk/src/kmk/tests/scripts/functions/wildcard
r969 r2591 82 82 &compare_output($answer,&get_logfile(1)); 83 83 84 # TEST #4: Verify that failed wildcards don't return the pattern 85 86 run_make_test(q! 87 all: ; @echo $(wildcard xz--y*.7) 88 !, 89 '', "\n"); 84 90 85 91 1; 86 87 88 89 90 91 92 93 94 -
trunk/src/kmk/tests/scripts/misc/general4
r1963 r2591 30 30 !$is_kmk ? 0 : 512); 31 31 unlink('foo.c'); 32 33 34 # Test other implicit rule searching35 36 &touch('bar');37 run_make_test('38 test.foo:39 %.foo : baz ; @echo done $<40 %.foo : bar ; @echo done $<41 fox: baz42 ',43 '',44 'done bar');45 unlink('bar');46 32 47 33 … … 84 70 '', "mkdir -p dir/subdir\ntouch dir/subdir/file.\$b\ncp dir/subdir/file.\$b dir/subdir/file.\$a\n"); 85 71 72 # Test odd whitespace at the beginning of a line 73 74 run_make_test(" 75 all: 76 \f 77 78 \\ 79 \f \\ 80 \013 \\ 81 all: ; \@echo hi 82 ", 83 '', "hi\n"); 84 86 85 1; -
trunk/src/kmk/tests/scripts/options/dash-B
r969 r2591 71 71 rmfiles('foo.x', 'blah.x'); 72 72 73 # Test that $? is set properly with -B; all prerequisites will be newer! 74 75 utouch(-10, 'x.b'); 76 touch('x.a'); 77 78 run_make_test(q! 79 x.a: x.b ; @echo $? 80 !, 81 '-B', "x.b\n"); 82 83 unlink(qw(x.a x.b)); 84 73 85 1; -
trunk/src/kmk/tests/scripts/options/symlinks
- Property svn:keywords deleted
-
trunk/src/kmk/tests/scripts/variables/DEFAULT_GOAL
- Property svn:keywords deleted
r969 r2591 74 74 'foo'); 75 75 76 # TEST #5: .DEFAULT_GOAL containing just whitespace (Savannah bug #25697) 77 78 run_make_test(' 79 N = 80 .DEFAULT_GOAL = $N $N # Just whitespace 81 82 foo: ; @echo "boo" 83 ', 84 '', "#MAKE#: *** No targets. Stop.\n", 512); 76 85 77 86 # This tells the test driver that the perl test script executed properly. -
trunk/src/kmk/tests/scripts/variables/MAKE
r969 r2591 1 1 # -*-perl-*- 2 2 3 $description = "The following test creates a makefile to test MAKE \n" 4 ."(very generic)"; 3 $description = "Test proper behavior of the MAKE variable"; 5 4 6 5 $details = "DETAILS"; 7 6 8 open(MAKEFILE,"> $makefile"); 7 run_make_test(q! 8 TMP := $(MAKE) 9 MAKE := $(subst X=$(X),,$(MAKE)) 10 all: 11 @echo $(TMP) 12 $(MAKE) -f #MAKEFILE# foo 9 13 10 # The Contents of the MAKEFILE ... 14 foo: 15 @echo $(MAKE) 16 !, 17 '', 18 "#MAKEPATH#\n#MAKEPATH# -f #MAKEFILE# foo\n" 19 . "#MAKE#[1]: Entering directory `#PWD#'\n" 20 . "#MAKEPATH#\n#MAKE#[1]: Leaving directory `#PWD#'\n"); 11 21 12 print MAKEFILE "TMP := \$(MAKE)\n"; 13 print MAKEFILE "MAKE := \$(subst X=\$(X),,\$(MAKE))\n\n"; 14 print MAKEFILE "all:\n"; 15 print MAKEFILE "\t\@echo \$(TMP)\n"; 16 print MAKEFILE "\t\$(MAKE) -f $makefile foo\n\n"; 17 print MAKEFILE "foo:\n"; 18 print MAKEFILE "\t\@echo \$(MAKE)\n"; 19 20 # END of Contents of MAKEFILE 21 22 close(MAKEFILE); 23 24 # Create the answer to what should be produced by this Makefile 25 $answer = "$mkpath\n$mkpath -f $makefile foo\n" 26 . "${make_name}[1]: Entering directory `$pwd'\n" 27 . "$mkpath\n${make_name}[1]: Leaving directory `$pwd'\n"; 28 29 &run_make_with_options($makefile,"",&get_logfile,0); 30 31 &rmfiles("foo"); 32 # COMPARE RESULTS 33 &compare_output($answer,&get_logfile(1)); 22 rmfiles("foo"); 34 23 35 24 1; -
trunk/src/kmk/tests/scripts/variables/MAKEFILES
r969 r2591 32 32 &compare_output($answer,&get_logfile(1)); 33 33 34 # TEST 2: Verify that included makefiles don't set the default goal. 35 # See Savannah bug #13401. 36 37 create_file('xx-inc.mk', ' 38 include_goal: ; @echo $@ 39 include xx-ind.mk 40 '); 41 42 create_file('xx-ind.mk', ' 43 indirect_goal: ; @echo $@ 44 '); 45 46 run_make_test(q! 47 top: ; @echo $@ 48 !, 49 'MAKEFILES=xx-inc.mk', "top\n"); 50 51 unlink(qw(xx-inc.mk xx-ind.mk)); 52 34 53 1; -
trunk/src/kmk/tests/scripts/variables/MFILE_LIST
- Property svn:keywords deleted
-
trunk/src/kmk/tests/scripts/variables/SHELL
- Property svn:keywords deleted
r1969 r2591 50 50 $extraENV{SHELL} = $mshell; 51 51 52 # bird: This was wrong, see Savannah bug #24655. Fixed in kBuild. 53 run_make_test("all: export SHELL := /./$mshell\n".' 54 all:;@echo "$(SHELL) $$SHELL" 55 ', '', "/./$mshell /./$mshell"); 52 # bird: This was wrong at some point, see Savannah bug #24655. Was first fixed in kBuild. 53 run_make_test(" 54 SHELL := /././$mshell 55 one: two 56 two: export SHELL := /./$mshell\n".' 57 one two:;@echo "$@: $(SHELL) $$SHELL" 58 ', '', "two: /./$mshell /./$mshell\none: /././$mshell $mshell\n"); 59 60 # Test .SHELLFLAGS 61 62 # We don't know the output here: on Solaris for example, every line printed 63 # by the shell in -x mode has a trailing space (!!) 64 my $script = 'true; true'; 65 my $flags = '-xc'; 66 my $out = `/bin/sh $flags '$script' 2>&1`; 67 68 run_make_test(qq! 69 .SHELLFLAGS = $flags 70 all: ; \@$script 71 !, 72 '', $out); 73 74 # We can't just use "false" because on different systems it provides a 75 # different exit code--once again Solaris: false exits with 255 not 1 76 $script = 'true; false; true'; 77 $flags = '-xec'; 78 $out = `/bin/sh $flags '$script' 2>&1`; 79 my $err = $? >> 8; 80 81 run_make_test(qq! 82 .SHELLFLAGS = $flags 83 all: ; \@$script 84 !, 85 '', "$out#MAKE#: *** [all] Error $err\n", 512); 56 86 57 87 1; -
trunk/src/kmk/tests/scripts/variables/automatic
r1984 r2591 108 108 unlink('foo'); 109 109 110 # TEST #4: ensure prereq ordering is correct when the commmand target has none 111 # See Savannah bug #21198 112 113 run_make_test(' 114 all : A B 115 all : ; @echo $@ -- $^ -- $< 116 all : C D 117 all : E F 118 A B C D E F G H : ; @: 119 ', 120 '', "all -- A B C D E F -- A\n"); 121 110 122 1; -
trunk/src/kmk/tests/scripts/variables/flavors
r1970 r2591 5 5 $details = ""; 6 6 7 open(MAKEFILE, "> $makefile"); 7 # TEST 0: Recursive 8 8 9 # The Contents of the MAKEFILE ... 10 11 print MAKEFILE <<'EOF'; 9 run_make_test(' 10 ugh = Goodbye 12 11 foo = $(bar) 13 12 bar = ${ugh} 14 13 ugh = Hello 14 all: ; @echo $(foo) 15 ', 16 '', "Hello\n"); 15 17 16 all: multi ; @echo $(foo) 17 18 multi: ; $(multi) 19 20 x := foo 21 y := $(x) bar 22 x := later 23 24 nullstring := 25 space := $(nullstring) $(nullstring) 26 27 next: ; @echo $x$(space)$y 28 29 define multi 30 @echo hi 31 echo there 32 endef 33 34 ifdef BOGUS 35 define 36 @echo error 37 endef 38 endif 39 40 define outer 41 define inner 42 A = B 43 endef 44 endef 45 46 $(eval $(outer)) 47 48 outer: ; @echo $(inner) 49 50 EOF 51 52 # END of Contents of MAKEFILE 53 54 close(MAKEFILE); 55 56 # TEST #1 57 # ------- 58 59 &run_make_with_options($makefile, "", &get_logfile); 60 $answer = "hi\necho there\nthere\nHello\n"; 61 &compare_output($answer, &get_logfile(1)); 62 63 # TEST #2 64 # ------- 65 66 &run_make_with_options($makefile, "next", &get_logfile); 67 $answer = "later foo bar\n"; 68 &compare_output($answer, &get_logfile(1)); 69 70 # TEST #3 71 # ------- 72 73 &run_make_with_options($makefile, "BOGUS=true", &get_logfile, 512); 74 $answer = "$makefile:24: *** empty variable name. Stop.\n"; 75 &compare_output($answer, &get_logfile(1)); 76 77 # TEST #4 78 # ------- 79 80 &run_make_with_options($makefile, "outer", &get_logfile); 81 $answer = "A = B\n"; 82 &compare_output($answer, &get_logfile(1)); 83 84 # Clean up from "old style" testing. If all the above tests are converted to 85 # run_make_test() syntax than this line can be removed. 86 $makefile = undef; 87 88 # ------------------------- 89 # Make sure that prefix characters apply properly to define/endef values. 90 # 91 # There's a bit of oddness here if you try to use a variable to hold the 92 # prefix character for a define. Even though something like this: 93 # 94 # define foo 95 # echo bar 96 # endef 97 # 98 # all: ; $(V)$(foo) 99 # 100 # (where V=@) can be seen by the user to be obviously different than this: 101 # 102 # define foo 103 # $(V)echo bar 104 # endef 105 # 106 # all: ; $(foo) 107 # 108 # and the user thinks it should behave the same as when the "@" is literal 109 # instead of in a variable, that can't happen because by the time make 110 # expands the variables for the command line and sees it begins with a "@" it 111 # can't know anymore whether the prefix character came before the variable 112 # reference or was included in the first line of the variable reference. 113 114 # TEST #5 115 # ------- 18 # TEST 1: Simple 116 19 117 20 run_make_test(' 118 define FOO 119 $(V1)echo hello 120 $(V2)echo world 121 endef 122 all: ; @ $(FOO)123 ', '', 'hello124 world');21 bar = Goodbye 22 foo := $(bar) 23 bar = ${ugh} 24 ugh = Hello 25 all: ; @echo $(foo) 26 ', 27 '', "Goodbye\n"); 125 28 126 # TEST #6 127 # ------- 128 129 run_make_test(undef, 'V1=@ V2=@', 'hello 130 world'); 131 132 # TEST #7 133 # ------- 29 # TEST 2: Append to recursive 134 30 135 31 run_make_test(' 136 define FOO 137 $(V1)echo hello 138 $(V2)echo world 139 endef 140 all: ; $(FOO) 141 ', 'V1=@', 'hello 142 echo world 143 world');32 foo = Hello 33 ugh = Goodbye 34 foo += $(bar) 35 bar = ${ugh} 36 ugh = Hello 37 all: ; @echo $(foo) 38 ', 39 '', "Hello Hello\n"); 144 40 145 # TEST #8 146 # ------- 147 148 run_make_test(undef, 'V2=@', 'echo hello 149 hello 150 world'); 151 152 # TEST #9 153 # ------- 154 155 run_make_test(undef, 'V1=@ V2=@', 'hello 156 world'); 157 158 # TEST #10 159 # ------- 160 # Test the basics; a "@" internally to the variable applies to only one line. 161 # A "@" before the variable applies to the entire variable. 41 # TEST 3: Append to simple 162 42 163 43 run_make_test(' 164 define FOO 165 @echo hello 166 echo world 167 endef 168 define BAR 169 echo hello 170 echo world 171 endef 44 foo := Hello 45 ugh = Goodbye 46 bar = ${ugh} 47 foo += $(bar) 48 ugh = Hello 49 all: ; @echo $(foo) 50 ', 51 '', "Hello Goodbye\n"); 172 52 173 all: foo bar 174 foo: ; $(FOO) 175 bar: ; @$(BAR) 176 ', '-j1', 'hello 177 echo world 178 world 179 hello 180 world 181 '); 53 # TEST 4: Conditional pre-set 54 55 run_make_test(' 56 foo = Hello 57 ugh = Goodbye 58 bar = ${ugh} 59 foo ?= $(bar) 60 ugh = Hello 61 all: ; @echo $(foo) 62 ', 63 '', "Hello\n"); 64 65 # TEST 5: Conditional unset 66 67 run_make_test(' 68 ugh = Goodbye 69 bar = ${ugh} 70 foo ?= $(bar) 71 ugh = Hello 72 all: ; @echo $(foo) 73 ', 74 '', "Hello\n"); 182 75 183 76 1; -
trunk/src/kmk/tests/test_driver.pl
r1993 r2591 7 7 # 8 8 # Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 9 # 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 9 # 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 10 # Foundation, Inc. 10 11 # This file is part of GNU Make. 11 12 # … … 30 31 # variables and then calls &toplevel, which does all the real work. 31 32 32 # $Id: test_driver.pl,v 1. 24 2007/11/04 21:54:02psmith Exp $33 # $Id: test_driver.pl,v 1.30 2010/07/28 05:39:50 psmith Exp $ 33 34 34 35 … … 54 55 $test_timeout = 5; 55 56 57 # Path to Perl 58 $perl_name = $^X; 56 59 57 60 # %makeENV is the cleaned-out environment. … … 239 242 { 240 243 # Set up an initial value. In perl5 we can do it the easy way. 241 #242 244 $osname = defined($^O) ? $^O : ''; 245 246 # Find a path to Perl 243 247 244 248 # See if the filesystem supports long file names with multiple … … 276 280 if ($osname =~ /not found/i) 277 281 { 278 $osname = "(something unixy with no uname)";282 $osname = "(something posixy with no uname)"; 279 283 } 280 284 elsif ($@ ne "" || $?) … … 283 287 if ($@ ne "" || $?) 284 288 { 285 $osname = "(something unixy)";289 $osname = "(something posixy)"; 286 290 } 287 291 } … … 460 464 $diffext = 'd'; 461 465 $baseext = 'b'; 466 $runext = 'r'; 462 467 $extext = ''; 463 468 } else { … … 465 470 $diffext = 'diff'; 466 471 $baseext = 'base'; 472 $runext = 'run'; 467 473 $extext = '.'; 468 474 } … … 470 476 $diff_filename = "$testpath.$diffext"; 471 477 $base_filename = "$testpath.$baseext"; 478 $run_filename = "$testpath.$runext"; 472 479 $tmp_filename = "$testpath.$tmpfilesuffix"; 473 480 … … 483 490 $tests_run = 0; 484 491 $tests_passed = 0; 492 485 493 $code = do $perl_testname; 486 494 … … 716 724 717 725 &create_file (&get_basefile, $answer); 726 &create_file (&get_runfile, $command_string); 718 727 719 728 print "\nCreating Difference File ...\n" if $debug; … … 723 732 local($command) = "diff -c " . &get_basefile . " " . $logfile; 724 733 &run_command_with_output(&get_difffile,$command); 734 } else { 735 &rmfiles (); 725 736 } 726 737 … … 816 827 local $SIG{ALRM} = sub { die "timeout\n"; }; 817 828 alarm $test_timeout; 818 $code = system @_;829 $code = system(@_); 819 830 alarm 0; 820 831 }; … … 853 864 my $filename = shift; 854 865 855 print "\nrun_command_with_output($filename ): @_\n" if $debug;866 print "\nrun_command_with_output($filename,$runname): @_\n" if $debug; 856 867 &attach_default_output ($filename); 857 868 my $code = _run_command(@_); … … 1226 1237 } 1227 1238 1239 # This subroutine returns a command filename with a number appended 1240 # to the end corresponding to how many logfiles (and thus command files) 1241 # have been created in the current running test. 1242 1243 sub get_runfile 1244 { 1245 return ($run_filename . &num_suffix ($num_of_logfiles)); 1246 } 1247 1228 1248 # just like logfile, only a generic tmp filename for use by the test. 1229 1249 # they are automatically cleaned up unless -keep was used, or the test fails. -
trunk/src/kmk/variable.c
r2554 r2591 1 1 /* Internals of variables for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 47 47 static struct pattern_var *pattern_vars; 48 48 49 /* Pointer to last struct in the chain, so we can add onto the end. */ 50 51 static struct pattern_var *last_pattern_var; 52 53 /* Create a new pattern-specific variable struct. */ 49 /* Pointer to the last struct in the pack of a specific size, from 1 to 255.*/ 50 51 static struct pattern_var *last_pattern_vars[256]; 52 53 /* Create a new pattern-specific variable struct. The new variable is 54 inserted into the PATTERN_VARS list in the shortest patterns first 55 order to support the shortest stem matching (the variables are 56 matched in the reverse order so the ones with the longest pattern 57 will be considered first). Variables with the same pattern length 58 are inserted in the definition order. */ 54 59 55 60 struct pattern_var * 56 61 create_pattern_var (const char *target, const char *suffix) 57 62 { 63 register unsigned int len = strlen (target); 58 64 register struct pattern_var *p = xmalloc (sizeof (struct pattern_var)); 59 65 60 if (last_pattern_var != 0) 61 last_pattern_var->next = p; 66 if (pattern_vars != 0) 67 { 68 if (len < 256 && last_pattern_vars[len] != 0) 69 { 70 p->next = last_pattern_vars[len]->next; 71 last_pattern_vars[len]->next = p; 72 } 73 else 74 { 75 /* Find the position where we can insert this variable. */ 76 register struct pattern_var **v; 77 78 for (v = &pattern_vars; ; v = &(*v)->next) 79 { 80 /* Insert at the end of the pack so that patterns with the 81 same length appear in the order they were defined .*/ 82 83 if (*v == 0 || (*v)->len > len) 84 { 85 p->next = *v; 86 *v = p; 87 break; 88 } 89 } 90 } 91 } 62 92 else 63 pattern_vars = p; 64 last_pattern_var = p; 65 p->next = 0; 93 { 94 pattern_vars = p; 95 p->next = 0; 96 } 66 97 67 98 p->target = target; 68 p->len = strlen (target);99 p->len = len; 69 100 p->suffix = suffix + 1; 101 102 if (len < 256) 103 last_pattern_vars[len] = p; 70 104 71 105 return p; … … 170 204 static struct variable_set global_variable_set; 171 205 static struct variable_set_list global_setlist 172 = { 0, &global_variable_set };206 = { 0, &global_variable_set, 0 }; 173 207 struct variable_set_list *current_variable_set_list = &global_setlist; 174 208 … … 344 378 #endif 345 379 #ifndef CONFIG_WITH_STRCACHE2 346 v->name = savestring(name, length);380 v->name = xstrndup (name, length); 347 381 #else 348 382 v->name = name; /* already cached. */ … … 387 421 v->per_target = 0; 388 422 v->append = 0; 423 v->private_var = 0; 389 424 v->export = v_default; 390 425 MAKE_STATS_2(v->changes = 0); … … 414 449 } 415 450 451 452 453 /* Undefine variable named NAME in SET. LENGTH is the length of NAME, which 454 does not need to be null-terminated. ORIGIN specifies the origin of the 455 variable (makefile, command line or environment). */ 456 457 static void 458 free_variable_name_and_value (const void *item); 459 460 void 461 undefine_variable_in_set (const char *name, unsigned int length, 462 enum variable_origin origin, 463 struct variable_set *set) 464 { 465 struct variable *v; 466 struct variable **var_slot; 467 struct variable var_key; 468 469 if (set == NULL) 470 set = &global_variable_set; 471 472 var_key.name = (char *) name; 473 var_key.length = length; 474 var_slot = (struct variable **) hash_find_slot (&set->table, &var_key); 475 476 if (env_overrides && origin == o_env) 477 origin = o_env_override; 478 479 v = *var_slot; 480 if (! HASH_VACANT (v)) 481 { 482 if (env_overrides && v->origin == o_env) 483 /* V came from in the environment. Since it was defined 484 before the switches were parsed, it wasn't affected by -e. */ 485 v->origin = o_env_override; 486 487 /* If the definition is from a stronger source than this one, don't 488 undefine it. */ 489 if ((int) origin >= (int) v->origin) 490 { 491 hash_delete_at (&set->table, var_slot); 492 free_variable_name_and_value (v); 493 } 494 } 495 } 416 496 417 497 /* If the variable passed in is "special", handle its special nature. … … 515 595 516 596 517 #if def KMK/* bird: speed */597 #if 0 /*FIX THIS - def KMK*/ /* bird: speed */ 518 598 MY_INLINE struct variable * 519 599 lookup_cached_variable (const char *name) … … 646 726 lookup_variable (const char *name, unsigned int length) 647 727 { 648 #if ndef KMK728 #if 1 /*FIX THIS - ndef KMK*/ 649 729 const struct variable_set_list *setlist; 650 730 struct variable var_key; … … 652 732 struct variable *v; 653 733 #endif /* KMK */ 734 int is_parent = 0; 654 735 #ifdef CONFIG_WITH_STRCACHE2 655 736 const char *cached_name; … … 662 743 name = cached_name; 663 744 #endif /* CONFIG_WITH_STRCACHE2 */ 664 #if ndef KMK745 #if 1 /*FIX THIS - ndef KMK */ 665 746 666 747 var_key.name = (char *) name; … … 678 759 v = (struct variable *) hash_find_item_strcached ((struct hash_table *) &set->table, &var_key); 679 760 # endif /* CONFIG_WITH_STRCACHE2 */ 680 if (v )761 if (v && (!is_parent || !v->private_var)) 681 762 return v->special ? lookup_special_var (v) : v; 763 764 is_parent |= setlist->next_is_parent; 682 765 } 683 766 … … 747 830 #endif /* VMS */ 748 831 749 #if !defined (KMK) || defined(VMS)750 832 return 0; 751 #endif752 833 } 753 834 … … 838 919 initialize_file_variables (file->double_colon, reading); 839 920 l->next = file->double_colon->variables; 921 l->next_is_parent = 0; 840 922 return; 841 923 } … … 848 930 l->next = file->parent->variables; 849 931 } 932 l->next_is_parent = 1; 850 933 851 934 /* If we're not reading makefiles and we haven't looked yet, see if … … 900 983 v->per_target = p->variable.per_target; 901 984 v->export = p->variable.export; 985 v->private_var = p->variable.private_var; 902 986 } 903 987 while ((p = lookup_pattern_var (p, file->name)) != 0); … … 913 997 { 914 998 file->pat_variables->next = l->next; 999 file->pat_variables->next_is_parent = l->next_is_parent; 915 1000 l->next = file->pat_variables; 1001 l->next_is_parent = 0; 916 1002 } 917 1003 } … … 949 1035 setlist->set = set; 950 1036 setlist->next = current_variable_set_list; 1037 setlist->next_is_parent = 0; 951 1038 952 1039 return setlist; … … 1031 1118 global_setlist.set = setlist->set; 1032 1119 global_setlist.next = setlist->next; 1120 global_setlist.next_is_parent = setlist->next_is_parent; 1033 1121 } 1034 1122 … … 1169 1257 1170 1258 sprintf (buf, "%u", makelevel); 1171 (void) define_variable (MAKELEVEL_NAME, MAKELEVEL_LENGTH, buf, o_env, 0);1259 define_variable_cname (MAKELEVEL_NAME, buf, o_env, 0); 1172 1260 1173 1261 sprintf (buf, "%s%s%s", … … 1178 1266 ? "" : remote_description); 1179 1267 #ifndef KMK 1180 (void) define_variable ("MAKE_VERSION", 12, buf, o_default, 0);1268 define_variable_cname ("MAKE_VERSION", buf, o_default, 0); 1181 1269 #else /* KMK */ 1182 1270 1183 1271 /* Define KMK_VERSION to indicate kMk. */ 1184 (void) define_variable ("KMK_VERSION", 11, buf, o_default, 0);1272 define_variable_cname ("KMK_VERSION", buf, o_default, 0); 1185 1273 1186 1274 /* Define KBUILD_VERSION* */ 1187 1275 sprintf (buf, "%d", KBUILD_VERSION_MAJOR); 1188 define_variable ("KBUILD_VERSION_MAJOR", sizeof ("KBUILD_VERSION_MAJOR") - 1, 1189 buf, o_default, 0); 1276 define_variable_cname ("KBUILD_VERSION_MAJOR", buf, o_default, 0); 1190 1277 sprintf (buf, "%d", KBUILD_VERSION_MINOR); 1191 define_variable ("KBUILD_VERSION_MINOR", sizeof("KBUILD_VERSION_MINOR") - 1, 1192 buf, o_default, 0); 1278 define_variable_cname ("KBUILD_VERSION_MINOR", buf, o_default, 0); 1193 1279 sprintf (buf, "%d", KBUILD_VERSION_PATCH); 1194 define_variable ("KBUILD_VERSION_PATCH", sizeof ("KBUILD_VERSION_PATCH") - 1, 1195 buf, o_default, 0); 1280 define_variable_cname ("KBUILD_VERSION_PATCH", buf, o_default, 0); 1196 1281 sprintf (buf, "%d", KBUILD_SVN_REV); 1197 define_variable ("KBUILD_KMK_REVISION", sizeof ("KBUILD_KMK_REVISION") - 1, 1198 buf, o_default, 0); 1282 define_variable_cname ("KBUILD_KMK_REVISION", buf, o_default, 0); 1199 1283 1200 1284 sprintf (buf, "%d.%d.%d-r%d", KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, 1201 1285 KBUILD_VERSION_PATCH, KBUILD_SVN_REV); 1202 define_variable ("KBUILD_VERSION", sizeof ("KBUILD_VERSION") - 1, 1203 buf, o_default, 0); 1286 define_variable_cname ("KBUILD_VERSION", buf, o_default, 0); 1204 1287 1205 1288 /* The host defaults. The BUILD_* stuff will be replaced by KBUILD_* soon. */ … … 1210 1293 error (NULL, _("KBUILD_HOST and BUILD_PLATFORM differs, using KBUILD_HOST=%s."), val); 1211 1294 if (!envvar1) 1212 define_variable ("KBUILD_HOST", sizeof ("KBUILD_HOST") - 1, 1213 val, o_default, 0); 1295 define_variable_cname ("KBUILD_HOST", val, o_default, 0); 1214 1296 if (!envvar2) 1215 define_variable ("BUILD_PLATFORM", sizeof ("BUILD_PLATFORM") - 1, 1216 val, o_default, 0); 1297 define_variable_cname ("BUILD_PLATFORM", val, o_default, 0); 1217 1298 1218 1299 envvar1 = lookup_variable (STRING_SIZE_TUPLE ("KBUILD_HOST_ARCH")); … … 1222 1303 error (NULL, _("KBUILD_HOST_ARCH and BUILD_PLATFORM_ARCH differs, using KBUILD_HOST_ARCH=%s."), val); 1223 1304 if (!envvar1) 1224 define_variable ("KBUILD_HOST_ARCH", sizeof ("KBUILD_HOST_ARCH") - 1, 1225 val, o_default, 0); 1305 define_variable_cname ("KBUILD_HOST_ARCH", val, o_default, 0); 1226 1306 if (!envvar2) 1227 define_variable ("BUILD_PLATFORM_ARCH", sizeof ("BUILD_PLATFORM_ARCH") - 1, 1228 val, o_default, 0); 1307 define_variable_cname ("BUILD_PLATFORM_ARCH", val, o_default, 0); 1229 1308 1230 1309 envvar1 = lookup_variable (STRING_SIZE_TUPLE ("KBUILD_HOST_CPU")); … … 1234 1313 error (NULL, _("KBUILD_HOST_CPU and BUILD_PLATFORM_CPU differs, using KBUILD_HOST_CPU=%s."), val); 1235 1314 if (!envvar1) 1236 define_variable ("KBUILD_HOST_CPU", sizeof ("KBUILD_HOST_CPU") - 1, 1237 val, o_default, 0); 1315 define_variable_cname ("KBUILD_HOST_CPU", val, o_default, 0); 1238 1316 if (!envvar2) 1239 define_variable ("BUILD_PLATFORM_CPU", sizeof ("BUILD_PLATFORM_CPU") - 1, 1240 val, o_default, 0); 1317 define_variable_cname ("BUILD_PLATFORM_CPU", val, o_default, 0); 1241 1318 1242 1319 /* The host kernel version. */ … … 1277 1354 1278 1355 sprintf (buf, "%lu.%lu.%lu.%lu", ulMajor, ulMinor, ulPatch, ul4th); 1279 define_variable ("KBUILD_HOST_VERSION", sizeof ("KBUILD_HOST_VERSION") - 1, 1280 buf, o_default, 0); 1356 define_variable_cname ("KBUILD_HOST_VERSION", buf, o_default, 0); 1281 1357 1282 1358 sprintf (buf, "%lu", ulMajor); 1283 define_variable ("KBUILD_HOST_VERSION_MAJOR", sizeof ("KBUILD_HOST_VERSION_MAJOR") - 1, 1284 buf, o_default, 0); 1359 define_variable_cname ("KBUILD_HOST_VERSION_MAJOR", buf, o_default, 0); 1285 1360 1286 1361 sprintf (buf, "%lu", ulMinor); 1287 define_variable ("KBUILD_HOST_VERSION_MINOR", sizeof ("KBUILD_HOST_VERSION_MINOR") - 1, 1288 buf, o_default, 0); 1362 define_variable_cname ("KBUILD_HOST_VERSION_MINOR", buf, o_default, 0); 1289 1363 1290 1364 sprintf (buf, "%lu", ulPatch); 1291 define_variable ("KBUILD_HOST_VERSION_PATCH", sizeof ("KBUILD_HOST_VERSION_PATCH") - 1, 1292 buf, o_default, 0); 1365 define_variable_cname ("KBUILD_HOST_VERSION_PATCH", buf, o_default, 0); 1293 1366 1294 1367 /* The kBuild locations. */ 1295 define_variable ("KBUILD_PATH", sizeof ("KBUILD_PATH") - 1, 1296 get_kbuild_path (), o_default, 0); 1297 define_variable ("KBUILD_BIN_PATH", sizeof ("KBUILD_BIN_PATH") - 1, 1298 get_kbuild_bin_path (), o_default, 0); 1299 1300 define_variable ("PATH_KBUILD", sizeof ("PATH_KBUILD") - 1, 1301 get_kbuild_path (), o_default, 0); 1302 define_variable ("PATH_KBUILD_BIN", sizeof ("PATH_KBUILD_BIN") - 1, 1303 get_kbuild_bin_path (), o_default, 0); 1368 define_variable_cname ("KBUILD_PATH", get_kbuild_path (), o_default, 0); 1369 define_variable_cname ("KBUILD_BIN_PATH", get_kbuild_bin_path (), o_default, 0); 1370 1371 define_variable_cname ("PATH_KBUILD", get_kbuild_path (), o_default, 0); 1372 define_variable_cname ("PATH_KBUILD_BIN", get_kbuild_bin_path (), o_default, 0); 1304 1373 1305 1374 /* Define KMK_FEATURES to indicate various working KMK features. */ … … 1330 1399 && defined (CONFIG_WITH_DEFINED_FUNCTIONS) \ 1331 1400 && defined (KMK_HELPERS) 1332 (void) define_variable ("KMK_FEATURES", 12,1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1401 define_variable_cname ("KMK_FEATURES", 1402 "append-dash-n abspath includedep-queue install-hard-linking umask" 1403 " kBuild-define" 1404 " rsort" 1405 " abspathex" 1406 " toupper tolower" 1407 " defined" 1408 " comp-vars comp-cmds comp-cmds-ex" 1409 " stack" 1410 " math-int" 1411 " xargs" 1412 " explicit-multitarget" 1413 " dot-must-make" 1414 " prepend-assignment" 1415 " set-conditionals intersects" 1416 " date" 1417 " file-size" 1418 " expr if-expr select" 1419 " where" 1420 " which" 1421 " evalctx evalval evalvalctx evalcall evalcall2 eval-opt-var" 1422 " make-stats" 1423 " commands" 1424 " printf" 1425 " for while" 1426 " root" 1427 " length insert pos lastpos substr translate" 1428 " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl" 1429 " firstdefined lastdefined" 1430 , o_default, 0); 1362 1431 # else /* MSC can't deal with strings mixed with #if/#endif, thus the slow way. */ 1363 1432 # error "All features should be enabled by default!" … … 1442 1511 strcat (buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl"); 1443 1512 # endif 1444 (void) define_variable ("KMK_FEATURES", 12, buf, o_default, 0);1513 define_variable_cname ("KMK_FEATURES", buf, o_default, 0); 1445 1514 # endif 1446 1515 … … 1449 1518 #ifdef CONFIG_WITH_KMK_BUILTIN 1450 1519 /* The supported kMk Builtin commands. */ 1451 (void) define_variable ("KMK_BUILTIN", 11, "append cat chmod cp cmp echo expr install kDepIDB ln md5sum mkdir mv printf rm rmdir sleep test", o_default, 0);1520 define_variable_cname ("KMK_BUILTIN", "append cat chmod cp cmp echo expr install kDepIDB ln md5sum mkdir mv printf rm rmdir sleep test", o_default, 0); 1452 1521 #endif 1453 1522 … … 1461 1530 struct variable *comp = lookup_variable ("COMSPEC", 7); 1462 1531 1463 /* Make $MAKESHELL override $SHELLeven if -e is in effect. */1532 /* $(MAKESHELL) overrides $(SHELL) even if -e is in effect. */ 1464 1533 if (mshp) 1465 1534 (void) define_variable (shell_str, shlen, … … 1467 1536 else if (comp) 1468 1537 { 1469 /* $ COMSPEC shouldn't override $SHELL. */1538 /* $(COMSPEC) shouldn't override $(SHELL). */ 1470 1539 struct variable *shp = lookup_variable (shell_str, shlen); 1471 1540 … … 1526 1595 /* This won't override any definition, but it will provide one if there 1527 1596 isn't one there. */ 1528 v = define_variable ("SHELL", 5, default_shell, o_default, 0);1597 v = define_variable_cname ("SHELL", default_shell, o_default, 0); 1529 1598 #ifdef __MSDOS__ 1530 1599 v->export = v_export; /* Export always SHELL. */ … … 1555 1624 1556 1625 /* Make sure MAKEFILES gets exported if it is set. */ 1557 v = define_variable ("MAKEFILES", 9, "", o_default, 0);1626 v = define_variable_cname ("MAKEFILES", "", o_default, 0); 1558 1627 v->export = v_ifset; 1559 1628 … … 1562 1631 1563 1632 #ifdef VMS 1564 define_variable ("@D", 2, "$(dir $@)", o_automatic, 1);1565 define_variable ("%D", 2, "$(dir $%)", o_automatic, 1);1566 define_variable ("*D", 2, "$(dir $*)", o_automatic, 1);1567 define_variable ("<D", 2, "$(dir $<)", o_automatic, 1);1568 define_variable ("?D", 2, "$(dir $?)", o_automatic, 1);1569 define_variable ("^D", 2, "$(dir $^)", o_automatic, 1);1570 define_variable ("+D", 2, "$(dir $+)", o_automatic, 1);1633 define_variable_cname ("@D", "$(dir $@)", o_automatic, 1); 1634 define_variable_cname ("%D", "$(dir $%)", o_automatic, 1); 1635 define_variable_cname ("*D", "$(dir $*)", o_automatic, 1); 1636 define_variable_cname ("<D", "$(dir $<)", o_automatic, 1); 1637 define_variable_cname ("?D", "$(dir $?)", o_automatic, 1); 1638 define_variable_cname ("^D", "$(dir $^)", o_automatic, 1); 1639 define_variable_cname ("+D", "$(dir $+)", o_automatic, 1); 1571 1640 #else 1572 define_variable ("@D", 2, "$(patsubst %/,%,$(dir $@))", o_automatic, 1);1573 define_variable ("%D", 2, "$(patsubst %/,%,$(dir $%))", o_automatic, 1);1574 define_variable ("*D", 2, "$(patsubst %/,%,$(dir $*))", o_automatic, 1);1575 define_variable ("<D", 2, "$(patsubst %/,%,$(dir $<))", o_automatic, 1);1576 define_variable ("?D", 2, "$(patsubst %/,%,$(dir $?))", o_automatic, 1);1577 define_variable ("^D", 2, "$(patsubst %/,%,$(dir $^))", o_automatic, 1);1578 define_variable ("+D", 2, "$(patsubst %/,%,$(dir $+))", o_automatic, 1);1579 #endif 1580 define_variable ("@F", 2, "$(notdir $@)", o_automatic, 1);1581 define_variable ("%F", 2, "$(notdir $%)", o_automatic, 1);1582 define_variable ("*F", 2, "$(notdir $*)", o_automatic, 1);1583 define_variable ("<F", 2, "$(notdir $<)", o_automatic, 1);1584 define_variable ("?F", 2, "$(notdir $?)", o_automatic, 1);1585 define_variable ("^F", 2, "$(notdir $^)", o_automatic, 1);1586 define_variable ("+F", 2, "$(notdir $+)", o_automatic, 1);1641 define_variable_cname ("@D", "$(patsubst %/,%,$(dir $@))", o_automatic, 1); 1642 define_variable_cname ("%D", "$(patsubst %/,%,$(dir $%))", o_automatic, 1); 1643 define_variable_cname ("*D", "$(patsubst %/,%,$(dir $*))", o_automatic, 1); 1644 define_variable_cname ("<D", "$(patsubst %/,%,$(dir $<))", o_automatic, 1); 1645 define_variable_cname ("?D", "$(patsubst %/,%,$(dir $?))", o_automatic, 1); 1646 define_variable_cname ("^D", "$(patsubst %/,%,$(dir $^))", o_automatic, 1); 1647 define_variable_cname ("+D", "$(patsubst %/,%,$(dir $+))", o_automatic, 1); 1648 #endif 1649 define_variable_cname ("@F", "$(notdir $@)", o_automatic, 1); 1650 define_variable_cname ("%F", "$(notdir $%)", o_automatic, 1); 1651 define_variable_cname ("*F", "$(notdir $*)", o_automatic, 1); 1652 define_variable_cname ("<F", "$(notdir $<)", o_automatic, 1); 1653 define_variable_cname ("?F", "$(notdir $?)", o_automatic, 1); 1654 define_variable_cname ("^F", "$(notdir $^)", o_automatic, 1); 1655 define_variable_cname ("+F", "$(notdir $+)", o_automatic, 1); 1587 1656 #ifdef CONFIG_WITH_LAZY_DEPS_VARS 1588 1657 define_variable ("^", 1, "$(deps $@)", o_automatic, 1); … … 1753 1822 convert_Path_to_windows32(value, ';'); 1754 1823 #endif 1755 *result++ = xstrdup (concat ( v->name, "=", value));1824 *result++ = xstrdup (concat (3, v->name, "=", value)); 1756 1825 free (value); 1757 1826 } … … 1763 1832 convert_Path_to_windows32(v->value, ';'); 1764 1833 #endif 1765 *result++ = xstrdup (concat ( v->name, "=", v->value));1834 *result++ = xstrdup (concat (3, v->name, "=", v->value)); 1766 1835 } 1767 1836 } … … 1954 2023 value_len = strlen (value); 1955 2024 if (!free_value) 1956 p = alloc_value = savestring(value, value_len);2025 p = alloc_value = xstrndup (value, value_len); 1957 2026 else 1958 2027 { … … 2048 2117 unsigned int oldlen, vallen; 2049 2118 const char *val; 2050 char *tp ;2119 char *tp = NULL; 2051 2120 2052 2121 val = value; … … 2061 2130 memory for the expansion as we may still need the rest of the 2062 2131 buffer if we're looking at a target-specific variable. */ 2063 val = alloc_value= allocated_variable_expand (val);2132 val = tp = allocated_variable_expand (val); 2064 2133 2065 2134 oldlen = strlen (v->value); 2066 2135 vallen = strlen (val); 2067 tp = alloca(oldlen + 1 + vallen + 1);2136 p = alloc_value = xmalloc (oldlen + 1 + vallen + 1); 2068 2137 # ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 2069 2138 if (org_flavor == f_prepend) 2070 2139 { 2071 memcpy ( tp, val, vallen);2072 tp[oldlen] = ' ';2073 memcpy (& tp[oldlen + 1], v->value, oldlen + 1);2140 memcpy (alloc_value, val, vallen); 2141 alloc_value[oldlen] = ' '; 2142 memcpy (&alloc_value[oldlen + 1], v->value, oldlen + 1); 2074 2143 } 2075 2144 else 2076 2145 # endif /* CONFIG_WITH_PREPEND_ASSIGNMENT */ 2077 2146 { 2078 memcpy ( tp, v->value, oldlen);2079 tp[oldlen] = ' ';2080 memcpy (& tp[oldlen + 1], val, vallen + 1);2147 memcpy (alloc_value, v->value, oldlen); 2148 alloc_value[oldlen] = ' '; 2149 memcpy (&alloc_value[oldlen + 1], val, vallen + 1); 2081 2150 } 2082 p = tp; 2151 2152 if (tp) 2153 free (tp); 2083 2154 #endif /* !CONFIG_WITH_VALUE_LENGTH */ 2084 2155 } … … 2193 2264 else 2194 2265 { 2195 if (alloc_value) 2196 free (alloc_value); 2266 char *tp = alloc_value; 2197 2267 2198 2268 alloc_value = allocated_variable_expand (p); 2269 2199 2270 if (find_and_set_default_shell (alloc_value)) 2200 2271 { … … 2212 2283 else 2213 2284 v = lookup_variable (varname, varname_len); 2285 2286 if (tp) 2287 free (tp); 2214 2288 } 2215 2289 } … … 2250 2324 2251 2325 2252 /* Try to interpret LINE (a null-terminated string) as a variable definition. 2253 2254 ORIGIN may be o_file, o_override, o_env, o_env_override, 2255 or o_command specifying that the variable definition comes 2256 from a makefile, an override directive, the environment with 2257 or without the -e switch, or the command line. 2258 2259 See the comments for parse_variable_definition(). 2260 2261 If LINE was recognized as a variable definition, a pointer to its `struct 2262 variable' is returned. If LINE is not a variable definition, NULL is 2263 returned. */ 2264 2265 struct variable * 2266 #ifndef CONFIG_WITH_VALUE_LENGTH 2267 parse_variable_definition (struct variable *v, char *line) 2268 #else 2269 parse_variable_definition (struct variable *v, char *line, char *eos) 2270 #endif 2271 { 2272 register int c; 2273 register char *p = line; 2274 register char *beg; 2275 register char *end; 2276 enum variable_flavor flavor = f_bogus; 2277 #ifndef CONFIG_WITH_VALUE_LENGTH 2278 char *name; 2279 #endif 2326 /* Parse P (a null-terminated string) as a variable definition. 2327 2328 If it is not a variable definition, return NULL. 2329 2330 If it is a variable definition, return a pointer to the char after the 2331 assignment token and set *FLAVOR to the type of variable assignment. */ 2332 2333 char * 2334 parse_variable_definition (const char *p, enum variable_flavor *flavor) 2335 { 2336 int wspace = 0; 2337 2338 p = next_token (p); 2280 2339 2281 2340 while (1) 2282 2341 { 2283 c = *p++; 2342 int c = *p++; 2343 2344 /* If we find a comment or EOS, it's not a variable definition. */ 2284 2345 if (c == '\0' || c == '#') 2285 return 0; 2286 if (c == '=') 2346 return NULL; 2347 2348 if (c == '$') 2287 2349 { 2288 end = p - 1; 2289 flavor = f_recursive; 2290 break; 2291 } 2292 else if (c == ':') 2293 if (*p == '=') 2294 { 2295 end = p++ - 1; 2296 flavor = f_simple; 2297 break; 2298 } 2299 else 2300 /* A colon other than := is a rule line, not a variable defn. */ 2301 return 0; 2302 else if (c == '+' && *p == '=') 2303 { 2304 end = p++ - 1; 2305 flavor = f_append; 2306 break; 2307 } 2308 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 2309 else if (c == '<' && *p == '=') 2310 { 2311 end = p++ - 1; 2312 flavor = f_prepend; 2313 break; 2314 } 2315 #endif 2316 else if (c == '?' && *p == '=') 2317 { 2318 end = p++ - 1; 2319 flavor = f_conditional; 2320 break; 2321 } 2322 else if (c == '$') 2323 { 2324 /* This might begin a variable expansion reference. Make sure we 2325 don't misrecognize chars inside the reference as =, := or +=. */ 2350 /* This begins a variable expansion reference. Make sure we don't 2351 treat chars inside the reference as assignment tokens. */ 2326 2352 char closeparen; 2327 2353 int count; … … 2332 2358 closeparen = '}'; 2333 2359 else 2334 continue; /* Nope. */ 2360 /* '$$' or '$X'. Either way, nothing special to do here. */ 2361 continue; 2335 2362 2336 2363 /* P now points past the opening paren or brace. … … 2347 2374 } 2348 2375 } 2376 continue; 2349 2377 } 2350 } 2351 v->flavor = flavor; 2378 2379 /* If we find whitespace skip it, and remember we found it. */ 2380 if (isblank ((unsigned char)c)) 2381 { 2382 wspace = 1; 2383 p = next_token (p); 2384 c = *p; 2385 if (c == '\0') 2386 return NULL; 2387 ++p; 2388 } 2389 2390 2391 if (c == '=') 2392 { 2393 *flavor = f_recursive; 2394 return (char *)p; 2395 } 2396 2397 /* Match assignment variants (:=, +=, ?=) */ 2398 if (*p == '=') 2399 { 2400 switch (c) 2401 { 2402 case ':': 2403 *flavor = f_simple; 2404 break; 2405 case '+': 2406 *flavor = f_append; 2407 break; 2408 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 2409 case '<': 2410 *flavor = f_prepend; 2411 break; 2412 #endif 2413 case '?': 2414 *flavor = f_conditional; 2415 break; 2416 default: 2417 /* If we skipped whitespace, non-assignments means no var. */ 2418 if (wspace) 2419 return NULL; 2420 2421 /* Might be assignment, or might be $= or #=. Check. */ 2422 continue; 2423 } 2424 return (char *)++p; 2425 } 2426 else if (c == ':') 2427 /* A colon other than := is a rule line, not a variable defn. */ 2428 return NULL; 2429 2430 /* If we skipped whitespace, non-assignments means no var. */ 2431 if (wspace) 2432 return NULL; 2433 } 2434 2435 return (char *)p; 2436 } 2437 2438 2439 /* Try to interpret LINE (a null-terminated string) as a variable definition. 2440 2441 If LINE was recognized as a variable definition, a pointer to its `struct 2442 variable' is returned. If LINE is not a variable definition, NULL is 2443 returned. */ 2444 2445 struct variable * 2446 assign_variable_definition (struct variable *v, char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos)) 2447 { 2448 char *beg; 2449 char *end; 2450 enum variable_flavor flavor; 2451 #ifndef CONFIG_WITH_VALUE_LENGTH 2452 char *name; 2453 #endif 2352 2454 2353 2455 beg = next_token (line); 2456 line = parse_variable_definition (beg, &flavor); 2457 if (!line) 2458 return NULL; 2459 2460 end = line - (flavor == f_recursive ? 1 : 2); 2354 2461 while (end > beg && isblank ((unsigned char)end[-1])) 2355 2462 --end; 2356 p = next_token (p); 2357 v->value = p; 2463 line = next_token (line); 2464 v->value = line; 2465 v->flavor = flavor; 2358 2466 #ifdef CONFIG_WITH_VALUE_LENGTH 2359 2467 v->value_alloc_len = ~(unsigned int)0; 2360 v->value_length = eos != NULL ? eos - p: -1;2361 assert (eos == NULL || strchr ( p, '\0') == eos);2468 v->value_length = eos != NULL ? eos - line : -1; 2469 assert (eos == NULL || strchr (line, '\0') == eos); 2362 2470 # ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE 2363 2471 v->rdonly_val = 0; … … 2389 2497 or without the -e switch, or the command line. 2390 2498 2391 See the comments for parse_variable_definition().2499 See the comments for assign_variable_definition(). 2392 2500 2393 2501 If LINE was recognized as a variable definition, a pointer to its `struct … … 2396 2504 2397 2505 struct variable * 2398 #ifndef CONFIG_WITH_VALUE_LENGTH 2399 try_variable_definition (const struct floc *flocp, char *line,2506 try_variable_definition (const struct floc *flocp, char *line 2507 IF_WITH_VALUE_LENGTH_PARAM(char *eos), 2400 2508 enum variable_origin origin, int target_var) 2401 #else2402 try_variable_definition (const struct floc *flocp, char *line, char *eos,2403 enum variable_origin origin, int target_var)2404 #endif2405 2509 { 2406 2510 struct variable v; … … 2413 2517 2414 2518 #ifndef CONFIG_WITH_VALUE_LENGTH 2415 if (! parse_variable_definition (&v, line))2519 if (!assign_variable_definition (&v, line)) 2416 2520 return 0; 2417 2521 … … 2419 2523 origin, v.flavor, target_var); 2420 2524 #else 2421 if (! parse_variable_definition (&v, line, eos))2525 if (!assign_variable_definition (&v, line, eos)) 2422 2526 return 0; 2423 2527 … … 2486 2590 fputs ("# ", stdout); 2487 2591 fputs (origin, stdout); 2592 if (v->private_var) 2593 fputs (" private", stdout); 2488 2594 if (v->fileinfo.filenm) 2489 2595 printf (_(" (from `%s', line %lu)"), … … 2514 2620 else 2515 2621 { 2516 registerchar *p;2622 char *p; 2517 2623 2518 2624 printf ("%s %s= ", v->name, v->recursive ? v->append ? "+" : "" : ":"); … … 2660 2766 */ 2661 2767 convert_Path_to_windows32 (path, ';'); 2662 environ_path = xstrdup (concat ( "PATH", "=", path));2768 environ_path = xstrdup (concat (3, "PATH", "=", path)); 2663 2769 putenv (environ_path); 2664 2770 free (path); -
trunk/src/kmk/variable.h
r2005 r2591 82 82 exported. */ 83 83 unsigned int expanding:1; /* Nonzero if currently being expanded. */ 84 unsigned int private_var:1; /* Nonzero avoids inheritance of this 85 target-specific variable. */ 84 86 unsigned int exp_count:EXP_COUNT_BITS; 85 87 /* If >1, allow this many self-referential … … 122 124 struct variable_set_list *next; /* Link in the chain. */ 123 125 struct variable_set *set; /* Variable set. */ 126 int next_is_parent; /* True if next is a parent target. */ 124 127 }; 125 128 … … 137 140 extern char *variable_buffer; 138 141 extern struct variable_set_list *current_variable_set_list; 142 extern struct variable *default_goal_var; 143 139 144 #ifdef KMK 140 145 extern unsigned int variable_buffer_length; 141 # define VARIABLE_BUFFER_ZONE5146 # define VARIABLE_BUFFER_ZONE 5 142 147 #endif 143 148 144 149 /* expand.c */ 145 150 #ifndef KMK 146 char *variable_buffer_output (char *ptr, const char *string, unsigned int length); 151 char * 152 variable_buffer_output (char *ptr, const char *string, unsigned int length); 147 153 #else /* KMK */ 148 154 /* Subroutine of variable_expand and friends: … … 209 215 char *expand_argument (const char *str, const char *end); 210 216 #ifndef CONFIG_WITH_VALUE_LENGTH 211 char *variable_expand_string (char *line, const char *string, long length); 217 char * 218 variable_expand_string (char *line, const char *string, long length); 212 219 #else /* CONFIG_WITH_VALUE_LENGTH */ 213 char *variable_expand_string_2 (char *line, const char *string, long length, char **eol); 220 char * 221 variable_expand_string_2 (char *line, const char *string, long length, char **eol); 214 222 __inline static char * 215 223 variable_expand_string (char *line, const char *string, long length) … … 314 322 enum variable_flavor flavor, 315 323 int target_var); 316 struct variable *parse_variable_definition (struct variable *v, char *line);317 struct variable *try_variable_definition (const struct floc *flocp, char *line,318 enum variable_origin origin,319 int target_var);320 324 #else /* CONFIG_WITH_VALUE_LENGTH */ 321 325 # define do_variable_definition(flocp, varname, value, origin, flavor, target_var) \ 322 326 do_variable_definition_2 ((flocp), (varname), (value), ~0U, 0, NULL, \ 323 327 (origin), (flavor), (target_var)) 324 325 328 struct variable *do_variable_definition_2 (const struct floc *flocp, 326 329 const char *varname, … … 331 334 enum variable_flavor flavor, 332 335 int target_var); 333 struct variable *parse_variable_definition (struct variable *v, char *line, 334 char *eos); 335 struct variable *try_variable_definition (const struct floc *flocp, char *line, 336 char *eos, 336 #endif /* CONFIG_WITH_VALUE_LENGTH */ 337 char *parse_variable_definition (const char *line, 338 enum variable_flavor *flavor); 339 struct variable *assign_variable_definition (struct variable *v, char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos)); 340 struct variable *try_variable_definition (const struct floc *flocp, char *line 341 IF_WITH_VALUE_LENGTH_PARAM(char *eos), 337 342 enum variable_origin origin, 338 343 int target_var); 339 #endif /* CONFIG_WITH_VALUE_LENGTH */340 344 void init_hash_global_variable_set (void); 341 345 void hash_init_function_table (void); … … 367 371 current_variable_set_list->set,NILF) 368 372 373 /* Define a variable with a constant name in the current variable set. */ 374 375 #define define_variable_cname(n,v,o,r) \ 376 define_variable_in_set((n),(sizeof (n) - 1),(v),~0U,1,(o),(r),\ 377 current_variable_set_list->set,NILF) 378 369 379 /* Define a variable with a location in the current variable set. */ 370 380 … … 401 411 current_variable_set_list->set,NILF) /* force merge conflict */ 402 412 413 /* Define a variable with a constant name in the current variable set. */ 414 415 #define define_variable_cname(n,v,o,r) \ 416 define_variable_in_set((n),(sizeof (n) - 1),(v),(o),(r),\ 417 current_variable_set_list->set,NILF) /* force merge conflict */ 418 403 419 /* Define a variable with a location in the current variable set. */ 404 420 … … 418 434 419 435 #endif /* !CONFIG_WITH_VALUE_LENGTH */ 436 437 void undefine_variable_in_set (const char *name, unsigned int length, 438 enum variable_origin origin, 439 struct variable_set *set); 440 441 /* Remove variable from the current variable set. */ 442 443 #define undefine_variable_global(n,l,o) \ 444 undefine_variable_in_set((n),(l),(o),NULL) 420 445 421 446 /* Warn that NAME is an undefined variable. */ … … 444 469 #endif 445 470 #define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1) 471 -
trunk/src/kmk/version.c
r1993 r2591 1 1 /* Record version and build host architecture for GNU make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 -
trunk/src/kmk/vmsdir.h
r1993 r2591 1 1 /* dirent.h for vms 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 3 2007 Free Software Foundation, Inc.3 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/vmsfunctions.c
r1993 r2591 1 1 /* VMS functions 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 3 2007 Free Software Foundation, Inc.3 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 … … 35 35 opendir (char *dspec) 36 36 { 37 struct DIR *dir = (struct DIR *)xmalloc (sizeof (struct DIR));38 struct NAM *dnam = (struct NAM *)xmalloc (sizeof (struct NAM));37 struct DIR *dir = xcalloc (sizeof (struct DIR)); 38 struct NAM *dnam = xmalloc (sizeof (struct NAM)); 39 39 struct FAB *dfab = &dir->fab; 40 40 char *searchspec = xmalloc (MAXNAMLEN + 1); 41 42 memset (dir, 0, sizeof *dir);43 41 44 42 *dfab = cc$rms_fab; … … 92 90 if (!((i = sys$search (dfab)) & 1)) 93 91 { 94 DB (DB_VERBOSE, (_("sys$search failed with %d\n"), i));92 DB (DB_VERBOSE, (_("sys$search() failed with %d\n"), i)); 95 93 return (NULL); 96 94 } … … 142 140 } 143 141 142 #if 0 143 /* 144 * Is this used? I don't see any reference, so I suggest to remove it. 145 */ 144 146 int 145 147 vms_stat (char *name, struct stat *buf) … … 238 240 return 0; 239 241 } 242 #endif 240 243 241 244 char * -
trunk/src/kmk/vmsify.c
r1993 r2591 1 1 /* vmsify.c -- Module for vms <-> unix file name conversion 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 3 2007 Free Software Foundation, Inc.3 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 … … 121 121 char *s; 122 122 123 INIT_DSC_CSTRING (name_dsc, name); 123 /* 124 * the string isn't changed, but there is no string descriptor with 125 * "const char *dsc$a_pointer" 126 */ 127 INIT_DSC_CSTRING (name_dsc, (char *)name); 124 128 125 129 stat = lib$sys_trnlog (&name_dsc, &resltlen, &reslt_dsc); … … 228 232 int as_dir; 229 233 int count; 234 const char *s; 235 const char *s1; 236 const char *s2; 230 237 231 238 if (name == 0) … … 240 247 if (t != 0) 241 248 { 242 const char *s1;243 const char *s2;249 // const char *s1; 250 // const char *s2; 244 251 245 252 if (type == 1) … … 273 280 if (t != 0) 274 281 { 275 const char *s; 276 const char *s1 = strchr (t+1, '['); 282 // const char *s; 283 // const char *s1 = strchr (t+1, '['); 284 s1 = strchr (t+1, '['); 277 285 if (s1 == 0) 278 286 { … … 389 397 case 3: /* '//' at start */ 390 398 { 391 const char *s;392 const char *s1;399 // const char *s; 400 // const char *s1; 393 401 char *vp; 394 402 while (*fptr == '/') /* collapse all '/' */ -
trunk/src/kmk/vmsjobs.c
- Property svn:keywords deleted
r1993 r2591 3 3 4 4 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 5 2007 Free Software Foundation, Inc.5 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 6 6 This file is part of GNU Make. 7 7 … … 111 111 } 112 112 113 /* This is called as an AST when a child process dies (it won't get 114 interrupted by anything except a higher level AST). 113 static int ctrlYPressed= 0; 114 /* This is called at main or AST level. It is at AST level for DONTWAITFORCHILD 115 and at main level otherwise. In any case it is called when a child process 116 terminated. At AST level it won't get interrupted by anything except a 117 inner mode level AST. 115 118 */ 116 119 int … … 124 127 125 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 } 126 135 127 136 (void) sigblock (fatal_signal_mask); … … 220 229 static int oldCtrlMask; 221 230 static int setupYAstTried= 0; 222 static int pidToAbort= 0; 223 static int chan= 0; 231 static unsigned short int chan= 0; 224 232 225 233 static void … … 229 237 } 230 238 231 static void232 ast Handler (void)239 static int 240 astYHandler (void) 233 241 { 234 if (pidToAbort) {235 sys$forcex (&pidToAbort, 0, SS$_ABORT);236 pidToAbort= 0;237 }242 struct child *c; 243 for (c = children; c != 0; c = c->next) 244 sys$delprc (&c->pid, 0, 0); 245 ctrlYPressed= 1; 238 246 kill (getpid(),SIGQUIT); 247 return SS$_NORMAL; 239 248 } 240 249 … … 248 257 int dvi; 249 258 } iosb; 259 unsigned short int loc_chan; 250 260 251 261 setupYAstTried++; 252 262 253 if (!chan) { 254 status= sys$assign(&inputDsc,&chan,0,0); 263 if (chan) 264 loc_chan= chan; 265 else { 266 status= sys$assign(&inputDsc,&loc_chan,0,0); 255 267 if (!(status&SS$_NORMAL)) { 256 268 lib$signal(status); … … 258 270 } 259 271 } 260 status= sys$qiow (0, chan, IO$_SETMODE|IO$M_CTRLYAST,&iosb,0,0, 261 astHandler,0,0,0,0,0); 262 if (status==SS$_NORMAL) 263 status= iosb.status; 264 if (status==SS$_ILLIOFUNC || status==SS$_NOPRIV) { 265 sys$dassgn(chan); 266 #ifdef CTRLY_ENABLED_ANYWAY 267 fprintf (stderr, 268 _("-warning, CTRL-Y will leave sub-process(es) around.\n")); 269 #else 270 return; 271 #endif 272 } 273 else if (!(status&SS$_NORMAL)) { 274 sys$dassgn(chan); 275 lib$signal(status); 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); 276 281 return; 277 282 } … … 288 293 return; 289 294 } 295 if (!chan) 296 chan = loc_chan; 290 297 } 291 298 … … 300 307 static struct dsc$descriptor_s efiledsc; 301 308 int have_redirection = 0; 309 int have_append = 0; 302 310 int have_newline = 0; 303 311 … … 306 314 char *cmd = alloca (strlen (argv) + 512), *p, *q; 307 315 char ifile[256], ofile[256], efile[256]; 308 char *comname = 0;316 int comnamelen; 309 317 char procname[100]; 310 318 int in_string; … … 315 323 ofile[0] = 0; 316 324 efile[0] = 0; 325 child->comname = NULL; 317 326 318 327 DB (DB_JOBS, ("child_execute_job (%s)\n", argv)); … … 384 393 else 385 394 { 395 if (*(p+1) == '>') 396 { 397 have_append = 1; 398 p += 1; 399 } 386 400 p = vms_redirect (&ofiledsc, ofile, p); 387 401 } … … 482 496 } 483 497 484 outfile = open_tmpfile (&c omname, "sys$scratch:CMDXXXXXX.COM");498 outfile = open_tmpfile (&child->comname, "sys$scratch:CMDXXXXXX.COM"); 485 499 if (outfile == 0) 486 500 pfatal_with_name (_("fopen (temporary file)")); 501 comnamelen = strlen (child->comname); 487 502 488 503 if (ifile[0]) … … 502 517 if (ofile[0]) 503 518 { 504 fprintf (outfile, "$ define sys$output %s\n", ofile); 505 DB (DB_JOBS, (_("Redirected output to %s\n"), ofile)); 506 ofiledsc.dsc$w_length = 0; 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 } 507 532 } 508 533 … … 559 584 } 560 585 561 fwrite (p, 1, q - p, outfile); 586 if (*p) 587 { 588 fwrite (p, 1, --q - p, outfile); 562 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 } 563 601 564 602 fclose (outfile); 565 603 566 sprintf (cmd, "$ @%s", c omname);604 sprintf (cmd, "$ @%s", child->comname); 567 605 568 606 DB (DB_JOBS, (_("Executing %s instead\n"), cmd)); … … 579 617 status = lib$get_ef ((unsigned long *)&child->efn); 580 618 if (!(status & 1)) 581 return 0; 619 { 620 if (child->comname) 621 { 622 if (!ISDB (DB_JOBS)) 623 unlink (child->comname); 624 free (child->comname); 625 } 626 return 0; 627 } 582 628 } 583 629 … … 648 694 if (status & 1) 649 695 { 650 pidToAbort= child->pid;651 696 status= sys$waitfr (child->efn); 652 pidToAbort= 0;653 697 vmsHandleChildTerm(child); 654 698 } … … 678 722 } 679 723 680 if (comname && !ISDB (DB_JOBS))681 unlink (comname);682 683 724 return (status & 1); 684 725 } -
trunk/src/kmk/vpath.c
r1993 r2591 1 1 /* Implementation of pattern-matching file search paths for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 150 150 151 151 152 /* Construct the VPATH listing for the pattern and searchpathgiven.152 /* Construct the VPATH listing for the PATTERN and DIRPATH given. 153 153 154 154 This function is called to generate selective VPATH lists and also for … … 158 158 variable. 159 159 160 If SEARCHPATH is nil, remove all previous listings with the same160 If DIRPATH is nil, remove all previous listings with the same 161 161 pattern. If PATTERN is nil, remove all VPATH listings. Existing 162 and readable directories that are not "." given in the searchpath162 and readable directories that are not "." given in the DIRPATH 163 163 separated by the path element separator (defined in make.h) are 164 164 loaded into the directory hash table if they are not there already … … 205 205 206 206 /* Free its unused storage. */ 207 free (path->searchpath); 207 /* MSVC erroneously warns without a cast here. */ 208 free ((void *)path->searchpath); 208 209 free (path); 209 210 } … … 310 311 else 311 312 /* There were no entries, so free whatever space we allocated. */ 312 free (vpath); 313 /* MSVC erroneously warns without a cast here. */ 314 free ((void *)vpath); 313 315 } 314 316 … … 335 337 FILE exists. If it is found, we return a cached name of the existing file 336 338 and set *MTIME_PTR (if MTIME_PTR is not NULL) to its modtime (or zero if no 337 stat call was done). Otherwise we return NULL. */ 339 stat call was done). Also set the matching directory index in PATH_INDEX 340 if it is not NULL. Otherwise we return NULL. */ 338 341 339 342 static const char * 340 343 selective_vpath_search (struct vpath *path, const char *file, 341 FILE_TIMESTAMP *mtime_ptr )344 FILE_TIMESTAMP *mtime_ptr, unsigned int* path_index) 342 345 { 343 346 int not_target; … … 519 522 /* Store the name we found and return it. */ 520 523 524 if (path_index) 525 *path_index = i; 526 521 527 return strcache_add_len (name, (p + 1 - name) + flen); 522 528 } … … 530 536 exists. If it is found, return the cached name of an existing file, and 531 537 set *MTIME_PTR (if MTIME_PTR is not NULL) to its modtime (or zero if no 532 stat call was done). Otherwise we return 0. */ 538 stat call was done). Also set the matching directory index in VPATH_INDEX 539 and PATH_INDEX if they are not NULL. Otherwise we return 0. */ 533 540 534 541 const char * 535 vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr) 542 vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr, 543 unsigned int* vpath_index, unsigned int* path_index) 536 544 { 537 545 struct vpath *v; … … 547 555 return 0; 548 556 557 if (vpath_index) 558 { 559 *vpath_index = 0; 560 *path_index = 0; 561 } 562 549 563 for (v = vpaths; v != 0; v = v->next) 550 if (pattern_matches (v->pattern, v->percent, file)) 551 { 552 const char *p = selective_vpath_search (v, file, mtime_ptr); 553 if (p) 554 return p; 555 } 564 { 565 if (pattern_matches (v->pattern, v->percent, file)) 566 { 567 const char *p = selective_vpath_search ( 568 v, file, mtime_ptr, path_index); 569 if (p) 570 return p; 571 } 572 573 if (vpath_index) 574 ++*vpath_index; 575 } 576 556 577 557 578 if (general_vpath != 0) 558 579 { 559 const char *p = selective_vpath_search (general_vpath, file, mtime_ptr); 580 const char *p = selective_vpath_search ( 581 general_vpath, file, mtime_ptr, path_index); 560 582 if (p) 561 583 return p; … … 564 586 return 0; 565 587 } 588 589 590 566 591 567 592 -
trunk/src/kmk/w32
- Property svn:ignore
-
old new 1 1 Makefile 2 2 Makefile.in 3 .deps
-
- Property svn:ignore
-
trunk/src/kmk/w32/Makefile.am
- Property svn:keywords deleted
r1993 r2591 1 1 # Makefile.am to create libw32.a for mingw32 host. 2 2 # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 3 # 2007 Free Software Foundation, Inc.3 # 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 # This file is part of GNU Make. 5 5 # -
trunk/src/kmk/w32/compat/dirent.c
r1993 r2591 1 1 /* Directory entry code for Window platforms. 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 3 2006, 2007 Free Software Foundation, Inc.3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 … … 17 17 18 18 19 #ifdef KMK 20 # include "config.h" /* my_stat */ 21 #endif 19 #include <config.h> 22 20 #include <sys/types.h> 23 21 #include <sys/stat.h> … … 142 140 143 141 /* fill in struct dirent values */ 144 pDir->dir_sdReturn.d_ino = -1;142 pDir->dir_sdReturn.d_ino = (ino_t)-1; 145 143 strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName); 146 144 -
trunk/src/kmk/w32/include/dirent.h
r1993 r2591 1 1 /* Windows version of dirent.h 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 3 2007 Free Software Foundation, Inc.3 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/w32/include/pathstuff.h
r1993 r2591 1 1 /* Definitions for Windows path manipulation. 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 3 2007 Free Software Foundation, Inc.3 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/w32/include/sub_proc.h
r1993 r2591 1 1 /* Definitions for Windows process invocation. 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 3 2006, 2007 Free Software Foundation, Inc.3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 … … 22 22 * Component Name: 23 23 * 24 * $Date: 20 07/10/24 20:06:32$24 * $Date: 2010/07/13 01:20:43 $ 25 25 * 26 26 * $Source: /sources/make/make/w32/include/sub_proc.h,v $ 27 27 * 28 * $Id: sub_proc.h,v 1.1 0 2007/10/24 20:06:32 elizExp $28 * $Id: sub_proc.h,v 1.12 2010/07/13 01:20:43 psmith Exp $ 29 29 */ 30 30 -
trunk/src/kmk/w32/include/w32err.h
r1993 r2591 1 1 /* Definitions for Windows error handling. 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 3 2006, 2007 Free Software Foundation, Inc.3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/w32/pathstuff.c
r2454 r2591 1 1 /* Path conversion for Windows pathnames. 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 3 2007, 200 9Free Software Foundation, Inc.3 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 … … 17 17 18 18 #include <Windows.h> /* bird */ 19 #include <stdio.h> /* bird */19 #include "make.h" 20 20 #include <string.h> 21 21 #include <stdlib.h> 22 #include "make.h"23 22 #include "pathstuff.h" 24 23 … … 83 82 *etok = to_delim; 84 83 p = ++etok; 85 84 } else 86 85 p += strlen(p); 87 86 } else { -
trunk/src/kmk/w32/subproc/NMakefile
r1993 r2591 3 3 # 4 4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 5 # 2006, 2007 Free Software Foundation, Inc.5 # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 6 6 # This file is part of GNU Make. 7 7 # -
trunk/src/kmk/w32/subproc/build.bat
r1993 r2591 19 19 @echo off 20 20 rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 21 rem 2005, 2006, 2007 Free Software Foundation, Inc.21 rem 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 22 22 rem This file is part of GNU Make. 23 23 rem -
trunk/src/kmk/w32/subproc/misc.c
r1993 r2591 1 1 /* Process handling for Windows 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 3 2006, 2007 Free Software Foundation, Inc.3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 … … 16 16 this program. If not, see <http://www.gnu.org/licenses/>. */ 17 17 18 #include <config.h> 18 19 #include <stddef.h> 19 20 #include <stdlib.h> … … 78 79 } 79 80 80 81 free(tmp); 81 82 return TRUE; 82 83 } -
trunk/src/kmk/w32/subproc/proc.h
r1993 r2591 1 1 /* Definitions for Windows 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 3 2006, 2007 Free Software Foundation, Inc.3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 -
trunk/src/kmk/w32/subproc/sub_proc.c
r1993 r2591 1 1 /* Process handling for Windows. 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 3 2006, 2007 Free Software Foundation, Inc.3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 … … 16 16 this program. If not, see <http://www.gnu.org/licenses/>. */ 17 17 18 #include <config.h> 18 19 #include <stdlib.h> 19 20 #include <stdio.h> 21 #ifdef _MSC_VER 22 # include <stddef.h> /* for intptr_t */ 23 #else 24 # include <stdint.h> 25 #endif 20 26 #include <process.h> /* for msvc _beginthreadex, _endthreadex */ 21 27 #include <signal.h> … … 25 31 #include "proc.h" 26 32 #include "w32err.h" 27 #include "config.h"28 33 #include "debug.h" 29 34 30 35 static char *make_command_line(char *shell_name, char *exec_path, char **argv); 36 extern char *xmalloc (unsigned int); 31 37 32 38 typedef struct sub_process_t { 33 int sv_stdin[2];34 int sv_stdout[2];35 int sv_stderr[2];39 intptr_t sv_stdin[2]; 40 intptr_t sv_stdout[2]; 41 intptr_t sv_stderr[2]; 36 42 int using_pipes; 37 43 char *inp; … … 41 47 char * volatile errp; 42 48 volatile DWORD errcnt; 43 int pid;49 pid_t pid; 44 50 int exit_code; 45 51 int signal; … … 316 322 return((HANDLE)pproc); 317 323 } 318 pproc->sv_stdin[0] = (int ) stdin_pipes[0];319 pproc->sv_stdin[1] = (int ) stdin_pipes[1];320 pproc->sv_stdout[0] = (int ) stdout_pipes[0];321 pproc->sv_stdout[1] = (int ) stdout_pipes[1];322 pproc->sv_stderr[0] = (int ) stderr_pipes[0];323 pproc->sv_stderr[1] = (int ) stderr_pipes[1];324 pproc->sv_stdin[0] = (intptr_t) stdin_pipes[0]; 325 pproc->sv_stdin[1] = (intptr_t) stdin_pipes[1]; 326 pproc->sv_stdout[0] = (intptr_t) stdout_pipes[0]; 327 pproc->sv_stdout[1] = (intptr_t) stdout_pipes[1]; 328 pproc->sv_stderr[0] = (intptr_t) stderr_pipes[0]; 329 pproc->sv_stderr[1] = (intptr_t) stderr_pipes[1]; 324 330 325 331 pproc->using_pipes = 1; … … 343 349 * pipe, bypassing pipes altogether. 344 350 */ 345 pproc->sv_stdin[1] = (int ) stdinh;346 pproc->sv_stdout[1] = (int ) stdouth;347 pproc->sv_stderr[1] = (int ) stderrh;351 pproc->sv_stdin[1] = (intptr_t) stdinh; 352 pproc->sv_stdout[1] = (intptr_t) stdouth; 353 pproc->sv_stderr[1] = (intptr_t) stderrh; 348 354 349 355 pproc->last_err = pproc->lerrno = 0; … … 354 360 355 361 static HANDLE 356 find_file(char *exec_path, LPOFSTRUCT file_info) 362 find_file(const char *exec_path, const char *path_var, 363 char *full_fname, DWORD full_len) 357 364 { 358 365 HANDLE exec_handle; 359 366 char *fname; 360 367 char *ext; 361 #ifdef KMK 362 size_t exec_path_len; 363 364 /* 365 * if there is an .exe extension there already, don't waste time here. 366 * If .exe scripts become common, they can be handled in a CreateProcess 367 * failure path instead of here. 368 */ 369 exec_path_len = strlen(exec_path); 370 if ( exec_path_len > 4 371 && exec_path[exec_path_len - 4] == '.' 372 && !stricmp(exec_path + exec_path_len - 3, "exe")){ 373 return((HANDLE)HFILE_ERROR); 374 } 375 376 fname = malloc(exec_path_len + 5); 377 #else 378 fname = malloc(strlen(exec_path) + 5); 379 #endif 368 DWORD req_len; 369 int i; 370 static const char *extensions[] = 371 /* Should .com come before no-extension case? */ 372 { ".exe", ".cmd", ".bat", "", ".com", NULL }; 373 374 fname = xmalloc(strlen(exec_path) + 5); 380 375 strcpy(fname, exec_path); 381 376 ext = fname + strlen(fname); 382 377 383 strcpy(ext, ".exe"); 384 if ((exec_handle = (HANDLE)OpenFile(fname, file_info, 385 OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) { 386 free(fname); 387 return(exec_handle); 388 } 389 390 strcpy(ext, ".cmd"); 391 if ((exec_handle = (HANDLE)OpenFile(fname, file_info, 392 OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) { 393 free(fname); 394 return(exec_handle); 395 } 396 397 strcpy(ext, ".bat"); 398 if ((exec_handle = (HANDLE)OpenFile(fname, file_info, 399 OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) { 400 free(fname); 401 return(exec_handle); 402 } 403 404 /* should .com come before this case? */ 405 if ((exec_handle = (HANDLE)OpenFile(exec_path, file_info, 406 OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) { 407 free(fname); 408 return(exec_handle); 409 } 410 411 strcpy(ext, ".com"); 412 if ((exec_handle = (HANDLE)OpenFile(fname, file_info, 413 OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) { 414 free(fname); 415 return(exec_handle); 378 for (i = 0; extensions[i]; i++) { 379 strcpy(ext, extensions[i]); 380 if (((req_len = SearchPath (path_var, fname, NULL, full_len, 381 full_fname, NULL)) > 0 382 /* For compatibility with previous code, which 383 used OpenFile, and with Windows operation in 384 general, also look in various default 385 locations, such as Windows directory and 386 Windows System directory. Warning: this also 387 searches PATH in the Make's environment, which 388 might not be what the Makefile wants, but it 389 seems to be OK as a fallback, after the 390 previous SearchPath failed to find on child's 391 PATH. */ 392 || (req_len = SearchPath (NULL, fname, NULL, full_len, 393 full_fname, NULL)) > 0) 394 && req_len <= full_len 395 && (exec_handle = 396 CreateFile(full_fname, 397 GENERIC_READ, 398 FILE_SHARE_READ | FILE_SHARE_WRITE, 399 NULL, 400 OPEN_EXISTING, 401 FILE_ATTRIBUTE_NORMAL, 402 NULL)) != INVALID_HANDLE_VALUE) { 403 free(fname); 404 return(exec_handle); 405 } 416 406 } 417 407 418 408 free(fname); 419 return (exec_handle);409 return INVALID_HANDLE_VALUE; 420 410 } 421 411 … … 440 430 int file_not_found=0; 441 431 HANDLE exec_handle; 432 char exec_fname[MAX_PATH]; 433 const char *path_var = NULL; 434 char **ep; 442 435 char buf[256]; 443 436 DWORD bytes_returned; … … 447 440 PROCESS_INFORMATION procInfo; 448 441 char *envblk=NULL; 449 OFSTRUCT file_info; 450 442 #ifdef KMK 443 size_t exec_path_len; 444 #endif 445 446 447 /* 448 * Shell script detection... if the exec_path starts with #! then 449 * we want to exec shell-script-name exec-path, not just exec-path 450 * NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl. We do not 451 * hard-code the path to the shell or perl or whatever: Instead, we 452 * assume it's in the path somewhere (generally, the NT tools 453 * bin directory) 454 */ 455 456 #ifdef KMK 457 /* kmk performace: Don't bother looking for shell scripts in .exe files. */ 458 exec_path_len = strlen(exec_path); 459 if (exec_path_len > 4 460 && exec_path[exec_path_len - 4] == '.' 461 && !stricmp(exec_path + exec_path_len - 3, "exe")) { 462 exec_handle = INVALID_HANDLE_VALUE; 463 } 464 else { 465 #endif /* KMK */ 466 /* Use the Makefile's value of PATH to look for the program to 467 execute, because it could be different from Make's PATH 468 (e.g., if the target sets its own value. */ 469 if (envp) 470 for (ep = envp; *ep; ep++) { 471 if (strncmp (*ep, "PATH=", 5) == 0 472 || strncmp (*ep, "Path=", 5) == 0) { 473 path_var = *ep + 5; 474 break; 475 } 476 } 477 exec_handle = find_file(exec_path, path_var, 478 exec_fname, sizeof(exec_fname)); 479 #ifdef KMK 480 } 481 #endif 451 482 452 483 /* 453 * Shell script detection... if the exec_path starts with #! then 454 * we want to exec shell-script-name exec-path, not just exec-path 455 * NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl. We do not 456 * hard-code the path to the shell or perl or whatever: Instead, we 457 * assume it's in the path somewhere (generally, the NT tools 458 * bin directory) 459 * We use OpenFile here because it is capable of searching the Path. 484 * If we couldn't open the file, just assume that Windows will be 485 * somehow able to find and execute it. 460 486 */ 461 462 exec_handle = find_file(exec_path, &file_info); 463 464 /* 465 * If we couldn't open the file, just assume that Windows32 will be able 466 * to find and execute it. 467 */ 468 if (exec_handle == (HANDLE)HFILE_ERROR) { 487 if (exec_handle == INVALID_HANDLE_VALUE) { 469 488 file_not_found++; 470 489 } … … 520 539 command_line = make_command_line( shell_name, exec_path, argv); 521 540 else 522 command_line = make_command_line( shell_name, file_info.szPathName, 523 argv); 541 command_line = make_command_line( shell_name, exec_fname, argv); 524 542 525 543 if ( command_line == NULL ) { … … 541 559 exec_path = 0; /* Search for the program in %Path% */ 542 560 } else { 543 exec_path = file_info.szPathName;561 exec_path = exec_fname; 544 562 } 545 563 … … 608 626 } 609 627 610 pproc->pid = ( int)procInfo.hProcess;628 pproc->pid = (pid_t)procInfo.hProcess; 611 629 /* Close the thread handle -- we'll just watch the process */ 612 630 CloseHandle(procInfo.hThread); -
trunk/src/kmk/w32/subproc/w32err.c
r1993 r2591 1 1 /* Error handling for Windows 2 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 3 2006, 2007 Free Software Foundation, Inc.3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5
Note:
See TracChangeset
for help on using the changeset viewer.