Changeset 280 in kBuild for branches/GNU/src/gmake
- Timestamp:
- May 16, 2005 4:54:02 PM (20 years ago)
- Location:
- branches/GNU/src/gmake
- Files:
-
- 1 added
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gmake
- Property svn:ignore
-
old new 34 34 README.DOS 35 35 README.W32 36 README.OS2 36 37 aclocal.m4 37 38 autom4te.cache
-
- Property svn:ignore
-
branches/GNU/src/gmake/.cvsignore
r52 r280 12 12 *.cp *.cps *.fn *.fns *.vr *.vrs *.tp *.tps *.ky *.kys *.pg *.pgs 13 13 14 README README.DOS README.W32 14 README README.DOS README.W32 README.OS2 15 15 aclocal.m4 autom4te.cache 16 16 config.h.in config.h config.status config.cache configure -
branches/GNU/src/gmake/AUTHORS
r54 r280 7 7 Development starting with GNU make 3.76 by: 8 8 Paul D. Smith <[email protected]> 9 Additional development starting with GNU make 3.81 by: 10 Boris Kolpackov <[email protected]> 9 11 10 12 … … 24 26 Port to VMS by: 25 27 Klaus Kaempf <[email protected]> 28 Hartmut Becker <[email protected]> 26 29 Archive support/Bug fixes by: 27 30 John W. Eaton <[email protected]> … … 31 34 Aaron Digulla <[email protected]> 32 35 33 34 Port to MS-DOS (DJGPP) and MS-Windows 95/NT by: 36 Port to MS-DOS (DJGPP), OS/2, and MS-Windows (native/MinGW) by: 35 37 DJ Delorie <[email protected]> 36 38 Rob Tulloh <[email protected]> 37 39 Eli Zaretskii <[email protected]> 40 Jonathan Grant <[email protected]> 41 Andreas Beuning <[email protected]> 42 Earnie Boyd <[email protected]> 38 43 39 44 ----------------------------------- … … 48 53 David Lubbren <[email protected]> 49 54 Tim Magill <[email protected]> 55 Markus Mauhart <[email protected]> 50 56 Greg McGary <[email protected]> 57 Thomas Riedl <[email protected]> 51 58 Han-Wen Nienhuys <[email protected]> 52 59 Andreas Schwab <[email protected]> -
branches/GNU/src/gmake/ChangeLog
r153 r280 1 2005-05-13 Paul D. Smith <[email protected]> 2 3 Implement "if... else if... endif" syntax. 4 5 * read.c (eval): Push all checks for conditional words ("ifeq", 6 "else", etc.) down into the conditional_line() function. 7 (conditional_line): Rework to allow "else if..." clause. New 8 return value -2 for lines which are not conditionals. The 9 ignoring flag can now also be 2, which means "already parsed a 10 true branch". If that value is seen no other branch of this 11 conditional can be considered true. In the else parsing if there 12 is extra text after the else, invoke conditional_line() 13 recursively to see if it's another conditional. If not, it's an 14 error. If so, raise the conditional value to this level instead 15 of creating a new conditional nesting level. Special check for 16 "else" and "endif", which aren't allowed on the "else" line. 17 * doc/make.texi (Conditional Syntax): Document the new syntax. 18 19 2005-05-09 Paul D. Smith <[email protected]> 20 21 * Makefile.am (EXTRA_make_SOURCES): Add vmsjobs.c 22 (MAYBE_W32): Rework how SUBDIRS are handled so that "make dist" 23 recurses to the w32 directory, even on non-Windows systems. Use 24 the method suggested in the automake manual. 25 * configure.in: Add w32/Makefile to AC_CONFIG_FILES. 26 * maintMakefile (gnulib-url): They moved the texinfo.tex files. 27 28 2005-05-07 Paul D. Smith <[email protected]> 29 30 * main.c (die): If we're dying with a fatal error (not that a 31 command has failed), write back any leftover tokens before we go. 32 33 * job.c (set_child_handler_action_flags): If there are jobs 34 waiting for the load to go down, set an alarm to go off in 1 35 second. This allows us to wake up from a potentially long-lasting 36 read() and start a new job if the load has gone down. Turn it off 37 after the read. 38 (job_noop): Dummy signal handler function. 39 (new_job): Invoke it with the new semantics. 40 41 * docs/make.texi: Document secondary expansion. Various cleanups 42 and random work. 43 44 2005-05-03 Paul D. Smith <[email protected]> 45 46 Rename .DEFAULT_TARGET to .DEFAULT_GOAL: in GNU make terminology 47 the targets which are to ultimately be made are called "goals"; 48 see the GNU make manual. Also, MAKECMDGOALS, etc. 49 50 * filedef.h, read.c, main.c: Change .DEFAULT_TARGET to 51 .DEFAULT_GOAL, and default_target_name to default_goal_name. 52 * doc/make.texi (Special Variables): Document .DEFAULT_GOAL. 53 54 2005-05-02 Paul D. Smith <[email protected]> 55 56 * job.c, vmsjobs.c (vmsWaitForChildren, vms_redirect, 57 vms_handle_apos, vmsHandleChildTerm, reEnableAst, astHandler, 58 tryToSetupYAst, child_execute_job) [VMS]: Move VMS-specific 59 functions to vmsjobs.c. #include it into jobs.c. 60 61 Grant Taylor <[email protected]> reports that -j# can lose 62 jobserver tokens. I found that this happens when an exported 63 recursive variable contains a $(shell ...) function reference: in 64 this situation we could "forget" to write back a token. 65 66 * job.c, job.h: Add variable jobserver_tokens: counts the tokens 67 we have. It's not reliable to depend on the number of children in 68 our linked list so keep a separate count. 69 (new_job): Check jobserver_tokens rather than children && 70 waiting_jobs. Increment jobserver_tokens when we get one. 71 (free_child): If jobserver_tokens is 0, internal error. If it's 72 >1, write a token back to the jobserver pipe (we don't write a 73 token for the "free" job). Decrement jobserver_tokens. 74 75 * main.c: Add variable master_job_slots. 76 (main): Set it to hold the number of jobs requested if we're the 77 master process, when using the jobserver. 78 (die): Sanity checks: first test jobserver_tokens to make sure 79 this process isn't holding any tokens we didn't write back. 80 Second, if master_job_slots is set count the tokens left in the 81 jobserver pipe and ensure it's the same as master_job_slots (- 1). 82 83 2005-04-24 Paul D. Smith <[email protected]> 84 85 Grant Taylor <[email protected]> reports that -j# in conjunction 86 with -l# can lose jobserver tokens, because waiting jobs are not 87 consulted properly when checking for the "free" token. 88 89 * job.c (free_child): Count waiting_jobs as having tokens. 90 * job.c (new_job): Ditto. Plus, call start_waiting_jobs() here to 91 handle jobs waiting for the load to drop. 92 93 2005-04-23 Paul D. Smith <[email protected]> 94 95 * main.c (main): Be careful to not core if a variable setting in 96 the environment doesn't contain an '='. This is illegal but can 97 happen in broken setups. 98 Reported by Joerg Schilling <[email protected]>. 99 100 2005-04-12 Paul D. Smith <[email protected]> 101 102 The second expansion feature causes significant slowdown. Timing 103 a complex makefile (GCC 4.1) shows a slowdown from .25s to just 104 read the makefile before the feature, to 11+s to do the same 105 operations after the feature. Additionally, memory usage 106 increased drastically. To fix this I added some intelligence that 107 avoids the overhead of the second expansion unless it's required. 108 109 * dep.h: Add a new boolean field, need_2nd_expansion. 110 111 * read.c (eval): When creating the struct dep for the target, 112 check if the name contains a "$"; if so set need_2nd_expansion to 1. 113 (record_files): If there's a "%" in a static pattern rule, it gets 114 converted to "$*" so set need_2nd_expansion to 1. 115 116 * file.c (expand_deps): Rework to be more efficient. Only perform 117 initialize_file_variables(), set_file_variables(), and 118 variable_expand_for_file() if the need_2nd_expansion is set. 119 120 * implicit.c (pattern_search): Default need_2nd_expansion to 0. 121 (pattern_search): Ditto. 122 * main.c (handle_non_switch_argument): Ditto. 123 (main): Ditto. 124 * read.c (read_all_makefiles): Ditto. 125 (eval_makefile): Ditto. 126 127 2005-04-07 Paul D. Smith <[email protected]> 128 129 * main.c (main) [WINDOWS32]: Export PATH to sub-shells, not Path. 130 * variable.c (sync_Path_environment): Ditto. 131 Patch by Alessandro Vesely. Fixes Savannah bug #12209. 132 133 * main.c (main): Define the .FEATURES variable. 134 * NEWS: Announce .FEATURES. 135 * doc/make.texi (Special Variables): Document .FEATURES. 136 137 * remake.c (check_dep): If a file is .PHONY, update it even if 138 it's marked intermediate. Fixes Savannah bug #12331. 139 140 2005-03-15 Boris Kolpackov <[email protected]> 141 142 * file.c (expand_deps): Factor out the second expansion and 143 prerequisite line parsing logic from snap_deps(). 144 145 * file.c (snap_deps): Use expand_deps(). Expand and parse 146 prerequisites of the .SUFFIXES special target first. Fixes 147 Savannah bug #12320. 148 149 2005-03-13 Paul D. Smith <[email protected]> 150 151 * main.c (main) [MSDOS]: Export SHELL in MSDOS. Requested by Eli 152 Zaretskii. 153 154 2005-03-11 Paul D. Smith <[email protected]> 155 156 * signame.c (strsignal): HAVE_DECL_SYS_SIGLIST is 0 when not 157 available, not undefined (from Earnie Boyd). 158 159 2005-03-10 Boris Kolpackov <[email protected]> 160 161 * implicit.c (pattern_search): Mark an intermediate target as 162 precious if it happened to be a prerequisite of some (other) 163 target. Fixes Savannah bug #12267. 164 165 2005-03-09 Paul D. Smith <[email protected]> 166 167 * read.c (eval_makefile): Add alloca(0). 168 (eval_buffer): Ditto. 169 170 2005-03-09 Boris Kolpackov <[email protected]> 171 172 * main.c (main): Use o_file instead of o_default when defining 173 the .DEFAULT_TARGET special variable. 174 * read.c (eval): Use define_variable_global() instead of 175 define_variable() when setting new value for the .DEFAULT_TARGET 176 special variable. Fixes Savannah bug #12266. 177 178 2005-03-04 Boris Kolpackov <[email protected]> 179 180 * imlicit.c (pattern_search): Mark files for which an implicit 181 rule has been found as targets. Fixes Savannah bug #12202. 182 183 2005-03-04 Paul D. Smith <[email protected]> 184 185 * AUTHORS: Update. 186 * doc/make.texi (Automatic Variables): Document $|. 187 188 2005-03-03 Boris Kolpackov <[email protected]> 189 190 * read.c (record_files): Instead of substituting % with 191 actual stem value in dependency list replace it with $*. 192 This fixes stem triple expansion bug. 193 194 * implicit.c (pattern_search): Copy stem to a separate 195 buffer and make it a properly terminated string. Assign 196 this buffer instead of STEM (which is not terminated) to 197 f->stem. Instead of substituting % with actual stem value 198 in dependency list replace it with $*. This fixes stem 199 triple expansion bug. 200 201 2005-03-01 Paul D. Smith <[email protected]> 202 203 * commands.c (fatal_error_signal) [WINDOWS32]: Don't call kill() 204 on Windows, as it takes a handle not a pid. Just exit. 205 Fix from patch #3679, provided by Alessandro Vesely. 206 207 * configure.in: Update check for sys_siglist[] from autoconf manual. 208 * signame.c (strsignal): Update to use the new autoconf macro. 209 210 2005-03-01 Boris Kolpackov <[email protected]> 211 212 * read.c (record_files): Add a check for the list of prerequisites 213 of a static pattern rule being empty. Fixes Savannah bug #12180. 214 215 2005-02-28 Paul D. Smith <[email protected]> 216 217 * doc/make.texi (Text Functions): Update docs to allow the end 218 ordinal for $(wordlist ...) to be 0. 219 * function.c (func_wordlist): Fail if the start ordinal for 220 $(wordlist ...) is <1. Matches documentation. 221 Resolves Savannah support request #103195. 222 223 * remake.c (update_goal_chain): Fix logic for stopping in -q: 224 previously we were stopping when !-q, exactly the opposite. This 225 has been wrong since version 1.34, in 1994! 226 (update_file): If we got an error don't break out to run more 227 double-colon rules: just return immediately. 228 Fixes Savannah bug #7144. 229 230 2005-02-27 Paul D. Smith <[email protected]> 231 232 * misc.c (end_of_token): Make argument const. 233 * make.h: Update prototype. 234 235 * function.c (abspath, func_realpath, func_abspath): Use 236 PATH_VAR() and GET_PATH_MAX instead of PATH_MAX. 237 * dir.c (downcase): Use PATH_VAR() instead of PATH_MAX. 238 * read.c (record_files): Ditto. 239 * variable.c (do_variable_definition): Ditto. 240 241 * function.c (func_error): Create a new function $(info ...) that 242 simply prints the message to stdout with no extras. 243 (function_table_init): Add new function to the table. 244 * NEWS: Add $(info ...) reference. 245 * doc/make.texi (Make Control Functions): Document it. 246 247 New feature: if the system supports symbolic links, and the user 248 provides the -L/--check-symlink-time flag, then use the latest 249 mtime between the symlink(s) and the target file. 250 251 * configure.in (MAKE_SYMLINKS): Check for lstat() and 252 readlink(). If both are available, define MAKE_SYMLINKS. 253 * main.c: New variable: check_symlink_flag. 254 (usage): Add a line for -L/--check-symlink-times to the help string. 255 (switches): Add -L/--check-symlink-times command line argument. 256 (main): If MAKE_SYMLINKS is not defined but the user specified -L, 257 print a warning and disable it again. 258 * make.h: Declare check_symlink_flag. 259 * remake.c (name_mtime): If MAKE_SYMLINKS and check_symlink_flag, 260 if the file is a symlink then check each link in the chain and 261 choose the NEWEST mtime we find as the mtime for the file. The 262 newest mtime might be the file itself! 263 * NEWS: Add information about this new feature. 264 * doc/make.texi (Options Summary): Add -L/--check-symlink-times docs. 265 266 Avoid core dumps described in Savannah bug # 12124: 267 268 * file.c: New variable snapped_deps remember whether we've run 269 snap_deps(). 270 (snap_deps): Set it. 271 * filedef.h: Extern it. 272 * read.c (record_files): Check snapped_deps; if it's set then 273 we're trying to eval a new target/prerequisite relationship from 274 within a command script, which we don't support. Fatal. 275 276 2005-02-28 Boris Kolpackov <[email protected]> 277 278 Implementation of the .DEFAULT_TARGET special variable. 279 280 * read.c (eval): If necessary, update default_target_name when 281 reading rules. 282 * read.c (record_files): Update default_target_file if 283 default_target_name has changed. 284 * main.c (default_target_name): Define. 285 * main.c (main): Enter .DEFAULT_TARGET as make variable. If 286 default_target_name is set use default_target_file as a root 287 target to make. 288 * filedef.h (default_target_name): Declare. 289 * dep.h (free_dep_chain): 290 * misc.c (free_dep_chain): Change to operate on struct nameseq 291 and change name to free_ns_chain. 292 * file.c (snap_deps): Update to use free_ns_chain. 293 294 2005-02-27 Boris Kolpackov <[email protected]> 295 296 Implementation of the second expansion in explicit rules, 297 static pattern rules and implicit rules. 298 299 * read.c (eval): Refrain from chopping up rule's dependencies. 300 Store them in a struct dep as a single dependency line. Remove 301 the code that implements SySV-style automatic variables. 302 303 * read.c (record_files): Adjust the code that handles static 304 pattern rules to expand all percents instead of only the first 305 one. Reverse the order in which dependencies are stored so that 306 when the second expansion reverses them again they appear in 307 the makefile order (with some exceptions, see comments in 308 the code). Remove the code that implements SySV-style automatic 309 variables. 310 311 * file.c (snap_deps): Implement the second expansion and chopping 312 of dependency lines for explicit rules. 313 314 * implicit.c (struct idep): Define an auxiliary data type to hold 315 implicit rule's dependencies after stem substitution and 316 expansion. 317 318 * implicit.c (free_idep_chain): Implement. 319 320 * implicit.c (get_next_word): Implement helper function for 321 parsing implicit rule's dependency lines into words taking 322 into account variable expansion requests. Used in the stem 323 splitting code. 324 325 * implicit.c (pattern_search): Implement the second expansion 326 for implicit rules. Also fixes bug #12091. 327 328 * commands.h (set_file_variables): Declare. 329 * commands.c (set_file_variables): Remove static specifier. 330 331 * dep.h (free_dep_chain): Declare. 332 * misc.c (free_dep_chain): Implement. 333 334 * variable.h (variable_expand_for_file): Declare. 335 * expand.c (variable_expand_for_file): Remove static specifier. 336 337 * make.h (strip_whitespace): Declare. 338 * function.c (strip_whitespace): Remove static specifier. 339 340 2005-02-26 Paul D. Smith <[email protected]> 341 342 * main.c (main): Check for ferror() when reading makefiles from stdin. 343 Apparently some shells in Windows don't close pipes properly and 344 require this check. 345 346 2005-02-24 Jonathan Grant <[email protected]> 347 348 * configure.in: Add MinGW configuration options, and extra w32 code 349 directory. 350 * Makefile.am: Add MinGW configuration options, and extra w32 code 351 directory. 352 * main.c: Determine correct program string (after last \ without .exe). 353 * subproc/sub_proc.c: `GetExitCodeProcess' from incompatible pointer 354 type fix x2 355 * w32/Makefile.am: Import to build win32 lib of sub_proc etc. 356 * subproc/w32err.c: MSVC thread directive not applied to MinGW builds. 357 * tests/run_make_tests.pl, tests/test_driver.pl: MSYS testing 358 environment support. 359 360 2004-04-16 Dmitry V. Levin <[email protected]> 361 362 * function.c (func_shell): When initializing error_prefix, check 363 that reading file name is not null. This fixes long-standing 364 segfault in cases like "make 'a1=$(shell :)' 'a2:=$(a1)'". 365 366 2005-02-09 Paul D. Smith <[email protected]> 367 368 * maintMakefile: Update the CVS download URL to simplify them. 369 Also, the ftp://ftp.gnu.org/GNUinfo site was removed so I'm 370 downloading the .texi files from Savannah now. 371 372 Fixed these issues reported by Markus Mauhart <[email protected]>: 373 374 * main.c (handle_non_switch_argument): Only add variables to 375 command_variables if they're not already there: duplicate settings 376 waste space and can be confusing to read. 377 378 * w32/include/sub_proc.h: Remove WINDOWS32. It's not needed since 379 this header is never included by non-WINDOWS32 code, and it 380 requires <config.h> to define which isn't always included first. 381 382 * dir.c (read_dirstream) [MINGW]: Use proper macro names when 383 testing MINGW32 versions. 384 385 * main.c (log_working_directory): flush stdout to be sure the WD 386 change is printed before any stderr messages show up. 387 388 2005-02-01 Paul D. Smith <[email protected]> 389 390 * maintMakefile (po_repo): Update the GNU translation site URL. 391 392 2004-12-01 Paul D. Smith <[email protected]> 393 394 * main.c (main): Change char* env_shell to struct variable shell_var. 395 * variable.c (target_environment): Use new shell_var. 396 397 2004-11-30 Paul D. Smith <[email protected]> 398 399 * configure.in: The old way we avoided creating build.sh from 400 build.sh.in before build.sh.in exists doesn't work anymore; we 401 have to use raw M4 (thanks to Andreas Schwab <[email protected]> for 402 the help!). This also keeps automake from complaining. 403 * Makefile.am (README): Add a dummy target so automake won't 404 complain that this file doesn't exist when we checkout from CVS. 405 * maintMakefile (.dep_segment): Rewrite this rule since newer 406 versions of automake don't provide DEP_FILES. 407 408 2004-11-30 Boris Kolpackov <[email protected]> 409 410 Implementation of `realpath' and `abspath' built-in functions. 411 412 * configure.in: Check for realpath. 413 * function.c (abspath): Return an absolute file name that does 414 not contain any `.' or `..' components, nor repeated `/'. 415 * function.c (func_abspath): For each name call abspath. 416 * function.c (func_realpath): For each name call realpath 417 from libc or delegate to abspath if realpath is not available. 418 * doc/make.texi (Functions for File Names): Document new functions. 419 * doc/make.texi (Quick Reference): Ditto. 420 421 2004-11-28 Paul D. Smith <[email protected]> 422 423 * main.c (main) [WINDOWS32]: Remove any trailing slashes from -C 424 arguments. Fixes bug #10252. 425 426 Fix for bug #1276: Handle SHELL according to POSIX requirements. 427 428 * main.c (main): Set SHELL to v_noexport by default. Remember the 429 original environment setting of SHELL in the env_shell variable. 430 * main.h: Export new env_shell variable. 431 * variable.c (target_environment): If we find a v_noexport 432 variable for SHELL, add a SHELL variable with the env_shell value. 433 * doc/make.texi (Quick Reference): Document the POSIX behavior. 434 * doc/make.texi (Variables/Recursion): Ditto. 435 436 2004-11-28 Paul D. Smith <[email protected]> 437 438 * main.c (find_and_set_default_shell) [WINDOWS32]: check for 439 equality of "cmd"/"cmd.exe", not inequality. Fixes bug #11155. 440 Patch by Alessandro Vesely. 441 442 2004-11-12 Paul D. Smith <[email protected]> 443 444 * job.c (child_execute_job) [VMS]: Don't treat "#" as a comment on 445 the command line if it's inside a string. 446 Patch by: Hartmut Becker <[email protected]> 447 448 2004-10-21 Boris Kolpackov <[email protected]> 449 450 * function.c (func_lastword): New function: return last word 451 from the list of words. 452 * doc/make.texi: Document $(lastword ). Fix broken links in 453 Quick Reference section. 454 455 2004-10-06 Paul D. Smith <[email protected]> 456 457 Apply patch from Alessandro Vesely, provided with bug # 9748. 458 Fix use of tmpnam() to work with Borland C. 459 460 * job.c (construct_command_argv_internal) [WINDOWS32]: Remove 461 construction of a temporary filename, and call new function 462 create_batch_filename(). 463 (create_batch_filename) [WINDOWS32]: New function to create a 464 temporary filename. 465 466 2004-10-05 Boris Kolpackov <[email protected]> 467 468 * read.c (record_target_var): Expand simple pattern-specific 469 variable. 470 * variable.c (initialize_file_variables): Do not expand simple 471 pattern-specific variable. 472 473 2004-09-28 Boris Kolpackov <[email protected]> 474 475 * remake.c (update_file_1): When rebuilding makefiles inherit 476 dontcare flag from a target that triggered update. 477 478 2004-09-27 Boris Kolpackov <[email protected]> 479 480 * variable.c (initialize_file_variables): Mark pattern-specific 481 variable as a per-target and copy export status. 482 483 2004-09-21 Boris Kolpackov <[email protected]> 484 485 * file.c (snap_deps): Mark .PHONY prerequisites as targets. 486 487 * implicit.c (pattern_search): When considering an implicit rule's 488 prerequisite check that it is actually a target rather then 489 just an entry in the file hashtable. 490 491 2004-09-21 Paul D. Smith <[email protected]> 492 493 * read.c (readstring): Fix some logic errors in backslash handling. 494 (eval): Remove some unnecessary processing in buffer handling. 495 (record_target_var): Assert that parse_variable_definition() succeeded. 496 Reported by: Markus Mauhart <[email protected]>. 497 498 * misc.c: Removed the sindex() function. All instances of this 499 function were trivially replaceable by the standard strstr() 500 function, and that function will always have better (or certainly 501 no worse) performance than the very simple-minded algorithm 502 sindex() used. This can matter with complex makefiles. 503 * make.h: Remove the prototype for sindex(). 504 * function.c (subst_expand): Convert sindex() call to strstr(). 505 This means we no longer need to track the TLEN value so remove that. 506 (func_findstring): Convert sindex() to strstr(). 507 * commands.c (chop_commands): Convert sindex() calls to strstr(). 508 Suggested by: Markus Mauhart <[email protected]>. 509 510 * main.c (find_and_set_default_shell) [WINDOWS32]: Implement the 511 idea behind Savannah Patch #3144 from [email protected]. 512 If SHELL is set to CMD.EXE then assume it's batch-mode and 513 non-unixy. I wrote the code differently from the patch, though, 514 to make it safer. This also resolves bug #9174. 515 516 2004-09-20 Paul D. Smith <[email protected]> 517 518 * expand.c (variable_expand_string): Modify to invoke 519 patsubst_expand() instead of subst_expand(); the latter didn't 520 handle suffix patterns correctly. 521 * function.c (subst_expand): Remove the SUFFIX_ONLY parameter; it 522 was used only from variable_expand_string() and is no longer used 523 there. 524 (func_subst): Ditto, on call to subst_expand(). 525 (patsubst_expand): Require the percent pointers to point to the 526 character after the %, not to the % itself. 527 * read.c (record_files): New call criteria for patsubst_expand(). 528 * variable.h: Remove SUFFIX_ONLY from subst_expand() prototype. 529 This is to fix a bug reported by Markus Mauhart <[email protected]>. 530 531 2004-09-19 Paul D. Smith <[email protected]> 532 533 * function.c (subst_expand): Fix a check in by_word: look for a 534 previous blank if we're beyond the beginning of the string, not 535 the beginning of the word. 536 Bugs reported by Markus Mauhart <[email protected]>. 537 538 2004-05-16 Paul D. Smith <[email protected]> 539 540 * remake.c (update_goal_chain): Change the argument specifying 541 whether we're rebuilding makefiles to be a global variable, 542 REBUILDING_MAKEFILES. 543 (complain): Extract the code that complains about no rules to make 544 a target into a separate function. 545 (update_file_1): If we tried to rebuild a file during the makefile 546 rebuild phase and it was dontcare, then no message was printed. 547 If we then try to build the same file during the normal build, 548 print a message this time. 549 (remake_file): Don't complain about un-remake-able files when 550 we're rebuilding makefiles. 551 552 2004-05-11 Paul D. Smith <[email protected]> 553 554 * job.c (construct_command_argv_internal): OS/2 patches from 555 Andreas Buening <[email protected]>. 556 557 2004-05-10 Paul D. Smith <[email protected]> 558 559 * remake.c (update_file): Don't walk the double-colon chain unless 560 this is a double-colon rule. Fix suggested by Boris Kolpackov 561 <[email protected]>. 562 563 * makefile.vms (CFLAGS): Remove glob/globfree (see readme.vms docs) 564 * readme.vms: New section describing OpenVMS support and issues. 565 * default.c (default_variables): Add support for IA64. 566 * job.c (tryToSetupYAst) [VMS]: On VMS running make in batch mode 567 without some privilege aborts make with the error 568 %SYSTEM-F-NOPRIV. It happens when setting up a handler for 569 pressing Ctrl+Y and the input device is no terminal. The change 570 catches this error and just continues. 571 572 Patches by Hartmut Becker <[email protected]> 573 574 2004-04-25 Paul D. Smith <[email protected]> 575 576 * commands.c (set_file_variables): Set $< properly in the face of 577 order-only prerequisites. 578 Patch from Boris Kolpackov <[email protected]> 579 580 2004-04-21 Bob Byrnes <[email protected]> 581 582 * main.c (main): Notice failures to remake makefiles. 583 584 2004-03-28 Paul D. Smith <[email protected]> 585 586 Patches for Acorn RISC OS by Peter Naulls <[email protected]> 587 588 * job.c: No default shell for RISC OS. 589 (load_too_high): Hard-code the return to 1. 590 (construct_command_argv_internal): No sh_chars or sh_cmds. 591 * getloadavg.c: Don't set LOAD_AVE_TYPE on RISC OS. 592 593 2004-03-20 Paul D. Smith <[email protected]> 594 595 * variable.c (do_variable_definition): Don't append from the 596 global set if a previous non-appending target-specific variable 597 definition exists. Reported by Oliver Schmidt <[email protected]> 598 (with fix). 599 600 * expand.c (reference_variable): Don't give up on variables with 601 no value that have the target-specific append flag set: they might 602 have a value after all. Reported by Oliver Schmidt 603 <[email protected]> (with fix) and also by Maksim A. Nikulin 604 <[email protected]>. 605 606 * rule.c (count_implicit_rule_limits): Don't delete patterns which 607 refer to absolute pathnames in directories that don't exist: some 608 portion of the makefile could create those directories before we 609 match the pattern. Fixes bugs #775 and #108. 610 611 Fixes from Jonathan R. Grant <[email protected]>: 612 613 * main.c (main): Free makefile_mtimes if we have any. 614 * README.W32.template: Update documentation for the current status 615 of the MS-Windows port. 616 * NMakefile.template (MAKE): Add "MAKE = nmake". A conflicting 617 environment variable is sometimes already defined which causes the 618 build to fail. 619 * main.c (debug_signal_handler): Only define this function if 620 SIGUSR1 is available. 621 622 Fixes for OS/2 from Andreas Beuning <[email protected]>: 623 624 * configure.in [OS/2]: Relocate setting of HAVE_SA_RESTART for OS/2. 625 * README.OS2.template: Documentation updates. 626 * build.template: Add LIBINTL into LOADLIBES. Add $CFLAGS to the 627 link line for safety. 628 * maintMakefile (build.sh.in): Remove an extraneous ")". 629 * job.c (child_execute_job): Close saved FDs. 630 * job.c (exec_command) [OS/2]: exec_command(): If the command 631 can't be exec'ed and if the shell is not Unix-sh, then try again 632 with argv = { "cmd", "/c", ... }. Normally, this code is never 633 reached for the cmd shell unless the command really doesn't exist. 634 (construct_command_argv_internal) [OS/2]: The code for cmd 635 handling now uses new_argv = { "cmd", "/c", "original line", NULL}. 636 The CMD builtin commands are case insensitive so use strcasecmp(). 637 638 2004-03-19 Paul D. Smith <[email protected]> 639 640 * read.c (do_define): Re-order line counter increment so the count 641 is accurate (we were losing one line per define). Reported by 642 Dave Yost <[email protected]>. 643 1 644 2004-03-06 Paul D. Smith <[email protected]> 2 645 … … 160 803 (get-config/config.guess get-config/config.sub): Get these files 161 804 from the Savannah config project instead of ftp.gnu.org. 805 806 2003-10-05 Paul Eggert <[email protected]> 807 808 * main.c (main): Avoid potential subscript error if environ has 809 short strings. 162 810 163 811 2003-08-22 Paul D. Smith <[email protected]> … … 1052 1700 * i18n/ja.po: Installed an updated translation. 1053 1701 1702 2001-09-06 Paul Eggert <[email protected]> 1703 1704 * configure.in (AC_CHECK_HEADERS): Add sys/resource.h. 1705 (AC_CHECK_FUNCS): Add getrlimit, setrlimit. 1706 1707 * main.c: Include <sys/resource.h> if it, getrlimit, and setrlimit 1708 are available. 1709 (main): Get rid of any avoidable limit on stack size. 1710 1054 1711 2001-09-04 Paul D. Smith <[email protected]> 1055 1712 -
branches/GNU/src/gmake/INSTALL
r153 r280 1 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software 2 Foundation, Inc. 3 4 This file is free documentation; the Free Software Foundation gives 1 Installation Instructions 2 ************************* 3 4 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free 5 Software Foundation, Inc. 6 7 This file is free documentation; the Free Software Foundation gives 5 8 unlimited permission to copy, distribute and modify it. 6 9 … … 8 11 ================== 9 12 10 13 These are generic installation instructions. 11 14 12 15 The `configure' shell script attempts to guess correct values for … … 68 71 ===================== 69 72 70 Some systems require unusual options for compilation or linking that 71 the `configure' script does not know about. Run `./configure --help' 72 fordetails on some of the pertinent environment variables.73 Some systems require unusual options for compilation or linking that the 74 `configure' script does not know about. Run `./configure --help' for 75 details on some of the pertinent environment variables. 73 76 74 77 You can give `configure' initial values for configuration parameters … … 83 86 ==================================== 84 87 85 88 You can compile the package for more than one kind of computer at the 86 89 same time, by placing the object files for each architecture in their 87 90 own directory. To do this, you must use a version of `make' that … … 100 103 ================== 101 104 102 105 By default, `make install' will install the package's files in 103 106 `/usr/local/bin', `/usr/local/man', etc. You can specify an 104 107 installation prefix other than `/usr/local' by giving `configure' the 105 option `--prefix=P ATH'.108 option `--prefix=PREFIX'. 106 109 107 110 You can specify separate installation prefixes for 108 111 architecture-specific files and architecture-independent files. If you 109 give `configure' the option `--exec-prefix=P ATH', the package will use110 PATHas the prefix for installing programs and libraries.112 give `configure' the option `--exec-prefix=PREFIX', the package will 113 use PREFIX as the prefix for installing programs and libraries. 111 114 Documentation and other data files will still use the regular prefix. 112 115 113 116 In addition, if you use an unusual directory layout you can give 114 options like `--bindir= PATH' to specify different values for particular117 options like `--bindir=DIR' to specify different values for particular 115 118 kinds of files. Run `configure --help' for a list of the directories 116 119 you can set and what kinds of files go in them. … … 123 126 ================= 124 127 125 128 Some packages pay attention to `--enable-FEATURE' options to 126 129 `configure', where FEATURE indicates an optional part of the package. 127 130 They may also pay attention to `--with-PACKAGE' options, where PACKAGE … … 138 141 ========================== 139 142 140 There may be some features `configure' cannot figure out 141 automatically, but needs to determine by the type of machine the package 142 will run on. Usually, assuming the package is built to be run on the 143 _same_ architectures, `configure' can figure that out, but if it prints 144 amessage saying it cannot guess the machine type, give it the143 There may be some features `configure' cannot figure out automatically, 144 but needs to determine by the type of machine the package will run on. 145 Usually, assuming the package is built to be run on the _same_ 146 architectures, `configure' can figure that out, but if it prints a 147 message saying it cannot guess the machine type, give it the 145 148 `--build=TYPE' option. TYPE can either be a short name for the system 146 149 type, such as `sun4', or a canonical name which has the form: … … 168 171 ================ 169 172 170 If you want to set default values for `configure' scripts to share, 171 you can create a site shell script called `config.site' that gives 172 defaultvalues for variables like `CC', `cache_file', and `prefix'.173 If you want to set default values for `configure' scripts to share, you 174 can create a site shell script called `config.site' that gives default 175 values for variables like `CC', `cache_file', and `prefix'. 173 176 `configure' looks for `PREFIX/share/config.site' if it exists, then 174 177 `PREFIX/etc/config.site' if it exists. Or, you can set the … … 179 182 ================== 180 183 181 184 Variables not defined in a site shell script can be set in the 182 185 environment passed to `configure'. However, some packages may run 183 186 configure again during the build, and the customized values of these … … 193 196 ====================== 194 197 195 `configure' recognizes the following options to control how it 196 operates. 198 `configure' recognizes the following options to control how it operates. 197 199 198 200 `--help' -
branches/GNU/src/gmake/Makefile.am
r153 r280 4 4 ACLOCAL_AMFLAGS = -I config 5 5 6 SUBDIRS = glob config po doc 6 # Only process if target is MS-Windows 7 if WINDOWSENV 8 MAYBE_W32 = w32 9 W32INC = -I $(top_srcdir)/w32/include 10 W32LIB = -Lw32 -lw32 11 endif 12 13 SUBDIRS = glob config po doc $(MAYBE_W32) 7 14 8 15 bin_PROGRAMS = make … … 20 27 variable.c version.c vpath.c hash.c 21 28 22 EXTRA_make_SOURCES = remote-stub.c remote-cstms.c29 EXTRA_make_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c 23 30 24 31 noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \ … … 26 33 27 34 make_LDADD = @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@ 35 # Only process if target is MS-Windows 36 if WINDOWSENV 37 make_LDADD += $(W32LIB) 38 endif 28 39 29 40 man_MANS = make.1 … … 32 43 33 44 AM_CPPFLAGS = $(GLOBINC) 45 # Only process if target is MS-Windows 46 if WINDOWSENV 47 AM_CPPFLAGS += $(W32INC) 48 endif 34 49 35 50 … … 115 130 .PHONY: check-loadavg check-regression 116 131 117 check-loadavg: loadavg 132 check-loadavg: loadavg$(EXEEXT) 118 133 @echo The system uptime program believes the load average to be: 119 134 -uptime 120 135 @echo The GNU load average checking code thinks: 121 -./loadavg 136 -./loadavg$(EXEEXT) 122 137 123 138 # The loadavg function is invoked during "make check" to test getloadavg. … … 158 173 # --------------- Maintainer's Section 159 174 175 # Tell automake that I haven't forgotten about this file and it will be 176 # created before we build a distribution (see maintMakefile in the CVS 177 # distribution). 178 179 README: 180 160 181 @MAINT_MAKEFILE@ -
branches/GNU/src/gmake/NEWS
r153 r280 1 1 GNU make NEWS -*-indented-text-*- 2 2 History of user-visible changes. 3 06 March 20044 5 Copyright (C) 2002,2003,2004 Free Software Foundation, Inc.3 13 May 2005 4 5 Copyright (C) 2002,2003,2004,2005 Free Software Foundation, Inc. 6 6 See the end for copying conditions. 7 7 8 8 All changes mentioned here are more fully described in the GNU make 9 9 manual, which is contained in this distribution as the file doc/make.texi. 10 11 Please send GNU make bug reports to <[email protected]>. 12 See the README file and the GNU make manual for details on reporting bugs. 13 14 15 Version 3.81beta1 10 See the README file and the GNU make manual for instructions for 11 reporting bugs. 12 13 14 Version 3.81beta3 16 15 17 16 * GNU make is ported to OS/2. 18 Port provided by Andreas Buening <[email protected]>. 17 18 * GNU make is ported to MinGW. 19 20 * WARNING: Backward-incompatibility! 21 GNU make now implements a generic "second expansion" feature on the 22 prerequisites of both explicit and implicit (pattern) rules. After 23 all rules have been parsed the prerequisites are expanded again, this 24 time with all the automatic variables in scope. This means that in 25 addition to using standard SysV $$@ in prerequisites lists, you can 26 also use complex functions such as $$(notdir $$@) etc. This behavior 27 applies to implicit rules, as well, where the second expansion occurs 28 after the rule is matched. However, this means that you need to 29 double-quote any "$" in your filenames; instead of "foo: boo$$bar" you 30 must write "foo: foo$$$$bar" 31 32 * New command-line option: -L (--check-symlink-times). On systems that 33 support symbolic links, if this option is given then GNU make will 34 use the most recent modification time of any symbolic links that are 35 used to resolve target files. The default behavior remains as it 36 always has: use the modification time of the actual target file only. 37 38 * The "else" conditional line can now be followed by any other legal 39 conditional on the same line: this does not increase the depth of the 40 conditional nesting. 19 41 20 42 * All pattern-specific variables that match a given target are now used … … 30 52 This version of GNU make uses an algorithm suggested by Thomas Riedl 31 53 <[email protected]> to track the number of jobs started in the 32 last second and adjust GNU make's view of the system's load average 33 accordingly. 34 35 * Enhancements for POSIX compatibility: 54 last second and artificially adjust GNU make's view of the system's 55 load average accordingly. 56 57 * New special variables available in this release: 58 - .FEATURES: Contains a list of special features available in this 59 version of GNU make. 60 - .DEFAULT_GOAL: Set the name of the default goal make will 61 use if no goals are provided on the command line. 62 - New automatic variable: $| (added in 3.80, actually): contains all 63 the order-only prerequisites defined for the target. 64 65 * New functions available in this release: 66 - $(lastword ...) returns the last word in the list. This gives 67 identical results as $(word $(words ...) ...), but is much faster. 68 - $(abspath ...) returns the absolute path (all "." and ".." 69 directories resolved, and any duplicate "/" characters removed) for 70 each path provided. 71 - $(realpath ...) returns the canonical pathname for each path 72 provided. The canonical pathname is the absolute pathname, with 73 all symbolic links resolved as well. 74 - $(info ...) prints informative messages to stdout. No makefile 75 name or line number info, etc. is printed, just the message. 76 77 * Changes made for POSIX compatibility: 36 78 - Only touch targets (under -t) if they have at least one command. 79 - Setting the SHELL make variable does NOT change the value of the 80 SHELL environment variable given to programs invoked by make. As 81 an enhancement to POSIX, if you export the make variable SHELL then 82 it will be set in the environment, just as before. 83 84 * On DOS and MS Windows systems, explicitly setting SHELL to a pathname 85 ending in "cmd" or "cmd.exe" (case-insensitive) will force GNU make to 86 use the DOS command interpreter in batch mode even if a UNIX-like 87 shell could be found on the system. 37 88 38 89 * Updated to autoconf 2.59, automake 1.8.2, and gettext 0.14.1. Users 39 90 should not be impacted. 91 92 * New translations for Swedish, Chinese (simplified), Ukrainian, 93 Belarusian, Finnish, Kinyarwandan, and Irish. Many updated 94 translations. 40 95 41 96 -
branches/GNU/src/gmake/NMakefile.template
r54 r280 26 26 LINK = link 27 27 CC = cl 28 MAKE = nmake 28 29 29 30 OUTDIR=. -
branches/GNU/src/gmake/README.OS2.template
r54 r280 47 47 48 48 - sh compatible shell (ksh, bash, ash, but tested only with pdksh 5.2.14 49 (release 2)49 release 2) 50 50 If you use pdksh it is recommended to update to 5.2.14 release 2. Older 51 51 versions may not work! You can get this version at … … 60 60 - grep 61 61 - sed 62 - GNU make 3.79.1 (special OS/2 patched version) 62 - GNU make 3.79.1 (special OS/2 patched version) or higher 63 63 - perl 5.005 or higher 64 64 - GNU texinfo (you can use 3.1 (gnuinfo.zip), but I recommend 4.0) 65 65 66 66 If you want to recreate the configuration files (developers only!) 67 you need also: GNU m4 1.4, autoconf 2.5 7, automake 1.7.2 (or compatible)67 you need also: GNU m4 1.4, autoconf 2.59, automake 1.8.2 (or compatible) 68 68 69 69 … … 148 148 149 149 export CPPFLAGS="-D__ST_MT_ERRNO__ -DNO_CMD_DEFAULT -DNO_CHDIR2" 150 export CFLAGS="-Zomf -O2 - s -Zmt"151 export LDFLAGS="-Zcrtdll - Zmt -s -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack 0x8000"150 export CFLAGS="-Zomf -O2 -Zmt" 151 export LDFLAGS="-Zcrtdll -s -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack 0x8000" 152 152 export RANLIB="echo" 153 153 ./configure --prefix=x:/usr --disable-nls 154 154 make AR=emxomfar 155 make check s155 make check 156 156 157 157 All tests should work fine with the exception of "default_names" which -
branches/GNU/src/gmake/README.W32.template
r54 r280 6 6 Tulloh, who is also the author of this README. 7 7 8 To build with nmake on Windows NT, Windows 95, or Windows 98:8 To build with nmake on MS-Windows: 9 9 10 10 1. Make sure cl.exe is in your %Path%. Example: … … 64 64 There are very few true ports of Bourne shell for NT right now. 65 65 There is a version of GNU bash available from Cygnus "Cygwin" 66 porting effort (http:// sourceware.cygnus.com/cygwin).66 porting effort (http://www.cygwin.com/). 67 67 Other possibilities are the MKS version of sh.exe, or building 68 68 your own with a package like NutCracker (DataFocus) or Portage 69 (Consensys). 69 (Consensys). Also MinGW includes sh (http://mingw.org/). 70 70 71 71 GNU make and brain-dead shells (BATCH_MODE_ONLY_SHELL): 72 72 73 Some versions of Bourne shell do esnot behave well when invoked73 Some versions of Bourne shell do not behave well when invoked 74 74 as 'sh -c' from CreateProcess(). The main problem is they seem 75 75 to have a hard time handling quoted strings correctly. This can … … 80 80 a batch mode. When BATCH_MODE_ONLY_SHELL is defined at compile 81 81 time, make forces all command lines to be executed via script 82 files instead of by command line. 82 files instead of by command line. In this mode you must have a 83 working sh.exe in order to use parallel builds (-j). 83 84 84 85 A native Windows32 system with no Bourne shell will also run 85 86 in batch mode. All command lines will be put into batch files 86 and executed via $(COMSPEC) (%COMSPEC%). 87 and executed via $(COMSPEC) (%COMSPEC%). Note that parallel 88 builds (-j) require a working Bourne shell; they will not work 89 with COM. 87 90 88 91 GNU make and Cygnus GNU Windows32 tools: … … 129 132 specification of paths. Make is able to figure out the intended 130 133 result and convert the paths internally to the format needed 131 when interacting with the operating system. 134 when interacting with the operating system, providing the path 135 is not within quotes, e.g. "x:/test/test.c". 132 136 133 137 You are encouraged to use colon as the separator character. … … 165 169 166 170 Unlike Unix, Windows 95/NT systems encourage pathnames which 167 contain white space (e.g. C:\Program Files\). These sorts of pathnames 168 are legal under Unix too, but are never encouraged. There is 169 at least one place in make (VPATH/vpath handling) where paths 170 containing white space will simply not work. There may be others 171 too. I chose to not try and port make in such a way so that 172 these sorts of paths could be handled. I offer these suggestions 173 as workarounds: 174 175 1. Use 8.3 notation 171 contain white space (e.g. C:\Program Files\). These sorts of 172 pathnames are legal under Unix too, but are never encouraged. 173 There is at least one place in make (VPATH/vpath handling) where 174 paths containing white space will simply not work. There may be 175 others too. I chose to not try and port make in such a way so 176 that these sorts of paths could be handled. I offer these 177 suggestions as workarounds: 178 179 1. Use 8.3 notation. i.e. "x:/long~1/", which is actually 180 "x:\longpathtest". Type "dir /x" to view these filenames 181 within the cmd.exe shell. 176 182 2. Rename the directory so it does not contain white space. 177 183 -
branches/GNU/src/gmake/README.cvs
r54 r280 24 24 ----------------- 25 25 26 To build GNU make from CVS, you will need Autoconf 2.57 (or better),27 Automake 1.7.3 (or better), and Gettext 0.11.5 (or better), and any 28 tools that those utilities require (GNU m4, Perl, etc.). You will also 29 need a copy of wget.26 To build GNU make from CVS, you will need Autoconf, Automake, and 27 Gettext, and any tools that those utilities require (GNU m4, Perl, 28 etc.). See the configure.in file to find the minimum versions of each 29 of these tools. You will also need a copy of wget. 30 30 31 31 After checking out the code, you will need to perform these steps to get -
branches/GNU/src/gmake/README.template
r54 r280 71 71 project to submit new problem reports or search for existing ones: 72 72 73 http://savannah.gnu.org/bugs/?group _id=7173 http://savannah.gnu.org/bugs/?group=make 74 74 75 75 If you need help using GNU make, try these forums: … … 80 80 news:gnu.utils.bug 81 81 82 http://savannah.gnu.org/support/?group _id=7182 http://savannah.gnu.org/support/?group=make 83 83 84 84 You may also find interesting patches to GNU Make available here: 85 85 86 http://savannah.gnu.org/patch/?group _id=7186 http://savannah.gnu.org/patch/?group=make 87 87 88 88 Note these patches are provided by our users as a service and we make no … … 98 98 GNU Subversions CVS server; look here for details: 99 99 100 http://savannah.gnu.org/cvs/?group _id=71100 http://savannah.gnu.org/cvs/?group=make 101 101 102 102 Please note: you won't be able to build GNU make from CVS without … … 113 113 114 114 It has been reported that the XLC 1.2 compiler on AIX 3.2 is buggy such 115 that if you compile make with `cc -O' on AIX 3.2, it will not work correctly. 116 It is said that using `cc' without `-O' does work. 115 that if you compile make with `cc -O' on AIX 3.2, it will not work 116 correctly. It is said that using `cc' without `-O' does work. 117 118 The standard /bin/sh on SunOS 4.1.3_U1 and 4.1.4 is broken and cannot be 119 used to configure GNU make. Please install a different shell such as 120 bash or pdksh in order to run "configure". See this message for more 121 information: 122 http://mail.gnu.org/archive/html/bug-autoconf/2003-10/msg00190.html 117 123 118 124 One area that is often a problem in configuration and porting is the code -
branches/GNU/src/gmake/build.template
r54 r280 3 3 # @configure_input@ 4 4 5 # Copyright (C) 1993, 1994, 1997, 2003 Free Software Foundation, Inc.5 # Copyright (C) 1993, 1994, 1997, 2003, 2004 Free Software Foundation, Inc. 6 6 # This file is part of GNU Make. 7 7 # … … 29 29 LDFLAGS='@LDFLAGS@' 30 30 ALLOCA='@ALLOCA@' 31 LOADLIBES='@LIBS@ '31 LOADLIBES='@LIBS@ @LIBINTL@' 32 32 eval extras=\'@LIBOBJS@\' 33 33 REMOTE='@REMOTE@' … … 79 79 # Link all the objects together. 80 80 echo linking make... 81 $CC $ LDFLAGS $objs $LOADLIBES -o makenew${EXEEXT}81 $CC $CFLAGS $LDFLAGS $objs $LOADLIBES -o makenew${EXEEXT} 82 82 echo done 83 83 mv -f makenew${EXEEXT} make${EXEEXT} -
branches/GNU/src/gmake/commands.c
r153 r280 40 40 /* Set FILE's automatic variables up. */ 41 41 42 staticvoid42 void 43 43 set_file_variables (struct file *file) 44 44 { 45 struct dep *d; 45 46 char *at, *percent, *star, *less; 46 47 … … 107 108 star = file->stem; 108 109 109 /* $< is the first dependency. */ 110 less = file->deps != 0 ? dep_name (file->deps) : ""; 110 /* $< is the first not order-only dependency. */ 111 less = ""; 112 for (d = file->deps; d != 0; d = d->next) 113 if (!d->ignore_mtime) 114 { 115 less = dep_name (d); 116 break; 117 } 111 118 112 119 if (file->cmds == default_file->cmds) … … 136 143 char *qp; 137 144 char *bp; 138 struct dep *d;139 145 unsigned int len; 140 146 … … 343 349 break; 344 350 } 345 if (!(flags & COMMANDS_RECURSE)) 346 { 347 unsigned int len = strlen (p); 348 if (sindex (p, len, "$(MAKE)", 7) != 0 349 || sindex (p, len, "${MAKE}", 7) != 0) 350 flags |= COMMANDS_RECURSE; 351 } 351 352 /* If no explicit '+' was given, look for MAKE variable references. */ 353 if (!(flags & COMMANDS_RECURSE) 354 && (strstr (p, "$(MAKE)") != 0 || strstr (p, "${MAKE}") != 0)) 355 flags |= COMMANDS_RECURSE; 352 356 353 357 cmds->lines_flags[idx] = flags; … … 482 486 #endif 483 487 488 #ifdef WINDOWS32 489 /* Cannot call W32_kill with a pid (it needs a handle) */ 490 exit (EXIT_FAILURE); 491 #else 484 492 /* Signal the same code; this time it will really be fatal. The signal 485 493 will be unblocked when we return and arrive then to kill us. */ 486 494 if (kill (getpid (), sig) < 0) 487 495 pfatal_with_name ("kill"); 496 #endif /* not WINDOWS32 */ 488 497 #endif /* not Amiga */ 489 498 #endif /* not __MSDOS__ */ -
branches/GNU/src/gmake/commands.h
r54 r280 41 41 extern void delete_child_targets PARAMS ((struct child *child)); 42 42 extern void chop_commands PARAMS ((struct commands *cmds)); 43 extern void set_file_variables PARAMS ((struct file *file)); -
branches/GNU/src/gmake/config
- Property svn:ignore
-
old new 1 1 *.m4 2 2 config.* 3 mkinstalldirs 4 texinfo.tex 3 5 Makefile 4 6 Makefile.in
-
- Property svn:ignore
-
branches/GNU/src/gmake/config.ami.template
r54 r280 147 147 /* #undef STAT_MACROS_BROKEN */ 148 148 149 /* Define if your compiler conforms to the ANSI C standard. */ 150 #define HAVE_ANSI_COMPILER 1 151 149 152 /* Define if you have the ANSI C header files. */ 150 153 #define STDC_HEADERS … … 278 281 /* #undef HAVE_NDIR_H */ 279 282 283 /* Define to 1 if you have the <stdarg.h> header file. */ 284 #define HAVE_STDARG_H 1 285 280 286 /* Define if you have the <stdlib.h> header file. */ 281 287 /* #undef HAVE_STDLIB_H */ -
branches/GNU/src/gmake/config.h-vms.template
r54 r280 306 306 /* Define if you have the <ndir.h> header file. */ 307 307 /* #undef HAVE_NDIR_H */ 308 309 /* Define if your compiler conforms to the ANSI C standard. */ 310 #define HAVE_ANSI_COMPILER 1 311 312 /* Define to 1 if you have the <stdarg.h> header file. */ 313 #define HAVE_STDARG_H 1 308 314 309 315 /* Define if you have the <stdlib.h> header file. */ -
branches/GNU/src/gmake/config.h.W32.template
r54 r280 159 159 /* #undef STAT_MACROS_BROKEN */ 160 160 161 /* Define if your compiler conforms to the ANSI C standard. */ 162 #define HAVE_ANSI_COMPILER 1 163 164 /* Define to 1 if you have the <stdarg.h> header file. */ 165 #define HAVE_STDARG_H 1 166 161 167 /* Define if you have the ANSI C header files. */ 162 168 #undef STDC_HEADERS -
branches/GNU/src/gmake/config/.cvsignore
r53 r280 1 1 *.m4 2 2 config.* 3 mkinstalldirs 4 texinfo.tex 3 5 4 6 Makefile Makefile.in -
branches/GNU/src/gmake/configh.dos.template
r54 r280 57 57 #define HAVE_SELECT 1 58 58 59 /* Define if your compiler conforms to the ANSI C standard. */ 60 #define HAVE_ANSI_COMPILER 1 61 62 /* Define to 1 if you have the <stdarg.h> header file. */ 63 #define HAVE_STDARG_H 1 64 59 65 /* Define if you have the vprintf library function. */ 60 66 #undef HAVE_VPRINTF -
branches/GNU/src/gmake/configure.in
r153 r280 1 1 # Process this file with autoconf to produce a configure script. 2 2 3 AC_INIT([GNU make],[3.81beta 1],[[email protected]])3 AC_INIT([GNU make],[3.81beta3],[[email protected]]) 4 4 5 5 AC_PREREQ(2.59) 6 AC_REVISION([[$Id: configure.in,v 1.1 25 2004/03/06 08:05:19psmith Exp $]])6 AC_REVISION([[$Id: configure.in,v 1.135 2005/05/10 01:38:18 psmith Exp $]]) 7 7 8 8 # Autoconf setup … … 51 51 AC_HEADER_TIME 52 52 AC_CHECK_HEADERS(stdlib.h locale.h unistd.h limits.h fcntl.h string.h \ 53 memory.h sys/param.h sys/ time.h sys/timeb.h)53 memory.h sys/param.h sys/resource.h sys/time.h sys/timeb.h) 54 54 55 55 # Set a flag if we have an ANSI C compiler … … 135 135 136 136 AC_CHECK_FUNCS( memcpy memmove strchr strdup mkstemp mktemp fdopen \ 137 bsd_signal dup2 getcwd sigsetmask sigaction getgroups \ 138 seteuid setegid setlinebuf setreuid setregid setvbuf pipe \ 139 strerror strsignal) 137 bsd_signal dup2 getcwd realpath sigsetmask sigaction \ 138 getgroups seteuid setegid setlinebuf setreuid setregid \ 139 getrlimit setrlimit setvbuf pipe strerror strsignal \ 140 lstat readlink) 140 141 141 142 AC_FUNC_SETVBUF_REVERSED … … 167 168 fi 168 169 169 AC_CHECK_DECLS([sys_siglist]) 170 AC_CHECK_DECLS([sys_siglist],,, 171 [#include <signal.h> 172 /* NetBSD declares sys_siglist in unistd.h. */ 173 #if HAVE_UNISTD_H 174 # include <unistd.h> 175 #endif 176 ]) 170 177 171 178 … … 236 243 AM_CONDITIONAL(USE_CUSTOMS, test "$use_customs" = true) 237 244 245 # See if the user asked to handle case insensitive file systems. 246 247 AH_TEMPLATE(HAVE_CASE_INSENSITIVE_FS, [Use case insensitive file names]) 248 AC_ARG_ENABLE(case-insensitive-file-system, 249 AC_HELP_STRING([--enable-case-insensitive-file-system], 250 [enable case insensitive file system support]), 251 case_insensitive_fs="yes" AC_DEFINE(HAVE_CASE_INSENSITIVE_FS), 252 case_insensitive_fs="no") 253 238 254 # See if we can handle the job server feature, and if the user wants it. 239 255 … … 255 271 [make_cv_sa_restart=no])]) 256 272 257 # enable make_cv_sa_restart for OS/2258 case "$host_os" in259 os2*) make_cv_sa_restart=yes ;;260 esac261 262 273 if test "$make_cv_sa_restart" != no; then 263 274 AC_DEFINE(HAVE_SA_RESTART, 1, 264 275 [Define if <signal.h> defines the SA_RESTART constant.]) 265 276 fi 277 278 # enable make_cv_sa_restart for OS/2 so that the jobserver will be enabled, 279 # but do it after HAVE_SA_RESTART has been defined. 280 case "$host_os" in 281 os2*) make_cv_sa_restart=yes ;; 282 esac 266 283 267 284 case "$ac_cv_func_pipe/$ac_cv_func_sigaction/$make_cv_sa_restart/$has_wait_nohang/$make_cv_job_server" in … … 269 286 AC_DEFINE(MAKE_JOBSERVER, 1, 270 287 [Define this to enable job server support in GNU make.]);; 288 esac 289 290 # if we have both lstat() and readlink() then we can support symlink 291 # timechecks. 292 case "$ac_cv_func_lstat/$ac_cv_func_readlink" in 293 yes/yes) 294 AC_DEFINE(MAKE_SYMLINKS, 1, 295 [Define this to enable symbolic link timestamp checking.]);; 271 296 esac 272 297 … … 331 356 AC_SUBST(MAKE_HOST) 332 357 358 w32_target_env=no 359 AM_CONDITIONAL([WINDOWSENV], false) 360 361 case "$host" in 362 *-*-mingw32) 363 AM_CONDITIONAL(WINDOWSENV, true) 364 w32_target_env=yes 365 AC_DEFINE([WINDOWS32], [1], [Use platform specific coding]) 366 AC_DEFINE([HAVE_DOS_PATHS], [1], [Use platform specific coding]) 367 ;; 368 esac 369 333 370 # Include the Maintainer's Makefile section, if it's here. 334 371 … … 389 426 390 427 # Specify what files are to be created. 428 AC_CONFIG_FILES(Makefile glob/Makefile po/Makefile.in config/Makefile doc/Makefile w32/Makefile) 429 430 # OK, do it! 431 432 AC_OUTPUT 433 391 434 # We only generate the build.sh if we have a build.sh.in; we won't have 392 435 # one before we've created a distribution. 393 394 AC_CONFIG_FILES(Makefile glob/Makefile po/Makefile.in config/Makefile doc/Makefile) 395 396 if test -f $srcdir/build.sh.in; then 397 AC_CONFIG_FILES(build.sh) 398 fi 399 400 401 # OK, do it! 402 403 AC_OUTPUT 404 436 if test -f build.sh.in; then 437 ./config.status --file build.sh 438 chmod +x build.sh 439 fi 405 440 406 441 dnl Local Variables: -
branches/GNU/src/gmake/default.c
r54 r280 309 309 #ifdef __ALPHA 310 310 "ARCH", "ALPHA", 311 #else 311 #endif 312 #ifdef __ia64 313 "ARCH", "IA64", 314 #endif 315 #ifdef __VAX 312 316 "ARCH", "VAX", 313 317 #endif -
branches/GNU/src/gmake/dep.h
r54 r280 41 41 unsigned int changed : 8; 42 42 unsigned int ignore_mtime : 1; 43 unsigned int need_2nd_expansion : 1; 43 44 }; 44 45 … … 73 74 74 75 extern struct dep *copy_dep_chain PARAMS ((struct dep *d)); 76 extern void free_ns_chain PARAMS ((struct nameseq *n)); 75 77 extern struct dep *read_all_makefiles PARAMS ((char **makefiles)); 76 78 extern int eval_buffer PARAMS ((char *buffer)); 77 extern int update_goal_chain PARAMS ((struct dep *goals , int makefiles));79 extern int update_goal_chain PARAMS ((struct dep *goals)); 78 80 extern void uniquize_deps PARAMS ((struct dep *)); -
branches/GNU/src/gmake/dir.c
r54 r280 124 124 downcase (char *filename) 125 125 { 126 #ifdef _AMIGA 127 static char new_filename[136]; 128 #else 129 static char new_filename[PATH_MAX]; 130 #endif 126 static PATH_VAR (new_filename); 131 127 char *df; 132 128 int i; … … 1142 1138 d = (struct dirent *) buf; 1143 1139 #ifdef __MINGW32__ 1144 # if __MINGW32_ VERSION_MAJOR < 3 || (__MINGW32_VERSION_MAJOR== 3 && \1145 __MINGW32_ VERSION_MINOR== 0)1140 # if __MINGW32_MAJOR_VERSION < 3 || (__MINGW32_MAJOR_VERSION == 3 && \ 1141 __MINGW32_MINOR_VERSION == 0) 1146 1142 d->d_name = xmalloc(len); 1147 1143 # endif … … 1163 1159 1164 1160 static void 1165 ansi_free (void *p)1166 { 1167 1168 1161 ansi_free (void *p) 1162 { 1163 if (p) 1164 free(p); 1169 1165 } 1170 1166 -
branches/GNU/src/gmake/doc/make.texi
r153 r280 8 8 @c FSF publishers: format makebook.texi instead of using this file directly. 9 9 10 @set RCSID $Id: make.texi,v 1. 18 2004/02/23 06:25:54psmith Exp $11 @set EDITION 0. 6110 @set RCSID $Id: make.texi,v 1.30 2005/05/13 12:45:31 psmith Exp $ 11 @set EDITION 0.70 12 12 @set VERSION 3.81 13 @set UPDATED 0 2 May 200314 @set UPDATE-MONTH May 200 315 @c omment The ISBN number might need to change on next publication.16 @set ISBN 1-882114-8 1-7 @c From Brian Youmans <[email protected]>, 25 Apr 200013 @set UPDATED 07 May 2005 14 @set UPDATE-MONTH May 2005 15 @c ISBN provided by Lisa M. Opus Goldstein <[email protected]>, 5 May 2004 16 @set ISBN 1-882114-83-5 17 17 18 18 @c finalout … … 40 40 41 41 Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 42 1998, 1999, 2000, 2002, 2003, 2004 42 1998, 1999, 2000, 2002, 2003, 2004, 2005 43 43 Free Software Foundation, Inc. 44 44 … … 163 163 with another makefile. 164 164 * Reading Makefiles:: How makefiles are parsed. 165 * Secondary Expansion:: How and when secondary expansion is performed. 165 166 166 167 Writing Rules … … 339 340 * Install Command Categories:: Three categories of commands in the `install' 340 341 341 Copying This Manual342 343 342 @end detailmenu 344 343 @end menu … … 643 642 prerequisites. These shell commands say how to update the target file. 644 643 A tab character must come at the beginning of every command line to 645 distinguish command slines from other lines in the makefile. (Bear in644 distinguish command lines from other lines in the makefile. (Bear in 646 645 mind that @code{make} does not know anything about how the commands 647 646 work. It is up to you to supply commands that will update the target … … 674 673 names start with @samp{.}). This is called the @dfn{default goal}. 675 674 (@dfn{Goals} are the targets that @code{make} strives ultimately to 676 update. @xref{Goals, , Arguments to Specify the Goals}.) 675 update. You can override this behavior using the command line 676 (@pxref{Goals, , Arguments to Specify the Goals}) or with the 677 @code{.DEFAULT_GOAL} special variable (@pxref{Special Variables, , 678 Other Special Variables}). 677 679 @cindex default goal 678 680 @cindex goal, default … … 956 958 with another makefile. 957 959 * Reading Makefiles:: How makefiles are parsed. 960 * Secondary Expansion:: How and when secondary expansion is performed. 958 961 @end menu 959 962 … … 1224 1227 @cindex makefiles, and @code{MAKEFILE_LIST} variable 1225 1228 @cindex including (@code{MAKEFILE_LIST} variable) 1229 @vindex MAKEFILE_LIST 1226 1230 1227 1231 As @code{make} reads various makefiles, including any obtained from the … … 1240 1244 @example 1241 1245 @group 1242 name1 := $( word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))1246 name1 := $(lastword $(MAKEFILE_LIST)) 1243 1247 1244 1248 include inc.mk 1245 1249 1246 name2 := $( word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))1250 name2 := $(lastword $(MAKEFILE_LIST)) 1247 1251 1248 1252 all: … … 1273 1277 @cindex special variables 1274 1278 1275 GNU @code{make} also supports a special variable. Note that any value 1276 you assign to this variable will be ignored; it will always return its 1277 special value. 1278 1279 @vindex $(.VARIABLES) 1279 GNU @code{make} also supports other special variables. Unless 1280 otherwise documented here, these values lose their special properties 1281 if they are set by a makefile or on the command line. 1282 1283 @table @code 1284 1285 @vindex .DEFAULT_GOAL @r{(define default goal)} 1286 @item .DEFAULT_GOAL 1287 Sets the default goal to be used if no targets were specified on the 1288 command line (@pxref{Goals, , Arguments to Specify the Goals}). The 1289 @code{.DEFAULT_GOAL} variable allows you to discover the current 1290 default goal, restart the default goal selection algorithm by clearing 1291 its value, or to explicitly set the default goal. The following 1292 example illustrates these cases: 1293 1294 @example 1295 @group 1296 # Query the default goal. 1297 ifeq ($(.DEFAULT_GOAL),) 1298 $(warning no default goal is set) 1299 endif 1300 1301 .PHONY: foo 1302 foo: ; @@echo $@@ 1303 1304 $(warning default goal is $(.DEFAULT_GOAL)) 1305 1306 # Reset the default goal. 1307 .DEFAULT_GOAL := 1308 1309 .PHONY: bar 1310 bar: ; @@echo $@@ 1311 1312 $(warning default goal is $(.DEFAULT_GOAL)) 1313 1314 # Set our own. 1315 .DEFAULT_GOAL := foo 1316 @end group 1317 @end example 1318 1319 This makefile prints: 1320 1321 @example 1322 @group 1323 no default goal is set 1324 default goal is foo 1325 default goal is bar 1326 foo 1327 @end group 1328 @end example 1329 1330 Note that assigning more than one target name to @code{.DEFAULT_GOAL} is 1331 illegal and will result in an error. 1332 1280 1333 @vindex .VARIABLES @r{(list of variables)} 1281 The first special variable is @code{.VARIABLES}. When expanded, the 1282 value consists of a list of the @emph{names} of all global variables 1283 defined in all makefiles read up until that point. This includes1284 variables which have empty values, as well as built-in variables 1285 (@pxref{Implicit Variables, , Variables Used by Implicit Rules}), but 1286 d oes not include any variables which are only defined in a1287 t arget-specific context.1288 1289 @c @vindex $(.TARGETS) 1334 @item .VARIABLES 1335 Expands to a list of the @emph{names} of all global variables defined 1336 so far. This includes variables which have empty values, as well as 1337 built-in variables (@pxref{Implicit Variables, , Variables Used by 1338 Implicit Rules}), but does not include any variables which are only 1339 defined in a target-specific context. Note that any value you assign 1340 to this variable will be ignored; it will always return its special 1341 value. 1342 1290 1343 @c @vindex .TARGETS @r{(list of targets)} 1344 @c @item .TARGETS 1291 1345 @c The second special variable is @code{.TARGETS}. When expanded, the 1292 1346 @c value consists of a list of all targets defined in all makefiles read … … 1296 1350 @c file must appear as a target, on the left-hand side of a ``:'', to be 1297 1351 @c considered a target for the purposes of this variable. 1352 1353 @vindex .FEATURES @r{(list of supported features)} 1354 @item .FEATURES 1355 Expands to a list of special features supported by this version of 1356 @code{make}. Possible values include: 1357 1358 @table @samp 1359 @item target-specific 1360 Supports target-specific and pattern-specific variable assignments. 1361 @xref{Target-specific, ,Target-specific Variable Values}. 1362 1363 @item order-only 1364 Supports order-only prerequisites. @xref{Prerequisite Types, ,Types 1365 of Prerequisites}. 1366 1367 @item second-expansion 1368 Supports secondary expansion of prerequisite lists. 1369 1370 @item jobserver 1371 Supports ``job server'' enhanced parallel builds. @xref{Parallel, 1372 ,Parallel Execution}. 1373 1374 @item check-symlink 1375 Supports the @code{-L} (@code{--check-symlink-times}) flag. 1376 @xref{Options Summary, ,Summary of Options}. 1377 1378 @end table 1379 1380 @end table 1298 1381 1299 1382 @node Remaking Makefiles, Overriding Makefiles, Special Variables, Makefiles … … 1425 1508 @file{force} itself and create a prerequisite loop! 1426 1509 1427 @node Reading Makefiles, , Overriding Makefiles, Makefiles1510 @node Reading Makefiles, Secondary Expansion, Overriding Makefiles, Makefiles 1428 1511 @section How @code{make} Reads a Makefile 1429 1512 @cindex reading makefiles … … 1486 1569 All instances of conditional syntax are parsed immediately, in their 1487 1570 entirety; this includes the @code{ifdef}, @code{ifeq}, @code{ifndef}, 1488 and @code{ifneq} forms. 1571 and @code{ifneq} forms. Of course this means that automatic variables 1572 cannot be used in conditional statements, as automatic variables are 1573 not set until the command script for that rule is invoked. If you 1574 need to use automatic variables in a conditional you @emph{must} use 1575 shell conditional syntax, in your command script proper, for these 1576 tests, not @code{make} conditionals. 1489 1577 1490 1578 @subheading Rule Definition … … 1506 1594 general rule is true for explicit rules, pattern rules, suffix rules, 1507 1595 static pattern rules, and simple prerequisite definitions. 1596 1597 @node Secondary Expansion, , Reading Makefiles, Makefiles 1598 @section Secondary Expansion 1599 @cindex secondary expansion 1600 @cindex expansion, secondary 1601 1602 In the previous section we learned that GNU @code{make} works in two 1603 distinct phases: a read-in phase and a target-update phase 1604 (@pxref{Reading Makefiles, , How @code{make} Reads a Makefile}). 1605 There is an extra wrinkle that comes in between those two phases, 1606 right at the end of the read-in phase: at that time, all the 1607 prerequisites of all of the targets are expanded a @emph{second time}. 1608 In most circumstances this secondary expansion will have no effect, 1609 since all variable and function references will have been expanded 1610 during the initial parsing of the makefiles. In order to take 1611 advantage of the secondary expansion phase of the parser, then, it's 1612 necessary to @emph{escape} the variable or function reference in the 1613 makefile. In this case the first expansion merely un-escapes the 1614 reference but doesn't expand it, and expansion is left to the 1615 secondary expansion phase. For example, consider this makefile: 1616 1617 @example 1618 ONEVAR = onefile 1619 TWOVAR = twofile 1620 myfile: $(ONEVAR) $$(TWOVAR) 1621 @end example 1622 1623 After the first expansion phase the prerequisites list of the 1624 @file{myfile} target will be @code{onefile} and @code{$(TWOVAR)}; the 1625 first (unescaped) variable reference to @var{ONEVAR} is expanded, 1626 while the second (escaped) variable reference is simply unescaped, 1627 without being recognized as a variable reference. Now during the 1628 secondary expansion the first word is expanded again but since it 1629 contains no variable or function references it remains the static 1630 value @file{onefile}, while the second word is now a normal reference 1631 to the variable @var{TWOVAR}, which is expanded to the value 1632 @file{twofile}. The final result is that there are two prerequisites, 1633 @file{onefile} and @file{twofile}. 1634 1635 Obviously, this is not a very interesting case since the same result 1636 could more easily have been achieved simply by having both variables 1637 appear, unescaped, in the prerequisites list. One difference becomes 1638 apparent if the variables are reset; consider this example: 1639 1640 @example 1641 AVAR = top 1642 onefile: $(AVAR) 1643 twofile: $$(AVAR) 1644 AVAR = bottom 1645 @end example 1646 1647 Here the prerequisite of @file{onefile} will be expanded immediately, 1648 and resolve to the value @file{top}, while the prerequisite of 1649 @file{twofile} will not be full expanded until the secondary expansion 1650 and yield a value of @file{bottom}. 1651 1652 This is marginally more exciting, but the true power of this feature 1653 only becomes apparent when you discover that secondary expansions 1654 always take place within the scope of the automatic variables for that 1655 target. This means that you can use variables such as @code{$@@}, 1656 @code{$*}, etc. during the second expansion and they will have their 1657 expected values, just as in the command script. All you have to do is 1658 defer the expansion by escaping the @code{$}. Also, secondary 1659 expansion occurs for both explicit and implicit (pattern) rules. 1660 Knowing this, the possible uses for this feature are almost endless. 1661 For example: 1662 1663 @example 1664 main_OBJS := main.o try.o test.o 1665 lib_OBJS := lib.o api.o 1666 1667 main lib: $$($$@@_OBJS) 1668 @end example 1669 1670 Here, after the initial expansion the prerequisites of both the 1671 @file{main} and @file{lib} targets will be @code{$($@@_OBJS)}. During 1672 the secondary expansion, the @code{$@@} variable is set to the name of 1673 the target and so the expansion for the @file{main} target will yield 1674 @code{$(main_OBJS)}, or @code{main.o try.o test.o}, while the 1675 secondary expansion for the @file{lib} target will yield 1676 @code{$(lib_OBJS)}, or @code{lib.o api.o}. 1677 1678 You can also mix functions here, as long as they are properly escaped: 1679 1680 @example 1681 main_SRCS := main.c try.c test.c 1682 lib_SRCS := lib.c api.c 1683 1684 main lib: $$(patsubst %.c,%.o,$$($$@@_SRCS)) 1685 @end example 1686 1687 This version allows users to specify source files rather than object 1688 files, but gives the same resulting prerequisites list as the previous 1689 example. 1690 1691 Evaluation of automatic variables during the secondary expansion 1692 phase, especially of the target name variable @code{$$@@}, behaves 1693 similarly to evaluation within command scripts. However, there are 1694 some subtle differences and ``corner cases'' which come into play for 1695 the different types of rule definitions that @code{make} understands. 1696 The subtleties of using the different automatic variables are 1697 described below. 1698 1699 @subheading Secondary Expansion of Explicit Rules 1700 @cindex secondary expansion and explicit rules 1701 @cindex explicit rules, secondary expansion of 1702 1703 During the secondary expansion of explicit rules, @code{$$@@} and 1704 @code{$$%} evaluate, respectively, to the file name of the target and, 1705 when the target is an archive member, the target member name. The 1706 @code{$$<} variable evaluates to the first prerequisite in the first 1707 rule for this target. @code{$$^} and @code{$$+} evaluate to the list 1708 of all prerequisites of rules @emph{that have already appeared} for 1709 the same target (@code{$$+} with repetitions and @code{$$^} 1710 without). The following example will help illustrate these behaviors: 1711 1712 @example 1713 foo: foo.1 bar.1 $$< $$^ $$+ # line #1 1714 1715 foo: foo.2 bar.2 $$< $$^ $$+ # line #2 1716 1717 foo: foo.3 bar.3 $$< $$^ $$+ # line #3 1718 @end example 1719 1720 For the first line, all three variables (@code{$$<}, @code{$$^}, and 1721 @code{$$+}) expand to the empty string. For the second line, they will 1722 have values @code{foo.1}, @code{foo.1 bar.1}, and @code{foo.1 bar.1} 1723 respectively. For the third they will have values @code{foo.1}, 1724 @code{foo.1 bar.1 foo.2 bar.2}, and @code{foo.1 bar.1 foo.2 bar.2} 1725 respectively. 1726 1727 Rules undergo secondary expansion in makefile order, except that 1728 the rule with the command script is always evaluated last. 1729 1730 The variables @code{$$?} and @code{$$*} are not available and expand 1731 to the empty string. 1732 1733 @subheading Secondary Expansion of Static Pattern Rules 1734 @cindex secondary expansion and static pattern rules 1735 @cindex static pattern rules, secondary expansion of 1736 1737 Rules for secondary expansion of static pattern rules are identical to 1738 those for explicit rules, above, with one exception: for static 1739 pattern rules the @code{$$*} variable is set to the pattern stem. As 1740 with explicit rules, @code{$$?} is not available and expands to the 1741 empty string. 1742 1743 @subheading Secondary Expansion of Implicit Rules 1744 @cindex secondary expansion and implicit rules 1745 @cindex implicit rules, secondary expansion of 1746 1747 As @code{make} searches for an implicit rule, it substitutes the stem 1748 and then performs secondary expansion for every rule with a matching 1749 target pattern. The value of the automatic variables is derived in 1750 the same fashion as for static pattern rules. As an example: 1751 1752 @example 1753 foo: bar 1754 1755 foo foz: fo%: bo% 1756 1757 %oo: $$< $$^ $$+ $$* 1758 @end example 1759 1760 When the implicit rule is tried for target @file{foo}, @code{$$<} 1761 expands to @file{bar}, @code{$$^} expands to @file{bar boo}, 1762 @code{$$+} also expands to @file{bar boo}, and @code{$$*} expands to 1763 @file{f}. 1764 1765 Note that the directory prefix (D), as described in @ref{Implicit Rule 1766 Search, ,Implicit Rule Search Algorithm}, is appended (after 1767 expansion) to all the patterns in the prerequisites list. As an 1768 example: 1769 1770 @example 1771 /tmp/foo.o: 1772 1773 %.o: $$(addsuffix /%.c,foo bar) foo.h 1774 @end example 1775 1776 The prerequisite list after the secondary expansion and directory 1777 prefix reconstruction will be @file{/tmp/foo/foo.c /tmp/var/bar/foo.c 1778 foo.h}. If you are not interested in this reconstruction, you can use 1779 @code{$$*} instead of @code{%} in the prerequisites list. 1508 1780 1509 1781 @node Rules, Commands, Makefiles, Top … … 1636 1908 Because dollar signs are used to start variable references, if you really 1637 1909 want a dollar sign in a rule you must write two of them, @samp{$$} 1638 (@pxref{Using Variables, ,How to Use Variables}). 1910 (@pxref{Using Variables, ,How to Use Variables}). In prerequisite 1911 lists you must actually write @emph{four} dollar signs (@samp{$$$$}), 1912 due to secondary expansion (@pxref{Secondary Expansion}). 1639 1913 You may split a long line by inserting a backslash 1640 1914 followed by a newline, but this is not required, as @code{make} places no … … 2426 2700 2427 2701 @noindent 2428 Now you can say just @samp{make} to remake all three programs, or specify 2429 as arguments the ones to remake (as in @samp{make prog1 prog3}). 2702 Now you can say just @samp{make} to remake all three programs, or 2703 specify as arguments the ones to remake (as in @samp{make prog1 2704 prog3}). Phoniness is not inherited: the prerequisites of a phony 2705 target are not themselves phony, unless explicitly declared to be so. 2430 2706 2431 2707 When one phony target is a prerequisite of another, it serves as a subroutine … … 3163 3439 Note that the @samp{.d} files contain target definitions; you should 3164 3440 be sure to place the @code{include} directive @emph{after} the first, 3165 default targetin your makefiles or run the risk of having a random3166 object file become the default target.3441 default goal in your makefiles or run the risk of having a random 3442 object file become the default goal. 3167 3443 @xref{How Make Works}. 3168 3444 … … 3357 3633 3358 3634 @cindex environment, @code{SHELL} in 3635 @vindex MAKESHELL @r{(MS-DOS alternative to @code{SHELL})} 3359 3636 Unlike most variables, the variable @code{SHELL} is never set from the 3360 3637 environment. This is because the @code{SHELL} environment variable is … … 3733 4010 characters other than letters, numbers, and underscores. 3734 4011 3735 The special variables @code{SHELL} and @code{MAKEFLAGS} are always 3736 exported (unless you unexport them). 3737 @code{MAKEFILES} is exported if you set it to anything. 4012 @cindex SHELL, exported value 4013 The value of the @code{make} variable @code{SHELL} is not exported. 4014 Instead, the value of the @code{SHELL} variable from the invoking 4015 environment is passed to the sub-@code{make}. You can force 4016 @code{make} to export its value for @code{SHELL} by using the 4017 @code{export} directive, described below. 4018 4019 The special variable @code{MAKEFLAGS} is always exported (unless you 4020 unexport it). @code{MAKEFILES} is exported if you set it to anything. 3738 4021 3739 4022 @code{make} automatically passes down variable values that were defined … … 5138 5421 @cindex environment 5139 5422 Variables in @code{make} can come from the environment in which 5140 @code{make} is run. Every environment variable that @code{make} sees when5141 it starts up is transformed into a @code{make} variable with the same name5142 and value. But an explicit assignment in the makefile, or with a command 5143 argument, overrides the environment. (If the @samp{-e} flag is specified, 5144 then values from the environment override assignments in the makefile. 5145 @xref{Options Summary, ,Summary of Options}. 5146 But this is not recommended practice.)5423 @code{make} is run. Every environment variable that @code{make} sees 5424 when it starts up is transformed into a @code{make} variable with the 5425 same name and value. However, an explicit assignment in the makefile, 5426 or with a command argument, overrides the environment. (If the 5427 @samp{-e} flag is specified, then values from the environment override 5428 assignments in the makefile. @xref{Options Summary, ,Summary of 5429 Options}. But this is not recommended practice.) 5147 5430 5148 5431 Thus, by setting the variable @code{CFLAGS} in your environment, you can 5149 5432 cause all C compilations in most makefiles to use the compiler switches you 5150 5433 prefer. This is safe for variables with standard or conventional meanings 5151 because you know that no makefile will use them for other things. ( But5434 because you know that no makefile will use them for other things. (Note 5152 5435 this is not totally reliable; some makefiles set @code{CFLAGS} explicitly 5153 5436 and therefore are not affected by the value in the environment.) 5154 5437 5155 When @code{make} is invoked recursively, variables defined in the5156 outer invocation can be passed to inner invocations through the 5157 environment (@pxref{Recursion, ,Recursive Use of @code{make}}). By 5158 default, only variables that came from the environment or the command 5159 line are passed to recursive invocations. You can use the5160 @code{export} directive to pass other variables. 5161 @xref{Variables/Recursion, , Communicating Variables to a5438 When @code{make} runs a command script, variables defined in the 5439 makefile are placed into the environment of that command. This allows 5440 you to pass values to sub-@code{make} invocations. (@pxref{Recursion, 5441 ,Recursive Use of @code{make}}). By default, only variables that came 5442 from the environment or the command line are passed to recursive 5443 invocations. You can use the @code{export} directive to pass other 5444 variables. @xref{Variables/Recursion, , Communicating Variables to a 5162 5445 Sub-@code{make}}, for full details. 5163 5446 … … 5168 5451 purpose of most makefiles. 5169 5452 5453 @cindex SHELL, import from environment 5170 5454 Such problems would be especially likely with the variable @code{SHELL}, 5171 5455 which is normally present in the environment to specify the user's choice … … 5175 5459 usually not set. @xref{Execution, ,Special handling of SHELL on 5176 5460 MS-DOS}.)@refill 5461 5462 @cindex SHELL, export to environment 5463 The @code{SHELL} variable is special in another way: just as the value 5464 of the @code{make} variable @code{SHELL} is not taken from the 5465 environment, so also it is not placed into the environment of commands 5466 that @code{make} invokes. Instead, the value of @code{SHELL} from the 5467 invoking environment is provided to the command. You can use 5468 @code{export SHELL} to force the value of the @code{make} variable 5469 @code{SHELL} to be placed in the environment of commands. 5177 5470 5178 5471 @node Target-specific, Pattern-specific, Environment, Using Variables … … 5431 5724 @end example 5432 5725 5433 @noindent 5434 If the condition is true, @var{text-if-true} is used; otherwise, 5435 @var{text-if-false} is used instead. The @var{text-if-false} can be any 5436 number of lines of text. 5726 or: 5727 5728 @example 5729 @var{conditional-directive} 5730 @var{text-if-one-is-true} 5731 else @var{conditional-directive} 5732 @var{text-if-true} 5733 else 5734 @var{text-if-false} 5735 endif 5736 @end example 5737 5738 @noindent 5739 There can be as many ``@code{else} @var{conditional-directive}'' 5740 clauses as necessary. Once a given condition is true, 5741 @var{text-if-true} is used and no other clause is used; if no 5742 condition is true then @var{text-if-false} is used. The 5743 @var{text-if-true} and @var{text-if-false} can be any number of lines 5744 of text. 5437 5745 5438 5746 The syntax of the @var{conditional-directive} is the same whether the 5439 conditional is simple or complex. There are four different directives that 5440 test different conditions. Here is a table of them: 5747 conditional is simple or complex; after an @code{else} or not. There 5748 are four different directives that test different conditions. Here is 5749 a table of them: 5441 5750 5442 5751 @table @code … … 5479 5788 5480 5789 @item ifdef @var{variable-name} 5481 If the variable @var{variable-name} has a non-empty value, the 5482 @var{text-if-true} is effective; otherwise, the @var{text-if-false}, 5483 if any, is effective. Variables that have never been defined have an 5484 empty value. The variable @var{variable-name} is itself expanded, so 5485 it could be a variable or function that expands to the name of a 5486 variable. 5790 The @code{ifdef} form takes the @emph{name} of a variable as its 5791 argument, not a reference to a variable. The value of that variable 5792 has a non-empty value, the @var{text-if-true} is effective; otherwise, 5793 the @var{text-if-false}, if any, is effective. Variables that have 5794 never been defined have an empty value. The text @var{variable-name} 5795 is expanded, so it could be a variable or function that expands 5796 to the name of a variable. For example: 5797 5798 @example 5799 bar = true 5800 foo = bar 5801 ifdef $(foo) 5802 frobozz = yes 5803 endif 5804 @end example 5805 5806 The variable reference @code{$(foo)} is expanded, yielding @code{bar}, 5807 which is considered to be the name of a variable. The variable 5808 @code{bar} is not expanded, but its value is examined to determine if 5809 it is non-empty. 5487 5810 5488 5811 Note that @code{ifdef} only tests whether a variable has a value. It … … 5520 5843 If the variable @var{variable-name} has an empty value, the 5521 5844 @var{text-if-true} is effective; otherwise, the @var{text-if-false}, 5522 if any, is effective. 5845 if any, is effective. The rules for expansion and testing of 5846 @var{variable-name} are identical to the @code{ifdef} directive. 5523 5847 @end table 5524 5848 … … 5927 6251 Returns the list of words in @var{text} starting with word @var{s} and 5928 6252 ending with word @var{e} (inclusive). The legitimate values of @var{s} 5929 and @var{e} start from 1. If @var{s} is bigger than the number of words 5930 in @var{text}, the value is empty. If @var{e} is bigger than the number 5931 of words in @var{text}, words up to the end of @var{text} are returned. 5932 If @var{s} is greater than @var{e}, nothing is returned. For example, 6253 start from 1; @var{e} may start from 0. If @var{s} is bigger than the 6254 number of words in @var{text}, the value is empty. If @var{e} is 6255 bigger than the number of words in @var{text}, words up to the end of 6256 @var{text} are returned. If @var{s} is greater than @var{e}, nothing 6257 is returned. For example, 5933 6258 5934 6259 @example … … 5964 6289 @var{text})} is the same as @code{$(word 1,@var{text})}, the 5965 6290 @code{firstword} function is retained for its simplicity.@refill 6291 6292 6293 @item $(lastword @var{names}@dots{}) 6294 @findex lastword 6295 @cindex words, extracting last 6296 The argument @var{names} is regarded as a series of names, separated 6297 by whitespace. The value is the last name in the series. 6298 6299 For example, 6300 6301 @example 6302 $(lastword foo bar) 6303 @end example 6304 6305 @noindent 6306 produces the result @samp{bar}. Although @code{$(lastword 6307 @var{text})} is the same as @code{$(word $(words @var{text}),@var{text})}, 6308 the @code{lastword} function was added for its simplicity and better 6309 performance.@refill 5966 6310 @end table 6311 5967 6312 5968 6313 Here is a realistic example of the use of @code{subst} and … … 6153 6498 that match the pattern. 6154 6499 @xref{Wildcards, ,Using Wildcard Characters in File Names}. 6500 6501 @item $(realpath @var{names}@dots{}) 6502 @findex realpath 6503 @cindex realpath 6504 @cindex file name, realpath of 6505 For each file name in @var{names} return the canonical absolute name. 6506 A canonical name does not contain any @code{.} or @code{..} components, 6507 nor any repeated path separators (@code{/}) or symlinks. In case of a 6508 failure the empty string is returned. Consult the @code{realpath(3)} 6509 documentation for a list of possible failure causes. 6510 6511 @item $(abspath @var{names}@dots{}) 6512 @findex abspath 6513 @cindex abspath 6514 @cindex file name, abspath of 6515 For each file name in @var{names} return an absolute name that does 6516 not contain any @code{.} or @code{..} components, nor any repeated path 6517 separators (@code{/}). Note that in contrast to @code{realpath} 6518 function, @code{abspath} does not resolve symlinks and does not require 6519 the file names to refer to an existing file or directory. Use the 6520 @code{wildcard} function to test for existence. 6155 6521 @end table 6156 6522 … … 6638 7004 sets @code{files} to the expansion of @samp{*.c}. Unless @code{make} is 6639 7005 using a very strange shell, this has the same result as 6640 @w{@samp{$(wildcard *.c)}}.@refill 7006 @w{@samp{$(wildcard *.c)}} (as long as at least one @samp{.c} file 7007 exists).@refill 6641 7008 6642 7009 @node Make Control Functions, , Shell Function, Functions … … 6693 7060 6694 7061 The result of the expansion of this function is the empty string. 7062 7063 @item $(info @var{text}@dots{}) 7064 @findex info 7065 @cindex printing messages 7066 This function does nothing more than print its (expanded) argument(s) 7067 to standard output. No makefile name or line number is added. The 7068 result of the expansion of this function is the empty string. 6695 7069 @end table 6696 7070 … … 6771 7145 programs they describe. If the first rule in the makefile has several 6772 7146 targets, only the first target in the rule becomes the default goal, not 6773 the whole list. 6774 6775 You can specify a different goal or goals with arguments to @code{make}. 6776 Use the name of the goal as an argument. If you specify several goals, 6777 @code{make} processes each of them in turn, in the order you name them. 7147 the whole list. You can manage the selection of the default goal from 7148 within your makefile using the @code{.DEFAULT_GOAL} variable 7149 (@pxref{Special Variables, , Other Special Variables}). 7150 7151 You can also specify a different goal or goals with command-line 7152 arguments to @code{make}. Use the name of the goal as an argument. 7153 If you specify several goals, @code{make} processes each of them in 7154 turn, in the order you name them. 6778 7155 6779 7156 Any target in the makefile may be specified as a goal (unless it … … 6783 7160 implicit rules that say how to make them. 6784 7161 6785 @cindex @code{MAKECMDGOALS}6786 7162 @vindex MAKECMDGOALS 6787 7163 @code{Make} will set the special variable @code{MAKECMDGOALS} to the … … 7308 7684 floating-point number). With no argument, removes a previous load 7309 7685 limit. @xref{Parallel, ,Parallel Execution}. 7686 7687 @item -L 7688 @cindex @code{-L} 7689 @itemx --check-symlink-times 7690 @cindex @code{--check-symlink-times} 7691 On systems that support symbolic links, this option causes @code{make} 7692 to consider the timestamps on any symbolic links in addition to the 7693 timestamp on the file referenced by those links. When this option is 7694 provided, the most recent timestamp among the file and the symbolic 7695 links is taken as the modification time for this target file. 7310 7696 7311 7697 @item -n … … 7520 7906 * Chained Rules:: How to use a chain of implicit rules. 7521 7907 * Pattern Rules:: How to define new implicit rules. 7522 * Last Resort:: How to defin ing commands for rules7523 whichcannot find any.7908 * Last Resort:: How to define commands for rules which 7909 cannot find any. 7524 7910 * Suffix Rules:: The old-fashioned style of implicit rule. 7525 7911 * Implicit Rule Search:: The precise algorithm for applying … … 8372 8758 automatic variable values are available: they only have values within 8373 8759 the command script. In particular, you cannot use them anywhere 8374 within the target or prerequisite lists of a rule; they have no value 8375 there and will expand to the empty string. A common mistake is 8376 attempting to use @code{$@@} within the prerequisites list in a rule; 8377 this will not work. However, see below for information on the 8378 SysV-style @code{$$@@} variables. 8760 within the target list of a rule; they have no value there and will 8761 expand to the empty string. Also, they cannot be accessed directly 8762 within the prerequisite list of a rule. A common mistake is 8763 attempting to use @code{$@@} within the prerequisites list; this will 8764 not work. However, there is a special feature of GNU @code{make}, 8765 secondary expansion (@pxref{Secondary Expansion}), which will allow 8766 automatic variable values to be used in prerequisite lists. 8379 8767 8380 8768 Here is a table of automatic variables: … … 8422 8810 it depends on, no matter how many times each file is listed as a 8423 8811 prerequisite. So if you list a prerequisite more than once for a target, 8424 the value of @code{$^} contains just one copy of the name. 8812 the value of @code{$^} contains just one copy of the name. This list 8813 does @strong{not} contain any of the order-only prerequisites; for those 8814 see the @samp{$|} variable, below. 8425 8815 @cindex prerequisites, list of all 8426 8816 @cindex list of all prerequisites … … 8433 8823 primarily useful for use in linking commands where it is meaningful to 8434 8824 repeat library file names in a particular order. 8825 8826 @vindex $| 8827 @vindex | @r{(automatic variable)} 8828 @item $| 8829 The names of all the order-only prerequisites, with spaces between 8830 them. 8435 8831 8436 8832 @vindex $* … … 8565 8961 as @samp{$(CFLAGS)} refers to the variable named @code{CFLAGS}. 8566 8962 You could just as well use @samp{$(<)} in place of @samp{$<}. 8567 8568 @vindex $$@@8569 @vindex $$(@@D)8570 @vindex $$(@@F)8571 @cindex $$@@, support for8572 GNU @code{make} provides support for the SysV @code{make} feature that8573 allows special variable references @code{$$@@}, @code{$$(@@D)}, and8574 @code{$$(@@F)} (note the required double-''$''!) to appear with the8575 @emph{prerequisites list} (normal automatic variables are available8576 only within a command script). When appearing in a prerequisites8577 list, these variables are expanded to the name of the target, the8578 directory component of the target, and the file component of the8579 target, respectively.8580 8581 Note that these variables are available only within explicit and8582 static pattern (@pxref{Static Pattern, ,Static Pattern Rules}) rules;8583 they have no special significance within implicit (suffix or pattern)8584 rules. Also note that while SysV @code{make} actually expands its8585 entire prerequisite list @emph{twice}, GNU @code{make} does not behave8586 this way: instead it simply expands these special variables without8587 re-expanding any other part of the prerequisites list.8588 8589 This somewhat bizarre feature is included only to provide some8590 compatibility with SysV makefiles. In a native GNU @code{make} file8591 there are other ways to accomplish the same results. This feature is8592 disabled if the special pseudo target @code{.POSIX} is defined.8593 8963 8594 8964 @node Pattern Match, Match-Anything Rules, Automatic Variables, Pattern Rules … … 9446 9816 The built-in variable @samp{MAKE_VERSION} gives the version number of 9447 9817 @code{make}. 9818 @vindex MAKE_VERSION 9448 9819 @end itemize 9449 9820 … … 9635 10006 @end table 9636 10007 9637 Here is a summary of the text manipulation functions (@pxref{Functions}):10008 Here is a summary of the built-in functions (@pxref{Functions}): 9638 10009 9639 10010 @table @code … … 9666 10037 @xref{Text Functions, , Functions for String Substitution and Analysis}. 9667 10038 10039 @item $(word @var{n},@var{text}) 10040 Extract the @var{n}th word (one-origin) of @var{text}.@* 10041 @xref{Text Functions, , Functions for String Substitution and Analysis}. 10042 10043 @item $(words @var{text}) 10044 Count the number of words in @var{text}.@* 10045 @xref{Text Functions, , Functions for String Substitution and Analysis}. 10046 10047 @item $(wordlist @var{s},@var{e},@var{text}) 10048 Returns the list of words in @var{text} from @var{s} to @var{e}.@* 10049 @xref{Text Functions, , Functions for String Substitution and Analysis}. 10050 10051 @item $(firstword @var{names}@dots{}) 10052 Extract the first word of @var{names}.@* 10053 @xref{Text Functions, , Functions for String Substitution and Analysis}. 10054 10055 @item $(lastword @var{names}@dots{}) 10056 Extract the last word of @var{names}.@* 10057 @xref{Text Functions, , Functions for String Substitution and Analysis}. 10058 9668 10059 @item $(dir @var{names}@dots{}) 9669 10060 Extract the directory part of each file name.@* … … 9692 10083 @item $(join @var{list1},@var{list2}) 9693 10084 Join two parallel lists of words.@* 9694 @xref{File Name Functions, ,Functions for File Names}.9695 9696 @item $(word @var{n},@var{text})9697 Extract the @var{n}th word (one-origin) of @var{text}.@*9698 @xref{File Name Functions, ,Functions for File Names}.9699 9700 @item $(words @var{text})9701 Count the number of words in @var{text}.@*9702 @xref{File Name Functions, ,Functions for File Names}.9703 9704 @item $(wordlist @var{s},@var{e},@var{text})9705 Returns the list of words in @var{text} from @var{s} to @var{e}.@*9706 @xref{File Name Functions, ,Functions for File Names}.9707 9708 @item $(firstword @var{names}@dots{})9709 Extract the first word of @var{names}.@*9710 10085 @xref{File Name Functions, ,Functions for File Names}. 9711 10086 … … 9714 10089 @samp{%} pattern).@* 9715 10090 @xref{Wildcard Function, ,The Function @code{wildcard}}. 10091 10092 @item $(realpath @var{names}@dots{}) 10093 For each file name in @var{names}, expand to an absolute name that 10094 does not contain any @code{.}, @code{..}, nor symlinks.@* 10095 @xref{File Name Functions, ,Functions for File Names}. 10096 10097 @item $(abspath @var{names}@dots{}) 10098 For each file name in @var{names}, expand to an absolute name that 10099 does not contain any @code{.} or @code{..} components, but preserves 10100 symlinks.@* 10101 @xref{File Name Functions, ,Functions for File Names}. 9716 10102 9717 10103 @item $(error @var{text}@dots{}) … … 9840 10226 The name of the system default command interpreter, usually @file{/bin/sh}. 9841 10227 You can set @code{SHELL} in the makefile to change the shell used to run 9842 commands. @xref{Execution, ,Command Execution}. 10228 commands. @xref{Execution, ,Command Execution}. The @code{SHELL} 10229 variable is handled specially when importing from and exporting to the 10230 environment. @xref{Environment, ,Using Variable from the Environment}. 9843 10231 9844 10232 @item MAKESHELL … … 9970 10358 command line, and @code{make} couldn't find any makefiles to read in. 9971 10359 The latter means that some makefile was found, but it didn't contain any 9972 default targetand none was given on the command line. GNU @code{make}10360 default goal and none was given on the command line. GNU @code{make} 9973 10361 has nothing to do in these situations. 9974 10362 @xref{Makefile Arguments, ,Arguments to Specify the Makefile}.@refill … … 10221 10609 @end group 10222 10610 10611 .PHONY: all 10223 10612 all: tar rmt tar.info 10224 10613 10225 10614 @group 10615 .PHONY: tar 10226 10616 tar: $(OBJS) 10227 10617 $(CC) $(LDFLAGS) -o $@@ $(OBJS) $(LIBS) … … 10239 10629 10240 10630 @group 10631 .PHONY: install 10241 10632 install: all 10242 10633 $(INSTALL) tar $(bindir)/$(binprefix)tar … … 10267 10658 10268 10659 @group 10660 .PHONY: clean 10269 10661 clean: 10270 10662 rm -f *.o tar rmt testpad testpad.h core … … 10272 10664 10273 10665 @group 10666 .PHONY: distclean 10274 10667 distclean: clean 10275 10668 rm -f TAGS Makefile config.status … … 10277 10670 10278 10671 @group 10672 .PHONY: realclean 10279 10673 realclean: distclean 10280 10674 rm -f tar.info* … … 10282 10676 10283 10677 @group 10678 .PHONY: shar 10284 10679 shar: $(SRCS) $(AUX) 10285 10680 shar $(SRCS) $(AUX) | compress \ … … 10291 10686 10292 10687 @group 10688 .PHONY: dist 10293 10689 dist: $(SRCS) $(AUX) 10294 10690 echo tar-`sed \ -
branches/GNU/src/gmake/expand.c
r54 r280 155 155 warn_undefined (name, length); 156 156 157 if (v == 0 || *v->value == '\0') 157 /* If there's no variable by that name or it has no value, stop now. */ 158 if (v == 0 || (*v->value == '\0' && !v->append)) 158 159 return o; 159 160 … … 306 307 warn_undefined (beg, colon - beg); 307 308 309 /* If the variable is not empty, perform the 310 substitution. */ 308 311 if (v != 0 && *v->value != '\0') 309 312 { 310 char *value = (v->recursive ? recursively_expand (v) 313 char *pattern, *replace, *ppercent, *rpercent; 314 char *value = (v->recursive 315 ? recursively_expand (v) 311 316 : v->value); 312 char *pattern, *percent; 313 if (free_beg) 314 { 315 *subst_end = '\0'; 316 pattern = subst_beg; 317 } 317 318 /* Copy the pattern and the replacement. Add in an 319 extra % at the beginning to use in case there 320 isn't one in the pattern. */ 321 pattern = (char *) alloca (subst_end - subst_beg + 2); 322 *(pattern++) = '%'; 323 bcopy (subst_beg, pattern, subst_end - subst_beg); 324 pattern[subst_end - subst_beg] = '\0'; 325 326 replace = (char *) alloca (replace_end 327 - replace_beg + 2); 328 *(replace++) = '%'; 329 bcopy (replace_beg, replace, 330 replace_end - replace_beg); 331 replace[replace_end - replace_beg] = '\0'; 332 333 /* Look for %. Set the percent pointers properly 334 based on whether we find one or not. */ 335 ppercent = find_percent (pattern); 336 if (ppercent) 337 { 338 ++ppercent; 339 rpercent = 0; 340 } 318 341 else 319 { 320 pattern = (char *) alloca (subst_end - subst_beg 321 + 1); 322 bcopy (subst_beg, pattern, subst_end - subst_beg); 323 pattern[subst_end - subst_beg] = '\0'; 324 } 325 percent = find_percent (pattern); 326 if (percent != 0) 327 { 328 char *replace; 329 if (free_beg) 330 { 331 *replace_end = '\0'; 332 replace = replace_beg; 333 } 334 else 335 { 336 replace = (char *) alloca (replace_end 337 - replace_beg 338 + 1); 339 bcopy (replace_beg, replace, 340 replace_end - replace_beg); 341 replace[replace_end - replace_beg] = '\0'; 342 } 343 344 o = patsubst_expand (o, value, pattern, replace, 345 percent, (char *) 0); 346 } 347 else 348 o = subst_expand (o, value, 349 pattern, replace_beg, 350 strlen (pattern), 351 end - replace_beg, 352 0, 1); 342 { 343 ppercent = pattern; 344 rpercent = replace; 345 --pattern; 346 --replace; 347 } 348 349 o = patsubst_expand (o, value, pattern, replace, 350 ppercent, rpercent); 351 353 352 if (v->recursive) 354 353 free (value); … … 447 446 FILE's commands were found. Expansion uses FILE's variable set list. */ 448 447 449 staticchar *448 char * 450 449 variable_expand_for_file (char *line, struct file *file) 451 450 { -
branches/GNU/src/gmake/file.c
r153 r280 31 31 #include "hash.h" 32 32 33 34 /* Remember whether snap_deps has been invoked: we need this to be sure we 35 don't add new rules (via $(eval ...)) afterwards. In the future it would 36 be nice to support this, but it means we'd need to re-run snap_deps() or 37 at least its functionality... it might mean changing snap_deps() to be run 38 per-file, so we can invoke it after the eval... or remembering which files 39 in the hash have been snapped (a new boolean flag?) and having snap_deps() 40 only work on files which have not yet been snapped. */ 41 int snapped_deps = 0; 33 42 34 43 /* Hash table of files the makefile knows how to make. */ … … 345 354 { 346 355 register struct file *f = *file_slot; 356 /* Is this file eligible for automatic deletion? 357 Yes, IFF: it's marked intermediate, it's not secondary, it wasn't 358 given on the command-line, and it's either a -include makefile or 359 it's not precious. */ 347 360 if (f->intermediate && (f->dontcare || !f->precious) 348 361 && !f->secondary && !f->cmd_target) … … 405 418 } 406 419 420 /* Expand and parse each dependency line. */ 421 static void 422 expand_deps (struct file *f) 423 { 424 struct dep *d, *d1; 425 struct dep *new = 0; 426 struct dep *old = f->deps; 427 unsigned int last_dep_has_cmds = f->updating; 428 int initialized = 0; 429 430 f->updating = 0; 431 f->deps = 0; 432 433 for (d = old; d != 0; d = d->next) 434 { 435 if (d->name != 0) 436 { 437 char *p; 438 439 /* If we need a second expansion on these, set up the file 440 variables, etc. It takes a lot of extra memory and processing 441 to do this, so only do it if it's needed. */ 442 if (! d->need_2nd_expansion) 443 p = d->name; 444 else 445 { 446 /* We are going to do second expansion so initialize file 447 variables for the file. */ 448 if (!initialized) 449 { 450 initialize_file_variables (f, 0); 451 initialized = 1; 452 } 453 454 set_file_variables (f); 455 456 p = variable_expand_for_file (d->name, f); 457 } 458 459 /* Parse the dependencies. */ 460 new = (struct dep *) 461 multi_glob ( 462 parse_file_seq (&p, '|', sizeof (struct dep), 1), 463 sizeof (struct dep)); 464 465 if (*p) 466 { 467 /* Files that follow '|' are special prerequisites that 468 need only exist in order to satisfy the dependency. 469 Their modification times are irrelevant. */ 470 struct dep **d_ptr; 471 472 for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next) 473 ; 474 ++p; 475 476 *d_ptr = (struct dep *) 477 multi_glob ( 478 parse_file_seq (&p, '\0', sizeof (struct dep), 1), 479 sizeof (struct dep)); 480 481 for (d1 = *d_ptr; d1 != 0; d1 = d1->next) 482 d1->ignore_mtime = 1; 483 } 484 485 /* Enter them as files. */ 486 for (d1 = new; d1 != 0; d1 = d1->next) 487 { 488 d1->file = lookup_file (d1->name); 489 if (d1->file == 0) 490 d1->file = enter_file (d1->name); 491 else 492 free (d1->name); 493 d1->name = 0; 494 d1->need_2nd_expansion = 0; 495 } 496 497 /* Add newly parsed deps to f->deps. If this is the last 498 dependency line and this target has commands then put 499 it in front so the last dependency line (the one with 500 commands) ends up being the first. This is important 501 because people expect $< to hold first prerequisite 502 from the rule with commands. If it is not the last 503 dependency line or the rule does not have commands 504 then link it at the end so it appears in makefile 505 order. */ 506 507 if (new != 0) 508 { 509 if (d->next == 0 && last_dep_has_cmds) 510 { 511 struct dep **d_ptr; 512 for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next) 513 ; 514 515 *d_ptr = f->deps; 516 f->deps = new; 517 } 518 else 519 { 520 struct dep **d_ptr; 521 for (d_ptr = &f->deps; *d_ptr; d_ptr = &(*d_ptr)->next) 522 ; 523 524 *d_ptr = new; 525 } 526 } 527 } 528 } 529 530 free_ns_chain ((struct nameseq *) old); 531 } 532 407 533 /* For each dependency of each file, make the `struct dep' point 408 534 at the appropriate `struct file' (which may have to be created). … … 414 540 snap_deps (void) 415 541 { 416 register struct file *f; 417 register struct file *f2; 418 register struct dep *d; 419 register struct file **file_slot_0; 420 register struct file **file_slot; 421 register struct file **file_end; 422 423 /* Enter each dependency name as a file. */ 542 struct file *f; 543 struct file *f2; 544 struct dep *d; 545 struct file **file_slot_0; 546 struct file **file_slot; 547 struct file **file_end; 548 549 /* Perform second expansion and enter each dependency 550 name as a file. */ 551 552 /* Expand .SUFFIXES first; it's dependencies are used for 553 $$* calculation. */ 554 for (f = lookup_file (".SUFFIXES"); f != 0; f = f->prev) 555 expand_deps (f); 556 424 557 /* We must use hash_dump (), because within this loop 425 558 we might add new files to the table, possibly causing … … 428 561 file_end = file_slot_0 + files.ht_fill; 429 562 for (file_slot = file_slot_0; file_slot < file_end; file_slot++) 430 for (f2 = *file_slot; f2 != 0; f2 = f2->prev) 431 for (d = f2->deps; d != 0; d = d->next) 432 if (d->name != 0) 433 { 434 d->file = lookup_file (d->name); 435 if (d->file == 0) 436 d->file = enter_file (d->name); 437 else 438 free (d->name); 439 d->name = 0; 440 } 563 for (f = *file_slot; f != 0; f = f->prev) 564 { 565 if (strcmp (f->name, ".SUFFIXES") != 0) 566 expand_deps (f); 567 } 441 568 free (file_slot_0); 442 569 … … 455 582 for (f2 = d->file; f2 != 0; f2 = f2->prev) 456 583 { 457 /* Mark this file as phony and nonexistent. */584 /* Mark this file as phony nonexistent target. */ 458 585 f2->phony = 1; 586 f2->is_target = 1; 459 587 f2->last_mtime = NONEXISTENT_MTIME; 460 588 f2->mtime_before_update = NONEXISTENT_MTIME; … … 525 653 if (f != 0 && f->is_target) 526 654 not_parallel = 1; 655 656 /* Remember that we've done this. */ 657 snapped_deps = 1; 527 658 } 528 659 … … 687 818 puts (_("# Command-line target.")); 688 819 if (f->dontcare) 689 puts (_("# A default or MAKEFILESmakefile."));820 puts (_("# A default, MAKEFILES, or -include/sinclude makefile.")); 690 821 puts (f->tried_implicit 691 822 ? _("# Implicit rule search has been done.") -
branches/GNU/src/gmake/filedef.h
r153 r280 101 101 102 102 extern struct file *default_goal_file, *suffix_file, *default_file; 103 extern char **default_goal_name; 103 104 104 105 … … 198 199 #define check_renamed(file) \ 199 200 while ((file)->renamed != 0) (file) = (file)->renamed /* No ; here. */ 201 202 /* Have we snapped deps yet? */ 203 extern int snapped_deps; -
branches/GNU/src/gmake/function.c
r153 r280 74 74 the length of SUBST and RLEN is the length of REPLACE. If BY_WORD is 75 75 nonzero, substitutions are done only on matches which are complete 76 whitespace-delimited words. If SUFFIX_ONLY is nonzero, substitutions are 77 done only at the ends of whitespace-delimited words. */ 76 whitespace-delimited words. */ 78 77 79 78 char * 80 79 subst_expand (char *o, char *text, char *subst, char *replace, 81 unsigned int slen, unsigned int rlen, 82 int by_word, int suffix_only) 80 unsigned int slen, unsigned int rlen, int by_word) 83 81 { 84 82 char *t = text; 85 unsigned int tlen = strlen (text);86 83 char *p; 87 84 88 if (slen == 0 && !by_word && !suffix_only)85 if (slen == 0 && !by_word) 89 86 { 90 87 /* The first occurrence of "" in any string is its end. */ 91 o = variable_buffer_output (o, t, tlen);88 o = variable_buffer_output (o, t, strlen (t)); 92 89 if (rlen > 0) 93 90 o = variable_buffer_output (o, replace, rlen); … … 97 94 do 98 95 { 99 if ( (by_word | suffix_only)&& slen == 0)96 if (by_word && slen == 0) 100 97 /* When matching by words, the empty string should match 101 98 the end of each word, rather than the end of the whole text. */ … … 103 100 else 104 101 { 105 p = s index (t, tlen, subst, slen);102 p = strstr (t, subst); 106 103 if (p == 0) 107 104 { 108 105 /* No more matches. Output everything left on the end. */ 109 o = variable_buffer_output (o, t, tlen);106 o = variable_buffer_output (o, t, strlen (t)); 110 107 return o; 111 108 } … … 118 115 /* If we're substituting only by fully matched words, 119 116 or only at the ends of words, check that this case qualifies. */ 120 if ((by_word 121 && ((p > t && !isblank ((unsigned char)p[-1])) 122 || (p[slen] != '\0' && !isblank ((unsigned char)p[slen])))) 123 || (suffix_only 124 && (p[slen] != '\0' && !isblank ((unsigned char)p[slen])))) 117 if (by_word 118 && ((p > text && !isblank ((unsigned char)p[-1])) 119 || (p[slen] != '\0' && !isblank ((unsigned char)p[slen])))) 125 120 /* Struck out. Output the rest of the string that is 126 121 no longer to be replaced. */ … … 130 125 o = variable_buffer_output (o, replace, rlen); 131 126 132 /* Advance T past the string to be replaced ; adjust tlen. */127 /* Advance T past the string to be replaced. */ 133 128 { 134 129 char *nt = p + slen; 135 tlen -= nt - t;136 130 t = nt; 137 131 } … … 140 134 return o; 141 135 } 136 142 137 143 138 … … 147 142 run through find_percent, and PATTERN_PERCENT is the result. 148 143 If REPLACE_PERCENT is not nil, REPLACE has already been 149 run through find_percent, and REPLACE_PERCENT is the result. */ 144 run through find_percent, and REPLACE_PERCENT is the result. 145 Note that we expect PATTERN_PERCENT and REPLACE_PERCENT to point to the 146 character _AFTER_ the %, not to the % itself. 147 */ 150 148 151 149 char * … … 154 152 { 155 153 unsigned int pattern_prepercent_len, pattern_postpercent_len; 156 unsigned int replace_prepercent_len, replace_postpercent_len = 0;154 unsigned int replace_prepercent_len, replace_postpercent_len; 157 155 char *t; 158 156 unsigned int len; … … 161 159 /* We call find_percent on REPLACE before checking PATTERN so that REPLACE 162 160 will be collapsed before we call subst_expand if PATTERN has no %. */ 163 if (replace_percent == 0) 164 replace_percent = find_percent (replace); 165 if (replace_percent != 0) 166 { 167 /* Record the length of REPLACE before and after the % so 168 we don't have to compute these lengths more than once. */ 169 replace_prepercent_len = replace_percent - replace; 170 replace_postpercent_len = strlen (replace_percent + 1); 161 if (!replace_percent) 162 { 163 replace_percent = find_percent (replace); 164 if (replace_percent) 165 ++replace_percent; 166 } 167 168 /* Record the length of REPLACE before and after the % so we don't have to 169 compute these lengths more than once. */ 170 if (replace_percent) 171 { 172 replace_prepercent_len = replace_percent - replace - 1; 173 replace_postpercent_len = strlen (replace_percent); 171 174 } 172 175 else 173 /* We store the length of the replacement 174 so we only need to compute it once. */ 175 replace_prepercent_len = strlen (replace); 176 177 if (pattern_percent == 0) 178 pattern_percent = find_percent (pattern); 179 if (pattern_percent == 0) 176 { 177 replace_prepercent_len = strlen (replace); 178 replace_postpercent_len = 0; 179 } 180 181 if (!pattern_percent) 182 { 183 pattern_percent = find_percent (pattern); 184 if (pattern_percent) 185 ++pattern_percent; 186 } 187 if (!pattern_percent) 180 188 /* With no % in the pattern, this is just a simple substitution. */ 181 189 return subst_expand (o, text, pattern, replace, 182 strlen (pattern), strlen (replace), 1 , 0);190 strlen (pattern), strlen (replace), 1); 183 191 184 192 /* Record the length of PATTERN before and after the % 185 193 so we don't have to compute it more than once. */ 186 pattern_prepercent_len = pattern_percent - pattern ;187 pattern_postpercent_len = strlen (pattern_percent + 1);194 pattern_prepercent_len = pattern_percent - pattern - 1; 195 pattern_postpercent_len = strlen (pattern_percent); 188 196 189 197 while ((t = find_next_token (&text, &len)) != 0) … … 198 206 if (!fail && pattern_prepercent_len > 0 199 207 && (*t != *pattern 200 || t[pattern_prepercent_len - 1] != pattern_percent[- 1]208 || t[pattern_prepercent_len - 1] != pattern_percent[-2] 201 209 || !strneq (t + 1, pattern + 1, pattern_prepercent_len - 1))) 202 210 fail = 1; … … 204 212 /* Does the suffix match? */ 205 213 if (!fail && pattern_postpercent_len > 0 206 && (t[len - 1] != pattern_percent[pattern_postpercent_len ]207 || t[len - pattern_postpercent_len] != pattern_percent[1]214 && (t[len - 1] != pattern_percent[pattern_postpercent_len - 1] 215 || t[len - pattern_postpercent_len] != *pattern_percent 208 216 || !strneq (&t[len - pattern_postpercent_len], 209 &pattern_percent[1], pattern_postpercent_len - 1)))217 pattern_percent, pattern_postpercent_len - 1))) 210 218 fail = 1; 211 219 … … 228 236 + pattern_postpercent_len)); 229 237 /* Output the part of the replacement after the %. */ 230 o = variable_buffer_output (o, replace_percent + 1,238 o = variable_buffer_output (o, replace_percent, 231 239 replace_postpercent_len); 232 240 } … … 648 656 { 649 657 o = subst_expand (o, argv[2], argv[0], argv[1], strlen (argv[0]), 650 strlen (argv[1]), 0 , 0);658 strlen (argv[1]), 0); 651 659 652 660 return o; … … 667 675 } 668 676 677 static char * 678 func_lastword (char *o, char **argv, const char *funcname UNUSED) 679 { 680 unsigned int i; 681 char *words = argv[0]; /* Use a temp variable for find_next_token */ 682 char *p = 0; 683 char *t; 684 685 while ((t = find_next_token (&words, &i))) 686 p = t; 687 688 if (p != 0) 689 o = variable_buffer_output (o, p, i); 690 691 return o; 692 } 669 693 670 694 static char * … … 690 714 * begpp-1. 691 715 */ 692 staticchar *716 char * 693 717 strip_whitespace (const char **begpp, const char **endpp) 694 718 { … … 755 779 756 780 start = atoi (argv[0]); 781 if (start < 1) 782 fatal (reading_file, 783 "invalid first argument to `wordlist' function: `%d'", start); 784 757 785 count = atoi (argv[1]) - start + 1; 758 786 … … 784 812 { 785 813 /* Find the first occurrence of the first string in the second. */ 786 int i = strlen (argv[0]); 787 if (sindex (argv[1], 0, argv[0], i) != 0) 788 o = variable_buffer_output (o, argv[0], i); 814 if (strstr (argv[1], argv[0]) != 0) 815 o = variable_buffer_output (o, argv[0], strlen (argv[0])); 789 816 790 817 return o; … … 1067 1094 strcpy (p, *argvp); 1068 1095 1069 if (*funcname == 'e') 1070 fatal (reading_file, "%s", msg); 1096 switch (*funcname) { 1097 case 'e': 1098 fatal (reading_file, "%s", msg); 1099 1100 case 'w': 1101 error (reading_file, "%s", msg); 1102 break; 1103 1104 case 'i': 1105 printf ("%s\n", msg); 1106 break; 1107 1108 default: 1109 fatal (reading_file, "Internal error: func_error: '%s'", funcname); 1110 } 1071 1111 1072 1112 /* The warning function expands to the empty string. */ 1073 error (reading_file, "%s", msg);1074 1075 1113 return o; 1076 1114 } … … 1457 1495 1458 1496 /* For error messages. */ 1459 if (reading_file != 0)1497 if (reading_file && reading_file->filenm) 1460 1498 { 1461 1499 error_prefix = (char *) alloca (strlen (reading_file->filenm)+11+4); … … 1700 1738 */ 1701 1739 static char * 1702 func_eq (char *o, char **argv, char *funcname)1740 func_eq (char *o, char **argv, char *funcname) 1703 1741 { 1704 1742 int result = ! strcmp (argv[0], argv[1]); … … 1712 1750 */ 1713 1751 static char * 1714 func_not (char *o, char **argv, char *funcname)1715 { 1716 char * 1752 func_not (char *o, char **argv, char *funcname) 1753 { 1754 char *s = argv[0]; 1717 1755 int result = 0; 1718 1756 while (isspace ((unsigned char)*s)) … … 1726 1764 1727 1765 1766 /* Return the absolute name of file NAME which does not contain any `.', 1767 `..' components nor any repeated path separators ('/'). */ 1768 1769 static char * 1770 abspath (const char *name, char *apath) 1771 { 1772 char *dest; 1773 const char *start, *end, *apath_limit; 1774 1775 if (name[0] == '\0' || apath == NULL) 1776 return NULL; 1777 1778 apath_limit = apath + GET_PATH_MAX; 1779 1780 if (name[0] != '/') 1781 { 1782 /* It is unlikely we would make it until here but just to make sure. */ 1783 if (!starting_directory) 1784 return NULL; 1785 1786 strcpy (apath, starting_directory); 1787 1788 dest = strchr (apath, '\0'); 1789 } 1790 else 1791 { 1792 apath[0] = '/'; 1793 dest = apath + 1; 1794 } 1795 1796 for (start = end = name; *start != '\0'; start = end) 1797 { 1798 unsigned long len; 1799 1800 /* Skip sequence of multiple path-separators. */ 1801 while (*start == '/') 1802 ++start; 1803 1804 /* Find end of path component. */ 1805 for (end = start; *end != '\0' && *end != '/'; ++end) 1806 ; 1807 1808 len = end - start; 1809 1810 if (len == 0) 1811 break; 1812 else if (len == 1 && start[0] == '.') 1813 /* nothing */; 1814 else if (len == 2 && start[0] == '.' && start[1] == '.') 1815 { 1816 /* Back up to previous component, ignore if at root already. */ 1817 if (dest > apath + 1) 1818 while ((--dest)[-1] != '/'); 1819 } 1820 else 1821 { 1822 if (dest[-1] != '/') 1823 *dest++ = '/'; 1824 1825 if (dest + len >= apath_limit) 1826 return NULL; 1827 1828 dest = memcpy (dest, start, len); 1829 dest += len; 1830 *dest = '\0'; 1831 } 1832 } 1833 1834 /* Unless it is root strip trailing separator. */ 1835 if (dest > apath + 1 && dest[-1] == '/') 1836 --dest; 1837 1838 *dest = '\0'; 1839 1840 return apath; 1841 } 1842 1843 1844 static char * 1845 func_realpath (char *o, char **argv, const char *funcname UNUSED) 1846 { 1847 /* Expand the argument. */ 1848 char *p = argv[0]; 1849 char *path = 0; 1850 int doneany = 0; 1851 unsigned int len = 0; 1852 PATH_VAR (in); 1853 PATH_VAR (out); 1854 1855 while ((path = find_next_token (&p, &len)) != 0) 1856 { 1857 if (len < GET_PATH_MAX) 1858 { 1859 strncpy (in, path, len); 1860 in[len] = '\0'; 1861 1862 if 1863 ( 1864 #ifdef HAVE_REALPATH 1865 realpath (in, out) 1866 #else 1867 abspath (in, out) 1868 #endif 1869 ) 1870 { 1871 o = variable_buffer_output (o, out, strlen (out)); 1872 o = variable_buffer_output (o, " ", 1); 1873 doneany = 1; 1874 } 1875 } 1876 } 1877 1878 /* Kill last space. */ 1879 if (doneany) 1880 --o; 1881 1882 return o; 1883 } 1884 1885 static char * 1886 func_abspath (char *o, char **argv, const char *funcname UNUSED) 1887 { 1888 /* Expand the argument. */ 1889 char *p = argv[0]; 1890 char *path = 0; 1891 int doneany = 0; 1892 unsigned int len = 0; 1893 PATH_VAR (in); 1894 PATH_VAR (out); 1895 1896 while ((path = find_next_token (&p, &len)) != 0) 1897 { 1898 if (len < GET_PATH_MAX) 1899 { 1900 strncpy (in, path, len); 1901 in[len] = '\0'; 1902 1903 if (abspath (in, out)) 1904 { 1905 o = variable_buffer_output (o, out, strlen (out)); 1906 o = variable_buffer_output (o, " ", 1); 1907 doneany = 1; 1908 } 1909 } 1910 } 1911 1912 /* Kill last space. */ 1913 if (doneany) 1914 --o; 1915 1916 return o; 1917 } 1918 1728 1919 /* Lookup table for builtin functions. 1729 1920 … … 1744 1935 { 1745 1936 /* Name/size */ /* MIN MAX EXP? Function */ 1937 { STRING_SIZE_TUPLE("abspath"), 0, 1, 1, func_abspath}, 1746 1938 { STRING_SIZE_TUPLE("addprefix"), 2, 2, 1, func_addsuffix_addprefix}, 1747 1939 { STRING_SIZE_TUPLE("addsuffix"), 2, 2, 1, func_addsuffix_addprefix}, … … 1756 1948 { STRING_SIZE_TUPLE("firstword"), 0, 1, 1, func_firstword}, 1757 1949 { STRING_SIZE_TUPLE("join"), 2, 2, 1, func_join}, 1950 { STRING_SIZE_TUPLE("lastword"), 0, 1, 1, func_lastword}, 1758 1951 { STRING_SIZE_TUPLE("patsubst"), 3, 3, 1, func_patsubst}, 1952 { STRING_SIZE_TUPLE("realpath"), 0, 1, 1, func_realpath}, 1759 1953 { STRING_SIZE_TUPLE("shell"), 0, 1, 1, func_shell}, 1760 1954 { STRING_SIZE_TUPLE("sort"), 0, 1, 1, func_sort}, … … 1767 1961 { STRING_SIZE_TUPLE("foreach"), 3, 3, 0, func_foreach}, 1768 1962 { STRING_SIZE_TUPLE("call"), 1, 0, 1, func_call}, 1963 { STRING_SIZE_TUPLE("info"), 0, 1, 1, func_error}, 1769 1964 { STRING_SIZE_TUPLE("error"), 0, 1, 1, func_error}, 1770 1965 { STRING_SIZE_TUPLE("warning"), 0, 1, 1, func_error}, -
branches/GNU/src/gmake/getloadavg.c
r54 r280 356 356 /* LOAD_AVE_TYPE should only get defined if we're going to use the 357 357 nlist method. */ 358 # if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL)) 358 # if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL)) && !defined(__riscos__) 359 359 # define LOAD_AVE_TYPE double 360 360 # endif -
branches/GNU/src/gmake/glob/ChangeLog
r53 r280 1 2005-03-11 Paul D. Smith <[email protected]> 2 3 * glob.c (glob_in_dir): Change FNM_CASEFOLD to be enabled if 4 HAVE_CASE_INSENSITIVE_FS is defined. 5 1 6 2003-01-30 Paul D. Smith <[email protected]> 2 7 -
branches/GNU/src/gmake/glob/glob.c
r53 r280 1305 1305 int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) 1306 1306 | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) 1307 #if defined _AMIGA || defined VMS1307 #if defined HAVE_CASE_INSENSITIVE_FS 1308 1308 | FNM_CASEFOLD 1309 1309 #endif -
branches/GNU/src/gmake/implicit.c
r153 r280 1 1 /* Implicit rule searching for GNU Make. 2 Copyright (C) 1988, 89,90,91,92,93,94,97,2000Free Software Foundation, Inc.2 Copyright (C) 1988,1989,1990,1991,1992,1993,1994,1997,2000,2004,2005 Free Software Foundation, Inc. 3 3 This file is part of GNU Make. 4 4 … … 23 23 #include "dep.h" 24 24 #include "debug.h" 25 26 static int pattern_search PARAMS ((struct file *file, int archive, unsigned int depth, 27 unsigned int recursions)); 25 #include "variable.h" 26 #include "job.h" /* struct child, used inside commands.h */ 27 #include "commands.h" /* set_file_variables */ 28 29 static int 30 pattern_search PARAMS ((struct file *file, int archive, 31 unsigned int depth, unsigned int recursions)); 28 32 29 33 … … 64 68 65 69 70 /* Struct idep captures information about implicit prerequisites 71 that come from implicit rules. */ 72 struct idep 73 { 74 struct idep *next; /* struct dep -compatible interface */ 75 char *name; /* name of the prerequisite */ 76 struct file *intermediate_file; /* intermediate file, 0 otherwise */ 77 char *intermediate_pattern; /* pattern for intermediate file */ 78 unsigned char had_stem; /* had % substituted with stem */ 79 unsigned char ignore_mtime; /* ignore_mtime flag */ 80 }; 81 82 static void 83 free_idep_chain (struct idep* p) 84 { 85 register struct idep* n; 86 register struct file *f; 87 88 for (; p != 0; p = n) 89 { 90 n = p->next; 91 92 if (p->name) 93 { 94 free (p->name); 95 96 f = p->intermediate_file; 97 98 if (f != 0 99 && (f->stem < f->name 100 || f->stem > f->name + strlen (f->name))) 101 free (f->stem); 102 } 103 104 free (p); 105 } 106 } 107 108 109 /* Scans the BUFFER for the next word with whitespace as a separator. 110 Returns the pointer to the beginning of the word. LENGTH hold the 111 length of the word. */ 112 113 static char * 114 get_next_word (char *buffer, unsigned int *length) 115 { 116 char *p = buffer, *beg; 117 char c; 118 119 /* Skip any leading whitespace. */ 120 while (isblank ((unsigned char)*p)) 121 ++p; 122 123 beg = p; 124 c = *(p++); 125 126 if (c == '\0') 127 return 0; 128 129 130 /* We already found the first value of "c", above. */ 131 while (1) 132 { 133 char closeparen; 134 int count; 135 136 switch (c) 137 { 138 case '\0': 139 case ' ': 140 case '\t': 141 goto done_word; 142 143 case '$': 144 c = *(p++); 145 if (c == '$') 146 break; 147 148 /* This is a variable reference, so read it to the matching 149 close paren. */ 150 151 if (c == '(') 152 closeparen = ')'; 153 else if (c == '{') 154 closeparen = '}'; 155 else 156 /* This is a single-letter variable reference. */ 157 break; 158 159 for (count = 0; *p != '\0'; ++p) 160 { 161 if (*p == c) 162 ++count; 163 else if (*p == closeparen && --count < 0) 164 { 165 ++p; 166 break; 167 } 168 } 169 break; 170 171 case '|': 172 goto done; 173 174 default: 175 break; 176 } 177 178 c = *(p++); 179 } 180 done_word: 181 --p; 182 183 done: 184 if (length) 185 *length = p - beg; 186 187 return beg; 188 } 189 66 190 /* Search the pattern rules for a rule with an existing dependency to make 67 191 FILE. If a rule is found, the appropriate commands and deps are put in FILE … … 96 220 struct file *intermediate_file = 0; 97 221 98 /* List of dependencies found recursively. */ 99 struct file **intermediate_files 100 = (struct file **) xmalloc (max_pattern_deps * sizeof (struct file *)); 101 102 /* List of the patterns used to find intermediate files. */ 103 char **intermediate_patterns 104 = (char **) alloca (max_pattern_deps * sizeof (char *)); 105 106 /* This buffer records all the dependencies actually found for a rule. */ 107 char **found_files = (char **) alloca (max_pattern_deps * sizeof (char *)); 108 /* Remember whether the associated dep has an "ignore_mtime" flag set. */ 109 unsigned char *found_files_im = (unsigned char *) alloca (max_pattern_deps * sizeof (unsigned char)); 110 /* Number of dep names now in FOUND_FILES. */ 111 unsigned int deps_found = 0; 222 /* This linked list records all the prerequisites actually 223 found for a rule along with some other useful information 224 (see struct idep for details). */ 225 struct idep* deps = 0; 226 227 /* 1 if we need to remove explicit prerequisites, 0 otherwise. */ 228 unsigned int remove_explicit_deps = 0; 112 229 113 230 /* Names of possible dependencies are constructed in this buffer. */ … … 149 266 register unsigned int i = 0; /* uninit checks OK */ 150 267 register struct rule *rule; 151 register struct dep *dep; 152 153 char *p, *vp; 268 register struct dep *dep, *expl_d; 269 270 char *p, *vname; 271 272 struct idep *d; 273 struct idep **id_ptr; 274 struct dep **d_ptr; 275 276 PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */ 154 277 155 278 #ifndef NO_ARCHIVES … … 298 421 } 299 422 423 /* We are going to do second expansion so initialize file variables 424 for the rule. */ 425 initialize_file_variables (file, 0); 426 300 427 /* Try each rule once without intermediate files, then once with them. */ 301 428 for (intermed_ok = 0; intermed_ok == !!intermed_ok; ++intermed_ok) 302 429 { 303 430 /* Try each pattern rule till we find one that applies. 304 If it does, copy the names ofits dependencies (as substituted)305 and store them in FOUND_FILES. DEPS_FOUND is the number of them. */431 If it does, expand its dependencies (as substituted) 432 and chain them in DEPS. */ 306 433 307 434 for (i = 0; i < nrules; i++) 308 435 { 436 struct file *f; 437 unsigned int failed = 0; 309 438 int check_lastslash; 310 439 311 440 rule = tryrules[i]; 441 442 remove_explicit_deps = 0; 312 443 313 444 /* RULE is nil when we discover that a rule, … … 340 471 (int) stemlen, stem)); 341 472 473 strncpy (stem_str, stem, stemlen); 474 stem_str[stemlen] = '\0'; 475 476 /* Temporary assign STEM to file->stem and set file variables. */ 477 file->stem = stem_str; 478 set_file_variables (file); 479 342 480 /* Try each dependency; see if it "exists". */ 343 481 344 deps_found = 0; 482 /* @@ There is always only one dep line for any given implicit 483 rule. So the loop is not necessary. Can rule->deps be 0? 484 485 Watch out for conversion of suffix rules to implicit rules. 486 */ 487 345 488 for (dep = rule->deps; dep != 0; dep = dep->next) 346 489 { 347 /* If the dependency name has a %, substitute the stem. */ 348 p = strchr (dep_name (dep), '%'); 349 if (p != 0) 350 { 351 register unsigned int i; 352 if (check_lastslash) 353 { 354 /* Copy directory name from the original FILENAME. */ 355 i = lastslash - filename + 1; 356 bcopy (filename, depname, i); 357 } 358 else 359 i = 0; 360 bcopy (dep_name (dep), depname + i, p - dep_name (dep)); 361 i += p - dep_name (dep); 362 bcopy (stem, depname + i, stemlen); 363 i += stemlen; 364 strcpy (depname + i, p + 1); 365 p = depname; 366 } 367 else 368 p = dep_name (dep); 369 370 /* P is now the actual dependency name as substituted. */ 371 372 if (file_impossible_p (p)) 373 { 374 /* If this dependency has already been ruled 375 "impossible", then the rule fails and don't 376 bother trying it on the second pass either 377 since we know that will fail too. */ 378 DBS (DB_IMPLICIT, 379 (p == depname 490 unsigned int len; 491 char *p2; 492 unsigned int order_only = 0; /* Set if '|' was seen. */ 493 494 /* In an ideal world we would take the dependency line, 495 substitute the stem, re-expand the whole line and 496 chop it into individual prerequisites. Unfortunately 497 this won't work because of the "check_lastslash" twist. 498 Instead, we will have to go word by word, taking $()'s 499 into account, for each word we will substitute the stem, 500 re-expand, chop it up, and, if check_lastslash != 0, 501 add the directory part to each resulting prerequisite. */ 502 503 p = get_next_word (dep->name, &len); 504 505 while (1) 506 { 507 int add_dir = 0; 508 int had_stem = 0; 509 510 if (p == 0) 511 break; /* No more words */ 512 513 /* If the dependency name has %, substitute the stem. 514 Watch out, we are going to do something tricky here. If 515 we just replace % with the stem value, later, when we do 516 the second expansion, we will re-expand this stem value 517 once again. This is not good especially if you have 518 certain characters in your setm (like $). 519 520 Instead, we will replace % with $* and allow the second 521 expansion to take care of it for us. This way (since $* 522 is a simple variable) there won't be additional 523 re-expansion of the stem. */ 524 525 for (p2 = p; p2 < p + len && *p2 != '%'; ++p2) 526 ; 527 528 if (p2 < p + len) 529 { 530 register unsigned int i = p2 - p; 531 bcopy (p, depname, i); 532 bcopy ("$*", depname + i, 2); 533 bcopy (p2 + 1, depname + i + 2, len - i - 1); 534 depname[len + 2 - 1] = '\0'; 535 536 if (check_lastslash) 537 add_dir = 1; 538 539 had_stem = 1; 540 } 541 else 542 { 543 bcopy (p, depname, len); 544 depname[len] = '\0'; 545 } 546 547 p2 = variable_expand_for_file (depname, file); 548 549 /* Parse the dependencies. */ 550 551 while (1) 552 { 553 id_ptr = &deps; 554 555 for (; *id_ptr; id_ptr = &(*id_ptr)->next) 556 ; 557 558 *id_ptr = (struct idep *) 559 multi_glob ( 560 parse_file_seq (&p2, 561 order_only ? '\0' : '|', 562 sizeof (struct idep), 563 1), sizeof (struct idep)); 564 565 /* @@ It would be nice to teach parse_file_seq or 566 multi_glob to add prefix. This would save us 567 some reallocations. */ 568 569 if (order_only || add_dir || had_stem) 570 { 571 unsigned long l = lastslash - filename + 1; 572 573 for (d = *id_ptr; d != 0; d = d->next) 574 { 575 if (order_only) 576 d->ignore_mtime = 1; 577 578 if (add_dir) 579 { 580 char *p = d->name; 581 582 d->name = xmalloc (strlen (p) + l + 1); 583 584 bcopy (filename, d->name, l); 585 bcopy (p, d->name + l, strlen (p) + 1); 586 587 free (p); 588 } 589 590 if (had_stem) 591 d->had_stem = 1; 592 } 593 } 594 595 if (!order_only && *p2) 596 { 597 ++p2; 598 order_only = 1; 599 continue; 600 } 601 602 break; 603 } 604 605 p += len; 606 p = get_next_word (p, &len); 607 } 608 } 609 610 /* Reset the stem in FILE. */ 611 612 file->stem = 0; 613 614 /* @@ This loop can be combined with the previous one. I do 615 it separately for now for transparency.*/ 616 617 for (d = deps; d != 0; d = d->next) 618 { 619 char *name = d->name; 620 621 if (file_impossible_p (name)) 622 { 623 /* If this dependency has already been ruled 624 "impossible", then the rule fails and don't 625 bother trying it on the second pass either 626 since we know that will fail too. */ 627 DBS (DB_IMPLICIT, 628 (d->had_stem 380 629 ? _("Rejecting impossible implicit prerequisite `%s'.\n") 381 630 : _("Rejecting impossible rule prerequisite `%s'.\n"), 382 p));383 384 break; 385 } 386 387 intermediate_files[deps_found] = 0; 388 389 390 ( p == depname631 name)); 632 tryrules[i] = 0; 633 634 failed = 1; 635 break; 636 } 637 638 DBS (DB_IMPLICIT, 639 (d->had_stem 391 640 ? _("Trying implicit prerequisite `%s'.\n") 392 : _("Trying rule prerequisite `%s'.\n"), p)); 393 394 /* The DEP->changed flag says that this dependency resides in a 395 nonexistent directory. So we normally can skip looking for 396 the file. However, if CHECK_LASTSLASH is set, then the 397 dependency file we are actually looking for is in a different 398 directory (the one gotten by prepending FILENAME's directory), 399 so it might actually exist. */ 400 401 if (lookup_file (p) != 0 402 || ((!dep->changed || check_lastslash) && file_exists_p (p))) 403 { 404 found_files_im[deps_found] = dep->ignore_mtime; 405 found_files[deps_found++] = xstrdup (p); 406 continue; 407 } 408 /* This code, given FILENAME = "lib/foo.o", dependency name 409 "lib/foo.c", and VPATH=src, searches for "src/lib/foo.c". */ 410 vp = p; 411 if (vpath_search (&vp, (FILE_TIMESTAMP *) 0)) 412 { 413 DBS (DB_IMPLICIT, 414 (_("Found prerequisite `%s' as VPATH `%s'\n"), p, vp)); 415 strcpy (vp, p); 416 found_files_im[deps_found] = dep->ignore_mtime; 417 found_files[deps_found++] = vp; 418 continue; 419 } 420 421 /* We could not find the file in any place we should look. 422 Try to make this dependency as an intermediate file, 423 but only on the second pass. */ 424 425 if (intermed_ok) 426 { 427 if (intermediate_file == 0) 428 intermediate_file 429 = (struct file *) alloca (sizeof (struct file)); 430 431 DBS (DB_IMPLICIT, 641 : _("Trying rule prerequisite `%s'.\n"), name)); 642 643 /* If this prerequisite also happened to be explicitly 644 mentioned for FILE skip all the test below since it 645 it has to be built anyway, no matter which implicit 646 rule we choose. */ 647 648 for (expl_d = file->deps; expl_d != 0; expl_d = expl_d->next) 649 if (strcmp (dep_name (expl_d), name) == 0) break; 650 651 if (expl_d != 0) 652 continue; 653 654 655 656 /* The DEP->changed flag says that this dependency resides in a 657 nonexistent directory. So we normally can skip looking for 658 the file. However, if CHECK_LASTSLASH is set, then the 659 dependency file we are actually looking for is in a different 660 directory (the one gotten by prepending FILENAME's directory), 661 so it might actually exist. */ 662 663 /* @@ dep->changed check is disabled. */ 664 if (((f = lookup_file (name)) != 0 && f->is_target) 665 /*|| ((!dep->changed || check_lastslash) && */ 666 || file_exists_p (name)) 667 { 668 continue; 669 } 670 671 /* This code, given FILENAME = "lib/foo.o", dependency name 672 "lib/foo.c", and VPATH=src, searches for "src/lib/foo.c". */ 673 vname = name; 674 if (vpath_search (&vname, (FILE_TIMESTAMP *) 0)) 675 { 676 DBS (DB_IMPLICIT, 677 (_("Found prerequisite `%s' as VPATH `%s'\n"), 678 name, 679 vname)); 680 681 free (vname); 682 continue; 683 } 684 685 686 /* We could not find the file in any place we should look. 687 Try to make this dependency as an intermediate file, 688 but only on the second pass. */ 689 690 if (intermed_ok) 691 { 692 if (intermediate_file == 0) 693 intermediate_file 694 = (struct file *) alloca (sizeof (struct file)); 695 696 DBS (DB_IMPLICIT, 432 697 (_("Looking for a rule with intermediate file `%s'.\n"), 433 p)); 434 435 bzero ((char *) intermediate_file, sizeof (struct file)); 436 intermediate_file->name = p; 437 if (pattern_search (intermediate_file, 0, depth + 1, 438 recursions + 1)) 439 { 440 p = xstrdup (p); 441 intermediate_patterns[deps_found] 442 = intermediate_file->name; 443 intermediate_file->name = p; 444 intermediate_files[deps_found] = intermediate_file; 445 intermediate_file = 0; 446 found_files_im[deps_found] = dep->ignore_mtime; 447 /* Allocate an extra copy to go in FOUND_FILES, 448 because every elt of FOUND_FILES is consumed 449 or freed later. */ 450 found_files[deps_found++] = xstrdup (p); 451 continue; 452 } 453 454 /* If we have tried to find P as an intermediate 455 file and failed, mark that name as impossible 456 so we won't go through the search again later. */ 457 file_impossible (p); 458 } 459 460 /* A dependency of this rule does not exist. 461 Therefore, this rule fails. */ 462 break; 463 } 464 465 /* This rule is no longer `in use' for recursive searches. */ 698 name)); 699 700 bzero ((char *) intermediate_file, sizeof (struct file)); 701 intermediate_file->name = name; 702 if (pattern_search (intermediate_file, 703 0, 704 depth + 1, 705 recursions + 1)) 706 { 707 d->intermediate_file = intermediate_file; 708 d->intermediate_pattern = intermediate_file->name; 709 710 intermediate_file->name = xstrdup (name); 711 intermediate_file = 0; 712 713 continue; 714 } 715 716 /* If we have tried to find P as an intermediate 717 file and failed, mark that name as impossible 718 so we won't go through the search again later. */ 719 file_impossible (name); 720 } 721 722 /* A dependency of this rule does not exist. Therefore, 723 this rule fails. */ 724 failed = 1; 725 break; 726 } 727 728 /* This rule is no longer `in use' for recursive searches. */ 466 729 rule->in_use = 0; 467 730 468 if (dep != 0) 469 { 470 /* This pattern rule does not apply. 471 If some of its dependencies succeeded, 472 free the data structure describing them. */ 473 while (deps_found-- > 0) 474 { 475 register struct file *f = intermediate_files[deps_found]; 476 free (found_files[deps_found]); 477 if (f != 0 478 && (f->stem < f->name 479 || f->stem > f->name + strlen (f->name))) 480 free (f->stem); 481 } 482 } 731 if (failed) 732 { 733 /* This pattern rule does not apply. If some of its 734 dependencies succeeded, free the data structure 735 describing them. */ 736 free_idep_chain (deps); 737 deps = 0; 738 } 483 739 else 484 740 /* This pattern rule does apply. Stop looking for one. */ … … 512 768 Convert them into entries on the deps-chain of FILE. */ 513 769 514 while (deps_found-- > 0) 770 if (remove_explicit_deps) 771 { 772 /* Remove all the dependencies that didn't come from 773 this implicit rule. */ 774 775 dep = file->deps; 776 while (dep != 0) 777 { 778 struct dep *next = dep->next; 779 free (dep->name); 780 free ((char *)dep); 781 dep = next; 782 } 783 file->deps = 0; 784 } 785 786 expl_d = file->deps; /* We will add them at the end. */ 787 d_ptr = &file->deps; 788 789 for (d = deps; d != 0; d = d->next) 515 790 { 516 791 register char *s; 517 792 518 if ( intermediate_files[deps_found]!= 0)793 if (d->intermediate_file != 0) 519 794 { 520 795 /* If we need to use an intermediate file, … … 525 800 of F below are null before we change them. */ 526 801 527 struct file *imf = intermediate_files[deps_found]; 528 register struct file *f = enter_file (imf->name); 802 struct file *imf = d->intermediate_file; 803 register struct file *f = lookup_file (imf->name); 804 805 /* We don't want to delete an intermediate file that happened 806 to be a prerequisite of some (other) target. Mark it as 807 precious. */ 808 if (f != 0) 809 f->precious = 1; 810 else 811 f = enter_file (imf->name); 812 529 813 f->deps = imf->deps; 530 814 f->cmds = imf->cmds; 531 815 f->stem = imf->stem; 532 816 f->also_make = imf->also_make; 533 imf = lookup_file (intermediate_patterns[deps_found]); 534 if (imf != 0 && imf->precious) 535 f->precious = 1; 817 f->is_target = 1; 818 819 if (!f->precious) 820 { 821 imf = lookup_file (d->intermediate_pattern); 822 if (imf != 0 && imf->precious) 823 f->precious = 1; 824 } 825 536 826 f->intermediate = 1; 537 827 f->tried_implicit = 1; … … 548 838 549 839 dep = (struct dep *) xmalloc (sizeof (struct dep)); 550 dep->ignore_mtime = found_files_im[deps_found]; 551 s = found_files[deps_found]; 840 dep->ignore_mtime = d->ignore_mtime; 841 dep->need_2nd_expansion = 0; 842 s = d->name; /* Hijacking the name. */ 843 d->name = 0; 552 844 if (recursions == 0) 553 845 { … … 568 860 dep->changed = 0; 569 861 } 570 if ( intermediate_files[deps_found]== 0 && tryrules[foundrule]->terminal)862 if (d->intermediate_file == 0 && tryrules[foundrule]->terminal) 571 863 { 572 864 /* If the file actually existed (was not an intermediate file), … … 580 872 dep->file->tried_implicit = 1; 581 873 } 582 dep->next = file->deps; 583 file->deps = dep; 874 875 *d_ptr = dep; 876 d_ptr = &dep->next; 584 877 } 878 879 *d_ptr = expl_d; 585 880 586 881 if (!checked_lastslash[foundrule]) … … 605 900 606 901 file->cmds = rule->cmds; 902 file->is_target = 1; 607 903 608 904 /* If this rule builds other targets, too, put the others into FILE's … … 616 912 /* GKM FIMXE: handle '|' here too */ 617 913 new->ignore_mtime = 0; 914 new->need_2nd_expansion = 0; 618 915 new->name = p = (char *) xmalloc (rule->lens[i] + fullstemlen + 1); 619 916 bcopy (rule->targets[i], p, … … 630 927 631 928 done: 632 free (intermediate_files);929 free_idep_chain (deps); 633 930 free (tryrules); 634 931 -
branches/GNU/src/gmake/job.c
r153 r280 1 1 /* Job execution and handling for GNU Make. 2 Copyright (C) 1988,89,90,91,92,93,94,95,96,97,99 Free Software Foundation, Inc. 2 Copyright (C) 1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1999, 3 2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc. 3 4 This file is part of GNU Make. 4 5 … … 61 62 62 63 # include <descrip.h> 64 char default_shell[] = ""; 65 int batch_mode_shell = 0; 66 67 #elif defined (__riscos__) 68 63 69 char default_shell[] = ""; 64 70 int batch_mode_shell = 0; … … 168 174 #endif /* Don't have `union wait'. */ 169 175 170 #ifdef VMS171 static int vms_jobsefnmask = 0;172 #endif /* !VMS */173 174 176 #ifndef HAVE_UNISTD_H 175 177 extern int dup2 (); … … 199 201 static int job_next_command PARAMS ((struct child *)); 200 202 static int start_waiting_job PARAMS ((struct child *)); 201 #ifdef VMS202 static void vmsWaitForChildren PARAMS ((int *));203 #endif204 203 205 204 … … 228 227 unsigned long job_counter = 0; 229 228 229 /* Number of jobserver tokens this instance is currently using. */ 230 231 unsigned int jobserver_tokens = 0; 230 232 231 233 … … 237 239 w32_kill(int pid, int sig) 238 240 { 239 return ((process_kill(pid, sig) == TRUE) ? 0 : -1); 241 return ((process_kill((HANDLE)pid, sig) == TRUE) ? 0 : -1); 242 } 243 244 /* This function creates a temporary file name with the given extension 245 * the unixy param controls both the extension and the path separator 246 * return an xmalloc'ed string of a newly created temp file or die. */ 247 static char * 248 create_batch_filename(char const *base, int unixy) 249 { 250 const char *const ext = unixy ? "sh" : "bat"; 251 const char *error = NULL; 252 char temp_path[MAXPATHLEN]; /* need to know its length */ 253 unsigned path_size = GetTempPath(sizeof temp_path, temp_path); 254 int path_is_dot = 0; 255 unsigned uniq = 1; 256 const unsigned sizemax = strlen (base) + strlen (ext) + 10; 257 258 if (path_size == 0) 259 { 260 path_size = GetCurrentDirectory (sizeof temp_path, temp_path); 261 path_is_dot = 1; 262 } 263 264 while (path_size > 0 && 265 path_size + sizemax < sizeof temp_path && 266 uniq < 0x10000) 267 { 268 unsigned size = sprintf (temp_path + path_size, 269 "%s%s-%x.%s", 270 temp_path[path_size - 1] == '\\' ? "" : "\\", 271 base, uniq, ext); 272 HANDLE h = CreateFile (temp_path, /* file name */ 273 GENERIC_READ | GENERIC_WRITE, /* desired access */ 274 0, /* no share mode */ 275 NULL, /* default security attributes */ 276 CREATE_NEW, /* creation disposition */ 277 FILE_ATTRIBUTE_NORMAL | /* flags and attributes */ 278 FILE_ATTRIBUTE_TEMPORARY, /* we'll delete it */ 279 NULL); /* no template file */ 280 281 if (h == INVALID_HANDLE_VALUE) 282 { 283 const DWORD er = GetLastError(); 284 285 if (er == ERROR_FILE_EXISTS || er == ERROR_ALREADY_EXISTS) 286 ++uniq; 287 288 /* the temporary path is not guaranteed to exist */ 289 else if (path_is_dot == 0) 290 { 291 path_size = GetCurrentDirectory (sizeof temp_path, temp_path); 292 path_is_dot = 1; 293 } 294 295 else 296 { 297 error = map_windows32_error_to_string (er); 298 break; 299 } 300 } 301 else 302 { 303 const unsigned final_size = path_size + size + 1; 304 char *const path = (char *) xmalloc (final_size); 305 memcpy (path, temp_path, final_size); 306 CloseHandle (h); 307 if (unixy) 308 { 309 char *p; 310 int ch; 311 for (p = path; (ch = *p) != 0; ++p) 312 if (ch == '\\') 313 *p = '/'; 314 } 315 return path; /* good return */ 316 } 317 } 318 319 if (error == NULL) 320 error = _("Cannot create a temporary file\n"); 321 fatal (NILF, error); 322 323 /* not reached */ 324 return NULL; 240 325 } 241 326 #endif /* WINDOWS32 */ … … 317 402 318 403 319 #ifdef VMS320 /* Wait for nchildren children to terminate */321 static void322 vmsWaitForChildren(int *status)323 {324 while (1)325 {326 if (!vms_jobsefnmask)327 {328 *status = 0;329 return;330 }331 332 *status = sys$wflor (32, vms_jobsefnmask);333 }334 return;335 }336 337 /* Set up IO redirection. */338 339 char *340 vms_redirect (struct dsc$descriptor_s *desc, char *fname, char *ibuf)341 {342 char *fptr;343 extern char *vmsify ();344 345 ibuf++;346 while (isspace ((unsigned char)*ibuf))347 ibuf++;348 fptr = ibuf;349 while (*ibuf && !isspace ((unsigned char)*ibuf))350 ibuf++;351 *ibuf = 0;352 if (strcmp (fptr, "/dev/null") != 0)353 {354 strcpy (fname, vmsify (fptr, 0));355 if (strchr (fname, '.') == 0)356 strcat (fname, ".");357 }358 desc->dsc$w_length = strlen(fname);359 desc->dsc$a_pointer = fname;360 desc->dsc$b_dtype = DSC$K_DTYPE_T;361 desc->dsc$b_class = DSC$K_CLASS_S;362 363 if (*fname == 0)364 printf (_("Warning: Empty redirection\n"));365 return ibuf;366 }367 368 369 /* found apostrophe at (p-1)370 inc p until after closing apostrophe.371 */372 373 static char *374 vms_handle_apos (char *p)375 {376 int alast;377 378 #define SEPCHARS ",/()= "379 380 alast = 0;381 382 while (*p != 0)383 {384 if (*p == '"')385 {386 if (alast)387 {388 alast = 0;389 p++;390 }391 else392 {393 p++;394 if (strchr (SEPCHARS, *p))395 break;396 alast = 1;397 }398 }399 else400 p++;401 }402 403 return p;404 }405 406 #endif407 408 404 409 405 /* Handle a dead child. This handler may or may not ever be installed. … … 474 470 { 475 471 int remote = 0; 476 register int pid;472 pid_t pid; 477 473 int exit_code, exit_sig, coredump; 478 474 register struct child *lastc, *c; … … 543 539 { 544 540 #ifdef VMS 541 static void vmsWaitForChildren PARAMS ((int *)); 545 542 vmsWaitForChildren (&status); 546 543 pid = c->pid; … … 616 613 HANDLE hPID; 617 614 int err; 615 exit_code = 0; 616 exit_sig = 0; 617 coredump = 0; 618 618 619 619 /* wait for anything to finish */ 620 if (hPID = process_wait_for_any()) { 621 622 /* was an error found on this process? */ 623 err = process_last_err(hPID); 624 625 /* get exit data */ 626 exit_code = process_exit_code(hPID); 627 628 if (err) 629 fprintf(stderr, "make (e=%d): %s", 630 exit_code, map_windows32_error_to_string(exit_code)); 631 632 /* signal */ 633 exit_sig = process_signal(hPID); 634 635 /* cleanup process */ 636 process_cleanup(hPID); 637 638 coredump = 0; 639 } 640 pid = (int) hPID; 620 hPID = process_wait_for_any(); 621 if (hPID) 622 { 623 624 /* was an error found on this process? */ 625 err = process_last_err(hPID); 626 627 /* get exit data */ 628 exit_code = process_exit_code(hPID); 629 630 if (err) 631 fprintf(stderr, "make (e=%d): %s", 632 exit_code, map_windows32_error_to_string(exit_code)); 633 634 /* signal */ 635 exit_sig = process_signal(hPID); 636 637 /* cleanup process */ 638 process_cleanup(hPID); 639 640 coredump = 0; 641 } 642 pid = (pid_t) hPID; 641 643 } 642 644 #endif /* WINDOWS32 */ … … 812 814 free_child (struct child *child) 813 815 { 814 /* If this child is the only one it was our "free" job, so don't put a 815 token back for it. This child has already been removed from the list, 816 so if there any left this wasn't the last one. */ 817 818 if (job_fds[1] >= 0 && children) 816 if (!jobserver_tokens) 817 fatal (NILF, "INTERNAL: Freeing child 0x%08lx (%s) but no tokens left!\n", 818 (unsigned long int) child, child->file->name); 819 820 /* If we're using the jobserver and this child is not the only outstanding 821 job, put a token back into the pipe for it. */ 822 823 if (job_fds[1] >= 0 && jobserver_tokens > 1) 819 824 { 820 825 char token = '+'; … … 830 835 (unsigned long int) child, child->file->name)); 831 836 } 837 838 --jobserver_tokens; 832 839 833 840 if (handling_fatal_signal) /* Don't bother free'ing if about to die. */ … … 870 877 } 871 878 872 #ifdef 879 #ifdef POSIX 873 880 void 874 881 unblock_sigs (void) … … 881 888 882 889 #ifdef MAKE_JOBSERVER 890 RETSIGTYPE 891 job_noop (int sig UNUSED) 892 { 893 } 883 894 /* Set the child handler action flags to FLAGS. */ 884 895 static void 885 set_child_handler_action_flags (int flags)896 set_child_handler_action_flags (int set_handler, int set_alarm) 886 897 { 887 898 struct sigaction sa; 899 900 #ifdef __EMX__ 901 /* The child handler must be turned off here. */ 902 signal (SIGCHLD, SIG_DFL); 903 #endif 904 888 905 bzero ((char *) &sa, sizeof sa); 889 906 sa.sa_handler = child_handler; 890 sa.sa_flags = flags;907 sa.sa_flags = set_handler ? 0 : SA_RESTART; 891 908 #if defined SIGCHLD 892 909 sigaction (SIGCHLD, &sa, NULL); … … 894 911 #if defined SIGCLD && SIGCLD != SIGCHLD 895 912 sigaction (SIGCLD, &sa, NULL); 913 #endif 914 #if defined SIGALRM 915 if (set_alarm) 916 { 917 /* If we're about to enter the read(), set an alarm to wake up in a 918 second so we can check if the load has dropped and we can start more 919 work. On the way out, turn off the alarm and set SIG_DFL. */ 920 alarm (set_handler ? 1 : 0); 921 sa.sa_handler = set_handler ? job_noop : SIG_DFL; 922 sa.sa_flags = 0; 923 sigaction (SIGALRM, &sa, NULL); 924 } 896 925 #endif 897 926 } … … 1158 1187 1159 1188 #ifdef VMS 1160 1161 1189 if (!child_execute_job (argv, child)) { 1162 1190 /* Fork failed! */ … … 1582 1610 1583 1611 /* If we don't already have a job started, use our "free" token. */ 1584 if (! children)1612 if (!jobserver_tokens) 1585 1613 break; 1586 1614 … … 1617 1645 reap_children (0, 0); 1618 1646 1619 /* If our "free" token has become available, use it. */ 1647 /* Kick off any jobs we have waiting for an opportunity that 1648 can run now (ie waiting for load). */ 1649 start_waiting_jobs (); 1650 1651 /* If our "free" slot has become available, use it; we don't need an 1652 actual token. */ 1653 if (!jobserver_tokens) 1654 break; 1655 1656 /* There must be at least one child already, or we have no business 1657 waiting for a token. */ 1620 1658 if (!children) 1621 break;1659 fatal (NILF, "INTERNAL: no children as we go to sleep on read\n"); 1622 1660 1623 1661 /* Set interruptible system calls, and read() for a job token. */ 1624 set_child_handler_action_flags ( 0);1662 set_child_handler_action_flags (1, waiting_jobs != NULL); 1625 1663 got_token = read (job_rfd, &token, 1); 1626 1664 saved_errno = errno; 1627 #ifdef __EMX__ 1628 /* The child handler must be turned off here. */ 1629 signal (SIGCHLD, SIG_DFL); 1630 #endif 1631 set_child_handler_action_flags (SA_RESTART); 1665 set_child_handler_action_flags (0, waiting_jobs != NULL); 1632 1666 1633 1667 /* If we got one, we're done here. */ … … 1648 1682 } 1649 1683 #endif 1684 1685 ++jobserver_tokens; 1650 1686 1651 1687 /* The job is now primed. Start it running. … … 1728 1764 load_too_high (void) 1729 1765 { 1730 #if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA) 1766 #if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA) || defined(__riscos__) 1731 1767 return 1; 1732 1768 #else … … 1812 1848 1813 1849 #ifndef WINDOWS32 1814 #ifdef VMS1815 #include <descrip.h>1816 #include <clidef.h>1817 1818 /* This is called as an AST when a child process dies (it won't get1819 interrupted by anything except a higher level AST).1820 */1821 int vmsHandleChildTerm(struct child *child)1822 {1823 int status;1824 register struct child *lastc, *c;1825 int child_failed;1826 1827 vms_jobsefnmask &= ~(1 << (child->efn - 32));1828 1829 lib$free_ef(&child->efn);1830 1831 (void) sigblock (fatal_signal_mask);1832 1833 child_failed = !(child->cstatus & 1 || ((child->cstatus & 7) == 0));1834 1835 /* Search for a child matching the deceased one. */1836 lastc = 0;1837 #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */1838 for (c = children; c != 0 && c != child; lastc = c, c = c->next);1839 #else1840 c = child;1841 #endif1842 1843 if (child_failed && !c->noerror && !ignore_errors_flag)1844 {1845 /* The commands failed. Write an error message,1846 delete non-precious targets, and abort. */1847 child_error (c->file->name, c->cstatus, 0, 0, 0);1848 c->file->update_status = 1;1849 delete_child_targets (c);1850 }1851 else1852 {1853 if (child_failed)1854 {1855 /* The commands failed, but we don't care. */1856 child_error (c->file->name, c->cstatus, 0, 0, 1);1857 child_failed = 0;1858 }1859 1860 #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */1861 /* If there are more commands to run, try to start them. */1862 start_job (c);1863 1864 switch (c->file->command_state)1865 {1866 case cs_running:1867 /* Successfully started. */1868 break;1869 1870 case cs_finished:1871 if (c->file->update_status != 0) {1872 /* We failed to start the commands. */1873 delete_child_targets (c);1874 }1875 break;1876 1877 default:1878 error (NILF, _("internal error: `%s' command_state"),1879 c->file->name);1880 abort ();1881 break;1882 }1883 #endif /* RECURSIVEJOBS */1884 }1885 1886 /* Set the state flag to say the commands have finished. */1887 c->file->command_state = cs_finished;1888 notice_finished_file (c->file);1889 1890 #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */1891 /* Remove the child from the chain and free it. */1892 if (lastc == 0)1893 children = c->next;1894 else1895 lastc->next = c->next;1896 free_child (c);1897 #endif /* RECURSIVEJOBS */1898 1899 /* There is now another slot open. */1900 if (job_slots_used > 0)1901 --job_slots_used;1902 1903 /* If the job failed, and the -k flag was not given, die. */1904 if (child_failed && !keep_going_flag)1905 die (EXIT_FAILURE);1906 1907 (void) sigsetmask (sigblock (0) & ~(fatal_signal_mask));1908 1909 return 1;1910 }1911 1912 /* VMS:1913 Spawn a process executing the command in ARGV and return its pid. */1914 1915 #define MAXCMDLEN 2001916 1917 /* local helpers to make ctrl+c and ctrl+y working, see below */1918 #include <iodef.h>1919 #include <libclidef.h>1920 #include <ssdef.h>1921 1922 static int ctrlMask= LIB$M_CLI_CTRLY;1923 static int oldCtrlMask;1924 static int setupYAstTried= 0;1925 static int pidToAbort= 0;1926 static int chan= 0;1927 1928 static void reEnableAst(void) {1929 lib$enable_ctrl (&oldCtrlMask,0);1930 }1931 1932 static astHandler (void) {1933 if (pidToAbort) {1934 sys$forcex (&pidToAbort, 0, SS$_ABORT);1935 pidToAbort= 0;1936 }1937 kill (getpid(),SIGQUIT);1938 }1939 1940 static void tryToSetupYAst(void) {1941 $DESCRIPTOR(inputDsc,"SYS$COMMAND");1942 int status;1943 struct {1944 short int status, count;1945 int dvi;1946 } iosb;1947 1948 setupYAstTried++;1949 1950 if (!chan) {1951 status= sys$assign(&inputDsc,&chan,0,0);1952 if (!(status&SS$_NORMAL)) {1953 lib$signal(status);1954 return;1955 }1956 }1957 status= sys$qiow (0, chan, IO$_SETMODE|IO$M_CTRLYAST,&iosb,0,0,1958 astHandler,0,0,0,0,0);1959 if (status==SS$_ILLIOFUNC) {1960 sys$dassgn(chan);1961 #ifdef CTRLY_ENABLED_ANYWAY1962 fprintf (stderr,1963 _("-warning, CTRL-Y will leave sub-process(es) around.\n"));1964 #else1965 return;1966 #endif1967 }1968 if (status==SS$_NORMAL)1969 status= iosb.status;1970 if (!(status&SS$_NORMAL)) {1971 lib$signal(status);1972 return;1973 }1974 1975 /* called from AST handler ? */1976 if (setupYAstTried>1)1977 return;1978 if (atexit(reEnableAst))1979 fprintf (stderr,1980 _("-warning, you may have to re-enable CTRL-Y handling from DCL.\n"));1981 status= lib$disable_ctrl (&ctrlMask, &oldCtrlMask);1982 if (!(status&SS$_NORMAL)) {1983 lib$signal(status);1984 return;1985 }1986 }1987 int1988 child_execute_job (char *argv, struct child *child)1989 {1990 int i;1991 static struct dsc$descriptor_s cmddsc;1992 static struct dsc$descriptor_s pnamedsc;1993 static struct dsc$descriptor_s ifiledsc;1994 static struct dsc$descriptor_s ofiledsc;1995 static struct dsc$descriptor_s efiledsc;1996 int have_redirection = 0;1997 int have_newline = 0;1998 1999 int spflags = CLI$M_NOWAIT;2000 int status;2001 char *cmd = alloca (strlen (argv) + 512), *p, *q;2002 char ifile[256], ofile[256], efile[256];2003 char *comname = 0;2004 char procname[100];2005 2006 /* Parse IO redirection. */2007 2008 ifile[0] = 0;2009 ofile[0] = 0;2010 efile[0] = 0;2011 2012 DB (DB_JOBS, ("child_execute_job (%s)\n", argv));2013 2014 while (isspace ((unsigned char)*argv))2015 argv++;2016 2017 if (*argv == 0)2018 return 0;2019 2020 sprintf (procname, "GMAKE_%05x", getpid () & 0xfffff);2021 pnamedsc.dsc$w_length = strlen(procname);2022 pnamedsc.dsc$a_pointer = procname;2023 pnamedsc.dsc$b_dtype = DSC$K_DTYPE_T;2024 pnamedsc.dsc$b_class = DSC$K_CLASS_S;2025 2026 /* Handle comments and redirection. */2027 for (p = argv, q = cmd; *p; p++, q++)2028 {2029 switch (*p)2030 {2031 case '#':2032 *p-- = 0;2033 *q-- = 0;2034 break;2035 case '\\':2036 p++;2037 if (*p == '\n')2038 p++;2039 if (isspace ((unsigned char)*p))2040 {2041 do { p++; } while (isspace ((unsigned char)*p));2042 p--;2043 }2044 *q = *p;2045 break;2046 case '<':2047 p = vms_redirect (&ifiledsc, ifile, p);2048 *q = ' ';2049 have_redirection = 1;2050 break;2051 case '>':2052 have_redirection = 1;2053 if (*(p-1) == '2')2054 {2055 q--;2056 if (strncmp (p, ">&1", 3) == 0)2057 {2058 p += 3;2059 strcpy (efile, "sys$output");2060 efiledsc.dsc$w_length = strlen(efile);2061 efiledsc.dsc$a_pointer = efile;2062 efiledsc.dsc$b_dtype = DSC$K_DTYPE_T;2063 efiledsc.dsc$b_class = DSC$K_CLASS_S;2064 }2065 else2066 {2067 p = vms_redirect (&efiledsc, efile, p);2068 }2069 }2070 else2071 {2072 p = vms_redirect (&ofiledsc, ofile, p);2073 }2074 *q = ' ';2075 break;2076 case '\n':2077 have_newline = 1;2078 default:2079 *q = *p;2080 break;2081 }2082 }2083 *q = *p;2084 2085 if (strncmp (cmd, "builtin_", 8) == 0)2086 {2087 child->pid = 270163;2088 child->efn = 0;2089 child->cstatus = 1;2090 2091 DB (DB_JOBS, (_("BUILTIN [%s][%s]\n"), cmd, cmd+8));2092 2093 p = cmd + 8;2094 2095 if ((*(p) == 'c')2096 && (*(p+1) == 'd')2097 && ((*(p+2) == ' ') || (*(p+2) == '\t')))2098 {2099 p += 3;2100 while ((*p == ' ') || (*p == '\t'))2101 p++;2102 DB (DB_JOBS, (_("BUILTIN CD %s\n"), p));2103 if (chdir (p))2104 return 0;2105 else2106 return 1;2107 }2108 else if ((*(p) == 'r')2109 && (*(p+1) == 'm')2110 && ((*(p+2) == ' ') || (*(p+2) == '\t')))2111 {2112 int in_arg;2113 2114 /* rm */2115 p += 3;2116 while ((*p == ' ') || (*p == '\t'))2117 p++;2118 in_arg = 1;2119 2120 DB (DB_JOBS, (_("BUILTIN RM %s\n"), p));2121 while (*p)2122 {2123 switch (*p)2124 {2125 case ' ':2126 case '\t':2127 if (in_arg)2128 {2129 *p++ = ';';2130 in_arg = 0;2131 }2132 break;2133 default:2134 break;2135 }2136 p++;2137 }2138 }2139 else2140 {2141 printf(_("Unknown builtin command '%s'\n"), cmd);2142 fflush(stdout);2143 return 0;2144 }2145 }2146 2147 /* Create a *.com file if either the command is too long for2148 lib$spawn, or the command contains a newline, or if redirection2149 is desired. Forcing commands with newlines into DCLs allows to2150 store search lists on user mode logicals. */2151 2152 if (strlen (cmd) > MAXCMDLEN2153 || (have_redirection != 0)2154 || (have_newline != 0))2155 {2156 FILE *outfile;2157 char c;2158 char *sep;2159 int alevel = 0; /* apostrophe level */2160 2161 if (strlen (cmd) == 0)2162 {2163 printf (_("Error, empty command\n"));2164 fflush (stdout);2165 return 0;2166 }2167 2168 outfile = open_tmpfile (&comname, "sys$scratch:CMDXXXXXX.COM");2169 if (outfile == 0)2170 pfatal_with_name (_("fopen (temporary file)"));2171 2172 if (ifile[0])2173 {2174 fprintf (outfile, "$ assign/user %s sys$input\n", ifile);2175 DB (DB_JOBS, (_("Redirected input from %s\n"), ifile));2176 ifiledsc.dsc$w_length = 0;2177 }2178 2179 if (efile[0])2180 {2181 fprintf (outfile, "$ define sys$error %s\n", efile);2182 DB (DB_JOBS, (_("Redirected error to %s\n"), efile));2183 efiledsc.dsc$w_length = 0;2184 }2185 2186 if (ofile[0])2187 {2188 fprintf (outfile, "$ define sys$output %s\n", ofile);2189 DB (DB_JOBS, (_("Redirected output to %s\n"), ofile));2190 ofiledsc.dsc$w_length = 0;2191 }2192 2193 p = sep = q = cmd;2194 for (c = '\n'; c; c = *q++)2195 {2196 switch (c)2197 {2198 case '\n':2199 /* At a newline, skip any whitespace around a leading $2200 from the command and issue exactly one $ into the DCL. */2201 while (isspace ((unsigned char)*p))2202 p++;2203 if (*p == '$')2204 p++;2205 while (isspace ((unsigned char)*p))2206 p++;2207 fwrite (p, 1, q - p, outfile);2208 fputc ('$', outfile);2209 fputc (' ', outfile);2210 /* Reset variables. */2211 p = sep = q;2212 break;2213 2214 /* Nice places for line breaks are after strings, after2215 comma or space and before slash. */2216 case '"':2217 q = vms_handle_apos (q);2218 sep = q;2219 break;2220 case ',':2221 case ' ':2222 sep = q;2223 break;2224 case '/':2225 case '\0':2226 sep = q - 1;2227 break;2228 default:2229 break;2230 }2231 if (sep - p > 78)2232 {2233 /* Enough stuff for a line. */2234 fwrite (p, 1, sep - p, outfile);2235 p = sep;2236 if (*sep)2237 {2238 /* The command continues. */2239 fputc ('-', outfile);2240 }2241 fputc ('\n', outfile);2242 }2243 }2244 2245 fwrite (p, 1, q - p, outfile);2246 fputc ('\n', outfile);2247 2248 fclose (outfile);2249 2250 sprintf (cmd, "$ @%s", comname);2251 2252 DB (DB_JOBS, (_("Executing %s instead\n"), cmd));2253 }2254 2255 cmddsc.dsc$w_length = strlen(cmd);2256 cmddsc.dsc$a_pointer = cmd;2257 cmddsc.dsc$b_dtype = DSC$K_DTYPE_T;2258 cmddsc.dsc$b_class = DSC$K_CLASS_S;2259 2260 child->efn = 0;2261 while (child->efn < 32 || child->efn > 63)2262 {2263 status = lib$get_ef ((unsigned long *)&child->efn);2264 if (!(status & 1))2265 return 0;2266 }2267 2268 sys$clref (child->efn);2269 2270 vms_jobsefnmask |= (1 << (child->efn - 32));2271 2272 /*2273 LIB$SPAWN [command-string]2274 [,input-file]2275 [,output-file]2276 [,flags]2277 [,process-name]2278 [,process-id] [,completion-status-address] [,byte-integer-event-flag-num]2279 [,AST-address] [,varying-AST-argument]2280 [,prompt-string] [,cli] [,table]2281 */2282 2283 #ifndef DONTWAITFORCHILD2284 /*2285 * Code to make ctrl+c and ctrl+y working.2286 * The problem starts with the synchronous case where after lib$spawn is2287 * called any input will go to the child. But with input re-directed,2288 * both control characters won't make it to any of the programs, neither2289 * the spawning nor to the spawned one. Hence the caller needs to spawn2290 * with CLI$M_NOWAIT to NOT give up the input focus. A sys$waitfr2291 * has to follow to simulate the wanted synchronous behaviour.2292 * The next problem is ctrl+y which isn't caught by the crtl and2293 * therefore isn't converted to SIGQUIT (for a signal handler which is2294 * already established). The only way to catch ctrl+y, is an AST2295 * assigned to the input channel. But ctrl+y handling of DCL needs to be2296 * disabled, otherwise it will handle it. Not to mention the previous2297 * ctrl+y handling of DCL needs to be re-established before make exits.2298 * One more: At the time of LIB$SPAWN signals are blocked. SIGQUIT will2299 * make it to the signal handler after the child "normally" terminates.2300 * This isn't enough. It seems reasonable for simple command lines like2301 * a 'cc foobar.c' spawned in a subprocess but it is unacceptable for2302 * spawning make. Therefore we need to abort the process in the AST.2303 *2304 * Prior to the spawn it is checked if an AST is already set up for2305 * ctrl+y, if not one is set up for a channel to SYS$COMMAND. In general2306 * this will work except if make is run in a batch environment, but there2307 * nobody can press ctrl+y. During the setup the DCL handling of ctrl+y2308 * is disabled and an exit handler is established to re-enable it.2309 * If the user interrupts with ctrl+y, the assigned AST will fire, force2310 * an abort to the subprocess and signal SIGQUIT, which will be caught by2311 * the already established handler and will bring us back to common code.2312 * After the spawn (now /nowait) a sys$waitfr simulates the /wait and2313 * enables the ctrl+y be delivered to this code. And the ctrl+c too,2314 * which the crtl converts to SIGINT and which is caught by the common2315 * signal handler. Because signals were blocked before entering this code2316 * sys$waitfr will always complete and the SIGQUIT will be processed after2317 * it (after termination of the current block, somewhere in common code).2318 * And SIGINT too will be delayed. That is ctrl+c can only abort when the2319 * current command completes. Anyway it's better than nothing :-)2320 */2321 2322 if (!setupYAstTried)2323 tryToSetupYAst();2324 status = lib$spawn (&cmddsc, /* cmd-string */2325 (ifiledsc.dsc$w_length == 0)?0:&ifiledsc, /* input-file */2326 (ofiledsc.dsc$w_length == 0)?0:&ofiledsc, /* output-file */2327 &spflags, /* flags */2328 &pnamedsc, /* proc name */2329 &child->pid, &child->cstatus, &child->efn,2330 0, 0,2331 0, 0, 0);2332 if (status & 1)2333 {2334 pidToAbort= child->pid;2335 status= sys$waitfr (child->efn);2336 pidToAbort= 0;2337 vmsHandleChildTerm(child);2338 }2339 #else2340 status = lib$spawn (&cmddsc,2341 (ifiledsc.dsc$w_length == 0)?0:&ifiledsc,2342 (ofiledsc.dsc$w_length == 0)?0:&ofiledsc,2343 &spflags,2344 &pnamedsc,2345 &child->pid, &child->cstatus, &child->efn,2346 vmsHandleChildTerm, child,2347 0, 0, 0);2348 #endif2349 2350 if (!(status & 1))2351 {2352 printf (_("Error spawning, %d\n") ,status);2353 fflush (stdout);2354 switch (status)2355 {2356 case 0x1c:2357 errno = EPROCLIM;2358 break;2359 default:2360 errno = EFAIL;2361 }2362 }2363 2364 if (comname && !ISDB (DB_JOBS))2365 unlink (comname);2366 2367 return (status & 1);2368 }2369 2370 #else /* !VMS */2371 1850 2372 1851 /* EMX: Start a child process. This function returns the new pid. */ 2373 # if defined __MSDOS__ || 1852 # if defined __MSDOS__ || defined __EMX__ 2374 1853 int 2375 1854 child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp) … … 2409 1888 pid = exec_command (argv, envp); 2410 1889 2411 /* Restore stdout/stdin of the parent process. */ 2412 if (stdin_fd != 0 && dup2 (save_stdin, 0) != 0) 2413 fatal (NILF, _("restoring of stdin failed\n")); 2414 if (stdout_fd != 1 && dup2 (save_stdout, 1) != 1) 2415 fatal (NILF, _("restoring of stdout failed\n")); 1890 /* Restore stdout/stdin of the parent and close temporary FDs. */ 1891 if (stdin_fd != 0) 1892 { 1893 if (dup2 (save_stdin, 0) != 0) 1894 fatal (NILF, _("Could not restore stdin\n")); 1895 else 1896 close (save_stdin); 1897 } 1898 1899 if (stdout_fd != 1) 1900 { 1901 if (dup2 (save_stdout, 1) != 1) 1902 fatal (NILF, _("Could not restore stdout\n")); 1903 else 1904 close (save_stdout); 1905 } 2416 1906 2417 1907 return pid; … … 2440 1930 } 2441 1931 #endif /* !AMIGA && !__MSDOS__ */ 2442 #endif /* !VMS */2443 1932 #endif /* !WINDOWS32 */ 2444 1933 … … 2452 1941 int 2453 1942 # else 2454 1943 void 2455 1944 # endif 2456 1945 exec_command (char **argv, char **envp) … … 2492 1981 2493 1982 /* wait and reap last child */ 2494 while (hWaitPID = process_wait_for_any()) 1983 hWaitPID = process_wait_for_any(); 1984 while (hWaitPID) 2495 1985 { 2496 1986 /* was an error found on this process? */ … … 2560 2050 char **new_argv; 2561 2051 int argc; 2052 int i=1; 2562 2053 2563 2054 # ifdef __EMX__ … … 2578 2069 ++argc; 2579 2070 2071 # ifdef __EMX__ 2072 if (!unixy_shell) 2073 ++argc; 2074 # endif 2075 2580 2076 new_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *)); 2581 2077 new_argv[0] = shell; 2582 new_argv[1] = argv[0]; 2078 2079 # ifdef __EMX__ 2080 if (!unixy_shell) 2081 { 2082 new_argv[1] = "/c"; 2083 ++i; 2084 --argc; 2085 } 2086 # endif 2087 2088 new_argv[i] = argv[0]; 2583 2089 while (argc > 0) 2584 2090 { 2585 new_argv[ 1+ argc] = argv[argc];2091 new_argv[i + argc] = argv[argc]; 2586 2092 --argc; 2587 2093 } … … 2751 2257 char* sh_chars; 2752 2258 char** sh_cmds; 2259 #elif defined(__riscos__) 2260 static char sh_chars[] = ""; 2261 static char *sh_cmds[] = { 0 }; 2753 2262 #else /* must be UNIX-ish */ 2754 2263 static char sh_chars[] = "#;\"*?[]&|<>(){}$`^~!"; … … 3021 2530 register int j; 3022 2531 for (j = 0; sh_cmds[j] != 0; ++j) 3023 if (streq (sh_cmds[j], new_argv[0])) 3024 goto slow; 2532 { 2533 if (streq (sh_cmds[j], new_argv[0])) 2534 goto slow; 2535 # ifdef __EMX__ 2536 /* Non-Unix shells are case insensitive. */ 2537 if (!unixy_shell 2538 && strcasecmp (sh_cmds[j], new_argv[0]) == 0) 2539 goto slow; 2540 # endif 2541 } 3025 2542 } 3026 2543 … … 3060 2577 /* Line was empty. */ 3061 2578 return 0; 3062 else 3063 2579 2580 return new_argv; 3064 2581 3065 2582 slow:; … … 3210 2727 int id = GetCurrentProcessId(); 3211 2728 PATH_VAR(fbuf); 3212 char* fname = NULL;3213 2729 3214 2730 /* create a file name */ 3215 2731 sprintf(fbuf, "make%d", id); 3216 fname = tempnam(".", fbuf); 3217 3218 /* create batch file name */ 3219 *batch_filename_ptr = xmalloc(strlen(fname) + 5); 3220 strcpy(*batch_filename_ptr, fname); 3221 3222 /* make sure path name is in DOS backslash format */ 3223 if (!unixy_shell) { 3224 fname = *batch_filename_ptr; 3225 for (i = 0; fname[i] != '\0'; ++i) 3226 if (fname[i] == '/') 3227 fname[i] = '\\'; 3228 strcat(*batch_filename_ptr, ".bat"); 3229 } else { 3230 strcat(*batch_filename_ptr, ".sh"); 3231 } 2732 *batch_filename_ptr = create_batch_filename (fbuf, unixy_shell); 3232 2733 3233 2734 DB (DB_JOBS, (_("Creating temporary batch file %s\n"), … … 3258 2759 (char *) 0, (char *) 0, 3259 2760 (char **) 0); 3260 # 2761 #ifdef __EMX__ 3261 2762 else if (!unixy_shell) 3262 2763 { 3263 /* new_line is local, must not be freed therefore */ 3264 char *p, *q; 3265 int quote; 3266 size_t index; 3267 size_t len; 3268 3269 /* handle quotes 3270 We have to remove all double quotes and to split the line 3271 into distinct arguments because of the strange handling 3272 of builtin commands by cmd: 'echo "bla"' prints "bla" 3273 (with quotes) while 'c:\bin\echo.exe "bla"' prints bla 3274 (without quotes). Some programs like autoconf rely 3275 on the second behaviour. */ 3276 3277 len = strlen (new_line) + 1; 3278 3279 /* More than 1 arg per character is impossible. */ 3280 new_argv = (char **) xmalloc (len * sizeof (char *)); 3281 3282 /* All the args can fit in a buffer as big as new_line is. */ 3283 new_argv[0] = (char *) xmalloc (len); 3284 3285 index = 0; 3286 quote = 0; 3287 q = new_line; 3288 p = new_argv[index]; 3289 while(*q != '\0') 3290 { 3291 /* searching for closing quote */ 3292 if (quote) 3293 { 3294 if (*q == quote) 3295 { 3296 /* remove the quote */ 3297 q++; 3298 quote = 0; 3299 } 3300 else /* normal character: copy it */ 3301 *p++ = *q++; 3302 } 3303 3304 /* searching for opening quote */ 3305 else if (*q == '\"' 3306 # ifndef NO_CMD_DEFAULT 3307 || *q == '\'' 3308 # endif 3309 ) 3310 { 3311 /* remove opening quote */ 3312 quote = *q; 3313 q++; 3314 } 3315 3316 /* spaces outside of a quoted string: remove them 3317 and start a new argument */ 3318 else if (*q == ' ' || *q == '\t') 3319 { 3320 *p++ = '\0'; /* trailing '\0' for last argument */ 3321 3322 /* remove all successive spaces */ 3323 do 3324 { 3325 q++; 3326 } 3327 while(*q == ' ' || *q == '\t'); 3328 3329 /* start new argument */ 3330 index++; 3331 new_argv[index] = p; 3332 } 3333 3334 /* normal character (no space) outside a quoted string*/ 3335 else 3336 *p++ = *q++; 3337 } /* end while() */ 3338 3339 *p = '\0'; /* trailing '\0' for the last argument */ 3340 new_argv[index + 1] = NULL; 3341 3342 # ifndef NO_CMD_DEFAULT 3343 /* special case: echo x="y" 3344 (e.g. autoconf uses this to determine whether make works) 3345 this is pure idioty but cmd works this way: 3346 if 'echo' and 'x="y"' are two different arguments cmd 3347 will print '"x="y""' but if they are only one argument 3348 cmd will print 'bla="blurb"' as it should be 3349 note: if we do not allow cmd to be the default shell 3350 we do not need this kind of voodoo */ 3351 if (index == 3 && strcasecmp(new_argv[2], "echo") == 0) 3352 { 3353 new_argv[2][4] = ' '; 3354 new_argv[3] = NULL; 3355 } 3356 # endif 2764 /* new_line is local, must not be freed therefore 2765 We use line here instead of new_line because we run the shell 2766 manually. */ 2767 size_t line_len = strlen (line); 2768 char *p = new_line; 2769 char *q = new_line; 2770 memcpy (new_line, line, line_len + 1); 2771 /* replace all backslash-newline combination and also following tabs */ 2772 while (*q != '\0') 2773 { 2774 if (q[0] == '\\' && q[1] == '\n') 2775 { 2776 q += 2; /* remove '\\' and '\n' */ 2777 if (q[0] == '\t') 2778 q++; /* remove 1st tab in the next line */ 2779 } 2780 else 2781 *p++ = *q++; 2782 } 2783 *p = '\0'; 2784 2785 # ifndef NO_CMD_DEFAULT 2786 if (strnicmp (new_line, "echo", 4) == 0 2787 && (new_line[4] == ' ' || new_line[4] == '\t')) 2788 { 2789 /* the builtin echo command: handle it separately */ 2790 size_t echo_len = line_len - 5; 2791 char *echo_line = new_line + 5; 2792 2793 /* special case: echo 'x="y"' 2794 cmd works this way: a string is printed as is, i.e., no quotes 2795 are removed. But autoconf uses a command like echo 'x="y"' to 2796 determine whether make works. autoconf expects the output x="y" 2797 so we will do exactly that. 2798 Note: if we do not allow cmd to be the default shell 2799 we do not need this kind of voodoo */ 2800 if (echo_line[0] == '\'' 2801 && echo_line[echo_len - 1] == '\'' 2802 && strncmp (echo_line + 1, "ac_maketemp=", 2803 strlen ("ac_maketemp=")) == 0) 2804 { 2805 /* remove the enclosing quotes */ 2806 memmove (echo_line, echo_line + 1, echo_len - 2); 2807 echo_line[echo_len - 2] = '\0'; 2808 } 2809 } 2810 # endif 2811 2812 { 2813 /* Let the shell decide what to do. Put the command line into the 2814 2nd command line argument and hope for the best ;-) */ 2815 size_t sh_len = strlen (shell); 2816 2817 /* exactly 3 arguments + NULL */ 2818 new_argv = (char **) xmalloc (4 * sizeof (char *)); 2819 /* Exactly strlen(shell) + strlen("/c") + strlen(line) + 3 times 2820 the trailing '\0' */ 2821 new_argv[0] = (char *) malloc (sh_len + line_len + 5); 2822 memcpy (new_argv[0], shell, sh_len + 1); 2823 new_argv[1] = new_argv[0] + sh_len + 1; 2824 memcpy (new_argv[1], "/c", 3); 2825 new_argv[2] = new_argv[1] + 3; 2826 memcpy (new_argv[2], new_line, line_len + 1); 2827 new_argv[3] = NULL; 2828 } 3357 2829 } 3358 2830 #elif defined(__MSDOS__) … … 3535 3007 } 3536 3008 #endif /* !HAPE_DUP2 && !_AMIGA */ 3009 3010 /* On VMS systems, include special VMS functions. */ 3011 3012 #ifdef VMS 3013 #include "vmsjobs.c" 3014 #endif -
branches/GNU/src/gmake/job.h
r54 r280 102 102 #endif 103 103 104 extern unsigned int jobserver_tokens; 105 104 106 #endif /* SEEN_JOB_H */ -
branches/GNU/src/gmake/main.c
r153 r280 1 1 /* Argument parsing and main program of GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 3 2002, 2003 Free Software Foundation, Inc.3 2002, 2003, 2005 Free Software Foundation, Inc. 4 4 This file is part of GNU Make. 5 5 … … 36 36 #ifdef WINDOWS32 37 37 #include <windows.h> 38 #include <io.h> 38 39 #include "pathstuff.h" 39 40 #endif … … 44 45 #ifdef HAVE_FCNTL_H 45 46 # include <fcntl.h> 47 #endif 48 49 #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) 50 # define SET_STACK_SIZE 51 #endif 52 53 #ifdef SET_STACK_SIZE 54 # include <sys/resource.h> 46 55 #endif 47 56 … … 186 195 int default_keep_going_flag = 0; 187 196 197 /* Nonzero means check symlink mtimes. */ 198 199 int check_symlink_flag = 0; 200 188 201 /* Nonzero means print directory before starting and when done (-w). */ 189 202 … … 207 220 unsigned int job_slots = 1; 208 221 unsigned int default_job_slots = 1; 222 static unsigned int master_job_slots = 0; 209 223 210 224 /* Value of job_slots that means no limit. */ … … 260 274 261 275 int always_make_flag = 0; 276 277 /* If nonzero, we're in the "try to rebuild makefiles" phase. */ 278 279 int rebuilding_makefiles = 0; 280 281 /* Remember the original value of the SHELL variable, from the environment. */ 282 283 struct variable shell_var; 284 262 285 263 286 … … 301 324 Don't start multiple jobs unless load is below N.\n"), 302 325 N_("\ 326 -L, --check-symlink-times Use the latest mtime between symlinks and target.\n"), 327 N_("\ 303 328 -n, --just-print, --dry-run, --recon\n\ 304 329 Don't actually run any commands; just print them.\n"), … … 348 373 #endif 349 374 { 'e', flag, (char *) &env_overrides, 1, 1, 0, 0, 0, 350 375 "environment-overrides", }, 351 376 { 'f', string, (char *) &makefiles, 0, 0, 0, 0, 0, "file" }, 352 377 { 'h', flag, (char *) &print_usage_flag, 0, 0, 0, 0, 0, "help" }, 353 378 { 'i', flag, (char *) &ignore_errors_flag, 1, 1, 0, 0, 0, 354 379 "ignore-errors" }, 355 380 { 'I', string, (char *) &include_directories, 1, 1, 0, 0, 0, 356 381 "include-dir" }, 357 382 { 'j', positive_int, (char *) &job_slots, 1, 1, 0, (char *) &inf_jobs, 358 383 (char *) &default_job_slots, "jobs" }, 359 384 { CHAR_MAX+2, string, (char *) &jobserver_fds, 1, 1, 0, 0, 0, 360 385 "jobserver-fds" }, 361 386 { 'k', flag, (char *) &keep_going_flag, 1, 1, 0, 0, 362 387 (char *) &default_keep_going_flag, "keep-going" }, 363 388 #ifndef NO_FLOAT 364 389 { 'l', floating, (char *) &max_load_average, 1, 1, 0, 365 366 390 (char *) &default_load_average, (char *) &default_load_average, 391 "load-average" }, 367 392 #else 368 393 { 'l', positive_int, (char *) &max_load_average, 1, 1, 0, 369 (char *) &default_load_average, (char *) &default_load_average, 370 "load-average" }, 371 #endif 394 (char *) &default_load_average, (char *) &default_load_average, 395 "load-average" }, 396 #endif 397 { 'L', flag, (char *) &check_symlink_flag, 1, 1, 0, 0, 0, 398 "check-symlink-times" }, 372 399 { 'm', ignore, 0, 0, 0, 0, 0, 0, 0 }, 373 400 { 'n', flag, (char *) &just_print_flag, 1, 1, 1, 0, 0, "just-print" }, 374 401 { 'o', string, (char *) &old_files, 0, 0, 0, 0, 0, "old-file" }, 375 402 { 'p', flag, (char *) &print_data_base_flag, 1, 1, 0, 0, 0, 376 403 "print-data-base" }, 377 404 { 'q', flag, (char *) &question_flag, 1, 1, 1, 0, 0, "question" }, 378 405 { 'r', flag, (char *) &no_builtin_rules_flag, 1, 1, 0, 0, 0, 379 406 "no-builtin-rules" }, 380 407 { 'R', flag, (char *) &no_builtin_variables_flag, 1, 1, 0, 0, 0, 381 408 "no-builtin-variables" }, 382 409 { 's', flag, (char *) &silent_flag, 1, 1, 0, 0, 0, "silent" }, 383 410 { 'S', flag_off, (char *) &keep_going_flag, 1, 1, 0, 0, … … 386 413 { 'v', flag, (char *) &print_version_flag, 1, 1, 0, 0, 0, "version" }, 387 414 { 'w', flag, (char *) &print_directory_flag, 1, 1, 0, 0, 0, 388 415 "print-directory" }, 389 416 { CHAR_MAX+3, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0, 390 417 "no-print-directory" }, 391 418 { 'W', string, (char *) &new_files, 0, 0, 0, 0, 0, "what-if" }, 392 419 { CHAR_MAX+4, flag, (char *) &warn_undefined_variables_flag, 1, 1, 0, 0, 0, 393 420 "warn-undefined-variables" }, 394 421 { 0 } 395 422 }; … … 446 473 447 474 struct file *default_goal_file; 475 476 /* Pointer to the value of the .DEFAULT_GOAL special 477 variable. */ 478 char ** default_goal_name; 448 479 449 480 /* Pointer to structure for the file .DEFAULT … … 549 580 /* Toggle -d on receipt of SIGUSR1. */ 550 581 582 #ifdef SIGUSR1 551 583 static RETSIGTYPE 552 584 debug_signal_handler (int sig UNUSED) … … 554 586 db_level = db_level ? DB_NONE : DB_BASIC; 555 587 } 588 #endif 556 589 557 590 static void … … 696 729 { 697 730 int sh_found = 0; 698 char* search_token; 731 char *search_token; 732 char *tokend; 699 733 PATH_VAR(sh_path); 700 734 extern char *default_shell; … … 705 739 search_token = token; 706 740 707 if (!no_default_sh_exe && 708 (token == NULL || !strcmp(search_token, default_shell))) { 741 742 /* If the user explicitly requests the DOS cmd shell, obey that request. 743 However, make sure that's what they really want by requiring the value 744 of SHELL either equal, or have a final path element of, "cmd" or 745 "cmd.exe" case-insensitive. */ 746 tokend = search_token + strlen (search_token) - 3; 747 if (((tokend == search_token 748 || (tokend > search_token 749 && (tokend[-1] == '/' || tokend[-1] == '\\'))) 750 && !strcmpi (tokend, "cmd")) 751 || ((tokend - 4 == search_token 752 || (tokend - 4 > search_token 753 && (tokend[-5] == '/' || tokend[-5] == '\\'))) 754 && !strcmpi (tokend - 4, "cmd.exe"))) { 755 batch_mode_shell = 1; 756 unixy_shell = 0; 757 sh_found = 0; 758 } else if (!no_default_sh_exe && 759 (token == NULL || !strcmp (search_token, default_shell))) { 709 760 /* no new information, path already set or known */ 710 761 sh_found = 1; … … 718 769 } else { 719 770 char *p; 720 struct variable *v = lookup_variable ("Path", 4); 721 722 /* 723 * Search Path for shell 724 */ 771 struct variable *v = lookup_variable ("PATH", 4); 772 773 /* Search Path for shell */ 725 774 if (v && v->value) { 726 775 char *ep; … … 841 890 struct file *f; 842 891 int i; 892 int makefile_status = MAKE_SUCCESS; 843 893 char **p; 844 894 struct dep *read_makefiles; … … 853 903 unixy_shell = 0; 854 904 no_default_sh_exe = 1; 905 #endif 906 907 #ifdef SET_STACK_SIZE 908 /* Get rid of any avoidable limit on stack size. */ 909 { 910 struct rlimit rlim; 911 912 /* Set the stack limit huge so that alloca does not fail. */ 913 if (getrlimit (RLIMIT_STACK, &rlim) == 0) 914 { 915 rlim.rlim_cur = rlim.rlim_max; 916 setrlimit (RLIMIT_STACK, &rlim); 917 } 918 } 855 919 #endif 856 920 … … 978 1042 program = argv[0] + 1; 979 1043 #endif 1044 #ifdef WINDOWS32 1045 if (program == 0) 1046 { 1047 /* Extract program from full path */ 1048 int argv0_len; 1049 char *p = strrchr (argv[0], '\\'); 1050 if (!p) 1051 p = argv[0]; 1052 argv0_len = strlen(p); 1053 if (argv0_len > 4 1054 && streq (&p[argv0_len - 4], ".exe")) 1055 { 1056 /* Remove .exe extension */ 1057 p[argv0_len - 4] = '\0'; 1058 /* Increment past the initial '\' */ 1059 program = p + 1; 1060 } 1061 } 1062 #endif 980 1063 if (program == 0) 981 1064 program = argv[0]; … … 998 1081 { 999 1082 #ifdef HAVE_GETCWD 1000 perror_with_name ("getcwd :", "");1083 perror_with_name ("getcwd", ""); 1001 1084 #else 1002 1085 error (NILF, "getwd: %s", current_directory); … … 1014 1097 /* Initialize the special variables. */ 1015 1098 define_variable (".VARIABLES", 10, "", o_default, 0)->special = 1; 1016 /* define_variable (".TARGETS", 8, "", o_default, 0); */ 1099 /* define_variable (".TARGETS", 8, "", o_default, 0)->special = 1; */ 1100 1101 /* Set up .FEATURES */ 1102 define_variable (".FEATURES", 9, 1103 "target-specific order-only second-expansion", 1104 o_default, 0); 1105 #ifdef MAKE_JOBSERVER 1106 do_variable_definition (NILF, ".FEATURES", "jobserver", 1107 o_default, f_append, 0); 1108 #endif 1109 #ifdef MAKE_SYMLINKS 1110 do_variable_definition (NILF, ".FEATURES", "check-symlink", 1111 o_default, f_append, 0); 1112 #endif 1017 1113 1018 1114 /* Read in variables from the environment. It is important that this be … … 1023 1119 for (i = 0; envp[i] != 0; ++i) 1024 1120 { 1025 int do_not_define; 1026 register char *ep = envp[i]; 1027 1028 /* by default, everything gets defined and exported */ 1029 do_not_define = 0; 1030 1031 while (*ep != '=') 1121 int do_not_define = 0; 1122 char *ep = envp[i]; 1123 1124 while (*ep != '\0' && *ep != '=') 1032 1125 ++ep; 1033 1126 #ifdef WINDOWS32 1034 1127 if (!unix_path && strneq(envp[i], "PATH=", 5)) 1035 1128 unix_path = ep+1; 1036 else if (! windows32_path && !strnicmp(envp[i], "Path=", 5)) {1129 else if (!strnicmp(envp[i], "Path=", 5)) { 1037 1130 do_not_define = 1; /* it gets defined after loop exits */ 1038 windows32_path = ep+1; 1131 if (!windows32_path) 1132 windows32_path = ep+1; 1039 1133 } 1040 1134 #endif … … 1043 1137 the same. */ 1044 1138 if (!do_not_define) 1045 define_variable (envp[i], (unsigned int) (ep - envp[i]), 1046 ep + 1, o_env, 1) 1047 /* Force exportation of every variable culled from the environment. 1048 We used to rely on target_environment's v_default code to do this. 1049 But that does not work for the case where an environment variable 1050 is redefined in a makefile with `override'; it should then still 1051 be exported, because it was originally in the environment. */ 1052 ->export = v_export; 1139 { 1140 struct variable *v; 1141 1142 v = define_variable (envp[i], (unsigned int) (ep - envp[i]), 1143 ep + 1, o_env, 1); 1144 /* Force exportation of every variable culled from the environment. 1145 We used to rely on target_environment's v_default code to do this. 1146 But that does not work for the case where an environment variable 1147 is redefined in a makefile with `override'; it should then still 1148 be exported, because it was originally in the environment. */ 1149 v->export = v_export; 1150 1151 /* Another wrinkle is that POSIX says the value of SHELL set in the 1152 makefile should not change the value of SHELL given to 1153 subprocesses, which seems silly to me but... */ 1154 if (strncmp (envp[i], "SHELL=", 6) == 0) 1155 { 1156 #ifndef __MSDOS__ 1157 v->export = v_noexport; 1158 #endif 1159 shell_var.name = "SHELL"; 1160 shell_var.value = xstrdup (ep + 1); 1161 } 1162 } 1053 1163 } 1054 1164 #ifdef WINDOWS32 1055 /* 1056 * Make sure that this particular spelling of 'Path' is available1165 /* If we didn't find a correctly spelled PATH we define PATH as 1166 * either the first mispelled value or an empty string 1057 1167 */ 1058 if (windows32_path) 1059 define_variable("Path", 4, windows32_path, o_env, 1)->export = v_export; 1060 else if (unix_path) 1061 define_variable("Path", 4, unix_path, o_env, 1)->export = v_export; 1062 else 1063 define_variable("Path", 4, "", o_env, 1)->export = v_export; 1064 1065 /* 1066 * PATH defaults to Path iff PATH not found and Path is found. 1067 */ 1068 if (!unix_path && windows32_path) 1069 define_variable("PATH", 4, windows32_path, o_env, 1)->export = v_export; 1168 if (!unix_path) 1169 define_variable("PATH", 4, 1170 windows32_path ? windows32_path : "", 1171 o_env, 1)->export = v_export; 1070 1172 #endif 1071 1173 #else /* For Amiga, read the ENV: device, ignoring all dirs */ … … 1237 1339 { 1238 1340 char *dir = directories->list[i]; 1341 char *expanded = 0; 1239 1342 if (dir[0] == '~') 1240 1343 { 1241 char *expanded = tilde_expand (dir);1344 expanded = tilde_expand (dir); 1242 1345 if (expanded != 0) 1243 1346 dir = expanded; 1244 1347 } 1348 #ifdef WINDOWS32 1349 /* WINDOWS32 chdir() doesn't work if the directory has a trailing '/' 1350 But allow -C/ just in case someone wants that. */ 1351 { 1352 char *p = dir + strlen (dir) - 1; 1353 while (p > dir && (p[0] == '/' || p[0] == '\\')) 1354 --p; 1355 p[1] = '\0'; 1356 } 1357 #endif 1245 1358 if (chdir (dir) < 0) 1246 1359 pfatal_with_name (dir); 1247 if ( dir != directories->list[i])1248 free ( dir);1360 if (expanded) 1361 free (expanded); 1249 1362 } 1250 1363 … … 1301 1414 { 1302 1415 #ifdef HAVE_GETCWD 1303 perror_with_name ("getcwd :", "");1416 perror_with_name ("getcwd", ""); 1304 1417 #else 1305 1418 error (NILF, "getwd: %s", current_directory); … … 1368 1481 if (outfile == 0) 1369 1482 pfatal_with_name (_("fopen (temporary file)")); 1370 while (!feof (stdin) )1483 while (!feof (stdin) && ! ferror (stdin)) 1371 1484 { 1372 1485 char buf[2048]; … … 1448 1561 define_default_variables (); 1449 1562 1563 default_file = enter_file (".DEFAULT"); 1564 1565 { 1566 struct variable *v = define_variable (".DEFAULT_GOAL", 13, "", o_file, 0); 1567 default_goal_name = &v->value; 1568 } 1569 1450 1570 /* Read all the makefiles. */ 1451 1452 default_file = enter_file (".DEFAULT");1453 1571 1454 1572 read_makefiles … … 1580 1698 want job_slots to be 0 to indicate we're using the jobserver. */ 1581 1699 1700 master_job_slots = job_slots; 1701 1582 1702 while (--job_slots) 1583 1703 { … … 1599 1719 jobserver_fds->idx = 1; 1600 1720 jobserver_fds->max = 1; 1721 } 1722 #endif 1723 1724 #ifndef MAKE_SYMLINKS 1725 if (check_symlink_flag) 1726 { 1727 error (NILF, _("Symbolic links not supported: disabling -L.")); 1728 check_symlink_flag = 0; 1601 1729 } 1602 1730 #endif … … 1668 1796 int nargc = argc; 1669 1797 int orig_db_level = db_level; 1798 int status; 1670 1799 1671 1800 if (! ISDB (DB_MAKEFILES)) … … 1728 1857 define_makeflags (1, 1); 1729 1858 1730 switch (update_goal_chain (read_makefiles, 1)) 1859 rebuilding_makefiles = 1; 1860 status = update_goal_chain (read_makefiles); 1861 rebuilding_makefiles = 0; 1862 1863 switch (status) 1731 1864 { 1732 1865 case 1: … … 1777 1910 any_remade |= (mtime != NONEXISTENT_MTIME 1778 1911 && mtime != makefile_mtimes[i]); 1912 makefile_status = MAKE_FAILURE; 1779 1913 } 1780 1914 } … … 1866 2000 #ifndef _AMIGA 1867 2001 for (p = environ; *p != 0; ++p) 1868 if ( (*p)[MAKELEVEL_LENGTH] == '='1869 && strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH))2002 if (strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH) 2003 && (*p)[MAKELEVEL_LENGTH] == '=') 1870 2004 { 1871 2005 /* The SGI compiler apparently can't understand … … 1922 2056 int pid; 1923 2057 int status; 1924 pid = child_execute_job (0, 1, nargv, environ);2058 pid = child_execute_job (0, 1, nargv, environ); 1925 2059 1926 2060 /* is this loop really necessary? */ 1927 2061 do { 1928 pid = wait (&status);1929 } while (pid <= 0);2062 pid = wait (&status); 2063 } while (pid <= 0); 1930 2064 /* use the exit code of the child process */ 1931 exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);2065 exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE); 1932 2066 } 1933 2067 #else … … 1943 2077 1944 2078 db_level = orig_db_level; 2079 2080 /* Free the makefile mtimes (if we allocated any). */ 2081 if (makefile_mtimes) 2082 free ((char *) makefile_mtimes); 1945 2083 } 1946 2084 … … 1959 2097 if (goals == 0) 1960 2098 { 1961 if (default_goal_file != 0) 1962 { 1963 goals = (struct dep *) xmalloc (sizeof (struct dep)); 1964 goals->next = 0; 1965 goals->name = 0; 2099 if (**default_goal_name != '\0') 2100 { 2101 if (default_goal_file == 0 || 2102 strcmp (*default_goal_name, default_goal_file->name) != 0) 2103 { 2104 default_goal_file = lookup_file (*default_goal_name); 2105 2106 /* In case user set .DEFAULT_GOAL to a non-existent target 2107 name let's just enter this name into the table and let 2108 the standard logic sort it out. */ 2109 if (default_goal_file == 0) 2110 { 2111 struct nameseq *ns; 2112 char *p = *default_goal_name; 2113 2114 ns = multi_glob ( 2115 parse_file_seq (&p, '\0', sizeof (struct nameseq), 1), 2116 sizeof (struct nameseq)); 2117 2118 /* .DEFAULT_GOAL should contain one target. */ 2119 if (ns->next != 0) 2120 fatal (NILF, _(".DEFAULT_GOAL contains more than one target")); 2121 2122 default_goal_file = enter_file (ns->name); 2123 2124 ns->name = 0; /* It was reused by enter_file(). */ 2125 free_ns_chain (ns); 2126 } 2127 } 2128 2129 goals = (struct dep *) xmalloc (sizeof (struct dep)); 2130 goals->next = 0; 2131 goals->name = 0; 1966 2132 goals->ignore_mtime = 0; 1967 goals->file = default_goal_file; 1968 } 2133 goals->need_2nd_expansion = 0; 2134 goals->file = default_goal_file; 2135 } 1969 2136 } 1970 2137 else 1971 2138 lastgoal->next = 0; 2139 1972 2140 1973 2141 if (!goals) … … 1983 2151 DB (DB_BASIC, (_("Updating goal targets....\n"))); 1984 2152 1985 switch (update_goal_chain (goals , 0))2153 switch (update_goal_chain (goals)) 1986 2154 { 1987 2155 case -1: … … 1989 2157 case 0: 1990 2158 /* Updated successfully. */ 1991 status = MAKE_SUCCESS;2159 status = makefile_status; 1992 2160 break; 1993 2161 case 1: … … 2093 2261 if (v != 0) 2094 2262 { 2095 /* It is indeed a variable definition. Record a pointer to 2096 the variable for later use in define_makeflags. */ 2097 struct command_variable *cv 2098 = (struct command_variable *) xmalloc (sizeof (*cv)); 2099 cv->variable = v; 2100 cv->next = command_variables; 2101 command_variables = cv; 2263 /* It is indeed a variable definition. If we don't already have this 2264 one, record a pointer to the variable for later use in 2265 define_makeflags. */ 2266 struct command_variable *cv; 2267 2268 for (cv = command_variables; cv != 0; cv = cv->next) 2269 if (cv->variable == v) 2270 break; 2271 2272 if (! cv) { 2273 cv = (struct command_variable *) xmalloc (sizeof (*cv)); 2274 cv->variable = v; 2275 cv->next = command_variables; 2276 command_variables = cv; 2277 } 2102 2278 } 2103 2279 else if (! env) … … 2122 2298 lastgoal->file = f; 2123 2299 lastgoal->ignore_mtime = 0; 2300 lastgoal->need_2nd_expansion = 0; 2124 2301 2125 2302 { … … 2770 2947 if (!dying) 2771 2948 { 2949 char token = '+'; 2772 2950 int err; 2773 2951 … … 2789 2967 if (print_data_base_flag) 2790 2968 print_data_base (); 2969 2970 /* Sanity: have we written all our jobserver tokens back? If our 2971 exit status is 2 that means some kind of syntax error; we might not 2972 have written all our tokens so do that now. If tokens are left 2973 after any other error code, that's bad. */ 2974 2975 if (job_fds[0] != -1 && jobserver_tokens) 2976 { 2977 if (status != 2) 2978 error (NILF, 2979 "INTERNAL: Exiting with %u jobserver tokens (should be 0)!", 2980 jobserver_tokens); 2981 else 2982 while (jobserver_tokens--) 2983 { 2984 int r; 2985 2986 EINTRLOOP (r, write (job_fds[1], &token, 1)); 2987 if (r != 1) 2988 perror_with_name ("write", ""); 2989 } 2990 } 2991 2992 2993 /* Sanity: If we're the master, were all the tokens written back? */ 2994 2995 if (master_job_slots) 2996 { 2997 /* We didn't write one for ourself, so start at 1. */ 2998 unsigned int tcnt = 1; 2999 3000 /* Close the write side, so the read() won't hang. */ 3001 close (job_fds[1]); 3002 3003 while ((err = read (job_fds[0], &token, 1)) == 1) 3004 ++tcnt; 3005 3006 if (tcnt != master_job_slots) 3007 error (NILF, 3008 "INTERNAL: Exiting with %u jobserver tokens available; should be %u!", 3009 tcnt, master_job_slots); 3010 } 2791 3011 2792 3012 /* Try to move back to the original directory. This is essential on … … 2854 3074 printf (_("%s[%u]: Leaving directory `%s'\n"), 2855 3075 program, makelevel, starting_directory); 3076 3077 /* Flush stdout to be sure this comes before any stderr output. */ 3078 fflush (stdout); 2856 3079 } -
branches/GNU/src/gmake/maintMakefile
r54 r280 2 2 # only if you have the full copy of the GNU make sources from the CVS 3 3 # tree, not a dist copy. 4 # 4 5 # We like mondo-warnings! 6 AM_CFLAGS += -Wall -W 5 7 6 8 # Find the glob source files... this might be dangerous, but we're maintainers! 7 #8 9 globsrc := $(wildcard glob/*.c) 9 10 globhdr := $(wildcard glob/*.h) … … 14 15 15 16 all-am: $(TEMPLATES) $(MTEMPLATES) build.sh.in 16 17 # We need this to ensure that README and build.sh.in are created on time to18 # avoid errors by automake.19 #20 #Makefile.in: README build.sh.in21 17 22 18 # General rule for turning a .template into a regular file. … … 56 52 rm -f $@ 57 53 sed -e 's@%objs%@$(patsubst %.o,%.$${OBJEXT},$(filter-out remote-%,$(make_OBJECTS)))@g' \ 58 -e 's@%globobjs%@$(patsubst %.c,%.$${OBJEXT},$(globsrc)) )@g' \54 -e 's@%globobjs%@$(patsubst %.c,%.$${OBJEXT},$(globsrc))@g' \ 59 55 $< > $@ 60 56 chmod a-w+x $@ … … 67 63 # to do it ourselves. 68 64 # 65 DEP_FILES := $(wildcard $(DEPDIR)/*.Po) 69 66 .dep_segment: Makefile.am maintMakefile $(DEP_FILES) 70 cat $(DEP_FILES) \ 71 | sed -e '/^[^:]*\.[ch] *:/d' \ 72 -e 's, /usr/[^ ]*,,g' \ 73 -e 's, $(srcdir)/, ,g' \ 74 -e '/^ \\$$/d' \ 75 > $@ 67 (for f in $(DEPDIR)/*.Po; do \ 68 echo ""; \ 69 echo "# $$f"; \ 70 cat $$f \ 71 | sed -e '/^[^:]*\.[ch] *:/d' \ 72 -e 's, /usr/[^ ]*,,g' \ 73 -e 's, $(srcdir)/, ,g' \ 74 -e '/^ *\\$$/d' \ 75 -e '/^ *$$/d'; \ 76 done) > $@ 76 77 77 78 # Get rid of everything "else". … … 80 81 81 82 CVS-CLEAN-FILES += $(maintFILES) $(TEMPLATES) $(MTEMPLATES) NMakefile \ 82 missing build.sh.in .dep_segment po-check-? 83 build.sh.in .deps .dep_segment ABOUT-NLS \ 84 ansi2knr.* 83 85 84 86 # This rule tries to clean the tree right down to how it looks when you do a 85 87 # virgin CVS checkout. 86 88 89 # This is potentially dangerous since it removes _ANY FILE_ that is not in 90 # CVS. Including files you might mean to add to CVS but haven't yet... 91 # I only use this in subdirectories where it's unlikely we have any new 92 # files. Stil... 93 cvsclean = perl -e '$$k{CVS} = 1; open(E,"< CVS/Entries") || die "CVS/Entries: $$!\n"; while (defined ($$_ = <E>)) { m%^/([^/]*)% or next; $$k{$$1} = 1; } close(E) || die "CVS/Entries: $$!\n"; opendir(D, ".") || die ".: $$!\n"; while (defined ($$_ = readdir(D))) { -f $$_ && ! exists $$k{$$_} && unlink($$_); } closedir(D) || die ".: $$!\n";' 94 87 95 .PHONY: cvs-clean 88 96 cvs-clean: maintainer-clean 89 -rm -f *~ 90 -rm -f config/*~ config/Makefile.in config/[a-z]* 91 -rm -f po/*~ po/Makefile.in.in po/Rules-quot po/[a-z]* 92 -rm -f doc/*~ doc/Makefile.in doc/fdl.texi doc/make-stds.texi \ 93 doc/texinfo.tex 94 -rm -f glob/*~ glob/Makefile.in 95 -rm -f ABOUT-NLS $(CVS-CLEAN-FILES) 97 -rm -rf *~ $(CVS-CLEAN-FILES) 98 -cd config && $(cvsclean) 99 -cd po && $(cvsclean) 100 -cd doc && $(cvsclean) 101 -cd glob && $(cvsclean) 96 102 97 103 … … 119 125 # ------------------- # 120 126 121 po_repo = http://www 2.iro.umontreal.ca/%7Egnutra/po/maint/$(PACKAGE)127 po_repo = http://www.iro.umontreal.ca/translation/maint/$(PACKAGE) 122 128 .PHONY: do-po-update po-update 123 129 do-po-update: … … 136 142 137 143 # -------------------------- # 138 # Updating GNU build tools. #144 # Updating GNU build files. # 139 145 # -------------------------- # 140 146 … … 142 148 # with each of the files that belongs to some other package and is 143 149 # regularly updated from the specified URL. 144 # $(srcdir)/src/ansi2knr.c 145 146 147 wget_files ?= $(srcdir)/doc/texinfo.tex $(srcdir)/doc/make-stds.texi \ 148 $(srcdir)/doc/fdl.texi 149 150 wget-targets = $(patsubst %, get-%, $(wget_files)) 151 152 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/ 153 154 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/ 155 156 standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/ 157 make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/ 158 fdl.texi-url_prefix = $(ftp-gnu)/GNUinfo/ 159 150 151 savannah-url = http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~ 160 152 target = $(patsubst get-%,%,$@) 161 url = $($(notdir $(target))-url_prefix)$(notdir $(target)) 162 163 .PHONY: $(wget-targets) 164 $(wget-targets): 165 @echo $(WGET) $(url) -O $(target) \ 166 && $(WGET) $(url) -O $(target).t \ 167 && $(move_if_change) 168 169 config-prefix = http://savannah.gnu.org/cgi-bin/viewcvs/config 170 config-url = $(config-prefix)/$(patsubst get-%,%,$@)?rev=HEAD 153 154 config-url = $(savannah-url)/config/config/$(patsubst get-config/%,%,$@) 171 155 get-config/config.guess get-config/config.sub: 172 156 @echo $(WGET) $(config-url) -O $(target) \ … … 174 158 && $(move_if_change) 175 159 176 177 .PHONY: wget-update 178 wget-update: $(wget-targets) 179 180 181 # Updating tools via CVS. 182 cvs_files ?= depcomp missing 183 # config/config.guess config/config.sub 184 cvs-targets = $(patsubst %, get-%, $(cvs_files)) 185 186 automake_repo = :pserver:[email protected]:/cvs/automake 187 .PHONY: $(cvs-targets) 188 $(cvs-targets): 189 $(CVS) -d $(automake_repo) co -p automake/lib/$(notdir $(target)) \ 190 >$(target).t \ 191 && $(move_if_change) 160 gnulib-url = $(savannah-url)/gnulib/gnulib/build-aux/$(patsubst get-config/%,%,$@) 161 get-config/texinfo.tex: 162 @echo $(WGET) $(gnulib-url) -O $(target) \ 163 && $(WGET) $(gnulib-url) -O $(target).t \ 164 && $(move_if_change) 165 166 gnustandards-url = $(savannah-url)/gnustandards/gnustandards/$(patsubst get-doc/%,%,$@) 167 get-doc/make-stds.texi get-doc/fdl.texi: 168 @echo $(WGET) $(gnustandards-url) -O $(target) \ 169 && $(WGET) $(gnustandards-url) -O $(target).t \ 170 && $(move_if_change) 192 171 193 172 .PHONY: cvs-update 194 cvs-update: $(cvs-targets) get-config/config.guess get-config/config.sub173 cvs-update: get-config/texinfo.tex get-config/config.guess get-config/config.sub get-doc/make-stds.texi get-doc/fdl.texi 195 174 196 175 … … 200 179 201 180 .PHONY: update 202 update: wget-update po-update 203 204 # cvs-update 181 update: po-update cvs-update 205 182 206 183 … … 232 209 rm -f $@-1 $@-2; \ 233 210 fi 211 212 ## ------------------------- ## 213 ## GNU FTP upload artifacts. ## 214 ## ------------------------- ## 215 216 # This target creates the upload artifacts. 217 # Sign it with my key. 218 219 GPG = gpg 220 GPGFLAGS = -u 6338B6D4 221 222 DIST_ARCHIVES_SIG = $(addsuffix .sig,$(DIST_ARCHIVES)) 223 DIST_ARCHIVES_DIRECTIVE = $(addsuffix .directive.asc,$(DIST_ARCHIVES)) 224 225 .PHONY: distsign 226 distsign: $(DIST_ARCHIVES_SIG) $(DIST_ARCHIVES_DIRECTIVE) 227 228 $(DIST_ARCHIVES_DIRECTIVE): .directive.asc 229 cp $< $@ 230 231 %.sig : % 232 @echo "Signing file '$<':" 233 $(GPG) $(GPGFLAGS) -o $@ -b $< 234 235 .directive.asc: 236 @echo "Creating directive file '$@':" 237 @echo 'directory: make' > .directive 238 $(GPG) $(GPGFLAGS) -o $@ --clearsign .directive 239 @rm -f .directive 240 241 # Upload the artifacts 242 243 FTPPUT = ncftpput 244 gnu-url = ftp-upload.gnu.org /incoming 245 246 UPLOADS = upload-alpha upload-ftp 247 .PHONY: $(UPLOADS) 248 $(UPLOADS): $(DIST_ARCHIVES) $(DIST_ARCHIVES_SIG) $(DIST_ARCHIVES_DIRECTIVE) 249 $(FTPPUT) $(gnu-url)/$(@:upload-%=%) $^ -
branches/GNU/src/gmake/make.h
r153 r280 367 367 extern void sync_Path_environment(void); 368 368 extern int kill(int pid, int sig); 369 extern int safe_stat(char *file, struct stat *sb);370 369 extern char *end_of_token_w32(char *s, char stopchar); 371 370 extern int find_and_set_default_shell(char *token); … … 422 421 extern char *find_next_token PARAMS ((char **, unsigned int *)); 423 422 extern char *next_token PARAMS ((const char *)); 424 extern char *end_of_token PARAMS ((c har *));423 extern char *end_of_token PARAMS ((const char *)); 425 424 extern void collapse_continuations PARAMS ((char *)); 426 425 extern void remove_comments PARAMS((char *)); 427 extern char *sindex PARAMS ((const char *, unsigned int, \428 const char *, unsigned int));429 426 extern char *lindex PARAMS ((const char *, const char *, int)); 430 427 extern int alpha_compare PARAMS ((const void *, const void *)); … … 464 461 extern void child_access PARAMS ((void)); 465 462 463 extern char * 464 strip_whitespace PARAMS ((const char **begpp, const char **endpp)); 465 466 466 467 #ifdef HAVE_VFORK_H 467 468 # include <vfork.h> … … 496 497 extern int print_data_base_flag, question_flag, touch_flag, always_make_flag; 497 498 extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag; 498 extern int print_version_flag, print_directory_flag ;499 extern int print_version_flag, print_directory_flag, check_symlink_flag; 499 500 extern int warn_undefined_variables_flag, posix_pedantic, not_parallel; 500 extern int clock_skew_detected ;501 extern int clock_skew_detected, rebuilding_makefiles; 501 502 502 503 /* can we run commands via 'sh -c xxx' or must we use batch files? */ -
branches/GNU/src/gmake/makefile.vms
r54 r280 6 6 # Modified for version 3.78.1 by [email protected]. 7 7 # Modified for version 3.80 by [email protected] 8 # Modified for version 3.81 by Hartmut Becker 8 9 # 9 10 # GNU Make is free software; you can redistribute it and/or modify … … 32 33 33 34 ifeq ($(CC),cc) 34 CFLAGS = $(defines) /include=([],[.glob])/prefix= all/standard=relaxed35 CFLAGS = $(defines) /include=([],[.glob])/prefix=(all,except=(glob,globfree))/standard=relaxed 35 36 else 36 37 CFLAGS = $(defines) /include=([],[.glob]) … … 112 113 $$ purge [...] 113 114 -$(RM) make.exe;,*.obj; 114 -$(RM) *.opt;115 115 -$(RM) [.glob]*.obj; 116 116 -
branches/GNU/src/gmake/misc.c
r153 r280 419 419 420 420 421 /* Search string BIG (length BLEN) for an occurrence of422 string SMALL (length SLEN). Return a pointer to the423 beginning of the first occurrence, or return nil if none found. */424 425 char *426 sindex (const char *big, unsigned int blen,427 const char *small, unsigned int slen)428 {429 if (!blen)430 blen = strlen (big);431 if (!slen)432 slen = strlen (small);433 434 if (slen && blen >= slen)435 {436 register unsigned int b;437 438 /* Quit when there's not enough room left for the small string. */439 --slen;440 blen -= slen;441 442 for (b = 0; b < blen; ++b, ++big)443 if (*big == *small && strneq (big + 1, small + 1, slen))444 return (char *)big;445 }446 447 return 0;448 }449 421 450 422 /* Limited INDEX: … … 468 440 469 441 char * 470 end_of_token (c har *s)442 end_of_token (const char *s) 471 443 { 472 444 while (*s != '\0' && !isblank ((unsigned char)*s)) 473 445 ++s; 474 return s;446 return (char *)s; 475 447 } 476 448 … … 563 535 564 536 537 /* Free a chain of `struct nameseq'. Each nameseq->name is freed 538 as well. Can be used on `struct dep' chains.*/ 539 540 void 541 free_ns_chain (struct nameseq *n) 542 { 543 register struct nameseq *tmp; 544 545 while (n != 0) 546 { 547 if (n->name != 0) 548 free (n->name); 549 550 tmp = n; 551 552 n = n->next; 553 554 free (tmp); 555 } 556 557 } 558 565 559 #ifdef iAPX286 566 560 /* The losing compiler on this machine can't handle this macro. */ -
branches/GNU/src/gmake/po
- Property svn:ignore
-
old new 6 6 Makefile.in 7 7 Makefile.in.in 8 Makevars.template 8 9 Rules-quot 10 stamp-po 9 11 *.sed 10 12 *.sin
-
- Property svn:ignore
-
branches/GNU/src/gmake/po/.cvsignore
r53 r280 1 1 *.gmo *.mo *.pot *.po 2 2 3 Makefile Makefile.in Makefile.in.in 4 Rules-quot 3 Makefile Makefile.in Makefile.in.in Makevars.template 4 Rules-quot stamp-po 5 5 *.sed *.sin *.header 6 6 POTFILES -
branches/GNU/src/gmake/po/ChangeLog
r53 r280 1 2005-05-09 Paul D. Smith <[email protected]> 2 3 * POTFILES.in: Add new file vmsjobs.c. 4 5 2005-04-06 Paul D. Smith <[email protected]> 6 7 * LINGUAS: Added a new translation for Kinywarwanda (rw). 8 9 2005-02-09 Paul D. Smith <[email protected]> 10 11 * LINGUAS: Added a new translation for Irish (ga). 12 13 2005-02-01 Paul D. Smith <[email protected]> 14 15 * LINGUAS: Added a new translation for Finnish (fi). 16 1 17 2003-10-18 Paul D. Smith <[email protected]> 2 18 -
branches/GNU/src/gmake/po/LINGUAS
r53 r280 1 # Set of available languages: 16languages1 # Set of available languages: 20 languages 2 2 3 be da de es f r gl he hr ja ko nl pl pt_BR sv rutr uk zh_CN3 be da de es fi fr ga gl he hr ja ko nl pl pt_BR ru rw sv tr uk zh_CN 4 4 5 5 # Can't seem to get en@quot and en@boldquot to build properly? -
branches/GNU/src/gmake/po/POTFILES.in
r53 r280 23 23 variable.h 24 24 vmsfunctions.c 25 vmsjobs.c 25 26 vpath.c -
branches/GNU/src/gmake/read.c
r153 r280 79 79 unsigned int if_cmds; /* Depth of conditional nesting. */ 80 80 unsigned int allocated; /* Elts allocated in following arrays. */ 81 char *ignoring; /* Are we ignoring or interepreting? */ 81 char *ignoring; /* Are we ignoring or interpreting? 82 0=interpreting, 1=not yet interpreted, 83 2=already interpreted */ 82 84 char *seen_else; /* Have we already seen an `else'? */ 83 85 }; … … 131 133 enum variable_origin origin, 132 134 struct ebuffer *ebuf)); 133 static int conditional_line PARAMS ((char *line, const struct floc *flocp));135 static int conditional_line PARAMS ((char *line, int len, const struct floc *flocp)); 134 136 static void record_files PARAMS ((struct nameseq *filenames, char *pattern, char *pattern_percent, 135 137 struct dep *deps, unsigned int cmds_started, char *commands, 136 138 unsigned int commands_idx, int two_colon, 137 int have_sysv_atvar, 138 const struct floc *flocp, int set_default)); 139 const struct floc *flocp)); 139 140 static void record_target_var PARAMS ((struct nameseq *filenames, char *defn, 140 141 enum variable_origin origin, … … 256 257 d->file->dontcare = 1; 257 258 d->ignore_mtime = 0; 259 d->need_2nd_expansion = 0; 258 260 /* Tell update_goal_chain to bail out as soon as this file is 259 261 made, and main not to die if we can't make this file. */ … … 371 373 deps->file = lookup_file (filename); 372 374 if (deps->file == 0) 373 { 374 deps->file = enter_file (xstrdup (filename)); 375 if (flags & RM_DONTCARE) 376 deps->file->dontcare = 1; 377 } 375 deps->file = enter_file (xstrdup (filename)); 378 376 if (filename != ebuf.floc.filenm) 379 377 free (filename); … … 381 379 deps->changed = flags; 382 380 deps->ignore_mtime = 0; 381 deps->need_2nd_expansion = 0; 382 if (flags & RM_DONTCARE) 383 deps->file->dontcare = 1; 383 384 384 385 /* If the makefile can't be found at all, give up entirely. */ … … 412 413 413 414 free (ebuf.bufstart); 415 alloca (0); 414 416 return r; 415 417 } … … 443 445 reading_file = curfile; 444 446 447 alloca (0); 445 448 return r; 446 449 } … … 464 467 int ignoring = 0, in_ignored_define = 0; 465 468 int no_targets = 0; /* Set when reading a rule without targets. */ 466 int have_sysv_atvar = 0;467 469 struct nameseq *filenames = 0; 468 470 struct dep *deps = 0; … … 481 483 record_files (filenames, pattern, pattern_percent, deps, \ 482 484 cmds_started, commands, commands_idx, two_colon, \ 483 have_sysv_atvar, &fi, set_default);\485 &fi); \ 484 486 } \ 485 487 filenames = 0; \ … … 618 620 following lines. */ 619 621 620 if (!in_ignored_define 621 && (word1eq ("ifdef") || word1eq ("ifndef")622 || word1eq ("ifeq") || word1eq ("ifneq") 623 || word1eq ("else") || word1eq ("endif")))624 625 int i = conditional_line (p, fstart);626 if (i < 0) 627 fatal (fstart, _("invalid syntax in conditional")); 628 629 ignoring = i;630 continue; 622 if (!in_ignored_define) 623 { 624 int i = conditional_line (p, len, fstart); 625 if (i != -2) 626 { 627 if (i == -1) 628 fatal (fstart, _("invalid syntax in conditional")); 629 630 ignoring = i; 631 continue; 632 } 631 633 } 632 634 … … 853 855 goto rule_complete; 854 856 857 /* This line starts with a tab but was not caught above because there 858 was no preceding target, and the line might have been usable as a 859 variable definition. But now we know it is definitely lossage. */ 855 860 if (line[0] == '\t') 856 { 857 p = collapsed; /* Ignore comments, etc. */ 858 while (isblank ((unsigned char)*p)) 859 ++p; 860 if (*p == '\0') 861 /* The line is completely blank; that is harmless. */ 862 continue; 863 864 /* This line starts with a tab but was not caught above 865 because there was no preceding target, and the line 866 might have been usable as a variable definition. 867 But now we know it is definitely lossage. */ 868 fatal(fstart, _("commands commence before first target")); 869 } 861 fatal(fstart, _("commands commence before first target")); 870 862 871 863 /* This line describes some target files. This is complicated by … … 886 878 unsigned int len, plen = 0; 887 879 char *colonp; 880 const char *end, *beg; /* Helpers for whitespace stripping. */ 888 881 889 882 /* Record the previous rule. */ … … 934 927 935 928 p2 = variable_expand_string(NULL, lb_next, len); 929 936 930 while (1) 937 931 { … … 1040 1034 if (*lb_next != '\0') 1041 1035 { 1042 unsigned int l = p - variable_buffer; 1043 unsigned int l2 = p2 - variable_buffer; 1036 unsigned int l = p2 - variable_buffer; 1044 1037 plen = strlen (p2); 1045 1038 (void) variable_buffer_output (p2+plen, 1046 1039 lb_next, strlen (lb_next)+1); 1047 p = variable_buffer + l; 1048 p2 = variable_buffer + l2; 1040 p2 = variable_buffer + l; 1049 1041 } 1050 1042 … … 1112 1104 } 1113 1105 } 1114 1115 /* Do any of the prerequisites appear to have $@ etc.? */1116 have_sysv_atvar = 0;1117 if (!posix_pedantic)1118 for (p = strchr (p2, '$'); p != 0; p = strchr (p+1, '$'))1119 if (p[1] == '@' || ((p[1] == '(' || p[1] == '{') && p[2] == '@'))1120 {1121 have_sysv_atvar = 1;1122 break;1123 }1124 1106 1125 1107 /* Is this a static pattern rule: `target: %targ: %dep; ...'? */ … … 1187 1169 pattern = 0; 1188 1170 1189 /* Parse the dependencies. */ 1190 deps = (struct dep *) 1191 multi_glob (parse_file_seq (&p2, '|', sizeof (struct dep), 1), 1192 sizeof (struct dep)); 1193 if (*p2) 1171 /* Strip leading and trailing whitespaces. */ 1172 beg = p2; 1173 end = beg + strlen (beg) - 1; 1174 strip_whitespace (&beg, &end); 1175 1176 if (beg <= end && *beg != '\0') 1194 1177 { 1195 /* Files that follow '|' are special prerequisites that 1196 need only exist in order to satisfy the dependency. 1197 Their modification times are irrelevant. */ 1198 struct dep **deps_ptr = &deps; 1199 struct dep *d; 1200 for (deps_ptr = &deps; *deps_ptr; deps_ptr = &(*deps_ptr)->next) 1201 ; 1202 ++p2; 1203 *deps_ptr = (struct dep *) 1204 multi_glob (parse_file_seq (&p2, '\0', sizeof (struct dep), 1), 1205 sizeof (struct dep)); 1206 for (d = *deps_ptr; d != 0; d = d->next) 1207 d->ignore_mtime = 1; 1178 char *top; 1179 const char *fromp = beg; 1180 1181 /* Make a copy of the dependency string. Note if we find '$'. */ 1182 deps = (struct dep*) xmalloc (sizeof (struct dep)); 1183 deps->next = 0; 1184 deps->name = top = (char *) xmalloc (end - beg + 2); 1185 deps->need_2nd_expansion = 0; 1186 while (fromp <= end) 1187 { 1188 if (*fromp == '$') 1189 deps->need_2nd_expansion = 1; 1190 *(top++) = *(fromp++); 1191 } 1192 *top = '\0'; 1193 deps->file = 0; 1208 1194 } 1195 else 1196 deps = 0; 1209 1197 1210 1198 commands_idx = 0; … … 1225 1213 commands_idx += len; 1226 1214 commands[commands_idx++] = '\n'; 1215 } 1216 1217 /* Determine if this target should be made default. We used to do 1218 this in record_files() but because of the delayed target recording 1219 and because preprocessor directives are legal in target's commands 1220 it is too late. Consider this fragment for example: 1221 1222 foo: 1223 1224 ifeq ($(.DEFAULT_GOAL),foo) 1225 ... 1226 endif 1227 1228 Because the target is not recorded until after ifeq directive is 1229 evaluated the .DEFAULT_GOAL does not contain foo yet as one 1230 would expect. Because of this we have to move some of the logic 1231 here. */ 1232 1233 if (**default_goal_name == '\0' && set_default) 1234 { 1235 char* name; 1236 struct dep *d; 1237 struct nameseq *t = filenames; 1238 1239 for (; t != 0; t = t->next) 1240 { 1241 int reject = 0; 1242 name = t->name; 1243 1244 /* We have nothing to do if this is an implicit rule. */ 1245 if (strchr (name, '%') != 0) 1246 break; 1247 1248 /* See if this target's name does not start with a `.', 1249 unless it contains a slash. */ 1250 if (*name == '.' && strchr (name, '/') == 0 1251 #ifdef HAVE_DOS_PATHS 1252 && strchr (name, '\\') == 0 1253 #endif 1254 ) 1255 continue; 1256 1257 1258 /* If this file is a suffix, don't let it be 1259 the default goal file. */ 1260 for (d = suffix_file->deps; d != 0; d = d->next) 1261 { 1262 register struct dep *d2; 1263 if (*dep_name (d) != '.' && streq (name, dep_name (d))) 1264 { 1265 reject = 1; 1266 break; 1267 } 1268 for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next) 1269 { 1270 register unsigned int len = strlen (dep_name (d2)); 1271 if (!strneq (name, dep_name (d2), len)) 1272 continue; 1273 if (streq (name + len, dep_name (d))) 1274 { 1275 reject = 1; 1276 break; 1277 } 1278 } 1279 1280 if (reject) 1281 break; 1282 } 1283 1284 if (!reject) 1285 { 1286 define_variable_global (".DEFAULT_GOAL", 13, t->name, 1287 o_file, 0, NILF); 1288 break; 1289 } 1290 } 1227 1291 } 1228 1292 … … 1283 1347 char *line; 1284 1348 1349 nlines = readline (ebuf); 1285 1350 ebuf->floc.lineno += nlines; 1286 nlines = readline (ebuf);1287 1351 1288 1352 /* If there is nothing left to eval, we're done. */ … … 1365 1429 current makefile. They are used for error messages. 1366 1430 1367 Value is -1 if the line is invalid, 1431 Value is -2 if the line is not a conditional at all, 1432 -1 if the line is an invalid conditional, 1368 1433 0 if following text should be interpreted, 1369 1434 1 if following text should be ignored. */ 1370 1435 1371 1436 static int 1372 conditional_line (char *line, const struct floc *flocp)1437 conditional_line (char *line, int len, const struct floc *flocp) 1373 1438 { 1374 int notdef;1375 1439 char *cmdname; 1376 register unsigned int i; 1377 1378 if (*line == 'i') 1379 { 1380 /* It's an "if..." command. */ 1381 notdef = line[2] == 'n'; 1382 if (notdef) 1383 { 1384 cmdname = line[3] == 'd' ? "ifndef" : "ifneq"; 1385 line += cmdname[3] == 'd' ? 7 : 6; 1386 } 1387 else 1388 { 1389 cmdname = line[2] == 'd' ? "ifdef" : "ifeq"; 1390 line += cmdname[2] == 'd' ? 6 : 5; 1391 } 1392 } 1440 enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype; 1441 unsigned int i; 1442 unsigned int o; 1443 1444 /* Compare a word, both length and contents. */ 1445 #define word1eq(s) (len == sizeof(s)-1 && strneq (s, line, sizeof(s)-1)) 1446 #define chkword(s, t) if (word1eq (s)) { cmdtype = (t); cmdname = (s); } 1447 1448 /* Make sure this line is a conditional. */ 1449 chkword ("ifdef", c_ifdef) 1450 else chkword ("ifndef", c_ifndef) 1451 else chkword ("ifeq", c_ifeq) 1452 else chkword ("ifneq", c_ifneq) 1453 else chkword ("else", c_else) 1454 else chkword ("endif", c_endif) 1393 1455 else 1394 { 1395 /* It's an "else" or "endif" command. */ 1396 notdef = line[1] == 'n'; 1397 cmdname = notdef ? "endif" : "else"; 1398 line += notdef ? 5 : 4; 1399 } 1400 1401 line = next_token (line); 1402 1403 if (*cmdname == 'e') 1456 return -2; 1457 1458 /* Found one: skip past it and any whitespace after it. */ 1459 line = next_token (line + len); 1460 1461 #define EXTRANEOUS() error (flocp, _("Extraneous text after `%s' directive"), cmdname) 1462 1463 /* An 'endif' cannot contain extra text, and reduces the if-depth by 1 */ 1464 if (cmdtype == c_endif) 1404 1465 { 1405 1466 if (*line != '\0') 1406 error (flocp, _("Extraneous text after `%s' directive"), cmdname);1407 /* "Else" or "endif". */ 1408 if ( conditionals->if_cmds == 0)1467 EXTRANEOUS (); 1468 1469 if (!conditionals->if_cmds) 1409 1470 fatal (flocp, _("extraneous `%s'"), cmdname); 1410 /* NOTDEF indicates an `endif' command. */ 1411 if (notdef) 1412 --conditionals->if_cmds; 1413 else if (conditionals->seen_else[conditionals->if_cmds - 1]) 1414 fatal (flocp, _("only one `else' per conditional")); 1471 1472 --conditionals->if_cmds; 1473 1474 goto DONE; 1475 } 1476 1477 /* An 'else' statement can either be simple, or it can have another 1478 conditional after it. */ 1479 if (cmdtype == c_else) 1480 { 1481 const char *p; 1482 1483 if (!conditionals->if_cmds) 1484 fatal (flocp, _("extraneous `%s'"), cmdname); 1485 1486 o = conditionals->if_cmds - 1; 1487 1488 if (conditionals->seen_else[o]) 1489 fatal (flocp, _("only one `else' per conditional")); 1490 1491 /* Change the state of ignorance. */ 1492 switch (conditionals->ignoring[o]) 1493 { 1494 case 0: 1495 /* We've just been interpreting. Never do it again. */ 1496 conditionals->ignoring[o] = 2; 1497 break; 1498 case 1: 1499 /* We've never interpreted yet. Maybe this time! */ 1500 conditionals->ignoring[o] = 0; 1501 break; 1502 } 1503 1504 /* It's a simple 'else'. */ 1505 if (*line == '\0') 1506 { 1507 conditionals->seen_else[o] = 1; 1508 goto DONE; 1509 } 1510 1511 /* The 'else' has extra text. That text must be another conditional 1512 and cannot be an 'else' or 'endif'. */ 1513 1514 /* Find the length of the next word. */ 1515 for (p = line+1; *p != '\0' && !isspace ((unsigned char)*p); ++p) 1516 ; 1517 len = p - line; 1518 1519 /* If it's 'else' or 'endif' or an illegal conditional, fail. */ 1520 if (word1eq("else") || word1eq("endif") 1521 || conditional_line (line, len, flocp) < 0) 1522 EXTRANEOUS (); 1415 1523 else 1416 { 1417 /* Toggle the state of ignorance. */ 1418 conditionals->ignoring[conditionals->if_cmds - 1] 1419 = !conditionals->ignoring[conditionals->if_cmds - 1]; 1420 /* Record that we have seen an `else' in this conditional. 1421 A second `else' will be erroneous. */ 1422 conditionals->seen_else[conditionals->if_cmds - 1] = 1; 1423 } 1424 for (i = 0; i < conditionals->if_cmds; ++i) 1425 if (conditionals->ignoring[i]) 1426 return 1; 1427 return 0; 1524 { 1525 /* conditional_line() created a new level of conditional. 1526 Raise it back to this level. */ 1527 if (conditionals->ignoring[o] < 2) 1528 conditionals->ignoring[o] = conditionals->ignoring[o+1]; 1529 --conditionals->if_cmds; 1530 } 1531 1532 goto DONE; 1428 1533 } 1429 1534 … … 1435 1540 } 1436 1541 1437 ++conditionals->if_cmds;1542 o = conditionals->if_cmds++; 1438 1543 if (conditionals->if_cmds > conditionals->allocated) 1439 1544 { … … 1446 1551 1447 1552 /* Record that we have seen an `if...' but no `else' so far. */ 1448 conditionals->seen_else[ conditionals->if_cmds - 1] = 0;1553 conditionals->seen_else[o] = 0; 1449 1554 1450 1555 /* Search through the stack to see if we're already ignoring. */ 1451 for (i = 0; i < conditionals->if_cmds - 1; ++i)1556 for (i = 0; i < o; ++i) 1452 1557 if (conditionals->ignoring[i]) 1453 1558 { 1454 /* We are already ignoring, so just push a level 1455 to match the next "else" or "endif", and keep ignoring.1456 We don't want to expandvariables in the condition. */1457 conditionals->ignoring[ conditionals->if_cmds - 1] = 1;1559 /* We are already ignoring, so just push a level to match the next 1560 "else" or "endif", and keep ignoring. We don't want to expand 1561 variables in the condition. */ 1562 conditionals->ignoring[o] = 1; 1458 1563 return 1; 1459 1564 } 1460 1565 1461 if (cmd name[notdef ? 3 : 2] == 'd')1566 if (cmdtype == c_ifdef || cmdtype == c_ifndef) 1462 1567 { 1463 /* "Ifdef" or "ifndef". */1464 1568 char *var; 1465 1569 struct variable *v; 1466 registerchar *p;1570 char *p; 1467 1571 1468 1572 /* Expand the thing we're looking up, so we can use indirect and … … 1478 1582 1479 1583 var[i] = '\0'; 1480 v = lookup_variable (var, strlen (var)); 1481 conditionals->ignoring[conditionals->if_cmds - 1] 1482 = (v != 0 && *v->value != '\0') == notdef; 1584 v = lookup_variable (var, i); 1585 1586 conditionals->ignoring[o] = 1587 ((v != 0 && *v->value != '\0') == (cmdtype == c_ifndef)); 1483 1588 1484 1589 free (var); … … 1498 1603 if (termin == ',') 1499 1604 { 1500 registerint count = 0;1605 int count = 0; 1501 1606 for (; *line != '\0'; ++line) 1502 1607 if (*line == '(') … … 1572 1677 line = next_token (++line); 1573 1678 if (*line != '\0') 1574 error (flocp, _("Extraneous text after `%s' directive"), cmdname);1679 EXTRANEOUS (); 1575 1680 1576 1681 s2 = variable_expand (s2); 1577 conditionals->ignoring[conditionals->if_cmds - 1] 1578 = streq (s1, s2) == notdef; 1682 conditionals->ignoring[o] = (streq (s1, s2) == (cmdtype == c_ifneq)); 1579 1683 } 1580 1684 1685 DONE: 1581 1686 /* Search through the stack to see if we're ignoring. */ 1582 1687 for (i = 0; i < conditionals->if_cmds; ++i) … … 1694 1799 p = create_pattern_var (name, percent); 1695 1800 p->variable.fileinfo = *flocp; 1801 /* I don't think this can fail since we already determined it was a 1802 variable definition. */ 1696 1803 v = parse_variable_definition (&p->variable, defn); 1697 v->value = xstrdup (v->value); 1698 if (!v) 1699 error (flocp, _("Malformed pattern-specific variable definition")); 1804 assert (v != 0); 1805 1806 if (v->flavor == f_simple) 1807 v->value = allocated_variable_expand (v->value); 1808 else 1809 v->value = xstrdup (v->value); 1810 1700 1811 fname = p->target; 1701 1812 } … … 1771 1882 struct dep *deps, unsigned int cmds_started, char *commands, 1772 1883 unsigned int commands_idx, int two_colon, 1773 int have_sysv_atvar, const struct floc *flocp, int set_default)1884 const struct floc *flocp) 1774 1885 { 1775 1886 struct nameseq *nextf; … … 1778 1889 char **targets = 0, **target_percents = 0; 1779 1890 struct commands *cmds; 1891 1892 /* If we've already snapped deps, that means we're in an eval being 1893 resolved after the makefiles have been read in. We can't add more rules 1894 at this time, since they won't get snapped and we'll get core dumps. 1895 See Savannah bug # 12124. */ 1896 if (snapped_deps) 1897 fatal (flocp, _("prerequisites cannot be defined in command scripts")); 1780 1898 1781 1899 if (commands_idx > 0) … … 1843 1961 /* If there are multiple filenames, copy the chain DEPS 1844 1962 for all but the last one. It is not safe for the same deps 1845 to go in more than one place in the data 1963 to go in more than one place in the database. */ 1846 1964 this = nextf != 0 ? copy_dep_chain (deps) : deps; 1847 1965 … … 1860 1978 } 1861 1979 else 1862 { 1863 /* We use patsubst_expand to do the work of translating 1864 the target pattern, the target's name and the dependencies' 1865 patterns into plain dependency names. */ 1866 char *buffer = variable_expand (""); 1867 1868 for (d = this; d != 0; d = d->next) 1869 { 1870 char *o; 1871 char *percent = find_percent (d->name); 1872 if (percent == 0) 1873 continue; 1874 o = patsubst_expand (buffer, name, pattern, d->name, 1875 pattern_percent, percent); 1876 /* If the name expanded to the empty string, that's 1877 illegal. */ 1878 if (o == buffer) 1879 fatal (flocp, 1880 _("target `%s' leaves prerequisite pattern empty"), 1881 name); 1882 free (d->name); 1883 d->name = savestring (buffer, o - buffer); 1884 } 1885 } 1886 } 1887 1888 /* If at least one of the dependencies uses $$@ etc. deal with that. 1889 It would be very nice and very simple to just expand everything, but 1890 it would break a lot of backward compatibility. Maybe that's OK 1891 since we're just emulating a SysV function, and if we do that then 1892 why not emulate it completely (that's what SysV make does: it 1893 re-expands the entire prerequisite list, all the time, with $@ 1894 etc. in scope). But, it would be a pain indeed to document this 1895 ("iff you use $$@, your prerequisite lists is expanded twice...") 1896 Ouch. Maybe better to make the code more complex. */ 1897 1898 if (have_sysv_atvar) 1899 { 1900 char *p; 1901 int tlen = strlen (name); 1902 char *fnp = strrchr (name, '/'); 1903 int dlen; 1904 int flen; 1905 1906 if (fnp) 1907 { 1908 dlen = fnp - name; 1909 ++fnp; 1910 flen = strlen (fnp); 1911 } 1912 else 1913 { 1914 dlen = 0; 1915 fnp = name; 1916 flen = tlen; 1917 } 1918 1919 1920 for (d = this; d != 0; d = d->next) 1921 for (p = strchr (d->name, '$'); p != 0; p = strchr (p+1, '$')) 1980 /* We use subst_expand to do the work of translating % to $* in 1981 the dependency line. */ 1982 1983 if (this != 0 && find_percent (this->name) != 0) 1922 1984 { 1923 char *s = p; 1924 char *at; 1925 int atlen; 1926 1927 /* If it's '$@', '$(@', or '${@', it's escaped */ 1928 if ((++p)[0] == '$' 1929 && (p[1] == '@' 1930 || ((p[1] == '(' || p[1] == '{') && p[2] == '@'))) 1931 { 1932 bcopy (p, s, strlen (p)+1); 1933 continue; 1934 } 1935 1936 /* Maybe found one. We like anything of any form matching @, 1937 [({]@[}):], or [({]@[DF][}):]. */ 1938 1939 if (! (p[0] == '@' 1940 || ((p[0] == '(' || p[0] == '{') && (++p)[0] == '@' 1941 && (((++p)[0] == ')' || p[0] == '}' || p[0] == ':') 1942 || ((p[1] == ')' || p[1] == '}' || p[1] == ':') 1943 && (p[0] == 'D' || p[0] == 'F')))))) 1944 continue; 1945 1946 /* Found one. Compute the length and string ptr. Move p 1947 past the variable reference. */ 1948 switch (p[0]) 1949 { 1950 case 'D': 1951 atlen = dlen; 1952 at = name; 1953 p += 2; 1954 break; 1955 1956 case 'F': 1957 atlen = flen; 1958 at = fnp; 1959 p += 2; 1960 break; 1961 1962 default: 1963 atlen = tlen; 1964 at = name; 1965 ++p; 1966 break; 1967 } 1968 1969 /* Get more space. */ 1970 { 1971 int soff = s - d->name; 1972 int poff = p - d->name; 1973 d->name = (char *) xrealloc (d->name, 1974 strlen (d->name) + atlen + 1); 1975 s = d->name + soff; 1976 p = d->name + poff; 1977 } 1978 1979 /* Copy the string over. */ 1980 bcopy(p, s+atlen, strlen (p)+1); 1981 bcopy(at, s, atlen); 1982 p = s + atlen - 1; 1985 char *o; 1986 char *buffer = variable_expand (""); 1987 1988 o = subst_expand (buffer, this->name, "%", "$*", 1, 2, 0); 1989 1990 free (this->name); 1991 this->name = savestring (buffer, o - buffer); 1992 this->need_2nd_expansion = 1; 1983 1993 } 1984 1994 } 1985 1995 1986 1996 if (!two_colon) … … 2021 2031 if (cmds != 0) 2022 2032 f->cmds = cmds; 2033 2023 2034 /* Defining .SUFFIXES with no dependencies 2024 2035 clears out the list of suffixes. */ … … 2035 2046 f->deps = 0; 2036 2047 } 2037 else if (f->deps != 0)2048 else if (this != 0) 2038 2049 { 2039 2050 /* Add the file's old deps and the new ones in THIS together. */ 2040 2051 2041 struct dep *firstdeps, *moredeps; 2042 if (cmds != 0) 2043 { 2044 /* This is the rule with commands, so put its deps first. 2045 The rationale behind this is that $< expands to the 2046 first dep in the chain, and commands use $< expecting 2047 to get the dep that rule specifies. */ 2048 firstdeps = this; 2049 moredeps = f->deps; 2050 } 2051 else 2052 { 2053 /* Append the new deps to the old ones. */ 2054 firstdeps = f->deps; 2055 moredeps = this; 2056 } 2057 2058 if (firstdeps == 0) 2059 firstdeps = moredeps; 2060 else 2061 { 2062 d = firstdeps; 2063 while (d->next != 0) 2064 d = d->next; 2065 d->next = moredeps; 2066 } 2067 2068 f->deps = firstdeps; 2052 if (f->deps != 0) 2053 { 2054 struct dep **d_ptr = &f->deps; 2055 2056 while ((*d_ptr)->next != 0) 2057 d_ptr = &(*d_ptr)->next; 2058 2059 if (cmds != 0) 2060 { 2061 /* This is the rule with commands, so put its deps 2062 last. The rationale behind this is that $< expands 2063 to the first dep in the chain, and commands use $< 2064 expecting to get the dep that rule specifies. 2065 However the second expansion algorithm reverses 2066 the order thus we need to make it last here. */ 2067 2068 (*d_ptr)->next = this; 2069 } 2070 else 2071 { 2072 /* This is the rule without commands. Put its 2073 dependencies at the end but before dependencies 2074 from the rule with commands (if any). This way 2075 everything appears in makefile order. */ 2076 2077 if (f->cmds != 0) 2078 { 2079 this->next = *d_ptr; 2080 *d_ptr = this; 2081 } 2082 else 2083 (*d_ptr)->next = this; 2084 } 2085 } 2086 else 2087 f->deps = this; 2088 2089 /* This is a hack. I need a way to communicate to snap_deps() 2090 that the last dependency line in this file came with commands 2091 (so that logic in snap_deps() can put it in front and all 2092 this $< -logic works). I cannot simply rely on file->cmds 2093 being not 0 because of the cases like the following: 2094 2095 foo: bar 2096 foo: 2097 ... 2098 2099 I am going to temporarily "borrow" UPDATING member in 2100 `struct file' for this. */ 2101 2102 if (cmds != 0) 2103 f->updating = 1; 2069 2104 } 2070 else2071 f->deps = this;2072 2105 2073 2106 /* If this is a static pattern rule, set the file's stem to … … 2079 2112 char *buffer = variable_expand (""); 2080 2113 char *o = patsubst_expand (buffer, name, pattern, percent, 2081 pattern_percent , percent);2114 pattern_percent+1, percent+1); 2082 2115 f->stem = savestring (buffer, o - buffer); 2083 2116 } … … 2115 2148 } 2116 2149 2117 /* See if this is first target seen whose name does 2118 not start with a `.', unless it contains a slash. */ 2119 if (default_goal_file == 0 && set_default 2120 && (*name != '.' || strchr (name, '/') != 0 2121 #ifdef HAVE_DOS_PATHS 2122 || strchr (name, '\\') != 0 2123 #endif 2124 )) 2125 { 2126 int reject = 0; 2127 2128 /* If this file is a suffix, don't 2129 let it be the default goal file. */ 2130 2131 for (d = suffix_file->deps; d != 0; d = d->next) 2132 { 2133 register struct dep *d2; 2134 if (*dep_name (d) != '.' && streq (name, dep_name (d))) 2135 { 2136 reject = 1; 2137 break; 2138 } 2139 for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next) 2140 { 2141 register unsigned int len = strlen (dep_name (d2)); 2142 if (!strneq (name, dep_name (d2), len)) 2143 continue; 2144 if (streq (name + len, dep_name (d))) 2145 { 2146 reject = 1; 2147 break; 2148 } 2149 } 2150 if (reject) 2151 break; 2152 } 2153 2154 if (!reject) 2155 default_goal_file = f; 2156 } 2150 /* If this target is a default target, update DEFAULT_GOAL_FILE. */ 2151 if (strcmp (*default_goal_name, name) == 0 2152 && (default_goal_file == 0 2153 || strcmp (default_goal_file->name, name) != 0)) 2154 default_goal_file = f; 2157 2155 } 2158 2156 … … 2498 2496 readstring (struct ebuffer *ebuf) 2499 2497 { 2500 char * p;2498 char *eol; 2501 2499 2502 2500 /* If there is nothing left in this buffer, return 0. */ 2503 if (ebuf->bufnext > ebuf->bufstart + ebuf->size)2501 if (ebuf->bufnext >= ebuf->bufstart + ebuf->size) 2504 2502 return -1; 2505 2503 … … 2507 2505 next logical line (taking into account backslash/newline pairs). */ 2508 2506 2509 p= ebuf->buffer = ebuf->bufnext;2507 eol = ebuf->buffer = ebuf->bufnext; 2510 2508 2511 2509 while (1) 2512 2510 { 2513 2511 int backslash = 0; 2514 2515 /* Find the next newline. Keep track of backslashes as we look. */ 2516 for (; *p != '\n' && *p != '\0'; ++p) 2517 if (*p == '\\') 2518 backslash = !backslash; 2519 2520 /* If we got to the end of the string or a newline with no backslash, 2521 we're done. */ 2522 if (*p == '\0' || !backslash) 2512 char *bol = eol; 2513 char *p; 2514 2515 /* Find the next newline. At EOS, stop. */ 2516 eol = p = strchr (eol , '\n'); 2517 if (!eol) 2518 { 2519 ebuf->bufnext = ebuf->bufstart + ebuf->size + 1; 2520 return 0; 2521 } 2522 2523 /* Found a newline; if it's escaped continue; else we're done. */ 2524 while (p > bol && *(--p) == '\\') 2525 backslash = !backslash; 2526 if (!backslash) 2523 2527 break; 2528 ++eol; 2524 2529 } 2525 2530 2526 2531 /* Overwrite the newline char. */ 2527 * p= '\0';2528 ebuf->bufnext = p+1;2532 *eol = '\0'; 2533 ebuf->bufnext = eol+1; 2529 2534 2530 2535 return 0; -
branches/GNU/src/gmake/readme.vms
r54 r280 1 This is the VMS version of GNU Make, updated by Hartmut Becker 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. 10 11 Build instructions 12 Make a 1st version 13 $ @makefile.com 14 $ rena make.exe 1st-make.exe 15 Use the 1st version to generate a 2nd version 16 $ mc sys$disk:[]1st-make clean 17 $ mc sys$disk:[]1st-make 18 Verify your 2nd version 19 $ rena make.exe 2nd-make.exe 20 $ mc sys$disk:[]2nd-make clean 21 $ mc sys$disk:[]2nd-make 22 23 Changes: 24 25 . In default.c define variable ARCH as IA64 for VMS on Itanium systems. 26 27 . In makefile.vms avoid name collision for glob and globfree. 28 29 In newer version of the VMS CRTL there are glob and globfree implemented. 30 Compiling and linking may result in 31 32 %ILINK-W-MULDEFLNKG, symbol DECC$GLOBFREE has subsequent linkage definition 33 in module DECC$SHR file SYS$COMMON:[SYSLIB]DECC$SHR.EXE;1 34 %ILINK-W-MULDEF, symbol DECC$GLOBFREE multiply defined 35 in module DECC$SHR file SYS$COMMON:[SYSLIB]DECC$SHR.EXE;1 36 37 linker messages (and similar for DECC$GLOB). The messages just say, that 38 globfree is a known CRTL whose name was mapped by the compiler to 39 DECC$GLOBFREE. This is done in glob.c as well, so this name is defined 40 twice. One possible solution is to use the VMS versions of glob and 41 globfree. However, then the build environment needs to figure out if 42 there is a new CRTL supporting these or not. This adds complexity. Even 43 more, these functions return VMS file specifications, which is not 44 expected by the other make sources. There is a switch at run time (a VMS 45 logical DECC$GLOB_UNIX_STYLE), which can be set to get Unix style 46 names. This may conflict with other software. The recommended solution 47 for this is to set this switch just prior to calling main: in an 48 initialization routine. This adds more complexity and more VMS specific 49 code. It is easier to tell the compiler NOT to map the routine names 50 with a simple change in makefile.vms. 51 52 1 53 This is the VMS port of GNU Make done by [email protected]. 2 54 -
branches/GNU/src/gmake/remake.c
r153 r280 75 75 /* Remake all the goals in the `struct dep' chain GOALS. Return -1 if nothing 76 76 was done, 0 if all goals were updated successfully, or 1 if a goal failed. 77 If MAKEFILES is nonzero, these goals are makefiles, so -t, -q, and -n should 78 be disabled for them unless they were also command-line targets, and we 79 should only make one goal at a time and return as soon as one goal whose 80 `changed' member is nonzero is successfully made. */ 77 78 If rebuilding_makefiles is nonzero, these goals are makefiles, so -t, -q, 79 and -n should be disabled for them unless they were also command-line 80 targets, and we should only make one goal at a time and return as soon as 81 one goal whose `changed' member is nonzero is successfully made. */ 81 82 82 83 int 83 update_goal_chain (struct dep *goals , int makefiles)84 update_goal_chain (struct dep *goals) 84 85 { 85 86 int t = touch_flag, q = question_flag, n = just_print_flag; … … 87 88 int status = -1; 88 89 89 #define MTIME(file) ( makefiles ? file_mtime_no_search (file) \90 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \ 90 91 : file_mtime (file)) 91 92 … … 137 138 int x; 138 139 check_renamed (file); 139 if ( makefiles)140 if (rebuilding_makefiles) 140 141 { 141 142 if (file->cmd_target) … … 154 155 ocommands_started = commands_started; 155 156 156 x = update_file (file, makefiles ? 1 : 0);157 x = update_file (file, rebuilding_makefiles ? 1 : 0); 157 158 check_renamed (file); 158 159 … … 177 178 matter how much more we run, since we already know 178 179 the answer to return. */ 179 stop = ( !keep_going_flag && !question_flag180 && ! makefiles);180 stop = (question_flag && !keep_going_flag 181 && !rebuilding_makefiles); 181 182 } 182 183 else … … 194 195 If STATUS is changed, we will get re-exec'd, and 195 196 enter an infinite loop. */ 196 if (! makefiles197 if (!rebuilding_makefiles 197 198 || (!just_print_flag && !question_flag)) 198 199 status = 0; 199 if ( makefiles && file->dontcare)200 if (rebuilding_makefiles && file->dontcare) 200 201 /* This is a default makefile; stop remaking. */ 201 202 stop = 1; … … 220 221 print a message saying nothing needs doing. */ 221 222 222 if (! makefiles223 if (!rebuilding_makefiles 223 224 /* If the update_status is zero, we updated successfully 224 225 or not at all. G->changed will have been set above if … … 259 260 } 260 261 261 if ( makefiles)262 if (rebuilding_makefiles) 262 263 { 263 264 touch_flag = t; … … 309 310 check_renamed (f); 310 311 312 /* If we got an error, don't bother with double_colon etc. */ 311 313 if (status != 0 && !keep_going_flag) 312 break;314 return status; 313 315 314 316 if (f->command_state == cs_running … … 324 326 /* Process the remaining rules in the double colon chain so they're marked 325 327 considered. Start their prerequisites, too. */ 326 for (; f != 0 ; f = f->prev) 327 { 328 struct dep *d; 329 330 f->considered = considered; 331 332 for (d = f->deps; d != 0; d = d->next) 333 status |= update_file (d->file, depth + 1); 334 } 328 if (file->double_colon) 329 for (; f != 0 ; f = f->prev) 330 { 331 struct dep *d; 332 333 f->considered = considered; 334 335 for (d = f->deps; d != 0; d = d->next) 336 status |= update_file (d->file, depth + 1); 337 } 335 338 336 339 return status; 337 340 } 338 341 342 343 /* Show a message stating the target failed to build. */ 344 345 static void 346 complain (const struct file *file) 347 { 348 const char *msg_noparent 349 = _("%sNo rule to make target `%s'%s"); 350 const char *msg_parent 351 = _("%sNo rule to make target `%s', needed by `%s'%s"); 352 353 if (!keep_going_flag) 354 { 355 if (file->parent == 0) 356 fatal (NILF, msg_noparent, "", file->name, ""); 357 358 fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); 359 } 360 361 if (file->parent == 0) 362 error (NILF, msg_noparent, "*** ", file->name, "."); 363 else 364 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 365 } 339 366 340 367 /* Consider a single `struct file' and update it as appropriate. */ … … 357 384 DBF (DB_VERBOSE, 358 385 _("Recently tried and failed to update file `%s'.\n")); 386 387 /* If the file we tried to make is marked dontcare then no message 388 was printed about it when it failed during the makefile rebuild. 389 If we're trying to build it again in the normal rebuild, print a 390 message now. */ 391 if (file->dontcare && !rebuilding_makefiles) 392 { 393 file->dontcare = 0; 394 complain (file); 395 } 396 359 397 return file->update_status; 360 398 } … … 435 473 FILE_TIMESTAMP mtime; 436 474 int maybe_make; 475 int dontcare = 0; 437 476 438 477 check_renamed (d->file); … … 458 497 d->file->parent = file; 459 498 maybe_make = must_make; 499 500 /* Inherit dontcare flag from our parent. */ 501 if (rebuilding_makefiles) 502 { 503 dontcare = d->file->dontcare; 504 d->file->dontcare = file->dontcare; 505 } 506 507 460 508 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); 509 510 /* Restore original dontcare flag. */ 511 if (rebuilding_makefiles) 512 d->file->dontcare = dontcare; 513 461 514 if (! d->ignore_mtime) 462 515 must_make = maybe_make; … … 495 548 if (d->file->intermediate) 496 549 { 550 int dontcare = 0; 551 497 552 FILE_TIMESTAMP mtime = file_mtime (d->file); 498 553 check_renamed (d->file); 499 554 d->file->parent = file; 555 556 /* Inherit dontcare flag from our parent. */ 557 if (rebuilding_makefiles) 558 { 559 dontcare = d->file->dontcare; 560 d->file->dontcare = file->dontcare; 561 } 562 563 500 564 dep_status |= update_file (d->file, depth); 565 566 /* Restore original dontcare flag. */ 567 if (rebuilding_makefiles) 568 d->file->dontcare = dontcare; 569 501 570 check_renamed (d->file); 502 571 … … 846 915 start_updating (file); 847 916 848 if ( !file->intermediate)849 /* If this is a non-intermediate file, update it and record850 whether it is newer than THIS_MTIME. */851 {917 if (file->phony || !file->intermediate) 918 { 919 /* If this is a non-intermediate file, update it and record 920 whether it is newer than THIS_MTIME. */ 852 921 FILE_TIMESTAMP mtime; 853 922 dep_status = update_file (file, depth); … … 1016 1085 else 1017 1086 { 1018 const char *msg_noparent1019 = _("%sNo rule to make target `%s'%s");1020 const char *msg_parent1021 = _("%sNo rule to make target `%s', needed by `%s'%s");1022 1023 1087 /* This is a dependency file we cannot remake. Fail. */ 1024 if (!keep_going_flag && !file->dontcare) 1025 { 1026 if (file->parent == 0) 1027 fatal (NILF, msg_noparent, "", file->name, ""); 1028 1029 fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); 1030 } 1031 1032 if (!file->dontcare) 1033 { 1034 if (file->parent == 0) 1035 error (NILF, msg_noparent, "*** ", file->name, "."); 1036 else 1037 error (NILF, msg_parent, "*** ", 1038 file->name, file->parent->name, "."); 1039 } 1088 if (!rebuilding_makefiles || !file->dontcare) 1089 complain (file); 1040 1090 file->update_status = 2; 1041 1091 } … … 1273 1323 /* Return the mtime of the file or archive-member reference NAME. */ 1274 1324 1325 /* First, we check with stat(). If the file does not exist, then we return 1326 NONEXISTENT_MTIME. If it does, and the symlink check flag is set, then 1327 examine each indirection of the symlink and find the newest mtime. 1328 This causes one duplicate stat() when -L is being used, but the code is 1329 much cleaner. */ 1330 1275 1331 static FILE_TIMESTAMP 1276 1332 name_mtime (char *name) 1277 1333 { 1334 FILE_TIMESTAMP mtime; 1278 1335 struct stat st; 1279 1336 int e; … … 1283 1340 { 1284 1341 if (errno != ENOENT && errno != ENOTDIR) 1285 perror_with_name ("stat: ", name);1342 perror_with_name ("stat: ", name); 1286 1343 return NONEXISTENT_MTIME; 1287 1344 } 1288 1289 return FILE_TIMESTAMP_STAT_MODTIME (name, st); 1345 mtime = FILE_TIMESTAMP_STAT_MODTIME (name, st); 1346 1347 #ifdef MAKE_SYMLINKS 1348 #ifndef S_ISLNK 1349 # define S_ISLNK(_m) (((_m)&S_IFMT)==S_IFLNK) 1350 #endif 1351 if (check_symlink_flag) 1352 { 1353 PATH_VAR (lpath); 1354 1355 /* Check each symbolic link segment (if any). Find the latest mtime 1356 amongst all of them (and the target file of course). 1357 Note that we have already successfully dereferenced all the links 1358 above. So, if we run into any error trying to lstat(), or 1359 readlink(), or whatever, something bizarre-o happened. Just give up 1360 and use whatever mtime we've already computed at that point. */ 1361 strcpy (lpath, name); 1362 while (1) 1363 { 1364 FILE_TIMESTAMP ltime; 1365 PATH_VAR (lbuf); 1366 long llen; 1367 char *p; 1368 1369 EINTRLOOP (e, lstat (lpath, &st)); 1370 if (e) 1371 { 1372 /* Eh? Just take what we have. */ 1373 perror_with_name ("lstat: ", lpath); 1374 break; 1375 } 1376 1377 /* If this is not a symlink, we're done (we started with the real 1378 file's mtime so we don't need to test it again). */ 1379 if (!S_ISLNK (st.st_mode)) 1380 break; 1381 1382 /* If this mtime is newer than what we had, keep the new one. */ 1383 ltime = FILE_TIMESTAMP_STAT_MODTIME (lpath, st); 1384 if (ltime > mtime) 1385 mtime = ltime; 1386 1387 /* Set up to check the file pointed to by this link. */ 1388 EINTRLOOP (llen, readlink (lpath, lbuf, GET_PATH_MAX)); 1389 if (llen < 0) 1390 { 1391 /* Eh? Just take what we have. */ 1392 perror_with_name ("readlink: ", lpath); 1393 break; 1394 } 1395 lbuf[llen] = '\0'; 1396 1397 /* If the target is fully-qualified or the source is just a 1398 filename, then the new path is the target. Otherwise it's the 1399 source directory plus the target. */ 1400 if (lbuf[0] == '/' || (p = strrchr (lpath, '/')) == NULL) 1401 strcpy (lpath, lbuf); 1402 else if ((p - lpath) + llen + 2 > GET_PATH_MAX) 1403 /* Eh? Path too long! Again, just go with what we have. */ 1404 break; 1405 else 1406 /* Create the next step in the symlink chain. */ 1407 strcpy (p+1, lbuf); 1408 } 1409 } 1410 #endif 1411 1412 return mtime; 1290 1413 } 1291 1414 -
branches/GNU/src/gmake/rule.c
r153 r280 138 138 139 139 dep->changed = !dir_file_exists_p (name, ""); 140 #ifdef VMS141 if (dep->changed && strchr (name, ':') != 0)142 #else143 if (dep->changed && *name == '/')144 #endif145 {146 /* The name is absolute and the directory does not exist.147 This rule can never possibly match, since this dependency148 can never possibly exist. So just remove the rule from149 the list. */150 freerule (rule, lastrule);151 --num_pattern_rules;152 goto end_main_loop;153 }154 140 } 155 141 else … … 162 148 163 149 lastrule = rule; 164 end_main_loop:165 150 rule = next; 166 151 } … … 225 210 deps->name = depname; 226 211 deps->ignore_mtime = 0; 212 deps->need_2nd_expansion = 0; 227 213 } 228 214 -
branches/GNU/src/gmake/signame.c
r54 r280 28 28 */ 29 29 30 #if !defined( SYS_SIGLIST_DECLARED)30 #if !defined(HAVE_DECL_SYS_SIGLIST) 31 31 32 32 /* Some systems do not define NSIG in <signal.h>. */ … … 227 227 } 228 228 229 #endif /* SYS_SIGLIST_DECLARED*/229 #endif /* HAVE_DECL_SYS_SIGLIST */ 230 230 231 231 … … 235 235 static char buf[] = "Signal 12345678901234567890"; 236 236 237 #if ! defined(SYS_SIGLIST_DECLARED)237 #if ! HAVE_DECL_SYS_SIGLIST 238 238 static char sig_initted = 0; 239 239 -
branches/GNU/src/gmake/tests/ChangeLog
r153 r280 1 2005-05-13 Paul D. Smith <[email protected]> 2 3 * scripts/features/conditionals: Add tests for the new if... else 4 if... endif syntax. 5 6 2005-05-03 Paul D. Smith <[email protected]> 7 8 * scripts/variables/DEFAULT_GOAL: Rename DEFAULT_TARGET to 9 DEFAULT_GOAL. 10 11 2005-05-02 Paul D. Smith <[email protected]> 12 13 * scripts/features/parallelism: Add a test for exporting recursive 14 variables containing $(shell ) calls. Rewrite this script to use 15 run_make_test() everywhere. 16 17 2005-04-07 Paul D. Smith <[email protected]> 18 19 * scripts/targets/SECONDARY: Add a test for Savannah bug #12331. 20 21 2005-03-15 Boris Kolpackov <[email protected]> 22 23 * scripts/variables/automatic: Add a test for Savannah bug #12320. 24 25 2005-03-10 Boris Kolpackov <[email protected]> 26 27 * scripts/features/patternrules: Add a test for Savannah bug #12267. 28 29 2005-03-09 Boris Kolpackov <[email protected]> 30 31 * scripts/variables/DEFAULT_TARGET: Add a test for Savannah 32 bug #12266. 33 34 2005-03-04 Boris Kolpackov <[email protected]> 35 36 * scripts/features/patternrules: Add a test for Savannah bug #12202. 37 38 2005-03-03 Boris Kolpackov <[email protected]> 39 40 * scripts/features/se_implicit: Add a test for stem 41 termination bug. Add a test for stem triple-expansion bug. 42 43 * scripts/features/se_statpat: Add a test for stem 44 triple-expansion bug. 45 46 * scripts/features/statipattrules: Change test #4 to reflect 47 new way empty prerequisite list is handled. 48 49 50 2005-03-01 Boris Kolpackov <[email protected]> 51 52 * scripts/features/statipattrules: Add a test for 53 Savannah bug #12180. 54 55 2005-02-28 Paul D. Smith <[email protected]> 56 57 * scripts/options/dash-q: Add a test for Savannah bug # 7144. 58 59 * scripts/options/symlinks: New file to test checking of symlink 60 timestamps. Can't use filename dash-L because it conflicts with 61 dash-l on case-insensitive filesystems. 62 63 * scripts/variables/MAKEFILE_LIST, scripts/variables/MFILE_LIST: 64 Rename MAKEFILE_LIST test to MFILE_LIST, for systems that need 8.3 65 unique filenames. 66 67 2005-02-28 Boris Kolpackov <[email protected]> 68 69 * scripts/variables/DEFAULT_TARGET: Test the .DEFAULT_TARGET 70 special variable. 71 72 2005-02-27 Boris Kolpackov <[email protected]> 73 74 * scripts/features/se_explicit: Test the second expansion in 75 explicit rules. 76 * scripts/features/se_implicit: Test the second expansion in 77 implicit rules. 78 * scripts/features/se_statpat: Test the second expansion in 79 static pattern rules. 80 * scripts/variables/automatic: Fix to work with the second 81 expansion. 82 83 * scripts/misc/general4: Add a test for bug #12091. 84 85 2005-02-27 Paul D. Smith <[email protected]> 86 87 * scripts/functions/eval: Check that eval of targets within 88 command scripts fails. See Savannah bug # 12124. 89 90 2005-02-26 Paul D. Smith <[email protected]> 91 92 * test_driver.pl (compare_output): If a basic comparison of the 93 log and answer doesn't match, try harder: change all backslashes 94 to slashes and all CRLF to LF. This helps on DOS/Windows systems. 95 96 2005-02-09 Paul D. Smith <[email protected]> 97 98 * scripts/features/recursion: Test command line variable settings: 99 only one instance of a given variable should be provided. 100 101 2004-11-30 Boris Kolpackov <[email protected]> 102 103 * tests/scripts/functions/abspath: New file: test `abspath' 104 built-in function. 105 106 * tests/scripts/functions/realpath: New file: test `realpath' 107 built-in function. 108 109 2004-11-28 Paul D. Smith <[email protected]> 110 111 * scripts/options/dash-C [WINDOWS32]: Add a test for bug #10252; 112 this doesn't really test anything useful in UNIX but... 113 114 * scripts/variables/SHELL: New file: test proper handling of SHELL 115 according to POSIX rules. Fixes bug #1276. 116 117 2004-10-21 Boris Kolpackov <[email protected]> 118 119 * scripts/functions/word: Test $(firstword ) and $(lastword ). 120 121 2004-10-05 Boris Kolpackov <[email protected]> 122 123 * scripts/features/patspecific_vars: Test simple/recursive 124 variable expansion. 125 126 2004-09-28 Boris Kolpackov <[email protected]> 127 128 * scripts/features/include: Test dontcare flag inheritance 129 when rebuilding makefiles. 130 131 2004-09-27 Boris Kolpackov <[email protected]> 132 133 * scripts/features/patspecific_vars: Test exported variables. 134 135 2004-09-22 Paul D. Smith <[email protected]> 136 137 * run_make_tests.pl (run_make_test): Don't add newlines to the 138 makestring or answer if they are completely empty. 139 140 * scripts/features/patternrules: Rename from implicit_prereq_eval. 141 142 * scripts/test_template: Rework the template. 143 144 2004-09-21 Boris Kolpackov <[email protected]> 145 146 * run_make_tests.pl: Change `#!/usr/local/bin/perl' to be 147 `#!/usr/bin/env perl'. 148 149 * scripts/features/implicit_prereq_eval: Test implicit rule 150 prerequisite evaluation code. 151 152 2004-09-21 Paul D. Smith <[email protected]> 153 154 * run_make_tests.pl (run_make_test): Enhance to allow the make 155 string to be undef: in that case it reuses the previous make 156 string. Allows multiple tests on the same makefile. 157 158 * scripts/variables/flavors: Add some tests for prefix characters 159 interacting with define/endef variables. 160 161 2004-09-20 Paul D. Smith <[email protected]> 162 163 * scripts/functions/substitution: Rewrite to use run_make_test() 164 interface, and add test for substitution failures reported by 165 Markus Mauhart <[email protected]>. 166 167 2004-03-22 Paul D. Smith <[email protected]> 168 169 * test_driver.pl (run_each_test, toplevel, compare_output): Change 170 to track both the testing categories _AND_ the number of 171 individual tests, and report both sets of numbers. 172 1 173 2004-02-21 Paul D. Smith <[email protected]> 2 174 -
branches/GNU/src/gmake/tests/run_make_tests.pl
r53 r280 1 #!/usr/ local/bin/perl1 #!/usr/bin/env perl 2 2 # -*-perl-*- 3 3 … … 13 13 14 14 $valgrind = 0; # invoke make with valgrind 15 $pure_log = undef; 15 16 16 17 require "test_driver.pl"; … … 38 39 } 39 40 40 # This doesn't work--it _should_! Someone needs to fix this badly.41 # This doesn't work--it _should_! Someone badly needs to fix this. 41 42 # 42 43 # elsif ($option =~ /^-work([-_]?dir)?$/) … … 49 50 } 50 51 51 sub run_make_with_options 52 { 53 local ($filename,$options,$logname,$expected_code) = @_; 54 local($code); 55 local($command) = $make_path; 56 57 $expected_code = 0 unless defined($expected_code); 58 59 if ($filename) 60 { 61 $command .= " -f $filename"; 62 } 63 64 if ($options) 65 { 66 $command .= " $options"; 67 } 68 69 if ($valgrind) { 70 print VALGRIND "\n\nExecuting: $command\n"; 71 } 72 73 $code = &run_command_with_output($logname,$command); 74 75 # Check to see if we have Purify errors. If so, keep the logfile. 76 # For this to work you need to build with the Purify flag -exit-status=yes 77 78 if ($pure_log && -f $pure_log) { 79 if ($code & 0x7000) { 80 $code &= ~0x7000; 81 82 # If we have a purify log, save it 83 $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : ""); 84 print("Renaming purify log file to $tn\n") if $debug; 85 rename($pure_log, "$tn") 86 || die "Can't rename $log to $tn: $!\n"; 87 ++$purify_errors; 88 } 89 else { 90 unlink($pure_log); 91 } 92 } 93 94 if ($code != $expected_code) 95 { 96 print "Error running $make_path ($code): $command\n"; 97 $test_passed = 0; 98 # If it's a SIGINT, stop here 99 if ($code & 127) { 100 print STDERR "\nCaught signal ".($code & 127)."!\n"; 101 exit($code); 102 } 103 return 0; 104 } 105 106 if ($profile & $vos) 107 { 108 system "add_profile $make_path"; 109 } 110 1; 52 53 # This is an "all-in-one" function. Arguments are as follows: 54 # 55 # [0] (string): The makefile to be tested. undef means use the last one. 56 # [1] (string): Arguments to pass to make. 57 # [2] (string): Answer we should get back. 58 # [3] (integer): Exit code we expect. A missing code means 0 (success) 59 60 $old_makefile = undef; 61 62 sub run_make_test 63 { 64 local ($makestring, $options, $answer, $err_code) = @_; 65 66 # If the user specified a makefile string, create a new makefile to contain 67 # it. If the first value is not defined, use the last one (if there is 68 # one). 69 70 if (! defined $makestring) { 71 defined $old_makefile 72 || die "run_make_test(undef) invoked before run_make_test('...')\n"; 73 $makefile = $old_makefile; 74 } else { 75 if (! defined($makefile)) { 76 $makefile = &get_tmpfile(); 77 } 78 79 # Make sure it ends in a newline. 80 $makestring && $makestring !~ /\n$/s and $makestring .= "\n"; 81 82 # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to 83 # make 84 $makestring =~ s/#MAKEFILE#/$makefile/g; 85 $makestring =~ s/#MAKEPATH#/$mkpath/g; 86 $makestring =~ s/#MAKE#/$make_name/g; 87 $makestring =~ s/#PWD#/$pwd/g; 88 89 # Populate the makefile! 90 open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n"; 91 print MAKEFILE $makestring; 92 close(MAKEFILE) || die "Failed to write $makefile: $!\n"; 93 } 94 95 # Do the same processing on $answer as we did on $makestring. 96 97 $answer && $answer !~ /\n$/s and $answer .= "\n"; 98 $answer =~ s/#MAKEFILE#/$makefile/g; 99 $answer =~ s/#MAKEPATH#/$mkpath/g; 100 $answer =~ s/#MAKE#/$make_name/g; 101 $answer =~ s/#PWD#/$pwd/g; 102 103 &run_make_with_options($makefile, $options, &get_logfile(0), $err_code); 104 &compare_output($answer, &get_logfile(1)); 105 106 $old_makefile = $makefile; 107 $makefile = undef; 108 } 109 110 # The old-fashioned way... 111 sub run_make_with_options { 112 local ($filename,$options,$logname,$expected_code) = @_; 113 local($code); 114 local($command) = $make_path; 115 116 $expected_code = 0 unless defined($expected_code); 117 118 # Reset to reflect this one test. 119 $test_passed = 1; 120 121 if ($filename) { 122 $command .= " -f $filename"; 123 } 124 125 if ($options) { 126 $command .= " $options"; 127 } 128 129 if ($valgrind) { 130 print VALGRIND "\n\nExecuting: $command\n"; 131 } 132 133 $code = &run_command_with_output($logname,$command); 134 135 # Check to see if we have Purify errors. If so, keep the logfile. 136 # For this to work you need to build with the Purify flag -exit-status=yes 137 138 if ($pure_log && -f $pure_log) { 139 if ($code & 0x7000) { 140 $code &= ~0x7000; 141 142 # If we have a purify log, save it 143 $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : ""); 144 print("Renaming purify log file to $tn\n") if $debug; 145 rename($pure_log, "$tn") 146 || die "Can't rename $log to $tn: $!\n"; 147 ++$purify_errors; 148 } else { 149 unlink($pure_log); 150 } 151 } 152 153 if ($code != $expected_code) { 154 print "Error running $make_path (expected $expected_code; got $code): $command\n"; 155 $test_passed = 0; 156 # If it's a SIGINT, stop here 157 if ($code & 127) { 158 print STDERR "\nCaught signal ".($code & 127)."!\n"; 159 exit($code); 160 } 161 return 0; 162 } 163 164 if ($profile & $vos) { 165 system "add_profile $make_path"; 166 } 167 168 1; 111 169 } 112 170 … … 159 217 # This is probably not specific enough. 160 218 # 161 if ($osname =~ /Windows/i ) {219 if ($osname =~ /Windows/i || $osname =~ /MINGW32/i) { 162 220 $port_type = 'W32'; 163 221 } … … 184 242 # timestamps with second granularity (!!). Change the sleep time 185 243 # needed to force a file to be considered "old". 186 #187 244 $wtime = $port_type eq 'UNIX' ? 1 : $port_type eq 'OS/2' ? 2 : 4; 245 246 print "Port type: $port_type\n" if $debug; 247 print "Make path: $make_path\n" if $debug; 188 248 189 249 # Find the full pathname of Make. For DOS systems this is more 190 250 # complicated, so we ask make itself. 191 192 251 $make_path = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`; 193 252 chop $make_path; … … 227 286 # Get Purify log info--if any. 228 287 229 $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/; 230 $pure_log = $1 || ''; 231 $pure_log =~ s/%v/$make_name/; 232 $purify_errors = 0; 288 if (exists $ENV{PURIFYOPTIONS} 289 && $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/) { 290 $pure_log = $1 || ''; 291 $pure_log =~ s/%v/$make_name/; 292 $purify_errors = 0; 293 } 233 294 234 295 $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`; -
branches/GNU/src/gmake/tests/scripts/features/conditionals
r153 r280 4 4 $details = "Attempt various different flavors of GNU make conditionals."; 5 5 6 open(MAKEFILE,"> $makefile"); 7 8 # The Contents of the MAKEFILE ... 9 10 print MAKEFILE <<'EOMAKE'; 11 objects = foo.obj 6 run_make_test(' 12 7 arg1 = first 13 8 arg2 = second … … 23 18 endif 24 19 25 ifeq '$(arg2)' "$(arg5)"20 ifeq \'$(arg2)\' "$(arg5)" 26 21 @echo arg2 equals arg5 27 22 else … … 29 24 endif 30 25 31 ifneq '$(arg3)' '$(arg4)'26 ifneq \'$(arg3)\' \'$(arg4)\' 32 27 @echo arg3 NOT equal arg4 33 28 else … … 44 39 else 45 40 @echo arg4 is NOT defined 46 endif 47 48 EOMAKE 49 50 close(MAKEFILE); 51 52 &run_make_with_options($makefile,"",&get_logfile,0); 53 54 $answer = "arg1 NOT equal arg2 41 endif', 42 '', 43 'arg1 NOT equal arg2 55 44 arg2 equals arg5 56 45 arg3 NOT equal arg4 57 46 variable is undefined 58 arg4 is defined 59 "; 60 61 &compare_output($answer,&get_logfile(1)); 47 arg4 is defined'); 62 48 63 49 64 50 # Test expansion of variables inside ifdef. 65 51 66 $makefile2 = &get_tmpfile; 67 68 open(MAKEFILE, "> $makefile2"); 69 70 print MAKEFILE <<'EOF'; 71 52 run_make_test(' 72 53 foo = 1 73 54 … … 93 74 endif 94 75 95 all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3) 76 all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)', 77 '', 78 'DEF=yes DEF2=yes DEF3=yes'); 96 79 97 EOF98 80 99 close(MAKEFILE) 81 # Test all the different "else if..." constructs 100 82 101 &run_make_with_options($makefile2,"",&get_logfile,0); 102 $answer = "DEF=yes DEF2=yes DEF3=yes\n"; 103 &compare_output($answer,&get_logfile(1)); 83 run_make_test(' 84 arg1 = first 85 arg2 = second 86 arg3 = third 87 arg4 = cc 88 arg5 = fifth 89 90 result = 91 92 ifeq ($(arg1),$(arg2)) 93 result += arg1 equals arg2 94 else ifeq \'$(arg2)\' "$(arg5)" 95 result += arg2 equals arg5 96 else ifneq \'$(arg3)\' \'$(arg3)\' 97 result += arg3 NOT equal arg4 98 else ifndef arg5 99 result += variable is undefined 100 else ifdef undefined 101 result += arg4 is defined 102 else 103 result += success 104 endif 105 106 107 all: ; @echo $(result)', 108 '', 109 'success'); 110 111 112 # Test some random "else if..." construct nesting 113 114 run_make_test(' 115 arg1 = first 116 arg2 = second 117 arg3 = third 118 arg4 = cc 119 arg5 = second 120 121 ifeq ($(arg1),$(arg2)) 122 $(info failed 1) 123 else ifeq \'$(arg2)\' "$(arg2)" 124 ifdef undefined 125 $(info failed 2) 126 else 127 $(info success) 128 endif 129 else ifneq \'$(arg3)\' \'$(arg3)\' 130 $(info failed 3) 131 else ifdef arg5 132 $(info failed 4) 133 else ifdef undefined 134 $(info failed 5) 135 else 136 $(info failed 6) 137 endif 138 139 .PHONY: all 140 all: ; @:', 141 '', 142 'success'); 104 143 105 144 -
branches/GNU/src/gmake/tests/scripts/features/echoing
r53 r280 55 55 56 56 &run_make_with_options($makefile,"clean",&get_logfile,0); 57 $answer = ""; 58 &compare_output($answer,&get_logfile(1)); 59 60 if (-f $example) 61 { 62 $test_passed = 0; 57 if (-f $example) { 58 $test_passed = 0; 63 59 } 60 &compare_output('',&get_logfile(1)); 64 61 65 62 # TEST #3 -
branches/GNU/src/gmake/tests/scripts/features/errors
r53 r280 53 53 &run_make_with_options($makefile,"",&get_logfile); 54 54 55 # If make acted as planned, it should ignore the error from the first 56 # command in the target and execute the second which deletes the file "foo" 57 # This file, therefore, should not exist if the test PASSES. 58 if (-f "foo") { 59 $test_passed = 0; 60 } 61 55 62 # The output for this on VOS is too hard to replicate, so we only check it 56 63 # on unix. … … 58 65 { 59 66 &compare_output($answer,&get_logfile(1)); 60 }61 62 # If make acted as planned, it should ignore the error from the first63 # command in the target and execute the second which deletes the file "foo"64 # This file, therefore, should not exist if the test PASSES.65 if (-f "foo")66 {67 $test_passed = 0;68 67 } 69 68 … … 81 80 &run_make_with_options($makefile,"clean2 -i",&get_logfile); 82 81 83 if (!$vos) 84 { 82 if (-f "foo") { 83 $test_passed = 0; 84 } 85 86 if (!$vos) { 85 87 &compare_output($answer,&get_logfile(1)); 86 88 } 87 89 88 if (-f "foo")89 {90 $test_passed = 0;91 }92 93 90 1; -
branches/GNU/src/gmake/tests/scripts/test_template
r53 r280 1 $description = "The following test creates a makefile to ... 2 <FILL IN DESCRIPTION HERE> "; 1 # -*-perl-*- 3 2 3 $description = "<FILL IN SHORT DESCRIPTION HERE>"; 4 4 $details = "<FILL IN DETAILS OF HOW YOU TEST WHAT YOU SAY YOU ARE TESTING>"; 5 5 6 # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 7 # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 8 # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 9 # EXAMPLE: $makefile2 = &get_tmpfile; 6 # Run a make test. See the documentation of run_make_test() in 7 # run_make_tests.pl, but briefly the first argument is a string with the 8 # contents of a makefile to be tested, the second is a string containing the 9 # arguments to be passed to the make invocation, the third is a string 10 # containing the expected output. The fourth is the expected exit code for 11 # make. If not specified, it's assumed that the make program should succeed 12 # (exit with 0). 10 13 11 open(MAKEFILE,"> $makefile"); 14 run_make_test('Your test makefile goes here', 15 'Arguments to pass to make go here', 16 'Expected output from the invocation goes here'); 12 17 13 # The Contents of the MAKEFILE ... 18 # There are various special tokens, options, etc. See the full documentation 19 # in run_make_tests.pl. 14 20 15 print MAKEFILE " <FILL IN THE CONTENTS OF THE MAKEFILE HERE> \n";16 17 # END of Contents of MAKEFILE18 19 close(MAKEFILE);20 21 22 # Run make. You may specify a makefile, but if you don't want to, just23 # insert "" where $make_filename is now. You may also specify specific24 # options to run make with, but you also don't have to. (Insert "" where it25 # says <FILL IN OPTIONS HERE>), The last field in this subroutine call26 # is the code which is returned from make. If you think that make should27 # execute with no errors, you may OPTIONALLY put 0; Otherwise put the28 # error code that you expect back from make for this test.29 30 # Every time you run make, you just need to say &get_logfile and that31 # subroutine will get a new logfile name for you in incrementing order32 # according to how many times you call it within ONE test. It is33 # reset to 0 at the beginning of every new test script.34 35 &run_make_with_options($makefile,36 "<FILL IN OPTIONS HERE>",37 &get_logfile,38 0);39 40 41 # THE REST OF THIS FILE DEPENDS HIGHLY ON WHAT KIND OF TEST YOU ARE42 # CREATING, SO IT WILL VARY. BASICALLY, YOU MAY INSERT ANYTHING YOU43 # WISH AT THIS POINT TO SEE IF THE TEST WORKED OK. IF THERE ARE44 # ADDITIONAL TESTS BESIDES &compare_output, AND IT FAILES, YOU45 # MUST *** SET $test_passed = 0 !!! ***46 47 # Create the answer to what should be produced by this Makefile48 $answer = "<INSERT ANSWER HERE>";49 50 # COMPARE RESULTS51 52 # In this call to compare output, you should use the call &get_logfile(1)53 # to send the name of the last logfile created. You may also use54 # the special call &get_logfile(1) which returns the same as &get_logfile(1).55 56 &compare_output($answer,&get_logfile(1));57 58 # If you wish to &error ("abort59 ") if the compare fails, then add a "|| &error ("abort60 ")" to the61 # end of the previous line.62 21 63 22 # This tells the test driver that the perl test script executed properly. -
branches/GNU/src/gmake/tests/test_driver.pl
r53 r280 1 #!/usr/ local/bin/perl1 #!/usr/bin/perl 2 2 # -*-perl-*- 3 3 … … 12 12 # this routine controls the whole mess; each test suite sets up a few 13 13 # variables and then calls &toplevel, which does all the real work. 14 15 # $Id: test_driver.pl,v 1.14 2005/02/28 07:48:23 psmith Exp $ 16 17 18 # The number of test categories we've run 19 $categories_run = 0; 20 # The number of test categroies that have passed 21 $categories_passed = 0; 22 # The total number of individual tests that have been run 23 $total_tests_run = 0; 24 # The total number of individual tests that have passed 25 $total_tests_passed = 0; 26 # The number of tests in this category that have been run 27 $tests_run = 0; 28 # The number of tests in this category that have passed 29 $tests_passed = 0; 30 31 32 # Yeesh. This whole test environment is such a hack! 33 $test_passed = 1; 14 34 15 35 sub toplevel … … 151 171 $| = 1; 152 172 153 if ($num_failed) 154 { 155 print "\n$num_failed Test"; 156 print "s" unless $num_failed == 1; 173 $categories_failed = $categories_run - $categories_passed; 174 $total_tests_failed = $total_tests_run - $total_tests_passed; 175 176 if ($total_tests_failed) 177 { 178 print "\n$total_tests_failed Test"; 179 print "s" unless $total_tests_failed == 1; 180 print " in $categories_failed Categor"; 181 print ($categories_failed == 1 ? "y" : "ies"); 157 182 print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n"; 158 183 return 0; … … 160 185 else 161 186 { 162 print "\n$counter Test"; 163 print "s" unless $counter == 1; 187 print "\n$total_tests_passed Test"; 188 print "s" unless $total_tests_passed == 1; 189 print " in $categories_passed Categor"; 190 print ($categories_passed == 1 ? "y" : "ies"); 164 191 print " Complete ... No Failures :-)\n\n"; 165 192 return 1; … … 349 376 sub run_each_test 350 377 { 351 $c ounter= 0;378 $categories_run = 0; 352 379 353 380 foreach $testname (sort @TESTS) 354 381 { 355 $counter++;356 $ test_passed = 1; # reset by test on failure382 ++$categories_run; 383 $suite_passed = 1; # reset by test on failure 357 384 $num_of_logfiles = 0; 358 385 $num_of_tmpfiles = 0; 359 386 $description = ""; 360 387 $details = ""; 388 $old_makefile = undef; 361 389 $testname =~ s/^$scriptpath$pathsep//; 362 390 $perl_testname = "$scriptpath$pathsep$testname"; … … 391 419 392 420 # Run the actual test! 393 # 421 $tests_run = 0; 422 $tests_passed = 0; 394 423 $code = do $perl_testname; 424 425 $total_tests_run += $tests_run; 426 $total_tests_passed += $tests_passed; 427 428 # How did it go? 395 429 if (!defined($code)) 396 430 { 397 $ test_passed = 0;431 $suite_passed = 0; 398 432 if (length ($@)) 399 433 { … … 406 440 } 407 441 elsif ($code == -1) { 408 $ test_passed = 0;442 $suite_passed = 0; 409 443 } 410 444 elsif ($code != 1 && $code != -1) { 411 $ test_passed = 0;445 $suite_passed = 0; 412 446 warn "\n*** Test returned $code\n"; 413 447 } 414 448 415 if ($test_passed) { 416 $status = "ok"; 449 if ($suite_passed) { 450 ++$categories_passed; 451 $status = "ok ($tests_passed passed)"; 417 452 for ($i = $num_of_tmpfiles; $i; $i--) 418 453 { 419 & delete($tmp_filename . &num_suffix ($i) );454 &rmfiles ($tmp_filename . &num_suffix ($i) ); 420 455 } 421 456 422 457 for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--) 423 458 { 424 & delete($log_filename . &num_suffix ($i) );425 & delete($base_filename . &num_suffix ($i) );459 &rmfiles ($log_filename . &num_suffix ($i) ); 460 &rmfiles ($base_filename . &num_suffix ($i) ); 426 461 } 427 462 } 428 463 elsif ($code > 0) { 429 $status = "FAILED"; 430 $num_failed++; 464 $status = "FAILED ($tests_passed/$tests_run passed)"; 431 465 } 432 466 elsif ($code < 0) { 433 467 $status = "N/A"; 434 --$c ounter;468 --$categories_run; 435 469 } 436 470 … … 467 501 # are sent to it. 468 502 469 sub delete503 sub rmfiles 470 504 { 471 505 local(@files) = @_; … … 578 612 { 579 613 local($answer,$logfile) = @_; 580 local($slurp); 581 582 if ($debug) 583 { 584 print "Comparing Output ........ "; 585 } 614 local($slurp, $answer_matched) = ('', 0); 615 616 print "Comparing Output ........ " if $debug; 586 617 587 618 $slurp = &read_file_into_string ($logfile); … … 592 623 $slurp =~ s/^.*Clock skew detected.*\n//gm; 593 624 594 if ($slurp eq $answer) 595 { 596 if ($debug) 597 { 598 print "ok\n"; 599 } 625 ++$tests_run; 626 627 if ($slurp eq $answer) { 628 $answer_matched = 1; 629 } else { 630 # See if it is a slash or CRLF problem 631 local ($answer_mod) = $answer; 632 633 $answer_mod =~ tr,\\,/,; 634 $answer_mod =~ s,\r\n,\n,gs; 635 636 $slurp =~ tr,\\,/,; 637 $slurp =~ s,\r\n,\n,gs; 638 639 $answer_matched = ($slurp eq $answer_mod); 640 } 641 642 if ($answer_matched && $test_passed) 643 { 644 print "ok\n" if $debug; 645 ++$tests_passed; 600 646 return 1; 601 647 } 602 else 603 { 604 if ($debug) 605 { 606 print "DIFFERENT OUTPUT\n"; 607 } 608 $test_passed = 0; 648 649 if (! $answer_matched) { 650 print "DIFFERENT OUTPUT\n" if $debug; 651 609 652 &create_file (&get_basefile, $answer); 610 653 611 if ($debug) 612 { 613 print "\nCreating Difference File ...\n"; 614 } 654 print "\nCreating Difference File ...\n" if $debug; 655 615 656 # Create the difference file 657 616 658 local($command) = "diff -c " . &get_basefile . " " . $logfile; 617 659 &run_command_with_output(&get_difffile,$command); 618 619 return 0; 620 } 660 } 661 662 $suite_passed = 0; 663 return 0; 621 664 } 622 665 … … 702 745 local ($code); 703 746 704 if ($debug) 705 { 706 print "\nrun_command: @_\n"; 707 $code = system @_; 708 print "run_command: \"@_\" returned $code.\n"; 709 return $code; 710 } 711 712 return system @_; 747 print "\nrun_command: @_\n" if $debug; 748 $code = system @_; 749 print "run_command: \"@_\" returned $code.\n" if $debug; 750 751 return $code; 713 752 } 714 753 … … 726 765 $code = system @_; 727 766 &detach_default_output; 728 if ($debug) 729 { 730 print "run_command_with_output: \"@_\" returned $code.\n"; 731 } 767 768 print "run_command_with_output: '@_' returned $code.\n" if $debug; 732 769 733 770 return $code; -
branches/GNU/src/gmake/variable.c
r54 r280 500 500 501 501 do 502 /* We found one, so insert it into the set. */ 503 do_variable_definition (&p->variable.fileinfo, p->variable.name, 504 p->variable.value, p->variable.origin, 505 p->variable.flavor, 1); 502 { 503 /* We found one, so insert it into the set. */ 504 505 struct variable *v; 506 507 if (p->variable.flavor == f_simple) 508 { 509 v = define_variable_loc ( 510 p->variable.name, strlen (p->variable.name), 511 p->variable.value, p->variable.origin, 512 0, &p->variable.fileinfo); 513 514 v->flavor = f_simple; 515 } 516 else 517 { 518 v = do_variable_definition ( 519 &p->variable.fileinfo, p->variable.name, 520 p->variable.value, p->variable.origin, 521 p->variable.flavor, 1); 522 } 523 524 /* Also mark it as a per-target and copy export status. */ 525 v->per_target = p->variable.per_target; 526 v->export = p->variable.export; 527 } 506 528 while ((p = lookup_pattern_var (p, file->name)) != 0); 507 529 … … 727 749 #endif 728 750 729 /* This won't override any definition, but it 730 will provide one if thereisn't one there. */751 /* This won't override any definition, but it will provide one if there 752 isn't one there. */ 731 753 v = define_variable ("SHELL", 5, default_shell, o_default, 0); 732 v->export = v_export; /* Always export SHELL. */ 733 734 /* On MSDOS we do use SHELL from environment, since 735 it isn't a standard environment variable on MSDOS, 736 so whoever sets it, does that on purpose. 737 On OS/2 we do not use SHELL from environment but 738 we have already handled that problem above. */ 754 755 /* On MSDOS we do use SHELL from environment, since it isn't a standard 756 environment variable on MSDOS, so whoever sets it, does that on purpose. 757 On OS/2 we do not use SHELL from environment but we have already handled 758 that problem above. */ 739 759 #if !defined(__MSDOS__) && !defined(__EMX__) 740 760 /* Don't let SHELL come from the environment. */ … … 854 874 855 875 case v_noexport: 856 continue; 876 /* If this is the SHELL variable and it's not exported, then 877 add the value from our original environment. */ 878 if (streq (v->name, "SHELL")) 879 { 880 extern struct variable shell_var; 881 v = &shell_var; 882 break; 883 } 884 continue; 857 885 858 886 case v_ifset: … … 969 997 v = lookup_variable_in_set (varname, strlen (varname), 970 998 current_variable_set_list->set); 999 1000 /* Don't append from the global set if a previous non-appending 1001 target-specific variable definition exists. */ 1002 if (v && !v->append) 1003 append = 0; 971 1004 } 972 1005 else … … 1027 1060 && strcmp (varname, "SHELL") == 0) 1028 1061 { 1029 char shellpath[PATH_MAX];1062 PATH_VAR (shellpath); 1030 1063 extern char * __dosexec_find_on_path (const char *, char *[], char *); 1031 1064 … … 1412 1445 sync_Path_environment (void) 1413 1446 { 1414 char *path = allocated_variable_expand ("$(P ath)");1447 char *path = allocated_variable_expand ("$(PATH)"); 1415 1448 static char *environ_path = NULL; 1416 1449 … … 1429 1462 */ 1430 1463 convert_Path_to_windows32 (path, ';'); 1431 environ_path = concat ("P ath", "=", path);1464 environ_path = concat ("PATH", "=", path); 1432 1465 putenv (environ_path); 1433 1466 free (path); -
branches/GNU/src/gmake/variable.h
r54 r280 113 113 extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length)); 114 114 extern char *variable_expand PARAMS ((char *line)); 115 extern char *variable_expand_for_file PARAMS ((char *line, struct file *file)); 115 116 extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file)); 116 117 #define allocated_variable_expand(line) \ … … 126 127 extern int pattern_matches PARAMS ((char *pattern, char *percent, char *str)); 127 128 extern char *subst_expand PARAMS ((char *o, char *text, char *subst, char *replace, 128 unsigned int slen, unsigned int rlen, int by_word , int suffix_only));129 unsigned int slen, unsigned int rlen, int by_word)); 129 130 extern char *patsubst_expand PARAMS ((char *o, char *text, char *pattern, char *replace, 130 131 char *pattern_percent, char *replace_percent)); -
branches/GNU/src/gmake/vmsfunctions.c
r54 r280 3 3 #include "make.h" 4 4 #include "debug.h" 5 #include "job.h" 5 6 6 7 #ifdef __DECC
Note:
See TracChangeset
for help on using the changeset viewer.