VirtualBox

Changeset 280 in kBuild for branches/GNU/src/gmake


Ignore:
Timestamp:
May 16, 2005 4:54:02 PM (20 years ago)
Author:
bird
Message:

Current make snaphot, 2005-05-16.

Location:
branches/GNU/src/gmake
Files:
1 added
61 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gmake

    • Property svn:ignore
      •  

        old new  
        3434README.DOS
        3535README.W32
         36README.OS2
        3637aclocal.m4
        3738autom4te.cache
  • branches/GNU/src/gmake/.cvsignore

    r52 r280  
    1212*.cp *.cps *.fn *.fns *.vr *.vrs *.tp *.tps *.ky *.kys *.pg *.pgs
    1313
    14 README README.DOS README.W32
     14README README.DOS README.W32 README.OS2
    1515aclocal.m4 autom4te.cache
    1616config.h.in config.h config.status config.cache configure
  • branches/GNU/src/gmake/AUTHORS

    r54 r280  
    77Development starting with GNU make 3.76 by:
    88    Paul D. Smith <[email protected]>
     9    Additional development starting with GNU make 3.81 by:
     10        Boris Kolpackov <[email protected]>
    911
    1012
     
    2426  Port to VMS by:
    2527      Klaus Kaempf <[email protected]>
     28      Hartmut Becker <[email protected]>
    2629      Archive support/Bug fixes by:
    2730        John W. Eaton <[email protected]>
     
    3134      Aaron Digulla <[email protected]>
    3235
    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:
    3537      DJ Delorie <[email protected]>
    3638      Rob Tulloh <[email protected]>
    3739      Eli Zaretskii <[email protected]>
     40      Jonathan Grant <[email protected]>
     41      Andreas Beuning <[email protected]>
     42      Earnie Boyd <[email protected]>
    3843
    3944-----------------------------------
     
    4853  David Lubbren <[email protected]>
    4954  Tim Magill <[email protected]>
     55  Markus Mauhart <[email protected]>
    5056  Greg McGary <[email protected]>
     57  Thomas Riedl <[email protected]>
    5158  Han-Wen Nienhuys <[email protected]>
    5259  Andreas Schwab <[email protected]>
  • branches/GNU/src/gmake/ChangeLog

    r153 r280  
     12005-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
     192005-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
     282005-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
     442005-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
     542005-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
     832005-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
     932005-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
     1002005-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
     1272005-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
     1402005-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
     1492005-03-13  Paul D. Smith  <[email protected]>
     150
     151        * main.c (main) [MSDOS]: Export SHELL in MSDOS.  Requested by Eli
     152        Zaretskii.
     153
     1542005-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
     1592005-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
     1652005-03-09  Paul D. Smith  <[email protected]>
     166
     167        * read.c (eval_makefile): Add alloca(0).
     168        (eval_buffer): Ditto.
     169
     1702005-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
     1782005-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
     1832005-03-04  Paul D. Smith  <[email protected]>
     184
     185        * AUTHORS: Update.
     186        * doc/make.texi (Automatic Variables): Document $|.
     187
     1882005-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
     2012005-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
     2102005-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
     2152005-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
     2302005-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
     2762005-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
     2942005-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
     3402005-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
     3462005-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
     3602004-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
     3662005-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
     3882005-02-01  Paul D. Smith  <[email protected]>
     389
     390        * maintMakefile (po_repo): Update the GNU translation site URL.
     391
     3922004-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
     3972004-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
     4082004-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
     4212004-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
     4362004-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
     4422004-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
     4482004-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
     4552004-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
     4662004-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
     4732004-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
     4782004-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
     4832004-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
     4912004-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
     5162004-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
     5312004-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
     5382004-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
     5522004-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
     5572004-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
     5742004-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
     5802004-04-21  Bob Byrnes  <[email protected]>
     581
     582        * main.c (main): Notice failures to remake makefiles.
     583
     5842004-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
     5932004-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
     6382004-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
    16442004-03-06  Paul D. Smith  <[email protected]>
    2645
     
    160803        (get-config/config.guess get-config/config.sub): Get these files
    161804        from the Savannah config project instead of ftp.gnu.org.
     805
     8062003-10-05  Paul Eggert  <[email protected]>
     807
     808        * main.c (main): Avoid potential subscript error if environ has
     809        short strings.
    162810
    1638112003-08-22  Paul D. Smith  <[email protected]>
     
    10521700        * i18n/ja.po: Installed an updated translation.
    10531701
     17022001-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
    105417112001-09-04  Paul D. Smith  <[email protected]>
    10551712
  • 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
     1Installation Instructions
     2*************************
     3
     4Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free
     5Software Foundation, Inc.
     6
     7This file is free documentation; the Free Software Foundation gives
    58unlimited permission to copy, distribute and modify it.
    69
     
    811==================
    912
    10    These are generic installation instructions.
     13These are generic installation instructions.
    1114
    1215   The `configure' shell script attempts to guess correct values for
     
    6871=====================
    6972
    70    Some systems require unusual options for compilation or linking that
    71 the `configure' script does not know about.  Run `./configure --help'
    72 for details on some of the pertinent environment variables.
     73Some systems require unusual options for compilation or linking that the
     74`configure' script does not know about.  Run `./configure --help' for
     75details on some of the pertinent environment variables.
    7376
    7477   You can give `configure' initial values for configuration parameters
     
    8386====================================
    8487
    85    You can compile the package for more than one kind of computer at the
     88You can compile the package for more than one kind of computer at the
    8689same time, by placing the object files for each architecture in their
    8790own directory.  To do this, you must use a version of `make' that
     
    100103==================
    101104
    102    By default, `make install' will install the package's files in
     105By default, `make install' will install the package's files in
    103106`/usr/local/bin', `/usr/local/man', etc.  You can specify an
    104107installation prefix other than `/usr/local' by giving `configure' the
    105 option `--prefix=PATH'.
     108option `--prefix=PREFIX'.
    106109
    107110   You can specify separate installation prefixes for
    108111architecture-specific files and architecture-independent files.  If you
    109 give `configure' the option `--exec-prefix=PATH', the package will use
    110 PATH as the prefix for installing programs and libraries.
     112give `configure' the option `--exec-prefix=PREFIX', the package will
     113use PREFIX as the prefix for installing programs and libraries.
    111114Documentation and other data files will still use the regular prefix.
    112115
    113116   In addition, if you use an unusual directory layout you can give
    114 options like `--bindir=PATH' to specify different values for particular
     117options like `--bindir=DIR' to specify different values for particular
    115118kinds of files.  Run `configure --help' for a list of the directories
    116119you can set and what kinds of files go in them.
     
    123126=================
    124127
    125    Some packages pay attention to `--enable-FEATURE' options to
     128Some packages pay attention to `--enable-FEATURE' options to
    126129`configure', where FEATURE indicates an optional part of the package.
    127130They may also pay attention to `--with-PACKAGE' options, where PACKAGE
     
    138141==========================
    139142
    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 a message saying it cannot guess the machine type, give it the
     143There may be some features `configure' cannot figure out automatically,
     144but needs to determine by the type of machine the package will run on.
     145Usually, assuming the package is built to be run on the _same_
     146architectures, `configure' can figure that out, but if it prints a
     147message saying it cannot guess the machine type, give it the
    145148`--build=TYPE' option.  TYPE can either be a short name for the system
    146149type, such as `sun4', or a canonical name which has the form:
     
    168171================
    169172
    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 default values for variables like `CC', `cache_file', and `prefix'.
     173If you want to set default values for `configure' scripts to share, you
     174can create a site shell script called `config.site' that gives default
     175values for variables like `CC', `cache_file', and `prefix'.
    173176`configure' looks for `PREFIX/share/config.site' if it exists, then
    174177`PREFIX/etc/config.site' if it exists.  Or, you can set the
     
    179182==================
    180183
    181    Variables not defined in a site shell script can be set in the
     184Variables not defined in a site shell script can be set in the
    182185environment passed to `configure'.  However, some packages may run
    183186configure again during the build, and the customized values of these
     
    193196======================
    194197
    195    `configure' recognizes the following options to control how it
    196 operates.
     198`configure' recognizes the following options to control how it operates.
    197199
    198200`--help'
  • branches/GNU/src/gmake/Makefile.am

    r153 r280  
    44ACLOCAL_AMFLAGS =  -I config
    55
    6 SUBDIRS =       glob config po doc
     6# Only process if target is MS-Windows
     7if WINDOWSENV
     8  MAYBE_W32 =   w32
     9  W32INC =      -I $(top_srcdir)/w32/include
     10  W32LIB =      -Lw32 -lw32
     11endif
     12
     13SUBDIRS =       glob config po doc $(MAYBE_W32)
    714
    815bin_PROGRAMS =  make
     
    2027                variable.c version.c vpath.c hash.c
    2128
    22 EXTRA_make_SOURCES = remote-stub.c remote-cstms.c
     29EXTRA_make_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c
    2330
    2431noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \
     
    2633
    2734make_LDADD =    @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@
     35# Only process if target is MS-Windows
     36if WINDOWSENV
     37    make_LDADD += $(W32LIB)
     38endif
    2839
    2940man_MANS =      make.1
     
    3243
    3344AM_CPPFLAGS =   $(GLOBINC)
     45# Only process if target is MS-Windows
     46if WINDOWSENV
     47    AM_CPPFLAGS +=      $(W32INC)
     48endif
    3449
    3550
     
    115130.PHONY: check-loadavg check-regression
    116131
    117 check-loadavg: loadavg
     132check-loadavg: loadavg$(EXEEXT)
    118133        @echo The system uptime program believes the load average to be:
    119134        -uptime
    120135        @echo The GNU load average checking code thinks:
    121         -./loadavg
     136        -./loadavg$(EXEEXT)
    122137
    123138# The loadavg function is invoked during "make check" to test getloadavg.
     
    158173# --------------- Maintainer's Section
    159174
     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
     179README:
     180
    160181@MAINT_MAKEFILE@
  • branches/GNU/src/gmake/NEWS

    r153 r280  
    11GNU make NEWS                                               -*-indented-text-*-
    22  History of user-visible changes.
    3   06 March 2004
    4 
    5 Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
     3  13 May 2005
     4
     5Copyright (C) 2002,2003,2004,2005  Free Software Foundation, Inc.
    66See the end for copying conditions.
    77
    88All changes mentioned here are more fully described in the GNU make
    99manual, 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
     10See the README file and the GNU make manual for instructions for
     11reporting bugs.
     12
     13
     14Version 3.81beta3
    1615
    1716* 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.
    1941
    2042* All pattern-specific variables that match a given target are now used
     
    3052  This version of GNU make uses an algorithm suggested by Thomas Riedl
    3153  <[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:
    3678   - 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.
    3788
    3889* Updated to autoconf 2.59, automake 1.8.2, and gettext 0.14.1.  Users
    3990  should not be impacted.
     91
     92* New translations for Swedish, Chinese (simplified), Ukrainian,
     93  Belarusian, Finnish, Kinyarwandan, and Irish.  Many updated
     94  translations.
    4095
    4196
  • branches/GNU/src/gmake/NMakefile.template

    r54 r280  
    2626LINK = link
    2727CC = cl
     28MAKE = nmake
    2829
    2930OUTDIR=.
  • branches/GNU/src/gmake/README.OS2.template

    r54 r280  
    4747
    4848 - sh compatible shell (ksh, bash, ash, but tested only with pdksh 5.2.14
    49    (release 2)
     49   release 2)
    5050   If you use pdksh it is recommended to update to 5.2.14 release 2. Older
    5151   versions may not work! You can get this version at
     
    6060 - grep
    6161 - 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
    6363 - perl 5.005 or higher
    6464 - GNU texinfo (you can use 3.1 (gnuinfo.zip), but I recommend 4.0)
    6565
    6666If you want to recreate the configuration files (developers only!)
    67 you need also: GNU m4 1.4, autoconf 2.57, automake 1.7.2 (or compatible)
     67you need also: GNU m4 1.4, autoconf 2.59, automake 1.8.2 (or compatible)
    6868
    6969
     
    148148
    149149  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"
    152152  export RANLIB="echo"
    153153  ./configure --prefix=x:/usr --disable-nls
    154154  make AR=emxomfar
    155   make checks
     155  make check
    156156
    157157All tests should work fine with the exception of "default_names" which
  • branches/GNU/src/gmake/README.W32.template

    r54 r280  
    66Tulloh, who is also the author of this README.
    77
    8 To build with nmake on Windows NT, Windows 95, or Windows 98:
     8To build with nmake on MS-Windows:
    99
    1010        1. Make sure cl.exe is in your %Path%. Example:
     
    6464        There are very few true ports of Bourne shell for NT right now.
    6565        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/).
    6767        Other possibilities are the MKS version of sh.exe, or building
    6868        your own with a package like NutCracker (DataFocus) or Portage
    69         (Consensys).
     69        (Consensys).  Also MinGW includes sh (http://mingw.org/).
    7070
    7171GNU make and brain-dead shells (BATCH_MODE_ONLY_SHELL):
    7272
    73         Some versions of Bourne shell does not behave well when invoked
     73        Some versions of Bourne shell do not behave well when invoked
    7474        as 'sh -c' from CreateProcess().  The main problem is they seem
    7575        to have a hard time handling quoted strings correctly. This can
     
    8080        a batch mode.  When BATCH_MODE_ONLY_SHELL is defined at compile
    8181        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).
    8384
    8485        A native Windows32 system with no Bourne shell will also run
    8586        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.
    8790
    8891GNU make and Cygnus GNU Windows32 tools:
     
    129132        specification of paths.  Make is able to figure out the intended
    130133        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".
    132136
    133137        You are encouraged to use colon as the separator character.
     
    165169
    166170        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.
    176182                2. Rename the directory so it does not contain white space.
    177183
  • branches/GNU/src/gmake/README.cvs

    r54 r280  
    2424-----------------
    2525
    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.
     26To build GNU make from CVS, you will need Autoconf, Automake, and
     27Gettext, and any tools that those utilities require (GNU m4, Perl,
     28etc.).  See the configure.in file to find the minimum versions of each
     29of these tools.  You will also need a copy of wget.
    3030
    3131After checking out the code, you will need to perform these steps to get
  • branches/GNU/src/gmake/README.template

    r54 r280  
    7171project to submit new problem reports or search for existing ones:
    7272
    73   http://savannah.gnu.org/bugs/?group_id=71
     73  http://savannah.gnu.org/bugs/?group=make
    7474
    7575If you need help using GNU make, try these forums:
     
    8080  news:gnu.utils.bug
    8181
    82   http://savannah.gnu.org/support/?group_id=71
     82  http://savannah.gnu.org/support/?group=make
    8383
    8484You may also find interesting patches to GNU Make available here:
    8585
    86   http://savannah.gnu.org/patch/?group_id=71
     86  http://savannah.gnu.org/patch/?group=make
    8787
    8888Note these patches are provided by our users as a service and we make no
     
    9898GNU Subversions CVS server; look here for details:
    9999
    100   http://savannah.gnu.org/cvs/?group_id=71
     100  http://savannah.gnu.org/cvs/?group=make
    101101
    102102Please note: you won't be able to build GNU make from CVS without
     
    113113
    114114It 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.
     115that if you compile make with `cc -O' on AIX 3.2, it will not work
     116correctly.  It is said that using `cc' without `-O' does work.
     117
     118The standard /bin/sh on SunOS 4.1.3_U1 and 4.1.4 is broken and cannot be
     119used to configure GNU make.  Please install a different shell such as
     120bash or pdksh in order to run "configure".  See this message for more
     121information:
     122  http://mail.gnu.org/archive/html/bug-autoconf/2003-10/msg00190.html
    117123
    118124One area that is often a problem in configuration and porting is the code
  • branches/GNU/src/gmake/build.template

    r54 r280  
    33# @configure_input@
    44
    5 # Copyright (C) 1993, 1994, 1997, 2003 Free Software Foundation, Inc.
     5# Copyright (C) 1993, 1994, 1997, 2003, 2004 Free Software Foundation, Inc.
    66# This file is part of GNU Make.
    77#
     
    2929LDFLAGS='@LDFLAGS@'
    3030ALLOCA='@ALLOCA@'
    31 LOADLIBES='@LIBS@'
     31LOADLIBES='@LIBS@ @LIBINTL@'
    3232eval extras=\'@LIBOBJS@\'
    3333REMOTE='@REMOTE@'
     
    7979# Link all the objects together.
    8080echo linking make...
    81 $CC $LDFLAGS $objs $LOADLIBES -o makenew${EXEEXT}
     81$CC $CFLAGS $LDFLAGS $objs $LOADLIBES -o makenew${EXEEXT}
    8282echo done
    8383mv -f makenew${EXEEXT} make${EXEEXT}
  • branches/GNU/src/gmake/commands.c

    r153 r280  
    4040/* Set FILE's automatic variables up.  */
    4141
    42 static void
     42void
    4343set_file_variables (struct file *file)
    4444{
     45  struct dep *d;
    4546  char *at, *percent, *star, *less;
    4647
     
    107108  star = file->stem;
    108109
    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      }
    111118
    112119  if (file->cmds == default_file->cmds)
     
    136143    char *qp;
    137144    char *bp;
    138     struct dep *d;
    139145    unsigned int len;
    140146
     
    343349            break;
    344350          }
    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;
    352356
    353357      cmds->lines_flags[idx] = flags;
     
    482486#endif
    483487
     488#ifdef WINDOWS32
     489  /* Cannot call W32_kill with a pid (it needs a handle) */
     490  exit (EXIT_FAILURE);
     491#else
    484492  /* Signal the same code; this time it will really be fatal.  The signal
    485493     will be unblocked when we return and arrive then to kill us.  */
    486494  if (kill (getpid (), sig) < 0)
    487495    pfatal_with_name ("kill");
     496#endif /* not WINDOWS32 */
    488497#endif /* not Amiga */
    489498#endif /* not __MSDOS__  */
  • branches/GNU/src/gmake/commands.h

    r54 r280  
    4141extern void delete_child_targets PARAMS ((struct child *child));
    4242extern void chop_commands PARAMS ((struct commands *cmds));
     43extern void set_file_variables PARAMS ((struct file *file));
  • branches/GNU/src/gmake/config

    • Property svn:ignore
      •  

        old new  
        11*.m4
        22config.*
         3mkinstalldirs
         4texinfo.tex
        35Makefile
        46Makefile.in
  • branches/GNU/src/gmake/config.ami.template

    r54 r280  
    147147/* #undef STAT_MACROS_BROKEN */
    148148
     149/* Define if your compiler conforms to the ANSI C standard. */
     150#define HAVE_ANSI_COMPILER 1
     151
    149152/* Define if you have the ANSI C header files.  */
    150153#define STDC_HEADERS
     
    278281/* #undef HAVE_NDIR_H */
    279282
     283/* Define to 1 if you have the <stdarg.h> header file. */
     284#define HAVE_STDARG_H 1
     285
    280286/* Define if you have the <stdlib.h> header file.  */
    281287/* #undef HAVE_STDLIB_H */
  • branches/GNU/src/gmake/config.h-vms.template

    r54 r280  
    306306/* Define if you have the <ndir.h> header file.  */
    307307/* #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
    308314
    309315/* Define if you have the <stdlib.h> header file.  */
  • branches/GNU/src/gmake/config.h.W32.template

    r54 r280  
    159159/* #undef STAT_MACROS_BROKEN */
    160160
     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
    161167/* Define if you have the ANSI C header files.  */
    162168#undef STDC_HEADERS
  • branches/GNU/src/gmake/config/.cvsignore

    r53 r280  
    11*.m4
    22config.*
     3mkinstalldirs
     4texinfo.tex
    35
    46Makefile Makefile.in
  • branches/GNU/src/gmake/configh.dos.template

    r54 r280  
    5757#define HAVE_SELECT 1
    5858
     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
    5965/* Define if you have the vprintf library function.  */
    6066#undef HAVE_VPRINTF
  • branches/GNU/src/gmake/configure.in

    r153 r280  
    11# Process this file with autoconf to produce a configure script.
    22
    3 AC_INIT([GNU make],[3.81beta1],[[email protected]])
     3AC_INIT([GNU make],[3.81beta3],[[email protected]])
    44
    55AC_PREREQ(2.59)
    6 AC_REVISION([[$Id: configure.in,v 1.125 2004/03/06 08:05:19 psmith Exp $]])
     6AC_REVISION([[$Id: configure.in,v 1.135 2005/05/10 01:38:18 psmith Exp $]])
    77
    88# Autoconf setup
     
    5151AC_HEADER_TIME
    5252AC_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)
    5454
    5555# Set a flag if we have an ANSI C compiler
     
    135135
    136136AC_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)
    140141
    141142AC_FUNC_SETVBUF_REVERSED
     
    167168fi
    168169
    169 AC_CHECK_DECLS([sys_siglist])
     170AC_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])
    170177
    171178
     
    236243AM_CONDITIONAL(USE_CUSTOMS, test "$use_customs" = true)
    237244
     245# See if the user asked to handle case insensitive file systems.
     246
     247AH_TEMPLATE(HAVE_CASE_INSENSITIVE_FS, [Use case insensitive file names])
     248AC_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
    238254# See if we can handle the job server feature, and if the user wants it.
    239255
     
    255271    [make_cv_sa_restart=no])])
    256272
    257 # enable make_cv_sa_restart for OS/2
    258 case "$host_os" in
    259   os2*) make_cv_sa_restart=yes ;;
    260 esac
    261 
    262273if test "$make_cv_sa_restart" != no; then
    263274  AC_DEFINE(HAVE_SA_RESTART, 1,
    264275     [Define if <signal.h> defines the SA_RESTART constant.])
    265276fi
     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.
     280case "$host_os" in
     281  os2*) make_cv_sa_restart=yes ;;
     282esac
    266283
    267284case "$ac_cv_func_pipe/$ac_cv_func_sigaction/$make_cv_sa_restart/$has_wait_nohang/$make_cv_job_server" in
     
    269286    AC_DEFINE(MAKE_JOBSERVER, 1,
    270287              [Define this to enable job server support in GNU make.]);;
     288esac
     289
     290# if we have both lstat() and readlink() then we can support symlink
     291# timechecks.
     292case "$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.]);;
    271296esac
    272297
     
    331356AC_SUBST(MAKE_HOST)
    332357
     358w32_target_env=no
     359AM_CONDITIONAL([WINDOWSENV], false)
     360
     361case "$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    ;;
     368esac
     369
    333370# Include the Maintainer's Makefile section, if it's here.
    334371
     
    389426
    390427# Specify what files are to be created.
     428AC_CONFIG_FILES(Makefile glob/Makefile po/Makefile.in config/Makefile doc/Makefile w32/Makefile)
     429
     430# OK, do it!
     431
     432AC_OUTPUT
     433
    391434# We only generate the build.sh if we have a build.sh.in; we won't have
    392435# 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 
     436if test -f build.sh.in; then
     437  ./config.status --file build.sh
     438  chmod +x build.sh
     439fi
    405440
    406441dnl Local Variables:
  • branches/GNU/src/gmake/default.c

    r54 r280  
    309309#ifdef __ALPHA
    310310    "ARCH", "ALPHA",
    311 #else
     311#endif
     312#ifdef __ia64
     313    "ARCH", "IA64",
     314#endif
     315#ifdef __VAX
    312316    "ARCH", "VAX",
    313317#endif
  • branches/GNU/src/gmake/dep.h

    r54 r280  
    4141    unsigned int changed : 8;
    4242    unsigned int ignore_mtime : 1;
     43    unsigned int need_2nd_expansion : 1;
    4344  };
    4445
     
    7374
    7475extern struct dep *copy_dep_chain PARAMS ((struct dep *d));
     76extern void free_ns_chain PARAMS ((struct nameseq *n));
    7577extern struct dep *read_all_makefiles PARAMS ((char **makefiles));
    7678extern int eval_buffer PARAMS ((char *buffer));
    77 extern int update_goal_chain PARAMS ((struct dep *goals, int makefiles));
     79extern int update_goal_chain PARAMS ((struct dep *goals));
    7880extern void uniquize_deps PARAMS ((struct dep *));
  • branches/GNU/src/gmake/dir.c

    r54 r280  
    124124downcase (char *filename)
    125125{
    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);
    131127  char *df;
    132128  int i;
     
    11421138          d = (struct dirent *) buf;
    11431139#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)
    11461142          d->d_name = xmalloc(len);
    11471143# endif
     
    11631159
    11641160static void
    1165 ansi_free(void *p)
    1166 {
    1167     if (p)
    1168       free(p);
     1161ansi_free (void *p)
     1162{
     1163  if (p)
     1164    free(p);
    11691165}
    11701166
  • branches/GNU/src/gmake/doc/make.texi

    r153 r280  
    88@c FSF publishers: format makebook.texi instead of using this file directly.
    99
    10 @set RCSID $Id: make.texi,v 1.18 2004/02/23 06:25:54 psmith Exp $
    11 @set EDITION 0.61
     10@set RCSID $Id: make.texi,v 1.30 2005/05/13 12:45:31 psmith Exp $
     11@set EDITION 0.70
    1212@set VERSION 3.81
    13 @set UPDATED 02 May 2003
    14 @set UPDATE-MONTH May 2003
    15 @comment The ISBN number might need to change on next publication.
    16 @set ISBN 1-882114-81-7 @c From Brian Youmans <[email protected]>, 25 Apr 2000
     13@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
    1717
    1818@c finalout
     
    4040
    4141Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    42 1998, 1999, 2000, 2002, 2003, 2004
     421998, 1999, 2000, 2002, 2003, 2004, 2005
    4343Free Software Foundation, Inc.
    4444
     
    163163                                  with another makefile.
    164164* Reading Makefiles::           How makefiles are parsed.
     165* Secondary Expansion::         How and when secondary expansion is performed.
    165166
    166167Writing Rules
     
    339340* Install Command Categories::  Three categories of commands in the `install'
    340341
    341 Copying This Manual
    342 
    343342@end detailmenu
    344343@end menu
     
    643642prerequisites.  These shell commands say how to update the target file.
    644643A tab character must come at the beginning of every command line to
    645 distinguish commands lines from other lines in the makefile.  (Bear in
     644distinguish command lines from other lines in the makefile.  (Bear in
    646645mind that @code{make} does not know anything about how the commands
    647646work.  It is up to you to supply commands that will update the target
     
    674673names start with @samp{.}).  This is called the @dfn{default goal}.
    675674(@dfn{Goals} are the targets that @code{make} strives ultimately to
    676 update.  @xref{Goals, , Arguments to Specify the Goals}.)
     675update.    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, ,
     678Other Special Variables}).
    677679@cindex default goal
    678680@cindex goal, default
     
    956958                                  with another makefile.
    957959* Reading Makefiles::           How makefiles are parsed.
     960* Secondary Expansion::         How and when secondary expansion is performed.
    958961@end menu
    959962
     
    12241227@cindex makefiles, and @code{MAKEFILE_LIST} variable
    12251228@cindex including (@code{MAKEFILE_LIST} variable)
     1229@vindex MAKEFILE_LIST
    12261230
    12271231As @code{make} reads various makefiles, including any obtained from the
     
    12401244@example
    12411245@group
    1242 name1 := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
     1246name1 := $(lastword $(MAKEFILE_LIST))
    12431247
    12441248include inc.mk
    12451249
    1246 name2 := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
     1250name2 := $(lastword $(MAKEFILE_LIST))
    12471251
    12481252all:
     
    12731277@cindex special variables
    12741278
    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)
     1279GNU @code{make} also supports other special variables.  Unless
     1280otherwise documented here, these values lose their special properties
     1281if 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
     1287Sets the default goal to be used if no targets were specified on the
     1288command line (@pxref{Goals, , Arguments to Specify the Goals}).  The
     1289@code{.DEFAULT_GOAL} variable allows you to discover the current
     1290default goal, restart the default goal selection algorithm by clearing
     1291its value, or to explicitly set the default goal. The following
     1292example illustrates these cases:
     1293
     1294@example
     1295@group
     1296# Query the default goal.
     1297ifeq ($(.DEFAULT_GOAL),)
     1298  $(warning no default goal is set)
     1299endif
     1300
     1301.PHONY: foo
     1302foo: ; @@echo $@@
     1303
     1304$(warning default goal is $(.DEFAULT_GOAL))
     1305
     1306# Reset the default goal.
     1307.DEFAULT_GOAL :=
     1308
     1309.PHONY: bar
     1310bar: ; @@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
     1319This makefile prints:
     1320
     1321@example
     1322@group
     1323no default goal is set
     1324default goal is foo
     1325default goal is bar
     1326foo
     1327@end group
     1328@end example
     1329
     1330Note that assigning more than one target name to @code{.DEFAULT_GOAL} is
     1331illegal and will result in an error.
     1332
    12801333@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 includes
    1284 variables which have empty values, as well as built-in variables
    1285 (@pxref{Implicit Variables, , Variables Used by Implicit Rules}), but
    1286 does not include any variables which are only defined in a
    1287 target-specific context.
    1288 
    1289 @c @vindex $(.TARGETS)
     1334@item .VARIABLES
     1335Expands to a list of the @emph{names} of all global variables defined
     1336so far.  This includes variables which have empty values, as well as
     1337built-in variables (@pxref{Implicit Variables, , Variables Used by
     1338Implicit Rules}), but does not include any variables which are only
     1339defined in a target-specific context.  Note that any value you assign
     1340to this variable will be ignored; it will always return its special
     1341value.
     1342
    12901343@c @vindex .TARGETS @r{(list of targets)}
     1344@c @item .TARGETS
    12911345@c The second special variable is @code{.TARGETS}.  When expanded, the
    12921346@c value consists of a list of all targets defined in all makefiles read
     
    12961350@c file must appear as a target, on the left-hand side of a ``:'', to be
    12971351@c considered a target for the purposes of this variable.
     1352
     1353@vindex .FEATURES @r{(list of supported features)}
     1354@item .FEATURES
     1355Expands 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
     1360Supports target-specific and pattern-specific variable assignments.
     1361@xref{Target-specific, ,Target-specific Variable Values}.
     1362
     1363@item order-only
     1364Supports order-only prerequisites.  @xref{Prerequisite Types, ,Types
     1365of Prerequisites}.
     1366
     1367@item second-expansion
     1368Supports secondary expansion of prerequisite lists.
     1369
     1370@item jobserver
     1371Supports ``job server'' enhanced parallel builds.  @xref{Parallel,
     1372,Parallel Execution}.
     1373
     1374@item check-symlink
     1375Supports the @code{-L} (@code{--check-symlink-times}) flag.
     1376@xref{Options Summary, ,Summary of Options}.
     1377
     1378@end table
     1379
     1380@end table
    12981381
    12991382@node Remaking Makefiles, Overriding Makefiles, Special Variables, Makefiles
     
    14251508@file{force} itself and create a prerequisite loop!
    14261509
    1427 @node Reading Makefiles,  , Overriding Makefiles, Makefiles
     1510@node Reading Makefiles,  Secondary Expansion, Overriding Makefiles, Makefiles
    14281511@section How @code{make} Reads a Makefile
    14291512@cindex reading makefiles
     
    14861569All instances of conditional syntax are parsed immediately, in their
    14871570entirety; this includes the @code{ifdef}, @code{ifeq}, @code{ifndef},
    1488 and @code{ifneq} forms.
     1571and @code{ifneq} forms.  Of course this means that automatic variables
     1572cannot be used in conditional statements, as automatic variables are
     1573not set until the command script for that rule is invoked.  If you
     1574need to use automatic variables in a conditional you @emph{must} use
     1575shell conditional syntax, in your command script proper, for these
     1576tests, not @code{make} conditionals.
    14891577
    14901578@subheading Rule Definition
     
    15061594general rule is true for explicit rules, pattern rules, suffix rules,
    15071595static 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
     1602In the previous section we learned that GNU @code{make} works in two
     1603distinct phases: a read-in phase and a target-update phase
     1604(@pxref{Reading Makefiles, , How @code{make} Reads a Makefile}).
     1605There is an extra wrinkle that comes in between those two phases,
     1606right at the end of the read-in phase: at that time, all the
     1607prerequisites of all of the targets are expanded a @emph{second time}.
     1608In most circumstances this secondary expansion will have no effect,
     1609since all variable and function references will have been expanded
     1610during the initial parsing of the makefiles.  In order to take
     1611advantage of the secondary expansion phase of the parser, then, it's
     1612necessary to @emph{escape} the variable or function reference in the
     1613makefile.  In this case the first expansion merely un-escapes the
     1614reference but doesn't expand it, and expansion is left to the
     1615secondary expansion phase.  For example, consider this makefile:
     1616
     1617@example
     1618ONEVAR = onefile
     1619TWOVAR = twofile
     1620myfile: $(ONEVAR) $$(TWOVAR)
     1621@end example
     1622
     1623After the first expansion phase the prerequisites list of the
     1624@file{myfile} target will be @code{onefile} and @code{$(TWOVAR)}; the
     1625first (unescaped) variable reference to @var{ONEVAR} is expanded,
     1626while the second (escaped) variable reference is simply unescaped,
     1627without being recognized as a variable reference.  Now during the
     1628secondary expansion the first word is expanded again but since it
     1629contains no variable or function references it remains the static
     1630value @file{onefile}, while the second word is now a normal reference
     1631to 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
     1635Obviously, this is not a very interesting case since the same result
     1636could more easily have been achieved simply by having both variables
     1637appear, unescaped, in the prerequisites list.  One difference becomes
     1638apparent if the variables are reset; consider this example:
     1639
     1640@example
     1641AVAR = top
     1642onefile: $(AVAR)
     1643twofile: $$(AVAR)
     1644AVAR = bottom
     1645@end example
     1646
     1647Here the prerequisite of @file{onefile} will be expanded immediately,
     1648and resolve to the value @file{top}, while the prerequisite of
     1649@file{twofile} will not be full expanded until the secondary expansion
     1650and yield a value of @file{bottom}.
     1651
     1652This is marginally more exciting, but the true power of this feature
     1653only becomes apparent when you discover that secondary expansions
     1654always take place within the scope of the automatic variables for that
     1655target.  This means that you can use variables such as @code{$@@},
     1656@code{$*}, etc. during the second expansion and they will have their
     1657expected values, just as in the command script.  All you have to do is
     1658defer the expansion by escaping the @code{$}.  Also, secondary
     1659expansion occurs for both explicit and implicit (pattern) rules.
     1660Knowing this, the possible uses for this feature are almost endless.
     1661For example:
     1662
     1663@example
     1664main_OBJS := main.o try.o test.o
     1665lib_OBJS := lib.o api.o
     1666
     1667main lib: $$($$@@_OBJS)
     1668@end example
     1669
     1670Here, after the initial expansion the prerequisites of both the
     1671@file{main} and @file{lib} targets will be @code{$($@@_OBJS)}.  During
     1672the secondary expansion, the @code{$@@} variable is set to the name of
     1673the 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
     1675secondary expansion for the @file{lib} target will yield
     1676@code{$(lib_OBJS)}, or @code{lib.o api.o}.
     1677
     1678You can also mix functions here, as long as they are properly escaped:
     1679
     1680@example
     1681main_SRCS := main.c try.c test.c
     1682lib_SRCS := lib.c api.c
     1683
     1684main lib: $$(patsubst %.c,%.o,$$($$@@_SRCS))
     1685@end example
     1686
     1687This version allows users to specify source files rather than object
     1688files, but gives the same resulting prerequisites list as the previous
     1689example.
     1690
     1691Evaluation of automatic variables during the secondary expansion
     1692phase, especially of the target name variable @code{$$@@}, behaves
     1693similarly to evaluation within command scripts.  However, there are
     1694some subtle differences and ``corner cases'' which come into play for
     1695the different types of rule definitions that @code{make} understands.
     1696The subtleties of using the different automatic variables are
     1697described below.
     1698
     1699@subheading Secondary Expansion of Explicit Rules
     1700@cindex secondary expansion and explicit rules
     1701@cindex explicit rules, secondary expansion of
     1702
     1703During the secondary expansion of explicit rules, @code{$$@@} and
     1704@code{$$%} evaluate, respectively, to the file name of the target and,
     1705when the target is an archive member, the target member name.  The
     1706@code{$$<} variable evaluates to the first prerequisite in the first
     1707rule for this target.  @code{$$^} and @code{$$+} evaluate to the list
     1708of all prerequisites of rules @emph{that have already appeared} for
     1709the same target (@code{$$+} with repetitions and @code{$$^}
     1710without). The following example will help illustrate these behaviors:
     1711
     1712@example
     1713foo: foo.1 bar.1 $$< $$^ $$+    # line #1
     1714
     1715foo: foo.2 bar.2 $$< $$^ $$+    # line #2
     1716
     1717foo: foo.3 bar.3 $$< $$^ $$+    # line #3
     1718@end example
     1719
     1720For the first line, all three variables (@code{$$<}, @code{$$^}, and
     1721@code{$$+}) expand to the empty string. For the second line, they will
     1722have values @code{foo.1}, @code{foo.1 bar.1}, and @code{foo.1 bar.1}
     1723respectively. 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}
     1725respectively.
     1726
     1727Rules undergo secondary expansion in makefile order, except that
     1728the rule with the command script is always evaluated last.
     1729
     1730The variables @code{$$?} and @code{$$*} are not available and expand
     1731to 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
     1737Rules for secondary expansion of static pattern rules are identical to
     1738those for explicit rules, above, with one exception: for static
     1739pattern rules the @code{$$*} variable is set to the pattern stem.  As
     1740with explicit rules, @code{$$?} is not available and expands to the
     1741empty string.
     1742
     1743@subheading Secondary Expansion of Implicit Rules
     1744@cindex secondary expansion and implicit rules
     1745@cindex implicit rules, secondary expansion of
     1746
     1747As @code{make} searches for an implicit rule, it substitutes the stem
     1748and then performs secondary expansion for every rule with a matching
     1749target pattern.  The value of the automatic variables is derived in
     1750the same fashion as for static pattern rules.  As an example:
     1751
     1752@example
     1753foo: bar
     1754
     1755foo foz: fo%: bo%
     1756
     1757%oo: $$< $$^ $$+ $$*
     1758@end example
     1759
     1760When the implicit rule is tried for target @file{foo}, @code{$$<}
     1761expands 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
     1765Note that the directory prefix (D), as described in @ref{Implicit Rule
     1766Search, ,Implicit Rule Search Algorithm}, is appended (after
     1767expansion) to all the patterns in the prerequisites list.  As an
     1768example:
     1769
     1770@example
     1771/tmp/foo.o:
     1772
     1773%.o: $$(addsuffix /%.c,foo bar) foo.h
     1774@end example
     1775
     1776The prerequisite list after the secondary expansion and directory
     1777prefix reconstruction will be @file{/tmp/foo/foo.c /tmp/var/bar/foo.c
     1778foo.h}.  If you are not interested in this reconstruction, you can use
     1779@code{$$*} instead of @code{%} in the prerequisites list.
    15081780
    15091781@node Rules, Commands, Makefiles, Top
     
    16361908Because dollar signs are used to start variable references, if you really
    16371909want 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
     1911lists you must actually write @emph{four} dollar signs (@samp{$$$$}),
     1912due to secondary expansion (@pxref{Secondary Expansion}).
    16391913You may split a long line by inserting a backslash
    16401914followed by a newline, but this is not required, as @code{make} places no
     
    24262700
    24272701@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}).
     2702Now you can say just @samp{make} to remake all three programs, or
     2703specify as arguments the ones to remake (as in @samp{make prog1
     2704prog3}).  Phoniness is not inherited: the prerequisites of a phony
     2705target are not themselves phony, unless explicitly declared to be so.
    24302706
    24312707When one phony target is a prerequisite of another, it serves as a subroutine
     
    31633439Note that the @samp{.d} files contain target definitions; you should
    31643440be sure to place the @code{include} directive @emph{after} the first,
    3165 default target in your makefiles or run the risk of having a random
    3166 object file become the default target.
     3441default goal in your makefiles or run the risk of having a random
     3442object file become the default goal.
    31673443@xref{How Make Works}.
    31683444
     
    33573633
    33583634@cindex environment, @code{SHELL} in
     3635@vindex MAKESHELL @r{(MS-DOS alternative to @code{SHELL})}
    33593636Unlike most variables, the variable @code{SHELL} is never set from the
    33603637environment.  This is because the @code{SHELL} environment variable is
     
    37334010characters other than letters, numbers, and underscores.
    37344011
    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
     4013The value of the @code{make} variable @code{SHELL} is not exported.
     4014Instead, the value of the @code{SHELL} variable from the invoking
     4015environment 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
     4019The special variable @code{MAKEFLAGS} is always exported (unless you
     4020unexport it).  @code{MAKEFILES} is exported if you set it to anything.
    37384021
    37394022@code{make} automatically passes down variable values that were defined
     
    51385421@cindex environment
    51395422Variables in @code{make} can come from the environment in which
    5140 @code{make} is run.  Every environment variable that @code{make} sees when
    5141 it starts up is transformed into a @code{make} variable with the same name
    5142 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
     5424when it starts up is transformed into a @code{make} variable with the
     5425same name and value.  However, an explicit assignment in the makefile,
     5426or with a command argument, overrides the environment.  (If the
     5427@samp{-e} flag is specified, then values from the environment override
     5428assignments in the makefile.  @xref{Options Summary, ,Summary of
     5429Options}.  But this is not recommended practice.)
    51475430
    51485431Thus, by setting the variable @code{CFLAGS} in your environment, you can
    51495432cause all C compilations in most makefiles to use the compiler switches you
    51505433prefer.  This is safe for variables with standard or conventional meanings
    5151 because you know that no makefile will use them for other things.  (But
     5434because you know that no makefile will use them for other things.  (Note
    51525435this is not totally reliable; some makefiles set @code{CFLAGS} explicitly
    51535436and therefore are not affected by the value in the environment.)
    51545437
    5155 When @code{make} is invoked recursively, variables defined in the
    5156 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 the
    5160 @code{export} directive to pass other variables.
    5161 @xref{Variables/Recursion, , Communicating Variables to a
     5438When @code{make} runs a command script, variables defined in the
     5439makefile are placed into the environment of that command.  This allows
     5440you to pass values to sub-@code{make} invocations. (@pxref{Recursion,
     5441,Recursive Use of @code{make}}).  By default, only variables that came
     5442from the environment or the command line are passed to recursive
     5443invocations.  You can use the @code{export} directive to pass other
     5444variables.  @xref{Variables/Recursion, , Communicating Variables to a
    51625445Sub-@code{make}}, for full details.
    51635446
     
    51685451purpose of most makefiles.
    51695452
     5453@cindex SHELL, import from environment
    51705454Such problems would be especially likely with the variable @code{SHELL},
    51715455which is normally present in the environment to specify the user's choice
     
    51755459usually not set.  @xref{Execution, ,Special handling of SHELL on
    51765460MS-DOS}.)@refill
     5461
     5462@cindex SHELL, export to environment
     5463The @code{SHELL} variable is special in another way: just as the value
     5464of the @code{make} variable @code{SHELL} is not taken from the
     5465environment, so also it is not placed into the environment of commands
     5466that @code{make} invokes.  Instead, the value of @code{SHELL} from the
     5467invoking 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.
    51775470
    51785471@node Target-specific, Pattern-specific, Environment, Using Variables
     
    54315724@end example
    54325725
    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.
     5726or:
     5727
     5728@example
     5729@var{conditional-directive}
     5730@var{text-if-one-is-true}
     5731else @var{conditional-directive}
     5732@var{text-if-true}
     5733else
     5734@var{text-if-false}
     5735endif
     5736@end example
     5737
     5738@noindent
     5739There can be as many ``@code{else} @var{conditional-directive}''
     5740clauses as necessary.  Once a given condition is true,
     5741@var{text-if-true} is used and no other clause is used; if no
     5742condition 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
     5744of text.
    54375745
    54385746The 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:
     5747conditional is simple or complex; after an @code{else} or not.  There
     5748are four different directives that test different conditions.  Here is
     5749a table of them:
    54415750
    54425751@table @code
     
    54795788
    54805789@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.
     5790The @code{ifdef} form takes the @emph{name} of a variable as its
     5791argument, not a reference to a variable.  The value of that variable
     5792has a non-empty value, the @var{text-if-true} is effective; otherwise,
     5793the @var{text-if-false}, if any, is effective.  Variables that have
     5794never been defined have an empty value.  The text @var{variable-name}
     5795is expanded, so it could be a variable or function that expands
     5796to the name of a variable.  For example:
     5797
     5798@example
     5799bar = true
     5800foo = bar
     5801ifdef $(foo)
     5802frobozz = yes
     5803endif
     5804@end example
     5805
     5806The variable reference @code{$(foo)} is expanded, yielding @code{bar},
     5807which 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
     5809it is non-empty.
    54875810
    54885811Note that @code{ifdef} only tests whether a variable has a value.  It
     
    55205843If the variable @var{variable-name} has an empty value, the
    55215844@var{text-if-true} is effective; otherwise, the @var{text-if-false},
    5522 if any, is effective.
     5845if any, is effective.  The rules for expansion and testing of
     5846@var{variable-name} are identical to the @code{ifdef} directive.
    55235847@end table
    55245848
     
    59276251Returns the list of words in @var{text} starting with word @var{s} and
    59286252ending 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,
     6253start from 1; @var{e} may start from 0.  If @var{s} is bigger than the
     6254number of words in @var{text}, the value is empty.  If @var{e} is
     6255bigger 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
     6257is returned.  For example,
    59336258
    59346259@example
     
    59646289@var{text})} is the same as @code{$(word 1,@var{text})}, the
    59656290@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
     6296The argument @var{names} is regarded as a series of names, separated
     6297by whitespace.  The value is the last name in the series.
     6298
     6299For example,
     6300
     6301@example
     6302$(lastword foo bar)
     6303@end example
     6304
     6305@noindent
     6306produces the result @samp{bar}.  Although @code{$(lastword
     6307@var{text})} is the same as @code{$(word $(words @var{text}),@var{text})},
     6308the @code{lastword} function was added for its simplicity and better
     6309performance.@refill
    59666310@end table
     6311
    59676312
    59686313Here is a realistic example of the use of @code{subst} and
     
    61536498that match the pattern.
    61546499@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
     6505For each file name in @var{names} return the canonical absolute name.
     6506A canonical name does not contain any @code{.} or @code{..} components,
     6507nor any repeated path separators (@code{/}) or symlinks. In case of a
     6508failure the empty string is returned. Consult the @code{realpath(3)}
     6509documentation 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
     6515For each file name in @var{names} return an absolute name that does
     6516not contain any @code{.} or @code{..} components, nor any repeated path
     6517separators (@code{/}). Note that in contrast to @code{realpath}
     6518function, @code{abspath} does not resolve symlinks and does not require
     6519the file names to refer to an existing file or directory. Use the
     6520@code{wildcard} function to test for existence.
    61556521@end table
    61566522
     
    66387004sets @code{files} to the expansion of @samp{*.c}.  Unless @code{make} is
    66397005using 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
     7007exists).@refill
    66417008
    66427009@node Make Control Functions,  , Shell Function, Functions
     
    66937060
    66947061The 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
     7066This function does nothing more than print its (expanded) argument(s)
     7067to standard output.  No makefile name or line number is added.  The
     7068result of the expansion of this function is the empty string.
    66957069@end table
    66967070
     
    67717145programs they describe.  If the first rule in the makefile has several
    67727146targets, 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.
     7147the whole list.  You can manage the selection of the default goal from
     7148within your makefile using the @code{.DEFAULT_GOAL} variable
     7149(@pxref{Special Variables, , Other Special Variables}).
     7150
     7151You can also specify a different goal or goals with command-line
     7152arguments to @code{make}.  Use the name of the goal as an argument.
     7153If you specify several goals, @code{make} processes each of them in
     7154turn, in the order you name them.
    67787155
    67797156Any target in the makefile may be specified as a goal (unless it
     
    67837160implicit rules that say how to make them.
    67847161
    6785 @cindex @code{MAKECMDGOALS}
    67867162@vindex MAKECMDGOALS
    67877163@code{Make} will set the special variable @code{MAKECMDGOALS} to the
     
    73087684floating-point number).  With no argument, removes a previous load
    73097685limit.  @xref{Parallel, ,Parallel Execution}.
     7686
     7687@item -L
     7688@cindex @code{-L}
     7689@itemx --check-symlink-times
     7690@cindex @code{--check-symlink-times}
     7691On systems that support symbolic links, this option causes @code{make}
     7692to consider the timestamps on any symbolic links in addition to the
     7693timestamp on the file referenced by those links.  When this option is
     7694provided, the most recent timestamp among the file and the symbolic
     7695links is taken as the modification time for this target file.
    73107696
    73117697@item -n
     
    75207906* Chained Rules::               How to use a chain of implicit rules.
    75217907* Pattern Rules::               How to define new implicit rules.
    7522 * Last Resort::                 How to defining commands for rules
    7523                                   which cannot find any.
     7908* Last Resort::                 How to define commands for rules which
     7909                                cannot find any.
    75247910* Suffix Rules::                The old-fashioned style of implicit rule.
    75257911* Implicit Rule Search::        The precise algorithm for applying
     
    83728758automatic variable values are available: they only have values within
    83738759the 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.
     8760within the target list of a rule; they have no value there and will
     8761expand to the empty string.  Also, they cannot be accessed directly
     8762within the prerequisite list of a rule.  A common mistake is
     8763attempting to use @code{$@@} within the prerequisites list; this will
     8764not work.  However, there is a special feature of GNU @code{make},
     8765secondary expansion (@pxref{Secondary Expansion}), which will allow
     8766automatic variable values to be used in prerequisite lists.
    83798767
    83808768Here is a table of automatic variables:
     
    84228810it depends on, no matter how many times each file is listed as a
    84238811prerequisite.  So if you list a prerequisite more than once for a target,
    8424 the value of @code{$^} contains just one copy of the name.
     8812the value of @code{$^} contains just one copy of the name.  This list
     8813does @strong{not} contain any of the order-only prerequisites; for those
     8814see the @samp{$|} variable, below.
    84258815@cindex prerequisites, list of all
    84268816@cindex list of all prerequisites
     
    84338823primarily useful for use in linking commands where it is meaningful to
    84348824repeat library file names in a particular order.
     8825
     8826@vindex $|
     8827@vindex | @r{(automatic variable)}
     8828@item $|
     8829The names of all the order-only prerequisites, with spaces between
     8830them.
    84358831
    84368832@vindex $*
     
    85658961as @samp{$(CFLAGS)} refers to the variable named @code{CFLAGS}.
    85668962You could just as well use @samp{$(<)} in place of @samp{$<}.
    8567 
    8568 @vindex $$@@
    8569 @vindex $$(@@D)
    8570 @vindex $$(@@F)
    8571 @cindex $$@@, support for
    8572 GNU @code{make} provides support for the SysV @code{make} feature that
    8573 allows special variable references @code{$$@@}, @code{$$(@@D)}, and
    8574 @code{$$(@@F)} (note the required double-''$''!) to appear with the
    8575 @emph{prerequisites list} (normal automatic variables are available
    8576 only within a command script).  When appearing in a prerequisites
    8577 list, these variables are expanded to the name of the target, the
    8578 directory component of the target, and the file component of the
    8579 target, respectively.
    8580 
    8581 Note that these variables are available only within explicit and
    8582 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 its
    8585 entire prerequisite list @emph{twice}, GNU @code{make} does not behave
    8586 this way: instead it simply expands these special variables without
    8587 re-expanding any other part of the prerequisites list.
    8588 
    8589 This somewhat bizarre feature is included only to provide some
    8590 compatibility with SysV makefiles.  In a native GNU @code{make} file
    8591 there are other ways to accomplish the same results.  This feature is
    8592 disabled if the special pseudo target @code{.POSIX} is defined.
    85938963
    85948964@node Pattern Match, Match-Anything Rules, Automatic Variables, Pattern Rules
     
    94469816The built-in variable @samp{MAKE_VERSION} gives the version number of
    94479817@code{make}.
     9818@vindex MAKE_VERSION
    94489819@end itemize
    94499820
     
    963510006@end table
    963610007
    9637 Here is a summary of the text manipulation functions (@pxref{Functions}):
     10008Here is a summary of the built-in functions (@pxref{Functions}):
    963810009
    963910010@table @code
     
    966610037@xref{Text Functions, , Functions for String Substitution and Analysis}.
    966710038
     10039@item $(word @var{n},@var{text})
     10040Extract 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})
     10044Count 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})
     10048Returns 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{})
     10052Extract the first word of @var{names}.@*
     10053@xref{Text Functions, , Functions for String Substitution and Analysis}.
     10054
     10055@item $(lastword @var{names}@dots{})
     10056Extract the last word of @var{names}.@*
     10057@xref{Text Functions, , Functions for String Substitution and Analysis}.
     10058
    966810059@item $(dir @var{names}@dots{})
    966910060Extract the directory part of each file name.@*
     
    969210083@item $(join @var{list1},@var{list2})
    969310084Join 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}.@*
    971010085@xref{File Name Functions, ,Functions for File Names}.
    971110086
     
    971410089@samp{%} pattern).@*
    971510090@xref{Wildcard Function, ,The Function @code{wildcard}}.
     10091
     10092@item $(realpath @var{names}@dots{})
     10093For each file name in @var{names}, expand to an absolute name that
     10094does not contain any @code{.}, @code{..}, nor symlinks.@*
     10095@xref{File Name Functions, ,Functions for File Names}.
     10096
     10097@item $(abspath @var{names}@dots{})
     10098For each file name in @var{names}, expand to an absolute name that
     10099does not contain any @code{.} or @code{..} components, but preserves
     10100symlinks.@*
     10101@xref{File Name Functions, ,Functions for File Names}.
    971610102
    971710103@item $(error @var{text}@dots{})
     
    984010226The name of the system default command interpreter, usually @file{/bin/sh}.
    984110227You can set @code{SHELL} in the makefile to change the shell used to run
    9842 commands.  @xref{Execution, ,Command Execution}.
     10228commands.  @xref{Execution, ,Command Execution}.  The @code{SHELL}
     10229variable is handled specially when importing from and exporting to the
     10230environment.  @xref{Environment, ,Using Variable from the Environment}.
    984310231
    984410232@item MAKESHELL
     
    997010358command line, and @code{make} couldn't find any makefiles to read in.
    997110359The latter means that some makefile was found, but it didn't contain any
    9972 default target and none was given on the command line.  GNU @code{make}
     10360default goal and none was given on the command line.  GNU @code{make}
    997310361has nothing to do in these situations.
    997410362@xref{Makefile Arguments, ,Arguments to Specify the Makefile}.@refill
     
    1022110609@end group
    1022210610
     10611.PHONY: all
    1022310612all:    tar rmt tar.info
    1022410613
    1022510614@group
     10615.PHONY: tar
    1022610616tar:    $(OBJS)
    1022710617        $(CC) $(LDFLAGS) -o $@@ $(OBJS) $(LIBS)
     
    1023910629
    1024010630@group
     10631.PHONY: install
    1024110632install: all
    1024210633        $(INSTALL) tar $(bindir)/$(binprefix)tar
     
    1026710658
    1026810659@group
     10660.PHONY: clean
    1026910661clean:
    1027010662        rm -f *.o tar rmt testpad testpad.h core
     
    1027210664
    1027310665@group
     10666.PHONY: distclean
    1027410667distclean: clean
    1027510668        rm -f TAGS Makefile config.status
     
    1027710670
    1027810671@group
     10672.PHONY: realclean
    1027910673realclean: distclean
    1028010674        rm -f tar.info*
     
    1028210676
    1028310677@group
     10678.PHONY: shar
    1028410679shar: $(SRCS) $(AUX)
    1028510680        shar $(SRCS) $(AUX) | compress \
     
    1029110686
    1029210687@group
     10688.PHONY: dist
    1029310689dist: $(SRCS) $(AUX)
    1029410690        echo tar-`sed \
  • branches/GNU/src/gmake/expand.c

    r54 r280  
    155155    warn_undefined (name, length);
    156156
    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))
    158159    return o;
    159160
     
    306307                      warn_undefined (beg, colon - beg);
    307308
     309                    /* If the variable is not empty, perform the
     310                       substitution.  */
    308311                    if (v != 0 && *v->value != '\0')
    309312                      {
    310                         char *value = (v->recursive ? recursively_expand (v)
     313                        char *pattern, *replace, *ppercent, *rpercent;
     314                        char *value = (v->recursive
     315                                       ? recursively_expand (v)
    311316                                       : 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                          }
    318341                        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
    353352                        if (v->recursive)
    354353                          free (value);
     
    447446   FILE's commands were found.  Expansion uses FILE's variable set list.  */
    448447
    449 static char *
     448char *
    450449variable_expand_for_file (char *line, struct file *file)
    451450{
  • branches/GNU/src/gmake/file.c

    r153 r280  
    3131#include "hash.h"
    3232
     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. */
     41int snapped_deps = 0;
    3342
    3443/* Hash table of files the makefile knows how to make.  */
     
    345354      {
    346355        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.  */
    347360        if (f->intermediate && (f->dontcare || !f->precious)
    348361            && !f->secondary && !f->cmd_target)
     
    405418}
    406419
     420/* Expand and parse each dependency line. */
     421static void
     422expand_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
    407533/* For each dependency of each file, make the `struct dep' point
    408534   at the appropriate `struct file' (which may have to be created).
     
    414540snap_deps (void)
    415541{
    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
    424557  /* We must use hash_dump (), because within this loop
    425558     we might add new files to the table, possibly causing
     
    428561  file_end = file_slot_0 + files.ht_fill;
    429562  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      }
    441568  free (file_slot_0);
    442569
     
    455582      for (f2 = d->file; f2 != 0; f2 = f2->prev)
    456583        {
    457           /* Mark this file as phony and nonexistent.  */
     584          /* Mark this file as phony nonexistent target.  */
    458585          f2->phony = 1;
     586          f2->is_target = 1;
    459587          f2->last_mtime = NONEXISTENT_MTIME;
    460588          f2->mtime_before_update = NONEXISTENT_MTIME;
     
    525653  if (f != 0 && f->is_target)
    526654    not_parallel = 1;
     655
     656  /* Remember that we've done this. */
     657  snapped_deps = 1;
    527658}
    528659
     
    687818    puts (_("#  Command-line target."));
    688819  if (f->dontcare)
    689     puts (_("#  A default or MAKEFILES makefile."));
     820    puts (_("#  A default, MAKEFILES, or -include/sinclude makefile."));
    690821  puts (f->tried_implicit
    691822        ? _("#  Implicit rule search has been done.")
  • branches/GNU/src/gmake/filedef.h

    r153 r280  
    101101
    102102extern struct file *default_goal_file, *suffix_file, *default_file;
     103extern char **default_goal_name;
    103104
    104105
     
    198199#define check_renamed(file) \
    199200  while ((file)->renamed != 0) (file) = (file)->renamed /* No ; here.  */
     201
     202/* Have we snapped deps yet?  */
     203extern int snapped_deps;
  • branches/GNU/src/gmake/function.c

    r153 r280  
    7474   the length of SUBST and RLEN is the length of REPLACE.  If BY_WORD is
    7575   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.  */
    7877
    7978char *
    8079subst_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)
    8381{
    8482  char *t = text;
    85   unsigned int tlen = strlen (text);
    8683  char *p;
    8784
    88   if (slen == 0 && !by_word && !suffix_only)
     85  if (slen == 0 && !by_word)
    8986    {
    9087      /* 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));
    9289      if (rlen > 0)
    9390        o = variable_buffer_output (o, replace, rlen);
     
    9794  do
    9895    {
    99       if ((by_word | suffix_only) && slen == 0)
     96      if (by_word && slen == 0)
    10097        /* When matching by words, the empty string should match
    10198           the end of each word, rather than the end of the whole text.  */
     
    103100      else
    104101        {
    105           p = sindex (t, tlen, subst, slen);
     102          p = strstr (t, subst);
    106103          if (p == 0)
    107104            {
    108105              /* 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));
    110107              return o;
    111108            }
     
    118115      /* If we're substituting only by fully matched words,
    119116         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]))))
    125120        /* Struck out.  Output the rest of the string that is
    126121           no longer to be replaced.  */
     
    130125        o = variable_buffer_output (o, replace, rlen);
    131126
    132       /* Advance T past the string to be replaced; adjust tlen.  */
     127      /* Advance T past the string to be replaced.  */
    133128      {
    134129        char *nt = p + slen;
    135         tlen -= nt - t;
    136130        t = nt;
    137131      }
     
    140134  return o;
    141135}
     136
    142137
    143138
     
    147142   run through find_percent, and PATTERN_PERCENT is the result.
    148143   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*/
    150148
    151149char *
     
    154152{
    155153  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;
    157155  char *t;
    158156  unsigned int len;
     
    161159  /* We call find_percent on REPLACE before checking PATTERN so that REPLACE
    162160     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);
    171174    }
    172175  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)
    180188    /* With no % in the pattern, this is just a simple substitution.  */
    181189    return subst_expand (o, text, pattern, replace,
    182                          strlen (pattern), strlen (replace), 1, 0);
     190                         strlen (pattern), strlen (replace), 1);
    183191
    184192  /* Record the length of PATTERN before and after the %
    185193     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);
    188196
    189197  while ((t = find_next_token (&text, &len)) != 0)
     
    198206      if (!fail && pattern_prepercent_len > 0
    199207          && (*t != *pattern
    200               || t[pattern_prepercent_len - 1] != pattern_percent[-1]
     208              || t[pattern_prepercent_len - 1] != pattern_percent[-2]
    201209              || !strneq (t + 1, pattern + 1, pattern_prepercent_len - 1)))
    202210        fail = 1;
     
    204212      /* Does the suffix match? */
    205213      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
    208216              || !strneq (&t[len - pattern_postpercent_len],
    209                           &pattern_percent[1], pattern_postpercent_len - 1)))
     217                          pattern_percent, pattern_postpercent_len - 1)))
    210218        fail = 1;
    211219
     
    228236                                                 + pattern_postpercent_len));
    229237              /* 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,
    231239                                          replace_postpercent_len);
    232240            }
     
    648656{
    649657  o = subst_expand (o, argv[2], argv[0], argv[1], strlen (argv[0]),
    650                     strlen (argv[1]), 0, 0);
     658                    strlen (argv[1]), 0);
    651659
    652660  return o;
     
    667675}
    668676
     677static char *
     678func_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}
    669693
    670694static char *
     
    690714 * begpp-1.
    691715 */
    692 static char *
     716char *
    693717strip_whitespace (const char **begpp, const char **endpp)
    694718{
     
    755779
    756780  start = atoi (argv[0]);
     781  if (start < 1)
     782    fatal (reading_file,
     783           "invalid first argument to `wordlist' function: `%d'", start);
     784
    757785  count = atoi (argv[1]) - start + 1;
    758786
     
    784812{
    785813  /* 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]));
    789816
    790817  return o;
     
    10671094  strcpy (p, *argvp);
    10681095
    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  }
    10711111
    10721112  /* The warning function expands to the empty string.  */
    1073   error (reading_file, "%s", msg);
    1074 
    10751113  return o;
    10761114}
     
    14571495
    14581496  /* For error messages.  */
    1459   if (reading_file != 0)
     1497  if (reading_file && reading_file->filenm)
    14601498    {
    14611499      error_prefix = (char *) alloca (strlen (reading_file->filenm)+11+4);
     
    17001738 */
    17011739static char *
    1702 func_eq (char* o, char **argv, char *funcname)
     1740func_eq (char *o, char **argv, char *funcname)
    17031741{
    17041742  int result = ! strcmp (argv[0], argv[1]);
     
    17121750 */
    17131751static char *
    1714 func_not (char* o, char **argv, char *funcname)
    1715 {
    1716   char * s = argv[0];
     1752func_not (char *o, char **argv, char *funcname)
     1753{
     1754  char *s = argv[0];
    17171755  int result = 0;
    17181756  while (isspace ((unsigned char)*s))
     
    17261764
    17271765
     1766/* Return the absolute name of file NAME which does not contain any `.',
     1767   `..' components nor any repeated path separators ('/').   */
     1768
     1769static char *
     1770abspath (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
     1844static char *
     1845func_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
     1885static char *
     1886func_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
    17281919/* Lookup table for builtin functions.
    17291920
     
    17441935{
    17451936 /* Name/size */                    /* MIN MAX EXP? Function */
     1937  { STRING_SIZE_TUPLE("abspath"),       0,  1,  1,  func_abspath},
    17461938  { STRING_SIZE_TUPLE("addprefix"),     2,  2,  1,  func_addsuffix_addprefix},
    17471939  { STRING_SIZE_TUPLE("addsuffix"),     2,  2,  1,  func_addsuffix_addprefix},
     
    17561948  { STRING_SIZE_TUPLE("firstword"),     0,  1,  1,  func_firstword},
    17571949  { STRING_SIZE_TUPLE("join"),          2,  2,  1,  func_join},
     1950  { STRING_SIZE_TUPLE("lastword"),      0,  1,  1,  func_lastword},
    17581951  { STRING_SIZE_TUPLE("patsubst"),      3,  3,  1,  func_patsubst},
     1952  { STRING_SIZE_TUPLE("realpath"),      0,  1,  1,  func_realpath},
    17591953  { STRING_SIZE_TUPLE("shell"),         0,  1,  1,  func_shell},
    17601954  { STRING_SIZE_TUPLE("sort"),          0,  1,  1,  func_sort},
     
    17671961  { STRING_SIZE_TUPLE("foreach"),       3,  3,  0,  func_foreach},
    17681962  { STRING_SIZE_TUPLE("call"),          1,  0,  1,  func_call},
     1963  { STRING_SIZE_TUPLE("info"),          0,  1,  1,  func_error},
    17691964  { STRING_SIZE_TUPLE("error"),         0,  1,  1,  func_error},
    17701965  { STRING_SIZE_TUPLE("warning"),       0,  1,  1,  func_error},
  • branches/GNU/src/gmake/getloadavg.c

    r54 r280  
    356356/* LOAD_AVE_TYPE should only get defined if we're going to use the
    357357   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__)
    359359#  define LOAD_AVE_TYPE double
    360360# endif
  • branches/GNU/src/gmake/glob/ChangeLog

    r53 r280  
     12005-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
    162003-01-30  Paul D. Smith  <[email protected]>
    27
  • branches/GNU/src/gmake/glob/glob.c

    r53 r280  
    13051305              int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
    13061306                               | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
    1307 #if defined _AMIGA || defined VMS
     1307#if defined HAVE_CASE_INSENSITIVE_FS
    13081308                                   | FNM_CASEFOLD
    13091309#endif
  • branches/GNU/src/gmake/implicit.c

    r153 r280  
    11/* Implicit rule searching for GNU Make.
    2 Copyright (C) 1988,89,90,91,92,93,94,97,2000 Free Software Foundation, Inc.
     2Copyright (C) 1988,1989,1990,1991,1992,1993,1994,1997,2000,2004,2005 Free Software Foundation, Inc.
    33This file is part of GNU Make.
    44
     
    2323#include "dep.h"
    2424#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
     29static int
     30pattern_search PARAMS ((struct file *file, int archive,
     31                        unsigned int depth, unsigned int recursions));
    2832
    2933
     
    6468
    6569
     70/* Struct idep captures information about implicit prerequisites
     71   that come from implicit rules. */
     72struct 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
     82static void
     83free_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
     113static char *
     114get_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
    66190/* Search the pattern rules for a rule with an existing dependency to make
    67191   FILE.  If a rule is found, the appropriate commands and deps are put in FILE
     
    96220  struct file *intermediate_file = 0;
    97221
    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;
    112229
    113230  /* Names of possible dependencies are constructed in this buffer.  */
     
    149266  register unsigned int i = 0;  /* uninit checks OK */
    150267  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. */
    154277
    155278#ifndef NO_ARCHIVES
     
    298421        }
    299422
     423  /* We are going to do second expansion so initialize file variables
     424     for the rule. */
     425  initialize_file_variables (file, 0);
     426
    300427  /* Try each rule once without intermediate files, then once with them.  */
    301428  for (intermed_ok = 0; intermed_ok == !!intermed_ok; ++intermed_ok)
    302429    {
    303430      /* Try each pattern rule till we find one that applies.
    304          If it does, copy the names of its 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.  */
    306433
    307434      for (i = 0; i < nrules; i++)
    308435        {
     436          struct file *f;
     437          unsigned int failed = 0;
    309438          int check_lastslash;
    310439
    311440          rule = tryrules[i];
     441
     442          remove_explicit_deps = 0;
    312443
    313444          /* RULE is nil when we discover that a rule,
     
    340471                             (int) stemlen, stem));
    341472
     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
    342480          /* Try each dependency; see if it "exists".  */
    343481
    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
    345488          for (dep = rule->deps; dep != 0; dep = dep->next)
    346489            {
    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
    380629                        ? _("Rejecting impossible implicit prerequisite `%s'.\n")
    381630                        : _("Rejecting impossible rule prerequisite `%s'.\n"),
    382                         p));
    383                   tryrules[i] = 0;
    384                   break;
    385                 }
    386 
    387               intermediate_files[deps_found] = 0;
    388 
    389               DBS (DB_IMPLICIT,
    390                    (p == depname
     631                        name));
     632                  tryrules[i] = 0;
     633
     634                  failed = 1;
     635                  break;
     636                }
     637
     638              DBS (DB_IMPLICIT,
     639                   (d->had_stem
    391640                    ? _("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,
    432697                       (_("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.  */
    466729          rule->in_use = 0;
    467730
    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            }
    483739          else
    484740            /* This pattern rule does apply.  Stop looking for one.  */
     
    512768     Convert them into entries on the deps-chain of FILE.  */
    513769
    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)
    515790    {
    516791      register char *s;
    517792
    518       if (intermediate_files[deps_found] != 0)
     793      if (d->intermediate_file != 0)
    519794        {
    520795          /* If we need to use an intermediate file,
     
    525800             of F below are null before we change them.  */
    526801
    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
    529813          f->deps = imf->deps;
    530814          f->cmds = imf->cmds;
    531815          f->stem = imf->stem;
    532816          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
    536826          f->intermediate = 1;
    537827          f->tried_implicit = 1;
     
    548838
    549839      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;
    552844      if (recursions == 0)
    553845        {
     
    568860          dep->changed = 0;
    569861        }
    570       if (intermediate_files[deps_found] == 0 && tryrules[foundrule]->terminal)
     862      if (d->intermediate_file == 0 && tryrules[foundrule]->terminal)
    571863        {
    572864          /* If the file actually existed (was not an intermediate file),
     
    580872            dep->file->tried_implicit = 1;
    581873        }
    582       dep->next = file->deps;
    583       file->deps = dep;
     874
     875      *d_ptr = dep;
     876      d_ptr = &dep->next;
    584877    }
     878
     879  *d_ptr = expl_d;
    585880
    586881  if (!checked_lastslash[foundrule])
     
    605900
    606901  file->cmds = rule->cmds;
     902  file->is_target = 1;
    607903
    608904  /* If this rule builds other targets, too, put the others into FILE's
     
    616912          /* GKM FIMXE: handle '|' here too */
    617913          new->ignore_mtime = 0;
     914          new->need_2nd_expansion = 0;
    618915          new->name = p = (char *) xmalloc (rule->lens[i] + fullstemlen + 1);
    619916          bcopy (rule->targets[i], p,
     
    630927
    631928 done:
    632   free (intermediate_files);
     929  free_idep_chain (deps);
    633930  free (tryrules);
    634931
  • branches/GNU/src/gmake/job.c

    r153 r280  
    11/* 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.
     2Copyright (C) 1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1999,
     32000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
    34This file is part of GNU Make.
    45
     
    6162
    6263# include <descrip.h>
     64char default_shell[] = "";
     65int batch_mode_shell = 0;
     66
     67#elif defined (__riscos__)
     68
    6369char default_shell[] = "";
    6470int batch_mode_shell = 0;
     
    168174#endif  /* Don't have `union wait'.  */
    169175
    170 #ifdef VMS
    171 static int vms_jobsefnmask = 0;
    172 #endif /* !VMS */
    173 
    174176#ifndef HAVE_UNISTD_H
    175177extern int dup2 ();
     
    199201static int job_next_command PARAMS ((struct child *));
    200202static int start_waiting_job PARAMS ((struct child *));
    201 #ifdef VMS
    202 static void vmsWaitForChildren PARAMS ((int *));
    203 #endif
    204203
    205204
     
    228227unsigned long job_counter = 0;
    229228
     229/* Number of jobserver tokens this instance is currently using.  */
     230
     231unsigned int jobserver_tokens = 0;
    230232
    231233
     
    237239w32_kill(int pid, int sig)
    238240{
    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.  */
     247static char *
     248create_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;
    240325}
    241326#endif /* WINDOWS32 */
     
    317402
    318403
    319 #ifdef VMS
    320 /* Wait for nchildren children to terminate */
    321 static void
    322 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           else
    392             {
    393               p++;
    394               if (strchr (SEPCHARS, *p))
    395                 break;
    396               alast = 1;
    397             }
    398         }
    399       else
    400         p++;
    401     }
    402 
    403   return p;
    404 }
    405 
    406 #endif
    407 
    408404
    409405/* Handle a dead child.  This handler may or may not ever be installed.
     
    474470    {
    475471      int remote = 0;
    476       register int pid;
     472      pid_t pid;
    477473      int exit_code, exit_sig, coredump;
    478474      register struct child *lastc, *c;
     
    543539            {
    544540#ifdef VMS
     541              static void vmsWaitForChildren PARAMS ((int *));
    545542              vmsWaitForChildren (&status);
    546543              pid = c->pid;
     
    616613            HANDLE hPID;
    617614            int err;
     615            exit_code = 0;
     616            exit_sig = 0;
     617            coredump = 0;
    618618
    619619            /* 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;
    641643          }
    642644#endif /* WINDOWS32 */
     
    812814free_child (struct child *child)
    813815{
    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)
    819824    {
    820825      char token = '+';
     
    830835                    (unsigned long int) child, child->file->name));
    831836    }
     837
     838  --jobserver_tokens;
    832839
    833840  if (handling_fatal_signal) /* Don't bother free'ing if about to die.  */
     
    870877}
    871878
    872 #ifdef  POSIX
     879#ifdef POSIX
    873880void
    874881unblock_sigs (void)
     
    881888
    882889#ifdef MAKE_JOBSERVER
     890RETSIGTYPE
     891job_noop (int sig UNUSED)
     892{
     893}
    883894/* Set the child handler action flags to FLAGS.  */
    884895static void
    885 set_child_handler_action_flags (int flags)
     896set_child_handler_action_flags (int set_handler, int set_alarm)
    886897{
    887898  struct sigaction sa;
     899
     900#ifdef __EMX__
     901  /* The child handler must be turned off here.  */
     902  signal (SIGCHLD, SIG_DFL);
     903#endif
     904
    888905  bzero ((char *) &sa, sizeof sa);
    889906  sa.sa_handler = child_handler;
    890   sa.sa_flags = flags;
     907  sa.sa_flags = set_handler ? 0 : SA_RESTART;
    891908#if defined SIGCHLD
    892909  sigaction (SIGCHLD, &sa, NULL);
     
    894911#if defined SIGCLD && SIGCLD != SIGCHLD
    895912  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    }
    896925#endif
    897926}
     
    11581187
    11591188#ifdef VMS
    1160 
    11611189      if (!child_execute_job (argv, child)) {
    11621190        /* Fork failed!  */
     
    15821610
    15831611        /* If we don't already have a job started, use our "free" token.  */
    1584         if (!children)
     1612        if (!jobserver_tokens)
    15851613          break;
    15861614
     
    16171645        reap_children (0, 0);
    16181646
    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. */
    16201658        if (!children)
    1621           break;
     1659          fatal (NILF, "INTERNAL: no children as we go to sleep on read\n");
    16221660
    16231661        /* 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);
    16251663        got_token = read (job_rfd, &token, 1);
    16261664        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);
    16321666
    16331667        /* If we got one, we're done here.  */
     
    16481682      }
    16491683#endif
     1684
     1685  ++jobserver_tokens;
    16501686
    16511687  /* The job is now primed.  Start it running.
     
    17281764load_too_high (void)
    17291765{
    1730 #if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA)
     1766#if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA) || defined(__riscos__)
    17311767  return 1;
    17321768#else
     
    18121848
    18131849#ifndef WINDOWS32
    1814 #ifdef VMS
    1815 #include <descrip.h>
    1816 #include <clidef.h>
    1817 
    1818 /* This is called as an AST when a child process dies (it won't get
    1819    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 #else
    1840     c = child;
    1841 #endif
    1842 
    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     else
    1852       {
    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     else
    1895       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 200
    1916 
    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_ANYWAY
    1962                 fprintf (stderr,
    1963                          _("-warning, CTRL-Y will leave sub-process(es) around.\n"));
    1964 #else
    1965                 return;
    1966 #endif
    1967         }
    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 int
    1988 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                 else
    2066                   {
    2067                     p = vms_redirect (&efiledsc, efile, p);
    2068                   }
    2069               }
    2070             else
    2071               {
    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           else
    2106             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       else
    2140         {
    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 for
    2148      lib$spawn, or the command contains a newline, or if redirection
    2149      is desired. Forcing commands with newlines into DCLs allows to
    2150      store search lists on user mode logicals.  */
    2151 
    2152   if (strlen (cmd) > MAXCMDLEN
    2153       || (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, after
    2215                  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 DONTWAITFORCHILD
    2284 /*
    2285  *      Code to make ctrl+c and ctrl+y working.
    2286  *      The problem starts with the synchronous case where after lib$spawn is
    2287  *      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, neither
    2289  *      the spawning nor to the spawned one. Hence the caller needs to spawn
    2290  *      with CLI$M_NOWAIT to NOT give up the input focus. A sys$waitfr
    2291  *      has to follow to simulate the wanted synchronous behaviour.
    2292  *      The next problem is ctrl+y which isn't caught by the crtl and
    2293  *      therefore isn't converted to SIGQUIT (for a signal handler which is
    2294  *      already established). The only way to catch ctrl+y, is an AST
    2295  *      assigned to the input channel. But ctrl+y handling of DCL needs to be
    2296  *      disabled, otherwise it will handle it. Not to mention the previous
    2297  *      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 will
    2299  *      make it to the signal handler after the child "normally" terminates.
    2300  *      This isn't enough. It seems reasonable for simple command lines like
    2301  *      a 'cc foobar.c' spawned in a subprocess but it is unacceptable for
    2302  *      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 for
    2305  *      ctrl+y, if not one is set up for a channel to SYS$COMMAND. In general
    2306  *      this will work except if make is run in a batch environment, but there
    2307  *      nobody can press ctrl+y. During the setup the DCL handling of ctrl+y
    2308  *      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, force
    2310  *      an abort to the subprocess and signal SIGQUIT, which will be caught by
    2311  *      the already established handler and will bring us back to common code.
    2312  *      After the spawn (now /nowait) a sys$waitfr simulates the /wait and
    2313  *      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 common
    2315  *      signal handler. Because signals were blocked before entering this code
    2316  *      sys$waitfr will always complete and the SIGQUIT will be processed after
    2317  *      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 the
    2319  *      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 #else
    2340   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 #endif
    2349 
    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 */
    23711850
    23721851/* EMX: Start a child process. This function returns the new pid.  */
    2373 # if defined __MSDOS__ ||  defined __EMX__
     1852# if defined __MSDOS__ || defined __EMX__
    23741853int
    23751854child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp)
     
    24091888  pid = exec_command (argv, envp);
    24101889
    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    }
    24161906
    24171907  return pid;
     
    24401930}
    24411931#endif /* !AMIGA && !__MSDOS__ */
    2442 #endif /* !VMS */
    24431932#endif /* !WINDOWS32 */
    24441933
     
    24521941int
    24531942# else
    2454  void
     1943void
    24551944# endif
    24561945exec_command (char **argv, char **envp)
     
    24921981
    24931982  /* wait and reap last child */
    2494   while (hWaitPID = process_wait_for_any())
     1983  hWaitPID = process_wait_for_any();
     1984  while (hWaitPID)
    24951985    {
    24961986      /* was an error found on this process? */
     
    25602050        char **new_argv;
    25612051        int argc;
     2052        int i=1;
    25622053
    25632054# ifdef __EMX__
     
    25782069          ++argc;
    25792070
     2071# ifdef __EMX__
     2072        if (!unixy_shell)
     2073          ++argc;
     2074# endif
     2075
    25802076        new_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
    25812077        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];
    25832089        while (argc > 0)
    25842090          {
    2585             new_argv[1 + argc] = argv[argc];
     2091            new_argv[i + argc] = argv[argc];
    25862092            --argc;
    25872093          }
     
    27512257  char*  sh_chars;
    27522258  char** sh_cmds;
     2259#elif defined(__riscos__)
     2260  static char sh_chars[] = "";
     2261  static char *sh_cmds[] = { 0 };
    27532262#else  /* must be UNIX-ish */
    27542263  static char sh_chars[] = "#;\"*?[]&|<>(){}$`^~!";
     
    30212530                register int j;
    30222531                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                  }
    30252542              }
    30262543
     
    30602577    /* Line was empty.  */
    30612578    return 0;
    3062   else
    3063     return new_argv;
     2579
     2580  return new_argv;
    30642581
    30652582 slow:;
     
    32102727      int id = GetCurrentProcessId();
    32112728      PATH_VAR(fbuf);
    3212       char* fname = NULL;
    32132729
    32142730      /* create a file name */
    32152731      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);
    32322733
    32332734      DB (DB_JOBS, (_("Creating temporary batch file %s\n"),
     
    32582759                                                  (char *) 0, (char *) 0,
    32592760                                                  (char **) 0);
    3260 # ifdef __EMX__
     2761#ifdef __EMX__
    32612762    else if (!unixy_shell)
    32622763      {
    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        }
    33572829      }
    33582830#elif defined(__MSDOS__)
     
    35353007}
    35363008#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  
    102102#endif
    103103
     104extern unsigned int jobserver_tokens;
     105
    104106#endif /* SEEN_JOB_H */
  • branches/GNU/src/gmake/main.c

    r153 r280  
    11/* Argument parsing and main program of GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1994, 1995, 1996, 1997, 1998, 1999,
    3 2002, 2003 Free Software Foundation, Inc.
     32002, 2003, 2005 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    3636#ifdef WINDOWS32
    3737#include <windows.h>
     38#include <io.h>
    3839#include "pathstuff.h"
    3940#endif
     
    4445#ifdef HAVE_FCNTL_H
    4546# 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>
    4655#endif
    4756
     
    186195int default_keep_going_flag = 0;
    187196
     197/* Nonzero means check symlink mtimes.  */
     198
     199int check_symlink_flag = 0;
     200
    188201/* Nonzero means print directory before starting and when done (-w).  */
    189202
     
    207220unsigned int job_slots = 1;
    208221unsigned int default_job_slots = 1;
     222static unsigned int master_job_slots = 0;
    209223
    210224/* Value of job_slots that means no limit.  */
     
    260274
    261275int always_make_flag = 0;
     276
     277/* If nonzero, we're in the "try to rebuild makefiles" phase.  */
     278
     279int rebuilding_makefiles = 0;
     280
     281/* Remember the original value of the SHELL variable, from the environment.  */
     282
     283struct variable shell_var;
     284
    262285
    263286
     
    301324                              Don't start multiple jobs unless load is below N.\n"),
    302325    N_("\
     326  -L, --check-symlink-times   Use the latest mtime between symlinks and target.\n"),
     327    N_("\
    303328  -n, --just-print, --dry-run, --recon\n\
    304329                              Don't actually run any commands; just print them.\n"),
     
    348373#endif
    349374    { 'e', flag, (char *) &env_overrides, 1, 1, 0, 0, 0,
    350         "environment-overrides", },
     375      "environment-overrides", },
    351376    { 'f', string, (char *) &makefiles, 0, 0, 0, 0, 0, "file" },
    352377    { 'h', flag, (char *) &print_usage_flag, 0, 0, 0, 0, 0, "help" },
    353378    { 'i', flag, (char *) &ignore_errors_flag, 1, 1, 0, 0, 0,
    354         "ignore-errors" },
     379      "ignore-errors" },
    355380    { 'I', string, (char *) &include_directories, 1, 1, 0, 0, 0,
    356         "include-dir" },
     381      "include-dir" },
    357382    { 'j', positive_int, (char *) &job_slots, 1, 1, 0, (char *) &inf_jobs,
    358         (char *) &default_job_slots, "jobs" },
     383      (char *) &default_job_slots, "jobs" },
    359384    { CHAR_MAX+2, string, (char *) &jobserver_fds, 1, 1, 0, 0, 0,
    360         "jobserver-fds" },
     385      "jobserver-fds" },
    361386    { 'k', flag, (char *) &keep_going_flag, 1, 1, 0, 0,
    362         (char *) &default_keep_going_flag, "keep-going" },
     387      (char *) &default_keep_going_flag, "keep-going" },
    363388#ifndef NO_FLOAT
    364389    { 'l', floating, (char *) &max_load_average, 1, 1, 0,
    365         (char *) &default_load_average, (char *) &default_load_average,
    366         "load-average" },
     390      (char *) &default_load_average, (char *) &default_load_average,
     391      "load-average" },
    367392#else
    368393    { '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" },
    372399    { 'm', ignore, 0, 0, 0, 0, 0, 0, 0 },
    373400    { 'n', flag, (char *) &just_print_flag, 1, 1, 1, 0, 0, "just-print" },
    374401    { 'o', string, (char *) &old_files, 0, 0, 0, 0, 0, "old-file" },
    375402    { 'p', flag, (char *) &print_data_base_flag, 1, 1, 0, 0, 0,
    376         "print-data-base" },
     403      "print-data-base" },
    377404    { 'q', flag, (char *) &question_flag, 1, 1, 1, 0, 0, "question" },
    378405    { 'r', flag, (char *) &no_builtin_rules_flag, 1, 1, 0, 0, 0,
    379406      "no-builtin-rules" },
    380407    { 'R', flag, (char *) &no_builtin_variables_flag, 1, 1, 0, 0, 0,
    381         "no-builtin-variables" },
     408      "no-builtin-variables" },
    382409    { 's', flag, (char *) &silent_flag, 1, 1, 0, 0, 0, "silent" },
    383410    { 'S', flag_off, (char *) &keep_going_flag, 1, 1, 0, 0,
     
    386413    { 'v', flag, (char *) &print_version_flag, 1, 1, 0, 0, 0, "version" },
    387414    { 'w', flag, (char *) &print_directory_flag, 1, 1, 0, 0, 0,
    388         "print-directory" },
     415      "print-directory" },
    389416    { CHAR_MAX+3, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
    390         "no-print-directory" },
     417      "no-print-directory" },
    391418    { 'W', string, (char *) &new_files, 0, 0, 0, 0, 0, "what-if" },
    392419    { CHAR_MAX+4, flag, (char *) &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
    393         "warn-undefined-variables" },
     420      "warn-undefined-variables" },
    394421    { 0 }
    395422  };
     
    446473
    447474struct file *default_goal_file;
     475
     476/* Pointer to the value of the .DEFAULT_GOAL special
     477   variable.  */
     478char ** default_goal_name;
    448479
    449480/* Pointer to structure for the file .DEFAULT
     
    549580/* Toggle -d on receipt of SIGUSR1.  */
    550581
     582#ifdef SIGUSR1
    551583static RETSIGTYPE
    552584debug_signal_handler (int sig UNUSED)
     
    554586  db_level = db_level ? DB_NONE : DB_BASIC;
    555587}
     588#endif
    556589
    557590static void
     
    696729{
    697730  int sh_found = 0;
    698   char* search_token;
     731  char *search_token;
     732  char *tokend;
    699733  PATH_VAR(sh_path);
    700734  extern char *default_shell;
     
    705739    search_token = token;
    706740
    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))) {
    709760    /* no new information, path already set or known */
    710761    sh_found = 1;
     
    718769  } else {
    719770    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 */
    725774    if (v && v->value) {
    726775      char *ep;
     
    841890  struct file *f;
    842891  int i;
     892  int makefile_status = MAKE_SUCCESS;
    843893  char **p;
    844894  struct dep *read_makefiles;
     
    853903  unixy_shell = 0;
    854904  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  }
    855919#endif
    856920
     
    9781042        program = argv[0] + 1;
    9791043#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
    9801063      if (program == 0)
    9811064        program = argv[0];
     
    9981081    {
    9991082#ifdef  HAVE_GETCWD
    1000       perror_with_name ("getcwd: ", "");
     1083      perror_with_name ("getcwd", "");
    10011084#else
    10021085      error (NILF, "getwd: %s", current_directory);
     
    10141097  /* Initialize the special variables.  */
    10151098  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
    10171113
    10181114  /* Read in variables from the environment.  It is important that this be
     
    10231119  for (i = 0; envp[i] != 0; ++i)
    10241120    {
    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 != '=')
    10321125        ++ep;
    10331126#ifdef WINDOWS32
    10341127      if (!unix_path && strneq(envp[i], "PATH=", 5))
    10351128        unix_path = ep+1;
    1036       else if (!windows32_path && !strnicmp(envp[i], "Path=", 5)) {
     1129      else if (!strnicmp(envp[i], "Path=", 5)) {
    10371130        do_not_define = 1; /* it gets defined after loop exits */
    1038         windows32_path = ep+1;
     1131        if (!windows32_path)
     1132          windows32_path = ep+1;
    10391133      }
    10401134#endif
     
    10431137         the same.  */
    10441138      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        }
    10531163    }
    10541164#ifdef WINDOWS32
    1055     /*
    1056      * Make sure that this particular spelling of 'Path' is available
     1165    /* If we didn't find a correctly spelled PATH we define PATH as
     1166     * either the first mispelled value or an empty string
    10571167     */
    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;
    10701172#endif
    10711173#else /* For Amiga, read the ENV: device, ignoring all dirs */
     
    12371339      {
    12381340        char *dir = directories->list[i];
     1341        char *expanded = 0;
    12391342        if (dir[0] == '~')
    12401343          {
    1241             char *expanded = tilde_expand (dir);
     1344            expanded = tilde_expand (dir);
    12421345            if (expanded != 0)
    12431346              dir = expanded;
    12441347          }
     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
    12451358        if (chdir (dir) < 0)
    12461359          pfatal_with_name (dir);
    1247         if (dir != directories->list[i])
    1248           free (dir);
     1360        if (expanded)
     1361          free (expanded);
    12491362      }
    12501363
     
    13011414        {
    13021415#ifdef  HAVE_GETCWD
    1303           perror_with_name ("getcwd: ", "");
     1416          perror_with_name ("getcwd", "");
    13041417#else
    13051418          error (NILF, "getwd: %s", current_directory);
     
    13681481            if (outfile == 0)
    13691482              pfatal_with_name (_("fopen (temporary file)"));
    1370             while (!feof (stdin))
     1483            while (!feof (stdin) && ! ferror (stdin))
    13711484              {
    13721485                char buf[2048];
     
    14481561  define_default_variables ();
    14491562
     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
    14501570  /* Read all the makefiles.  */
    1451 
    1452   default_file = enter_file (".DEFAULT");
    14531571
    14541572  read_makefiles
     
    15801698         want job_slots to be 0 to indicate we're using the jobserver.  */
    15811699
     1700      master_job_slots = job_slots;
     1701
    15821702      while (--job_slots)
    15831703        {
     
    15991719      jobserver_fds->idx = 1;
    16001720      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;
    16011729    }
    16021730#endif
     
    16681796      int nargc = argc;
    16691797      int orig_db_level = db_level;
     1798      int status;
    16701799
    16711800      if (! ISDB (DB_MAKEFILES))
     
    17281857      define_makeflags (1, 1);
    17291858
    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)
    17311864        {
    17321865        case 1:
     
    17771910                        any_remade |= (mtime != NONEXISTENT_MTIME
    17781911                                       && mtime != makefile_mtimes[i]);
     1912                        makefile_status = MAKE_FAILURE;
    17791913                      }
    17801914                  }
     
    18662000#ifndef _AMIGA
    18672001          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] == '=')
    18702004              {
    18712005                /* The SGI compiler apparently can't understand
     
    19222056            int pid;
    19232057            int status;
    1924             pid = child_execute_job(0, 1, nargv, environ);
     2058            pid = child_execute_job (0, 1, nargv, environ);
    19252059
    19262060            /* is this loop really necessary? */
    19272061            do {
    1928               pid = wait(&status);
    1929             } while(pid <= 0);
     2062              pid = wait (&status);
     2063            } while (pid <= 0);
    19302064            /* use the exit code of the child process */
    1931             exit(WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);
     2065            exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);
    19322066          }
    19332067#else
     
    19432077
    19442078      db_level = orig_db_level;
     2079
     2080      /* Free the makefile mtimes (if we allocated any).  */
     2081      if (makefile_mtimes)
     2082        free ((char *) makefile_mtimes);
    19452083    }
    19462084
     
    19592097    if (goals == 0)
    19602098      {
    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;
    19662132            goals->ignore_mtime = 0;
    1967             goals->file = default_goal_file;
    1968           }
     2133            goals->need_2nd_expansion = 0;
     2134            goals->file = default_goal_file;
     2135          }
    19692136      }
    19702137    else
    19712138      lastgoal->next = 0;
     2139
    19722140
    19732141    if (!goals)
     
    19832151    DB (DB_BASIC, (_("Updating goal targets....\n")));
    19842152
    1985     switch (update_goal_chain (goals, 0))
     2153    switch (update_goal_chain (goals))
    19862154    {
    19872155      case -1:
     
    19892157      case 0:
    19902158        /* Updated successfully.  */
    1991         status = MAKE_SUCCESS;
     2159        status = makefile_status;
    19922160        break;
    19932161      case 1:
     
    20932261  if (v != 0)
    20942262    {
    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      }
    21022278    }
    21032279  else if (! env)
     
    21222298      lastgoal->file = f;
    21232299      lastgoal->ignore_mtime = 0;
     2300      lastgoal->need_2nd_expansion = 0;
    21242301
    21252302      {
     
    27702947  if (!dying)
    27712948    {
     2949      char token = '+';
    27722950      int err;
    27732951
     
    27892967      if (print_data_base_flag)
    27902968        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        }
    27913011
    27923012      /* Try to move back to the original directory.  This is essential on
     
    28543074        printf (_("%s[%u]: Leaving directory `%s'\n"),
    28553075                program, makelevel, starting_directory);
     3076
     3077  /* Flush stdout to be sure this comes before any stderr output.  */
     3078  fflush (stdout);
    28563079}
  • branches/GNU/src/gmake/maintMakefile

    r54 r280  
    22# only if you have the full copy of the GNU make sources from the CVS
    33# tree, not a dist copy.
    4 #
     4
     5# We like mondo-warnings!
     6AM_CFLAGS += -Wall -W
    57
    68# Find the glob source files... this might be dangerous, but we're maintainers!
    7 #
    89globsrc := $(wildcard glob/*.c)
    910globhdr := $(wildcard glob/*.h)
     
    1415
    1516all-am: $(TEMPLATES) $(MTEMPLATES) build.sh.in
    16 
    17 # We need this to ensure that README and build.sh.in are created on time to
    18 # avoid errors by automake.
    19 #
    20 #Makefile.in: README build.sh.in
    2117
    2218# General rule for turning a .template into a regular file.
     
    5652        rm -f $@
    5753        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' \
    5955          $< > $@
    6056        chmod a-w+x $@
     
    6763# to do it ourselves.
    6864#
     65DEP_FILES := $(wildcard $(DEPDIR)/*.Po)
    6966.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) > $@
    7677
    7778# Get rid of everything "else".
     
    8081
    8182CVS-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.*
    8385
    8486# This rule tries to clean the tree right down to how it looks when you do a
    8587# virgin CVS checkout.
    8688
     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...
     93cvsclean = 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
    8795.PHONY: cvs-clean
    8896cvs-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)
    96102
    97103
     
    119125# ------------------- #
    120126
    121 po_repo = http://www2.iro.umontreal.ca/%7Egnutra/po/maint/$(PACKAGE)
     127po_repo = http://www.iro.umontreal.ca/translation/maint/$(PACKAGE)
    122128.PHONY: do-po-update po-update
    123129do-po-update:
     
    136142
    137143# -------------------------- #
    138 # Updating GNU build tools.  #
     144# Updating GNU build files.  #
    139145# -------------------------- #
    140146
     
    142148# with each of the files that belongs to some other package and is
    143149# 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
     151savannah-url = http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~
    160152target = $(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
     154config-url = $(savannah-url)/config/config/$(patsubst get-config/%,%,$@)
    171155get-config/config.guess get-config/config.sub:
    172156        @echo $(WGET) $(config-url) -O $(target) \
     
    174158          && $(move_if_change)
    175159
    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)
     160gnulib-url = $(savannah-url)/gnulib/gnulib/build-aux/$(patsubst get-config/%,%,$@)
     161get-config/texinfo.tex:
     162        @echo $(WGET) $(gnulib-url) -O $(target) \
     163          && $(WGET) $(gnulib-url) -O $(target).t \
     164          && $(move_if_change)
     165
     166gnustandards-url = $(savannah-url)/gnustandards/gnustandards/$(patsubst get-doc/%,%,$@)
     167get-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)
    192171
    193172.PHONY: cvs-update
    194 cvs-update: $(cvs-targets) get-config/config.guess get-config/config.sub
     173cvs-update: get-config/texinfo.tex get-config/config.guess get-config/config.sub get-doc/make-stds.texi get-doc/fdl.texi
    195174
    196175
     
    200179
    201180.PHONY: update
    202 update: wget-update po-update
    203 
    204 # cvs-update
     181update: po-update cvs-update
    205182
    206183
     
    232209          rm -f $@-1 $@-2; \
    233210        fi
     211
     212## ------------------------- ##
     213## GNU FTP upload artifacts. ##
     214## ------------------------- ##
     215
     216# This target creates the upload artifacts.
     217# Sign it with my key.
     218
     219GPG = gpg
     220GPGFLAGS = -u 6338B6D4
     221
     222DIST_ARCHIVES_SIG = $(addsuffix .sig,$(DIST_ARCHIVES))
     223DIST_ARCHIVES_DIRECTIVE = $(addsuffix .directive.asc,$(DIST_ARCHIVES))
     224
     225.PHONY: distsign
     226distsign: $(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
     243FTPPUT = ncftpput
     244gnu-url = ftp-upload.gnu.org /incoming
     245
     246UPLOADS = 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  
    367367extern void sync_Path_environment(void);
    368368extern int kill(int pid, int sig);
    369 extern int safe_stat(char *file, struct stat *sb);
    370369extern char *end_of_token_w32(char *s, char stopchar);
    371370extern int find_and_set_default_shell(char *token);
     
    422421extern char *find_next_token PARAMS ((char **, unsigned int *));
    423422extern char *next_token PARAMS ((const char *));
    424 extern char *end_of_token PARAMS ((char *));
     423extern char *end_of_token PARAMS ((const char *));
    425424extern void collapse_continuations PARAMS ((char *));
    426425extern void remove_comments PARAMS((char *));
    427 extern char *sindex PARAMS ((const char *, unsigned int, \
    428                              const char *, unsigned int));
    429426extern char *lindex PARAMS ((const char *, const char *, int));
    430427extern int alpha_compare PARAMS ((const void *, const void *));
     
    464461extern void child_access PARAMS ((void));
    465462
     463extern char *
     464strip_whitespace PARAMS ((const char **begpp, const char **endpp));
     465
     466
    466467#ifdef  HAVE_VFORK_H
    467468# include <vfork.h>
     
    496497extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
    497498extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
    498 extern int print_version_flag, print_directory_flag;
     499extern int print_version_flag, print_directory_flag, check_symlink_flag;
    499500extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
    500 extern int clock_skew_detected;
     501extern int clock_skew_detected, rebuilding_makefiles;
    501502
    502503/* can we run commands via 'sh -c xxx' or must we use batch files? */
  • branches/GNU/src/gmake/makefile.vms

    r54 r280  
    66# Modified for version 3.78.1 by [email protected].
    77# Modified for version 3.80 by [email protected]
     8# Modified for version 3.81 by Hartmut Becker
    89#
    910# GNU Make is free software; you can redistribute it and/or modify
     
    3233
    3334ifeq ($(CC),cc)
    34 CFLAGS = $(defines) /include=([],[.glob])/prefix=all/standard=relaxed
     35CFLAGS = $(defines) /include=([],[.glob])/prefix=(all,except=(glob,globfree))/standard=relaxed
    3536else
    3637CFLAGS = $(defines) /include=([],[.glob])
     
    112113        $$ purge [...]
    113114        -$(RM) make.exe;,*.obj;
    114         -$(RM) *.opt;
    115115        -$(RM) [.glob]*.obj;
    116116
  • branches/GNU/src/gmake/misc.c

    r153 r280  
    419419
    420420
    421 /* Search string BIG (length BLEN) for an occurrence of
    422    string SMALL (length SLEN).  Return a pointer to the
    423    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 }
    449421
    450422/* Limited INDEX:
     
    468440
    469441char *
    470 end_of_token (char *s)
     442end_of_token (const char *s)
    471443{
    472444  while (*s != '\0' && !isblank ((unsigned char)*s))
    473445    ++s;
    474   return s;
     446  return (char *)s;
    475447}
    476448
     
    563535
    564536
     537/* Free a chain of `struct nameseq'. Each nameseq->name is freed
     538   as well.  Can be used on `struct dep' chains.*/
     539
     540void
     541free_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
    565559#ifdef  iAPX286
    566560/* The losing compiler on this machine can't handle this macro.  */
  • branches/GNU/src/gmake/po

    • Property svn:ignore
      •  

        old new  
        66Makefile.in
        77Makefile.in.in
         8Makevars.template
        89Rules-quot
         10stamp-po
        911*.sed
        1012*.sin
  • branches/GNU/src/gmake/po/.cvsignore

    r53 r280  
    11*.gmo *.mo *.pot *.po
    22
    3 Makefile Makefile.in Makefile.in.in
    4 Rules-quot
     3Makefile Makefile.in Makefile.in.in Makevars.template
     4Rules-quot stamp-po
    55*.sed *.sin *.header
    66POTFILES
  • branches/GNU/src/gmake/po/ChangeLog

    r53 r280  
     12005-05-09  Paul D. Smith  <[email protected]>
     2
     3        * POTFILES.in: Add new file vmsjobs.c.
     4
     52005-04-06  Paul D. Smith  <[email protected]>
     6
     7        * LINGUAS: Added a new translation for Kinywarwanda (rw).
     8
     92005-02-09  Paul D. Smith  <[email protected]>
     10
     11        * LINGUAS: Added a new translation for Irish (ga).
     12
     132005-02-01  Paul D. Smith  <[email protected]>
     14
     15        * LINGUAS: Added a new translation for Finnish (fi).
     16
    1172003-10-18  Paul D. Smith  <[email protected]>
    218
  • branches/GNU/src/gmake/po/LINGUAS

    r53 r280  
    1 # Set of available languages: 16 languages
     1# Set of available languages: 20 languages
    22
    3 be da de es fr gl he hr ja ko nl pl pt_BR sv ru tr uk zh_CN
     3be da de es fi fr ga gl he hr ja ko nl pl pt_BR ru rw sv tr uk zh_CN
    44
    55# Can't seem to get en@quot and en@boldquot to build properly?
  • branches/GNU/src/gmake/po/POTFILES.in

    r53 r280  
    2323variable.h
    2424vmsfunctions.c
     25vmsjobs.c
    2526vpath.c
  • branches/GNU/src/gmake/read.c

    r153 r280  
    7979    unsigned int if_cmds;       /* Depth of conditional nesting.  */
    8080    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 */
    8284    char *seen_else;            /* Have we already seen an `else'?  */
    8385  };
     
    131133                               enum variable_origin origin,
    132134                               struct ebuffer *ebuf));
    133 static int conditional_line PARAMS ((char *line, const struct floc *flocp));
     135static int conditional_line PARAMS ((char *line, int len, const struct floc *flocp));
    134136static void record_files PARAMS ((struct nameseq *filenames, char *pattern, char *pattern_percent,
    135137                        struct dep *deps, unsigned int cmds_started, char *commands,
    136138                        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));
    139140static void record_target_var PARAMS ((struct nameseq *filenames, char *defn,
    140141                                       enum variable_origin origin,
     
    256257              d->file->dontcare = 1;
    257258              d->ignore_mtime = 0;
     259              d->need_2nd_expansion = 0;
    258260              /* Tell update_goal_chain to bail out as soon as this file is
    259261                 made, and main not to die if we can't make this file.  */
     
    371373  deps->file = lookup_file (filename);
    372374  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));
    378376  if (filename != ebuf.floc.filenm)
    379377    free (filename);
     
    381379  deps->changed = flags;
    382380  deps->ignore_mtime = 0;
     381  deps->need_2nd_expansion = 0;
     382  if (flags & RM_DONTCARE)
     383    deps->file->dontcare = 1;
    383384
    384385  /* If the makefile can't be found at all, give up entirely.  */
     
    412413
    413414  free (ebuf.bufstart);
     415  alloca (0);
    414416  return r;
    415417}
     
    443445  reading_file = curfile;
    444446
     447  alloca (0);
    445448  return r;
    446449}
     
    464467  int ignoring = 0, in_ignored_define = 0;
    465468  int no_targets = 0;           /* Set when reading a rule without targets.  */
    466   int have_sysv_atvar = 0;
    467469  struct nameseq *filenames = 0;
    468470  struct dep *deps = 0;
     
    481483          record_files (filenames, pattern, pattern_percent, deps,            \
    482484                        cmds_started, commands, commands_idx, two_colon,      \
    483                         have_sysv_atvar, &fi, set_default);                   \
     485                        &fi);                                                 \
    484486        }                                                                     \
    485487      filenames = 0;                                                          \
     
    618620         following lines.  */
    619621
    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            }
    631633        }
    632634
     
    853855        goto rule_complete;
    854856
     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.  */
    855860      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"));
    870862
    871863      /* This line describes some target files.  This is complicated by
     
    886878        unsigned int len, plen = 0;
    887879        char *colonp;
     880        const char *end, *beg; /* Helpers for whitespace stripping. */
    888881
    889882        /* Record the previous rule.  */
     
    934927
    935928        p2 = variable_expand_string(NULL, lb_next, len);
     929
    936930        while (1)
    937931          {
     
    10401034        if (*lb_next != '\0')
    10411035          {
    1042             unsigned int l = p - variable_buffer;
    1043             unsigned int l2 = p2 - variable_buffer;
     1036            unsigned int l = p2 - variable_buffer;
    10441037            plen = strlen (p2);
    10451038            (void) variable_buffer_output (p2+plen,
    10461039                                           lb_next, strlen (lb_next)+1);
    1047             p = variable_buffer + l;
    1048             p2 = variable_buffer + l2;
     1040            p2 = variable_buffer + l;
    10491041          }
    10501042
     
    11121104              }
    11131105          }
    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               }
    11241106
    11251107        /* Is this a static pattern rule: `target: %targ: %dep; ...'?  */
     
    11871169          pattern = 0;
    11881170
    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')
    11941177          {
    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;
    12081194          }
     1195        else
     1196          deps = 0;
    12091197
    12101198        commands_idx = 0;
     
    12251213            commands_idx += len;
    12261214            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              }
    12271291          }
    12281292
     
    12831347      char *line;
    12841348
     1349      nlines = readline (ebuf);
    12851350      ebuf->floc.lineno += nlines;
    1286       nlines = readline (ebuf);
    12871351
    12881352      /* If there is nothing left to eval, we're done. */
     
    13651429   current makefile.  They are used for error messages.
    13661430
    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,
    13681433   0 if following text should be interpreted,
    13691434   1 if following text should be ignored.  */
    13701435
    13711436static int
    1372 conditional_line (char *line, const struct floc *flocp)
     1437conditional_line (char *line, int len, const struct floc *flocp)
    13731438{
    1374   int notdef;
    13751439  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)
    13931455  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)
    14041465    {
    14051466      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)
    14091470        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 ();
    14151523      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;
    14281533    }
    14291534
     
    14351540    }
    14361541
    1437   ++conditionals->if_cmds;
     1542  o = conditionals->if_cmds++;
    14381543  if (conditionals->if_cmds > conditionals->allocated)
    14391544    {
     
    14461551
    14471552  /* 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;
    14491554
    14501555  /* 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)
    14521557    if (conditionals->ignoring[i])
    14531558      {
    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 expand variables 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;
    14581563        return 1;
    14591564      }
    14601565
    1461   if (cmdname[notdef ? 3 : 2] == 'd')
     1566  if (cmdtype == c_ifdef || cmdtype == c_ifndef)
    14621567    {
    1463       /* "Ifdef" or "ifndef".  */
    14641568      char *var;
    14651569      struct variable *v;
    1466       register char *p;
     1570      char *p;
    14671571
    14681572      /* Expand the thing we're looking up, so we can use indirect and
     
    14781582
    14791583      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));
    14831588
    14841589      free (var);
     
    14981603      if (termin == ',')
    14991604        {
    1500           register int count = 0;
     1605          int count = 0;
    15011606          for (; *line != '\0'; ++line)
    15021607            if (*line == '(')
     
    15721677      line = next_token (++line);
    15731678      if (*line != '\0')
    1574         error (flocp, _("Extraneous text after `%s' directive"), cmdname);
     1679        EXTRANEOUS ();
    15751680
    15761681      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));
    15791683    }
    15801684
     1685 DONE:
    15811686  /* Search through the stack to see if we're ignoring.  */
    15821687  for (i = 0; i < conditionals->if_cmds; ++i)
     
    16941799          p = create_pattern_var (name, percent);
    16951800          p->variable.fileinfo = *flocp;
     1801          /* I don't think this can fail since we already determined it was a
     1802             variable definition.  */
    16961803          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
    17001811          fname = p->target;
    17011812        }
     
    17711882              struct dep *deps, unsigned int cmds_started, char *commands,
    17721883              unsigned int commands_idx, int two_colon,
    1773               int have_sysv_atvar, const struct floc *flocp, int set_default)
     1884              const struct floc *flocp)
    17741885{
    17751886  struct nameseq *nextf;
     
    17781889  char **targets = 0, **target_percents = 0;
    17791890  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"));
    17801898
    17811899  if (commands_idx > 0)
     
    18431961      /* If there are multiple filenames, copy the chain DEPS
    18441962         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 base.  */
     1963         to go in more than one place in the database.  */
    18461964      this = nextf != 0 ? copy_dep_chain (deps) : deps;
    18471965
     
    18601978            }
    18611979          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)
    19221984              {
    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;
    19831993              }
    1984         }
     1994        }
    19851995
    19861996      if (!two_colon)
     
    20212031          if (cmds != 0)
    20222032            f->cmds = cmds;
     2033
    20232034          /* Defining .SUFFIXES with no dependencies
    20242035             clears out the list of suffixes.  */
     
    20352046              f->deps = 0;
    20362047            }
    2037           else if (f->deps != 0)
     2048          else if (this != 0)
    20382049            {
    20392050              /* Add the file's old deps and the new ones in THIS together.  */
    20402051
    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;
    20692104            }
    2070           else
    2071             f->deps = this;
    20722105
    20732106          /* If this is a static pattern rule, set the file's stem to
     
    20792112              char *buffer = variable_expand ("");
    20802113              char *o = patsubst_expand (buffer, name, pattern, percent,
    2081                                          pattern_percent, percent);
     2114                                         pattern_percent+1, percent+1);
    20822115              f->stem = savestring (buffer, o - buffer);
    20832116            }
     
    21152148        }
    21162149
    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;
    21572155    }
    21582156
     
    24982496readstring (struct ebuffer *ebuf)
    24992497{
    2500   char *p;
     2498  char *eol;
    25012499
    25022500  /* 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)
    25042502    return -1;
    25052503
     
    25072505     next logical line (taking into account backslash/newline pairs).  */
    25082506
    2509   p = ebuf->buffer = ebuf->bufnext;
     2507  eol = ebuf->buffer = ebuf->bufnext;
    25102508
    25112509  while (1)
    25122510    {
    25132511      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)
    25232527        break;
     2528      ++eol;
    25242529    }
    25252530
    25262531  /* Overwrite the newline char.  */
    2527   *p = '\0';
    2528   ebuf->bufnext = p+1;
     2532  *eol = '\0';
     2533  ebuf->bufnext = eol+1;
    25292534
    25302535  return 0;
  • branches/GNU/src/gmake/readme.vms

    r54 r280  
     1This is the VMS version of GNU Make, updated by Hartmut Becker
     2
     3Changes are based on GNU make 3.80. Latest changes are for OpenVMS/I64
     4and new VMS CRTLs.
     5
     6This version was tested on OpenVMS/I64 V8.2 (field test) with hp C
     7X7.1-024 OpenVMS/Alpha V7.3-2 with Compaq C V6.5-001 and OpenVMS/VAX 7.1
     8with Compaq C V6.2-003 There are still some warning and informational
     9message issued by the compilers.
     10
     11Build instructions
     12Make a 1st version
     13       $ @makefile.com
     14       $ rena make.exe 1st-make.exe
     15Use the 1st version to generate a 2nd version
     16       $ mc sys$disk:[]1st-make clean
     17       $ mc sys$disk:[]1st-make
     18Verify your 2nd version
     19       $ rena make.exe 2nd-make.exe
     20       $ mc sys$disk:[]2nd-make clean
     21       $ mc sys$disk:[]2nd-make
     22
     23Changes:
     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
     29In newer version of the VMS CRTL there are glob and globfree implemented.
     30Compiling 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
     37linker messages (and similar for DECC$GLOB). The messages just say, that
     38globfree is a known CRTL whose name was mapped by the compiler to
     39DECC$GLOBFREE.  This is done in glob.c as well, so this name is defined
     40twice. One possible solution is to use the VMS versions of glob and
     41globfree. However, then the build environment needs to figure out if
     42there is a new CRTL supporting these or not. This adds complexity. Even
     43more, these functions return VMS file specifications, which is not
     44expected by the other make sources. There is a switch at run time (a VMS
     45logical DECC$GLOB_UNIX_STYLE), which can be set to get Unix style
     46names. This may conflict with other software. The recommended solution
     47for this is to set this switch just prior to calling main: in an
     48initialization routine. This adds more complexity and more VMS specific
     49code. It is easier to tell the compiler NOT to map the routine names
     50with a simple change in makefile.vms.
     51
     52
    153This is the VMS port of GNU Make done by [email protected].
    254
  • branches/GNU/src/gmake/remake.c

    r153 r280  
    7575/* Remake all the goals in the `struct dep' chain GOALS.  Return -1 if nothing
    7676   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.  */
    8182
    8283int
    83 update_goal_chain (struct dep *goals, int makefiles)
     84update_goal_chain (struct dep *goals)
    8485{
    8586  int t = touch_flag, q = question_flag, n = just_print_flag;
     
    8788  int status = -1;
    8889
    89 #define MTIME(file) (makefiles ? file_mtime_no_search (file) \
     90#define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \
    9091                     : file_mtime (file))
    9192
     
    137138              int x;
    138139              check_renamed (file);
    139               if (makefiles)
     140              if (rebuilding_makefiles)
    140141                {
    141142                  if (file->cmd_target)
     
    154155              ocommands_started = commands_started;
    155156
    156               x = update_file (file, makefiles ? 1 : 0);
     157              x = update_file (file, rebuilding_makefiles ? 1 : 0);
    157158              check_renamed (file);
    158159
     
    177178                         matter how much more we run, since we already know
    178179                         the answer to return.  */
    179                       stop = (!keep_going_flag && !question_flag
    180                               && !makefiles);
     180                      stop = (question_flag && !keep_going_flag
     181                              && !rebuilding_makefiles);
    181182                    }
    182183                  else
     
    194195                             If STATUS is changed, we will get re-exec'd, and
    195196                             enter an infinite loop.  */
    196                           if (!makefiles
     197                          if (!rebuilding_makefiles
    197198                              || (!just_print_flag && !question_flag))
    198199                            status = 0;
    199                           if (makefiles && file->dontcare)
     200                          if (rebuilding_makefiles && file->dontcare)
    200201                            /* This is a default makefile; stop remaking.  */
    201202                            stop = 1;
     
    220221                 print a message saying nothing needs doing.  */
    221222
    222               if (!makefiles
     223              if (!rebuilding_makefiles
    223224                  /* If the update_status is zero, we updated successfully
    224225                     or not at all.  G->changed will have been set above if
     
    259260    }
    260261
    261   if (makefiles)
     262  if (rebuilding_makefiles)
    262263    {
    263264      touch_flag = t;
     
    309310      check_renamed (f);
    310311
     312      /* If we got an error, don't bother with double_colon etc.  */
    311313      if (status != 0 && !keep_going_flag)
    312         break;
     314        return status;
    313315
    314316      if (f->command_state == cs_running
     
    324326  /* Process the remaining rules in the double colon chain so they're marked
    325327     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      }
    335338
    336339  return status;
    337340}
    338341
     342
     343/* Show a message stating the target failed to build.  */
     344
     345static void
     346complain (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}
    339366
    340367/* Consider a single `struct file' and update it as appropriate.  */
     
    357384          DBF (DB_VERBOSE,
    358385               _("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
    359397          return file->update_status;
    360398        }
     
    435473      FILE_TIMESTAMP mtime;
    436474      int maybe_make;
     475      int dontcare = 0;
    437476
    438477      check_renamed (d->file);
     
    458497      d->file->parent = file;
    459498      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
    460508      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
    461514      if (! d->ignore_mtime)
    462515        must_make = maybe_make;
     
    495548        if (d->file->intermediate)
    496549          {
     550            int dontcare = 0;
     551
    497552            FILE_TIMESTAMP mtime = file_mtime (d->file);
    498553            check_renamed (d->file);
    499554            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
    500564            dep_status |= update_file (d->file, depth);
     565
     566            /* Restore original dontcare flag. */
     567            if (rebuilding_makefiles)
     568              d->file->dontcare = dontcare;
     569
    501570            check_renamed (d->file);
    502571
     
    846915  start_updating (file);
    847916
    848   if (!file->intermediate)
    849     /* If this is a non-intermediate file, update it and record
    850        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.  */
    852921      FILE_TIMESTAMP mtime;
    853922      dep_status = update_file (file, depth);
     
    10161085      else
    10171086        {
    1018           const char *msg_noparent
    1019             = _("%sNo rule to make target `%s'%s");
    1020           const char *msg_parent
    1021             = _("%sNo rule to make target `%s', needed by `%s'%s");
    1022 
    10231087          /* 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);
    10401090          file->update_status = 2;
    10411091        }
     
    12731323/* Return the mtime of the file or archive-member reference NAME.  */
    12741324
     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
    12751331static FILE_TIMESTAMP
    12761332name_mtime (char *name)
    12771333{
     1334  FILE_TIMESTAMP mtime;
    12781335  struct stat st;
    12791336  int e;
     
    12831340    {
    12841341      if (errno != ENOENT && errno != ENOTDIR)
    1285         perror_with_name ("stat:", name);
     1342        perror_with_name ("stat: ", name);
    12861343      return NONEXISTENT_MTIME;
    12871344    }
    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;
    12901413}
    12911414
  • branches/GNU/src/gmake/rule.c

    r153 r280  
    138138
    139139              dep->changed = !dir_file_exists_p (name, "");
    140 #ifdef VMS
    141               if (dep->changed && strchr (name, ':') != 0)
    142 #else
    143               if (dep->changed && *name == '/')
    144 #endif
    145                 {
    146                   /* The name is absolute and the directory does not exist.
    147                      This rule can never possibly match, since this dependency
    148                      can never possibly exist.  So just remove the rule from
    149                      the list.  */
    150                   freerule (rule, lastrule);
    151                   --num_pattern_rules;
    152                   goto end_main_loop;
    153                 }
    154140            }
    155141          else
     
    162148
    163149      lastrule = rule;
    164     end_main_loop:
    165150      rule = next;
    166151    }
     
    225210      deps->name = depname;
    226211      deps->ignore_mtime = 0;
     212      deps->need_2nd_expansion = 0;
    227213    }
    228214
  • branches/GNU/src/gmake/signame.c

    r54 r280  
    2828 */
    2929
    30 #if !defined(SYS_SIGLIST_DECLARED)
     30#if !defined(HAVE_DECL_SYS_SIGLIST)
    3131
    3232/* Some systems do not define NSIG in <signal.h>.  */
     
    227227}
    228228
    229 #endif  /* SYS_SIGLIST_DECLARED */
     229#endif  /* HAVE_DECL_SYS_SIGLIST */
    230230
    231231
     
    235235  static char buf[] = "Signal 12345678901234567890";
    236236
    237 #if !defined(SYS_SIGLIST_DECLARED)
     237#if ! HAVE_DECL_SYS_SIGLIST
    238238  static char sig_initted = 0;
    239239
  • branches/GNU/src/gmake/tests/ChangeLog

    r153 r280  
     12005-05-13  Paul D. Smith  <[email protected]>
     2
     3        * scripts/features/conditionals: Add tests for the new if... else
     4        if... endif syntax.
     5
     62005-05-03  Paul D. Smith  <[email protected]>
     7
     8        * scripts/variables/DEFAULT_GOAL: Rename DEFAULT_TARGET to
     9        DEFAULT_GOAL.
     10
     112005-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
     172005-04-07  Paul D. Smith  <[email protected]>
     18
     19        * scripts/targets/SECONDARY: Add a test for Savannah bug #12331.
     20
     212005-03-15  Boris Kolpackov  <[email protected]>
     22
     23        * scripts/variables/automatic: Add a test for Savannah bug #12320.
     24
     252005-03-10  Boris Kolpackov  <[email protected]>
     26
     27        * scripts/features/patternrules: Add a test for Savannah bug #12267.
     28
     292005-03-09  Boris Kolpackov  <[email protected]>
     30
     31        * scripts/variables/DEFAULT_TARGET: Add a test for Savannah
     32        bug #12266.
     33
     342005-03-04  Boris Kolpackov  <[email protected]>
     35
     36        * scripts/features/patternrules: Add a test for Savannah bug #12202.
     37
     382005-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
     502005-03-01  Boris Kolpackov  <[email protected]>
     51
     52        * scripts/features/statipattrules: Add a test for
     53        Savannah bug #12180.
     54
     552005-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
     672005-02-28  Boris Kolpackov  <[email protected]>
     68
     69        * scripts/variables/DEFAULT_TARGET: Test the .DEFAULT_TARGET
     70        special variable.
     71
     722005-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
     852005-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
     902005-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
     962005-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
     1012004-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
     1092004-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
     1172004-10-21  Boris Kolpackov  <[email protected]>
     118
     119        * scripts/functions/word: Test $(firstword ) and $(lastword ).
     120
     1212004-10-05  Boris Kolpackov  <[email protected]>
     122
     123        * scripts/features/patspecific_vars: Test simple/recursive
     124        variable expansion.
     125
     1262004-09-28  Boris Kolpackov  <[email protected]>
     127
     128        * scripts/features/include: Test dontcare flag inheritance
     129        when rebuilding makefiles.
     130
     1312004-09-27  Boris Kolpackov  <[email protected]>
     132
     133        * scripts/features/patspecific_vars: Test exported variables.
     134
     1352004-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
     1442004-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
     1522004-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
     1612004-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
     1672004-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
    11732004-02-21  Paul D. Smith  <[email protected]>
    2174
  • branches/GNU/src/gmake/tests/run_make_tests.pl

    r53 r280  
    1 #!/usr/local/bin/perl
     1#!/usr/bin/env perl
    22# -*-perl-*-
    33
     
    1313
    1414$valgrind = 0;              # invoke make with valgrind
     15$pure_log = undef;
    1516
    1617require "test_driver.pl";
     
    3839   }
    3940
    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.
    4142#
    4243#   elsif ($option =~ /^-work([-_]?dir)?$/)
     
    4950}
    5051
    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
     62sub 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...
     111sub 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;
    111169}
    112170
     
    159217   # This is probably not specific enough.
    160218   #
    161    if ($osname =~ /Windows/i) {
     219   if ($osname =~ /Windows/i || $osname =~ /MINGW32/i) {
    162220     $port_type = 'W32';
    163221   }
     
    184242   # timestamps with second granularity (!!).  Change the sleep time
    185243   # needed to force a file to be considered "old".
    186    #
    187244   $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;
    188248
    189249   # Find the full pathname of Make.  For DOS systems this is more
    190250   # complicated, so we ask make itself.
    191 
    192251   $make_path = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
    193252   chop $make_path;
     
    227286   # Get Purify log info--if any.
    228287
    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   }
    233294
    234295   $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`;
  • branches/GNU/src/gmake/tests/scripts/features/conditionals

    r153 r280  
    44$details = "Attempt various different flavors of GNU make conditionals.";
    55
    6 open(MAKEFILE,"> $makefile");
    7 
    8 # The Contents of the MAKEFILE ...
    9 
    10 print MAKEFILE <<'EOMAKE';
    11 objects = foo.obj
     6run_make_test('
    127arg1 = first
    138arg2 = second
     
    2318endif
    2419
    25 ifeq '$(arg2)' "$(arg5)"
     20ifeq \'$(arg2)\' "$(arg5)"
    2621        @echo arg2 equals arg5
    2722else
     
    2924endif
    3025
    31 ifneq '$(arg3)' '$(arg4)'
     26ifneq \'$(arg3)\' \'$(arg4)\'
    3227        @echo arg3 NOT equal arg4
    3328else
     
    4439else
    4540        @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
     41endif',
     42              '',
     43              'arg1 NOT equal arg2
    5544arg2 equals arg5
    5645arg3 NOT equal arg4
    5746variable is undefined
    58 arg4 is defined
    59 ";
    60 
    61 &compare_output($answer,&get_logfile(1));
     47arg4 is defined');
    6248
    6349
    6450# Test expansion of variables inside ifdef.
    6551
    66 $makefile2 = &get_tmpfile;
    67 
    68 open(MAKEFILE, "> $makefile2");
    69 
    70 print MAKEFILE <<'EOF';
    71 
     52run_make_test('
    7253foo = 1
    7354
     
    9374endif
    9475
    95 all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)
     76all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)',
     77              '',
     78              'DEF=yes DEF2=yes DEF3=yes');
    9679
    97 EOF
    9880
    99 close(MAKEFILE)
     81# Test all the different "else if..." constructs
    10082
    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));
     83run_make_test('
     84arg1 = first
     85arg2 = second
     86arg3 = third
     87arg4 = cc
     88arg5 = fifth
     89
     90result =
     91
     92ifeq ($(arg1),$(arg2))
     93  result += arg1 equals arg2
     94else ifeq \'$(arg2)\' "$(arg5)"
     95  result += arg2 equals arg5
     96else ifneq \'$(arg3)\' \'$(arg3)\'
     97  result += arg3 NOT equal arg4
     98else ifndef arg5
     99  result += variable is undefined
     100else ifdef undefined
     101  result += arg4 is defined
     102else
     103  result += success
     104endif
     105
     106
     107all: ; @echo $(result)',
     108              '',
     109              'success');
     110
     111
     112# Test some random "else if..." construct nesting
     113
     114run_make_test('
     115arg1 = first
     116arg2 = second
     117arg3 = third
     118arg4 = cc
     119arg5 = second
     120
     121ifeq ($(arg1),$(arg2))
     122  $(info failed 1)
     123else ifeq \'$(arg2)\' "$(arg2)"
     124  ifdef undefined
     125    $(info failed 2)
     126  else
     127    $(info success)
     128  endif
     129else ifneq \'$(arg3)\' \'$(arg3)\'
     130  $(info failed 3)
     131else ifdef arg5
     132  $(info failed 4)
     133else ifdef undefined
     134  $(info failed 5)
     135else
     136  $(info failed 6)
     137endif
     138
     139.PHONY: all
     140all: ; @:',
     141              '',
     142              'success');
    104143
    105144
  • branches/GNU/src/gmake/tests/scripts/features/echoing

    r53 r280  
    5555
    5656&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;
     57if (-f $example) {
     58  $test_passed = 0;
    6359}
     60&compare_output('',&get_logfile(1));
    6461
    6562# TEST #3
  • branches/GNU/src/gmake/tests/scripts/features/errors

    r53 r280  
    5353&run_make_with_options($makefile,"",&get_logfile);
    5454
     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.
     58if (-f "foo") {
     59  $test_passed = 0;
     60}
     61
    5562# The output for this on VOS is too hard to replicate, so we only check it
    5663# on unix.
     
    5865{
    5966   &compare_output($answer,&get_logfile(1));
    60 }
    61 
    62 # If make acted as planned, it should ignore the error from the first
    63 # 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;
    6867}
    6968
     
    8180&run_make_with_options($makefile,"clean2 -i",&get_logfile);
    8281
    83 if (!$vos)
    84 {
     82if (-f "foo") {
     83  $test_passed = 0;
     84}
     85
     86if (!$vos) {
    8587   &compare_output($answer,&get_logfile(1));
    8688}
    8789
    88 if (-f "foo")
    89 {
    90    $test_passed = 0;
    91 }
    92 
    93901;
  • 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-*-
    32
     3$description = "<FILL IN SHORT DESCRIPTION HERE>";
    44$details = "<FILL IN DETAILS OF HOW YOU TEST WHAT YOU SAY YOU ARE TESTING>";
    55
    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).
    1013
    11 open(MAKEFILE,"> $makefile");
     14run_make_test('Your test makefile goes here',
     15              'Arguments to pass to make go here',
     16              'Expected output from the invocation goes here');
    1217
    13 # The Contents of the MAKEFILE ...
     18# There are various special tokens, options, etc.  See the full documentation
     19# in run_make_tests.pl.
    1420
    15 print MAKEFILE " <FILL IN THE CONTENTS OF THE MAKEFILE HERE>  \n";
    16 
    17 # END of Contents of MAKEFILE
    18 
    19 close(MAKEFILE);
    20 
    21 
    22 # Run make.  You may specify a makefile, but if you don't want to, just
    23 # insert "" where $make_filename is now.  You may also specify specific
    24 # options to run make with, but you also don't have to. (Insert "" where it
    25 # says <FILL IN OPTIONS HERE>), The last field in this subroutine call
    26 # is the code which is returned from make.  If you think that make should
    27 # execute with no errors, you may OPTIONALLY put 0; Otherwise put the
    28 # 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 that
    31 # subroutine will get a new logfile name for you in incrementing order
    32 # according to how many times you call it within ONE test.  It is
    33 # 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 ARE
    42 # CREATING, SO IT WILL VARY.  BASICALLY, YOU MAY INSERT ANYTHING YOU
    43 # WISH AT THIS POINT TO SEE IF THE TEST WORKED OK.  IF THERE ARE
    44 # ADDITIONAL TESTS BESIDES &compare_output, AND IT FAILES, YOU
    45 # MUST *** SET $test_passed = 0 !!! ***
    46 
    47 # Create the answer to what should be produced by this Makefile
    48 $answer = "<INSERT ANSWER HERE>";
    49 
    50 # COMPARE RESULTS
    51 
    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 use
    54 # 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 ("abort
    59 ") if the compare fails, then add a "|| &error ("abort
    60 ")" to the
    61 # end of the previous line.
    6221
    6322# 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/perl
     1#!/usr/bin/perl
    22# -*-perl-*-
    33
     
    1212# this routine controls the whole mess; each test suite sets up a few
    1313# 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;
    1434
    1535sub toplevel
     
    151171  $| = 1;
    152172
    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");
    157182    print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n";
    158183    return 0;
     
    160185  else
    161186  {
    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");
    164191    print " Complete ... No Failures :-)\n\n";
    165192    return 1;
     
    349376sub run_each_test
    350377{
    351   $counter = 0;
     378  $categories_run = 0;
    352379
    353380  foreach $testname (sort @TESTS)
    354381  {
    355     $counter++;
    356     $test_passed = 1;       # reset by test on failure
     382    ++$categories_run;
     383    $suite_passed = 1;       # reset by test on failure
    357384    $num_of_logfiles = 0;
    358385    $num_of_tmpfiles = 0;
    359386    $description = "";
    360387    $details = "";
     388    $old_makefile = undef;
    361389    $testname =~ s/^$scriptpath$pathsep//;
    362390    $perl_testname = "$scriptpath$pathsep$testname";
     
    391419
    392420    # Run the actual test!
    393     #
     421    $tests_run = 0;
     422    $tests_passed = 0;
    394423    $code = do $perl_testname;
     424
     425    $total_tests_run += $tests_run;
     426    $total_tests_passed += $tests_passed;
     427
     428    # How did it go?
    395429    if (!defined($code))
    396430    {
    397       $test_passed = 0;
     431      $suite_passed = 0;
    398432      if (length ($@))
    399433      {
     
    406440    }
    407441    elsif ($code == -1) {
    408       $test_passed = 0;
     442      $suite_passed = 0;
    409443    }
    410444    elsif ($code != 1 && $code != -1) {
    411       $test_passed = 0;
     445      $suite_passed = 0;
    412446      warn "\n*** Test returned $code\n";
    413447    }
    414448
    415     if ($test_passed) {
    416       $status = "ok";
     449    if ($suite_passed) {
     450      ++$categories_passed;
     451      $status = "ok     ($tests_passed passed)";
    417452      for ($i = $num_of_tmpfiles; $i; $i--)
    418453      {
    419         &delete ($tmp_filename . &num_suffix ($i) );
     454        &rmfiles ($tmp_filename . &num_suffix ($i) );
    420455      }
    421456
    422457      for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--)
    423458      {
    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) );
    426461      }
    427462    }
    428463    elsif ($code > 0) {
    429       $status = "FAILED";
    430       $num_failed++;
     464      $status = "FAILED ($tests_passed/$tests_run passed)";
    431465    }
    432466    elsif ($code < 0) {
    433467      $status = "N/A";
    434       --$counter;
     468      --$categories_run;
    435469    }
    436470
     
    467501# are sent to it.
    468502
    469 sub delete
     503sub rmfiles
    470504{
    471505  local(@files) = @_;
     
    578612{
    579613  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;
    586617
    587618  $slurp = &read_file_into_string ($logfile);
     
    592623  $slurp =~ s/^.*Clock skew detected.*\n//gm;
    593624
    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;
    600646    return 1;
    601647  }
    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
    609652    &create_file (&get_basefile, $answer);
    610653
    611     if ($debug)
    612     {
    613       print "\nCreating Difference File ...\n";
    614     }
     654    print "\nCreating Difference File ...\n" if $debug;
     655
    615656    # Create the difference file
     657
    616658    local($command) = "diff -c " . &get_basefile . " " . $logfile;
    617659    &run_command_with_output(&get_difffile,$command);
    618 
    619     return 0;
    620   }
     660  }
     661
     662  $suite_passed = 0;
     663  return 0;
    621664}
    622665
     
    702745  local ($code);
    703746
    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;
    713752}
    714753
     
    726765  $code = system @_;
    727766  &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;
    732769
    733770  return $code;
  • branches/GNU/src/gmake/variable.c

    r54 r280  
    500500
    501501          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            }
    506528          while ((p = lookup_pattern_var (p, file->name)) != 0);
    507529
     
    727749#endif
    728750
    729   /* This won't override any definition, but it
    730      will provide one if there isn't one there.  */
     751  /* This won't override any definition, but it will provide one if there
     752     isn't one there.  */
    731753  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. */
    739759#if !defined(__MSDOS__) && !defined(__EMX__)
    740760  /* Don't let SHELL come from the environment.  */
     
    854874
    855875              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;
    857885
    858886              case v_ifset:
     
    969997            v = lookup_variable_in_set (varname, strlen (varname),
    970998                                        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;
    9711004          }
    9721005        else
     
    10271060      && strcmp (varname, "SHELL") == 0)
    10281061    {
    1029       char shellpath[PATH_MAX];
     1062      PATH_VAR (shellpath);
    10301063      extern char * __dosexec_find_on_path (const char *, char *[], char *);
    10311064
     
    14121445sync_Path_environment (void)
    14131446{
    1414   char *path = allocated_variable_expand ("$(Path)");
     1447  char *path = allocated_variable_expand ("$(PATH)");
    14151448  static char *environ_path = NULL;
    14161449
     
    14291462   */
    14301463  convert_Path_to_windows32 (path, ';');
    1431   environ_path = concat ("Path", "=", path);
     1464  environ_path = concat ("PATH", "=", path);
    14321465  putenv (environ_path);
    14331466  free (path);
  • branches/GNU/src/gmake/variable.h

    r54 r280  
    113113extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length));
    114114extern char *variable_expand PARAMS ((char *line));
     115extern char *variable_expand_for_file PARAMS ((char *line, struct file *file));
    115116extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
    116117#define allocated_variable_expand(line) \
     
    126127extern int pattern_matches PARAMS ((char *pattern, char *percent, char *str));
    127128extern 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));
    129130extern char *patsubst_expand PARAMS ((char *o, char *text, char *pattern, char *replace,
    130131                char *pattern_percent, char *replace_percent));
  • branches/GNU/src/gmake/vmsfunctions.c

    r54 r280  
    33#include "make.h"
    44#include "debug.h"
     5#include "job.h"
    56
    67#ifdef __DECC
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette