VirtualBox

Changeset 2591 in kBuild for trunk/src


Ignore:
Timestamp:
Jun 17, 2012 8:45:31 PM (13 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 3.82. Previous GNU make base version was gnumake-2008-10-28-CVS.

Location:
trunk/src/kmk
Files:
158 edited
9 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

    • Property svn:ignore
      •  

        old new  
        1313stamp-*
        1414makebook*
         15
        1516.*gdbinit
         17.gdb_history
         18
        1619*.dep
        1720*.dvi
         
        3134*.pg
        3235*.pgs
         36
        3337README
        3438README.DOS
        3539README.W32
         40README.OS2
        3641aclocal.m4
        3742autom4te.cache
         
        5257config.h.W32
        5358config.h-vms
         59
        5460loadavg
        5561loadavg.c
        5662make
         63
        5764.deps
        5865.dep_segment
         66ID
         67TAGS
         68
        5969_*
        6070sun4
         
        7282sol2
        7383i486-linux
         84
        7485customs
         86
        7587install-sh
        7688mkinstalldirs
         89
         90.directive.asc
  • trunk/src/kmk/AUTHORS

    r1993 r2591  
    6767
    6868-------------------------------------------------------------------------------
    69 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    70 Free Software Foundation, Inc.
     69Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
     702008, 2009, 2010 Free Software Foundation, Inc.
    7171This file is part of GNU Make.
    7272
  • trunk/src/kmk/ChangeLog

    r1993 r2591  
     12010-07-28  Paul Smith  <[email protected]>
     2
     3        Version 3.82 released.
     4
     5        * configure.in: Change release version.
     6        * NEWS: Change the date.
     7
     8        * read.c (parse_file_seq): Remove GLOB_NOSORT for
     9        backward-compatibility.  We'll add it back in next release.
     10        * NEWS: Note it.
     11
     122010-07-24  Eli Zaretskii  <[email protected]>
     13
     14        * job.c (pid2str) [WINDOWS32]: Fix CPP conditionals for using %Id
     15        format.
     16
     172010-07-18  Paul Smith  <[email protected]>
     18
     19        * configure.in: Switch bsd_signal to AC_CHECK_DECLS() to make sure
     20        we have a declaration.  Fixes Savannah bug #25713 (maybe?)
     21        * doc/make.texi (Complex Makefile): Cleanup variable assignments.
     22        (One Shell): New subsection for the .ONESHELL special target.
     23
     24        Patches by Ozkan Sezer <[email protected]>:
     25
     26        * misc.c (strncasecmp): Local implementation for systems without.
     27        * config.h.W32.template (HAVE_STRNICMP): Define on Windows.
     28        * configure.in: Check for strncasecmp/strncmpi/strnicmp.
     29        * job.c [WINDOWS32]: Don't define dup2 on Windows.
     30        (pid2str): Use "%Id" even with MSVC
     31        (exec_command): Cast to pid_t when calling pid2str().
     32        * w32/subproc/sub_proc.c [WINDOWS32]: Include config.h first.
     33        Use stddef.h on MSVC to get intptr_t.
     34        * w32/subproc/misc.c [WINDOWS32]: Include config.h first.
     35        * w32/compat/dirent.c [WINDOWS32]: Include config.h first.
     36        (readdir): Cast -1 to correct type for d_ino.
     37        * w32/pathstuff.c [WINDOWS32]: Ensure make.h is included first.
     38        * make.h [WINDOWS32]: Don't prototype alloca() on Windows.
     39        Add configuration for strncasecmp().
     40        * main.c (ADD_SIG) [WINDOWS32]: Avoid warnings in MSVC.
     41        * config.h.W32.template [WINDOWS32]: Don't warn on unsafe
     42        functions or variables.
     43        * NMakefile.template [WINDOWS32]: Remove /MACHINE:I386.
     44        * main.c (clean_jobserver): Cast due to MSVC brokenness.
     45        (decode_switches): Ditto.
     46        * vpath.c (construct_vpath_list): Ditto.
     47        * rule.c (freerule): Ditto.
     48        * ar.c (ar_glob): Ditto.
     49
     502010-07-16  Boris Kolpackov  <[email protected]>
     51
     52        * misc.c (concat): Fix buffer overrun.
     53
     542010-07-12  Paul Smith  <[email protected]>
     55
     56        Update copyrights to add 2010.
     57
     58        * build_w32.bat: Support for MSVC Windows x86_64 builds.
     59        * job.c: Don't define execve() on MSVC/64bit.
     60        Patch by Viktor Szakats.  Fixes Savannah bug #27590.
     61
     622010-07-12  Eli Zaretskii  <[email protected]>
     63
     64        * make.h (alloca) [!__GNUC__]: Don't define prototype.
     65        (int w32_kill): Use pid_t for process ID argument.
     66        Fixes Savannah bug #27809.
     67
     682010-07-12  Paul Smith  <[email protected]>
     69
     70        Integrated new .ONESHELL feature.
     71        Patch by David Boyce <[email protected]>.  Modified by me.
     72
     73        * NEWS: Add a note about the new feature.
     74        * job.c (is_bourne_compatible_shell): Determine whether we're
     75        using a standard POSIX shell or not.
     76        (start_job_command): Accept '-ec' as POSIX shell flags.
     77        (construct_command_argv_internal): If one_shell is set and we are
     78        using a POSIX shell, remove "interior" prefix characters such as
     79        "@", "+", "-".  Also treat "\n" as a special character when
     80        choosing the slow path, if ONESHELL is set.
     81        * job.h (is_bourne_compatible_argv): Define the new function.
     82
     83        * make.h (one_shell): New global variable to remember setting.
     84        * main.c: Declare it.
     85        * read.c (record_files): Set it.
     86        * commands.c (chop_commands): If one_shell is set, don't chop
     87        commands into multiple lines; just keep one line.
     88
     892010-07-09  Eli Zaretskii  <[email protected]>
     90
     91        * w32/subproc/sub_proc.c: Include stdint.h.
     92        (sub_process_t): Use intptr_t for file handles and pid_t for
     93        process ID.
     94        (process_pipes, process_init_fd, process_begin): Use intptr_t for
     95        file handles and pid_t for process ID.  Fixes Savannah bug #27809.
     96        Patch by Ozkan Sezer <[email protected]>
     97
     98        * function.c (abspath): Support absolute file names in UNC format.
     99        Fixes Savannah bug #30312.
     100
     101        * job.c (pid2str) [WINDOWS32]: Don't use %Id with GCC < 4.x.
     102        (exec_command) [WINDOWS32]: Use pid2str instead of non-portable
     103        %Id.
     104
     105        * main.c (handle_runtime_exceptions): Use %p to print addresses,
     106        to DTRT on both 32-bit and 64-bit hosts.  Savannah bug #27809.
     107
     108        * job.c (w32_kill, start_job_command, create_batch_file): Use
     109        pid_t for process IDs and intptr_t for the 1st arg of
     110        _open_osfhandle.
     111        * function.c (windows32_openpipe): Use pid_t for process IDs and
     112        intptr_t for the 1st arg of _open_osfhandle.
     113        (func_shell): Use pid_t for process IDs.
     114        * main.c (main) [WINDOWS32]: Pacify the compiler.
     115        * config.h.W32.template (pid_t): Add a definition for 64-bit
     116        Windows builds that don't use GCC.  Fixes Savannah bug #27809.
     117        Patch by Ozkan Sezer <[email protected]>
     118
     1192010-07-07  Paul Smith  <[email protected]>
     120
     121        * configure.in: Bump to a new prerelease version 3.81.91.
     122
     1232010-07-06  Paul Smith  <[email protected]>
     124
     125        * main.c (main): Set a default value of "-c" for .SHELLFLAGS.
     126        * NEWS: Mention the new behavior of .POSIX and the new .SHELLFLAGS
     127        variable.
     128        * job.c (construct_command_argv): Retrieve the .SHELLFLAGS value
     129        and pass it to construct_command_argv_internal().
     130        (construct_command_argv_internal): If .SHELLFLAGS is non-standard
     131        use the slow path.  Use that value instead of hard-coded "-c".
     132
     1332010-07-05  Paul Smith  <[email protected]>
     134
     135        * implicit.c (pattern_search): lastslash can be const.
     136        * dir.c (downcase): Remove unused variable.
     137        * hash.c (hash_init): Cast sizeof for error message.
     138        * arscan.c (ar_scan): Cast to char* for WINDOWS32.
     139        (ar_member_touch): Ditto.
     140        * ar.c (glob_pattern_p): Avoid symbol collision: open -> opened
     141        * signame.c (strsignal): Ditto: signal -> sig
     142        * job.c (create_batch_file): Ditto: error -> error_string
     143        (pid2str): Portably convert a pid_t into a string
     144        (reap_children): Use it.
     145        (start_waiting_job): Use it.
     146        Savannah bug #27809.  Patch by Ozkan Sezer <[email protected]>
     147
     1482010-07-03  Paul Smith  <[email protected]>
     149
     150        * read.c (parse_file_seq): All archive groups must end with ')' as
     151        the LAST character in a word.  If there is no word ending in ')'
     152        then it's not an archive group.  Fixes Savannah bug #28525.
     153
     1542010-07-01  Paul Smith  <[email protected]>
     155
     156        * main.c (main): Append optional features using separate calls.
     157        Not as efficient but not all compilers allow conditionals inside
     158        macro calls.  Fixes Savannah bug #29244.
     159
     1602010-01-10  Paul Smith  <[email protected]>
     161
     162        * make.h (patheq): Rename strieq() to patheq() for clarity.
     163        * dir.c (dir_contents_file_exists_p): Use it.
     164
     165        * dir.c (file_impossible): Convert xmalloc/memset to xcalloc.
     166        * file.c (enter_file): Ditto.
     167        * job.c (new_job): Ditto.
     168
     1692009-12-11  Eli Zaretskii  <[email protected]>
     170
     171        * job.c (construct_command_argv_internal) <sh_cmds_dos>
     172        [WINDOWS32]: Add "echo." and a few more commands that are built
     173        into cmd.exe.  Fixes Savannah bug #28126.
     174
     175        * file.c (lookup_file) [HAVE_DOS_PATHS]: Treat '\\' like we do
     176        with '/'.
     177
     1782009-11-15  Paul Smith  <[email protected]>
     179
     180        Patches for VMS provided by Hartmut Becker <[email protected]>
     181
     182        * vmsjobs.c (ctrlYPressed) [VMS]: Deal with CTRL-Y.
     183        (vmsHandleChildTerm) [VMS]: Ditto.
     184        (astYHandler) [VMS]: Ditto.
     185        (tryToSetupYAst) [VMS]: Ditto.
     186        (child_execute_job) [VMS]: Ditto.
     187
     188        * vmsify.c (trnlog) [VMS]: Fix const errors.
     189        (vmsify) [VMS]: Ditto.
     190
     191        * readme.vms [VMS]: Update with notes for 3.82.
     192
     193        * job.h (comname) [VMS]: Remember the temporary command filename
     194
     195        * dir.c (vmsify) [VMS]: Fix const errors.
     196        (vms_hash) [VMS]: Ditto.
     197        (vmsstat_dir) [VMS]: Ditto.
     198        (find_directory) [VMS]: Fix case-insensitive option for VMS
     199        (dir_contents_file_exists_p) [VMS]: Ditto.
     200        (file_impossible) [VMS]: Ditto.
     201
     202        * config.h-vms.template (HAVE_FDOPEN) [VMS]: Have it.
     203        (HAVE_STRCASECMP) [VMS]: Ditto.
     204
     205        * arscan.c (VMS_get_member_info) [VMS]: Fix timezone computation.
     206        (ar_scan) [VMS]: Fix const error.
     207
     2082009-11-12  Boris Kolpackov  <[email protected]>
     209
     210        * vpath.c (vpath_search, selective_vpath_search): Add index arguments
     211        which allows the caller to get the index of the matching directory.
     212
     213        * make.h (vpath_search): Update prototype.
     214
     215        * remake.c (library_search): Implement linker-compatible library
     216        search. Use the new VPATH_SEARCH index functionality to keep track
     217        of the directory index for each match. Select the match with the
     218        lowest directory index.
     219
     220        * implicit.c (pattern_search): Pass NULL for the index arguments in
     221        the VPATH_SEARCH call.
     222
     223        * doc/make.texi (Directory Search for Link Libraries): Describe the
     224        new search behavior.
     225
     226        * NEWS: Add a note about the new behavior.
     227
     2282009-10-25  Paul Smith  <[email protected]>
     229
     230        * AUTHORS, et.al.: Update copyright years.
     231
     232        * implicit.c (stemlen_compare): Fix qsort() compare bug that
     233        caused implicit rules with equal stem lengths to be sorted
     234        indeterminately.
     235
     2362009-10-24  Paul Smith  <[email protected]>
     237
     238        * main.c (usage): Add --eval to the usage string.
     239        (switches): Add the --eval switch.
     240        (main): If --eval is given, add them to the simply-expanded variable
     241        -*-eval-flags-*- (necessary to allow recursion to work properly).
     242        (define_makeflags): Add -*-eval-flags-*- to MAKEFLAGS.
     243
     244        * NEWS: Describe the new --eval command line argument.
     245        * doc/make.texi (Options Summary): Document --eval.
     246
     247        * dep.h: eval_buffer() returns void.
     248        * read.c (eval_buffer): Ditto.
     249        (eval): Ditto.
     250
     251        * variable.h (define_variable_cname): New macro for constant
     252        variable names.
     253        * default.c (set_default_suffixes): Use it.
     254        * main.c (main): Ditto.
     255        (handle_non_switch_argument): Ditto.
     256        (define_makeflags): Ditto.
     257        * read.c (read_all_makefiles): Ditto.
     258        * variable.c (define_automatic_variables): Ditto.
     259
     260        * commands.c (dep_hash_cmp): Avoid casts.
     261        (dep_hash_1): Ditto.
     262        (dep_hash_2): Ditto.
     263
     2642009-10-22  Boris Kolpackov  <[email protected]>
     265
     266        * read.c (read_all_makefiles): Mark the default makefile dependency
     267        dontcare.
     268
     2692009-10-07  Boris Kolpackov  <[email protected]>
     270
     271        * read.c (do_undefine): Free the expanded variable name.
     272
     273        * commands.c (dep_hash_cmp, set_file_variables): Move the order-only
     274        to normal upgrade logic from  dep_hash_cmp to set_file_variables.
     275
     2762009-10-06  Boris Kolpackov  <[email protected]>
     277
     278        * dep.h (uniquize_deps): Remove.
     279
     280        * read.c (uniquize_deps): Merge into set_file_variables in
     281        commands.c.
     282        (dep_hash_1, dep_hash_2, dep_hash_cmp): Move to commands.c.
     283
     284        * commands.c (set_file_variables): Avoid modifying the dep
     285        chain to achieve uniqueness. Fixes savannah bug 25780.
     286
     287        * implicit.c (pattern_search): Instead of re-setting all automatic
     288        variables for each rule we try, just update $*.
     289
     2902009-10-06  Boris Kolpackov  <[email protected]>
     291
     292        * variable.h (undefine_variable_in_set): New function declaration.
     293        (undefine_variable_global): New macro.
     294
     295        * variable.c (undefine_variable_in_set): New function implementation.
     296
     297        * read.c (vmodifiers): Add undefine_v modifier.
     298        (parse_var_assignment): Parse undefine.
     299        (do_undefine): Handle the undefine directive.
     300        (eval): Call do_undefine if undefine_v is set.
     301
     302        * main.c (.FEATURES): Add a keyword to indicate the new feature.
     303
     304        * doc/make.texi (Undefine Directive): Describe the new directive.
     305
     306        * NEWS: Add a note about the new directive.
     307
     3082009-10-05  Boris Kolpackov  <[email protected]>
     309
     310        * implicit.c (pattern_search): Initialize file variables only
     311        if we need to parse a rule that requires the second expansion.
     312
     3132009-10-03  Paul Smith  <[email protected]>
     314
     315        * make.h: Include <alloca.h> even on systems where __GNUC__ is
     316        defined.  Not sure why it was done the other way.
     317        Requested by David Boyce <[email protected]>.
     318
     3192009-09-30  Boris Kolpackov  <[email protected]>
     320
     321        * dep.h (dep): Add the DONTCARE bitfield.
     322
     323        * filedef.h (file):Add the NO_DIAG bitfield.
     324
     325        * read.c (eval_makefile): Set the DONTCARE flag in struct dep,
     326        not struct file (a file can be a dependency of many targets,
     327        some don't care, some do).
     328
     329        * remake.c (update_goal_chain): Propagate DONTCARE from struct
     330        dep to struct file before updating the goal and restore it
     331        afterwards.
     332        (update_file): Don't prune the dependency graph if this target
     333        has failed but the diagnostics hasn't been issued.
     334        (complain): Scan the file's dependency graph to find the file
     335        that caused the failure.
     336        (update_file_1): Use NO_DIAG instead of DONTCARE to decide
     337        whether to print diagnostics.
     338
     339        Fixes Savannah bugs #15110, #25493, #12686, and #17740.
     340
     3412009-09-28  Paul Smith  <[email protected]>
     342
     343        * doc/make.texi (Pattern Intro): Move the match algorithm
     344        discussion into the "Pattern Match" node.
     345        (Pattern Match): Expand on the pattern rule matching algorithm.
     346
     3472009-09-28  Andreas Buening  <[email protected]>
     348
     349        * job.c (construct_command_argv_internal) [OS2]: Don't eat too
     350        much of the command line on a single pass.
     351
     3522009-09-28  Boris Kolpackov  <[email protected]>
     353
     354        * varible.c (create_pattern_var): Insert variables into the
     355        PATTERN_VARS list in the shortest patterns first order.
     356
     357        * implicit.c (tryrule): Add STEMLEN and ORDER members. These are
     358        used to sort the rules.
     359        (stemlen_compare): Compare two tryrule elements.
     360        (pattern_search): Sort the rules so that they are in the shortest
     361        stem first order.
     362
     363        * main.c (.FEATURES): Add a keyword to indicate the new behavior.
     364
     365        * doc/make.texi (Pattern-specific Variable Values): Describe the
     366        new pattern-specific variables application order.
     367        (Introduction to Pattern Rules): Describe the new pattern rules
     368        search order.
     369
     370        * NEWS: Add a note about the new behavior.
     371
     3722009-09-27  Paul Smith  <[email protected]>
     373
     374        * doc/make.texi (Double-Colon): Mention that pattern rules with
     375        double-colons have a different meaning.  Savannah bug #27497.
     376
     3772009-09-27  Juan Manuel Guerrero  <[email protected]>
     378
     379        * configh.dos.template: Remove unconditional definition of
     380        SYS_SIGLIST_DECLARED.
     381        Include <sys/version.h> because ports of GCC 4.3.0 and later no
     382        longer include it, so macros like __DJGPP_MINOR__ are no longer
     383        defined automatically.
     384
     385        * Makefile.DOS.template (INCLUDES): Use $(prefix) and the
     386        corresponding variables to define LIBDIR, INCLUDEDIR and LOCALEDIR
     387        instead of using the hardcoded ones.
     388        (SUBDIRS): doc subdir added.
     389        (INFO_DEPS, DVIS): Values changed to 'make.info' and 'make.dvi'.
     390        (TEXI2HTML, TEXI2HTML_FLAGS): Removed.  Use makeinfo --html to
     391        create html formated docs.  texi2html may not be ported to DOS.
     392        (make.info, make.dvi, make.ps, make.html): Make targets depend on
     393        'make.texi'.
     394        (.texi.info, .texi, .texi.dvi): Now invoked recursively.  Change
     395        -I switch to look in ./ instead of ./doc.
     396        (html): Target depend on html-recursive instead of make_1.html.
     397        (make_1.html): Removed.
     398        (mostlyclean-aminfo): Use $(srcdir)/doc instead of ./ as prefix.
     399        (all-recursive): Allow for more than one subdir in the build
     400        process.
     401        (mostlyclean-recursive, clean-recursive, distclean-recursive)
     402        (maintainer-clean-recursive, check-recursive): Enter in doc/ too.
     403        (tags-recursive): Allow for more than one subdir in the build
     404        process.
     405        (info-recursive, dvi-recursive, ps-recursive, html-recursive): New
     406        targets.  Enter into doc/ to produce the targets.
     407        (all-am): $(INFO_DEPS) replaced by info.
     408
     4092009-09-26  Paul Smith  <[email protected]>
     410
     411        * read.c (record_files): Use free_ns() to free struct nameseq.
     412        (eval): Ditto.
     413
     414        * rule.c (freerule): Use free_dep_chain().
     415
     416        * read.c (record_files): Free FILENAMES chain for implicit rules.
     417        (eval): Static pattern targets go into the string cache.
     418
     419        * function.c (string_glob): Free NAME in the nameseq chain.
     420
     4212009-09-25  Boris Kolpackov  <[email protected]>
     422
     423        * implicit.c (pattern_search): Terminate early if we haven't
     424        found any rules to try (performance improvement).
     425
     4262009-09-25  Boris Kolpackov  <[email protected]>
     427
     428        * implicit.c (pattern_search): Merge three parallel arrays,
     429        TRYRULES, MATCHES, and CHECKED_LASTSLASH, into one array
     430        of struct TRYRULE. In the old version the latter two arrays
     431        had insufficient length.
     432
     4332009-09-24  Paul Smith  <[email protected]>
     434
     435        * implicit.c (pattern_search): Add back support for order-only
     436        prerequisites for secondary expansion implicit rules, that were
     437        accidentally dropped.  If we find a "|", enable order-only mode
     438        and set IGNORE_MTIME on all deps that are seen afterward.
     439        (pattern_search): Fix memory leaks: for intermediate files where
     440        we've already set the file variable and pattern variable sets, be
     441        sure to either save or free them as appropriate.
     442
     4432009-09-23  Paul Smith  <[email protected]>
     444
     445        Rework the way secondary expansion is stored, for efficiency.
     446        This changes secondary expansion so that ONLY WHEN we know we have
     447        a possibility of needing secondary expansion, do we defer the
     448        secondary expansion.  This means more parsing the deps but we use
     449        a lot less memory (due to the strcache).  Also, this fixes
     450        Savannah bug #18622.
     451
     452        * read.c (eval): Don't parse the dep string here anymore.
     453        (record_files): Take the dep argument as an unparsed string.  If
     454        secondary expansion is enabled AND the prereq string has a '$' in
     455        it, then set NEED_2ND_EXPANSION and keep the entire string.
     456        Otherwise, parse the dep string here to construct the dep list
     457        with the names in the strcache.
     458
     459        * misc.c (copy_dep_chain): For NEED_2ND_EXPANSION, we need to
     460        duplicate the name string (others are in the strcache).
     461
     462        * implicit.c: Remove struct idep and free_idep_chain(): unused.
     463        (struct patdeps): New structure to store prereq information.
     464        (pattern_search): Use the NEED_2ND_EXPANSION flag to determine
     465        which prerequisites need expansion, and expand only those.
     466
     467        * file.c (split_prereqs): Break parse_prereqs() into two parts: this
     468        and enter_prereqs().  split_prereqs() takes a fully-expanded string
     469        and splits it into a DEP list, handling order-only prereqs.
     470        (enter_prereqs): This function enters a list of DEPs into the file
     471        database.  If there's a stem defined, expand any pattern chars.
     472        (expand_deps): Only try to expand DEPs which have NEED_2ND_EXPANSION
     473        set.  Use the above functions.
     474        (snap_deps): Only perform second expansion on prereqs that need it,
     475        as defined by the NEED_2ND_EXPANSION flag.
     476        (print_prereqs): New function to print the prereqs
     477        (print_file): Call print_prereqs() rather than print inline.
     478
     479        * hash.h (STRING_COMPARE): Take advantage of strcache() by
     480        comparing pointers.
     481        (STRING_N_COMPARE): Ditto.
     482        (ISTRING_COMPARE): Ditto.
     483
     484        * dep.h (PARSE_FILE_SEQ): New macro to reduce casts.
     485        (parse_file_seq): Return void*
     486        * read.c (parse_file_seq): Return void*.
     487        (eval): Invoke macroized version of parse_file_seq()
     488        * default.c (set_default_suffixes): Ditto.
     489        * file.c (split_prereqs): Ditto.
     490        * function.c (string_glob): Ditto.
     491        * main.c (main): Ditto.
     492        * rule.c (install_pattern_rule): Ditto.
     493
     494        * filedef.h: Add split_prereqs(), enter_prereqs(), etc.
     495
     4962009-09-16  Paul Smith  <[email protected]>
     497
     498        * misc.c (alloc_dep, free_dep): Now that we have xcalloc(),
     499        convert to macros.
     500        * dep.h: Create alloc_dep() / free_dep() macros.
     501
     502        * implicit.c (pattern_search): Take advantage of the new
     503        parse_file_seq() to add the directory prefix to each prereq.
     504
     505        * dep.h: Remove multi_glob() and enhance parse_file_seq() to do it
     506        all.  Avoid reversing chains.  Support adding prefixes.
     507        * read.c (parse_file_seq): Rewrite to support globbing.  Allow for
     508        cached/non-cached results.
     509        (eval): Remove multi_glob() & invoke new parse_file_seq().
     510        * rule.c (install_pattern_rule): Ditto.
     511        * main.c (main): Ditto.
     512        * implicit.c (pattern_search): Ditto.
     513        * function.c (string_glob): Ditto.
     514        * file.c (parse_prereqs): Ditto.
     515        * default.c (set_default_suffixes): Ditto.
     516
     517        * variable.c (parse_variable_definition): Don't run off the end of
     518        the string if it ends in whitespace (found with valgrind).
     519
     520        * commands.c (set_file_variables): Keep space for all targets in
     521        $? if -B is given (found with valgrind).
     522
     5232009-09-15  Paul Smith  <[email protected]>
     524
     525        * misc.c (concat): Make concat() variadic so it takes >3 arguments.
     526        (xcalloc): Add new function.
     527        * make.h: New declarations.
     528
     529        * ar.c (ar_glob_match): New calling method for concat().
     530        * main.c (main): Ditto.
     531        (decode_env_switches): Ditto.
     532        * read.c (eval_makefile): Ditto.
     533        (tilde_expand): Ditto.
     534        (parse_file_seq): Ditto.
     535        * variable.c (target_environment): Ditto.
     536        (sync_Path_environment): Ditto.
     537
     538        * ar.c (ar_glob_match): Use xcalloc().
     539        * dir.c (file_impossible): Ditto.
     540        * file.c (enter_file): Ditto.
     541        * job.c (new_job): Ditto.
     542        * read.c (parse_file_seq): Ditto.
     543        * vmsfunctions.c (opendir): Ditto.
     544
     5452009-09-14  Rafi Einstein  <[email protected]>  (tiny patch)
     546
     547        * w32/subproc/sub_proc.c (process_begin): Check *ep non-NULL
     548        inside the loop that looks up environment for PATH.
     549
     5502009-08-31  Eli Zaretskii  <[email protected]>
     551
     552        * function.c (windows32_openpipe): Update envp after calling
     553        sync_Path_environment.
     554
     5552009-08-02  Paul Smith  <[email protected]>
     556
     557        * remake.c (notice_finished_file): Ensure file->cmds is not null
     558        before looping through them.  Fixes Savannah bug #21824.
     559
     560        * doc/make.texi (Wildcard Examples): Clarify when objects is
     561        wildcard-expanded.  Fixes Savannah bug #24509.  Patch by Martin Dorey.
     562        (Include): Clarify the behavior of -include.
     563        Fixes Savannah bug #18963.
     564
     5652009-08-01  Paul Smith  <[email protected]>
     566
     567        * doc/make.texi (Catalogue of Rules): Clarify where -c, -F,
     568        etc. come on the command line.  Fixes Savannah bug #27093.
     569
     570        * expand.c (expand_argument): If the argument is large enough use
     571        xmalloc() instead of alloca().  Fixes Savannah bug #27143.
     572
     573        * variable.c (do_variable_definition): Avoid using alloca() to
     574        hold values, which can be large.  Fixes Savannah bug #23960.
     575
     576        * job.c (new_job): Use memmove() instead of strcpy() since both
     577        pointers are in the same memory block.  Fixes Savannah bug #27148.
     578        Patch by Petr Machata.
     579
     5802009-07-29  Ralf Wildenhues  <[email protected]>
     581
     582        * job.c (construct_command_argv_internal): Add "ulimit" and
     583        "unset" to the sh_cmds for Unixy shells.
     584
     5852009-07-29  Ralf Wildenhues  <[email protected]>
     586
     587        * configure.in: Move side-effects outside AC_CACHE_VAL arguments
     588        that set make_cv_sys_gnu_glob, so they are also correctly set
     589        when the cache has been populated before.
     590
     5912009-07-04  Eli Zaretskii  <[email protected]>
     592
     593        * function.c (func_realpath) [!HAVE_REALPATH]: Require the file to
     594        exist, as realpath(3) does where it's supported.
     595
     5962006-07-04  Eli Zaretskii  <[email protected]>
     597
     598        * function.c (IS_ABSOLUTE, ROOT_LEN): New macros.
     599        (abspath): Support systems that define HAVE_DOS_PATHS (have
     600        drive letters in their file names).  Use IS_PATHSEP instead of a
     601        literal '/' comparison.  Fixes Savannah bug #26886.
     602
     6032009-06-14  Paul Smith  <[email protected]>
     604
     605        * remake.c (update_file_1): Remember the original file we marked
     606        as updating, so we can clear that flag again.  If we find a target
     607        via vpath, FILE might change.
     608        (check_dep): Ditto.  Fixes Savannah bug #13529.
     609        Patch by Reid Madsen <[email protected]>.
     610
     6112009-06-13  Paul Smith  <[email protected]>
     612
     613        * doc/make.texi (MAKEFILES Variable): Be explicit that files
     614        included by MAKEFILES cannot give default goals.
     615        * read.c (eval): If set_default is not set, pass the no-default-goal
     616        value when we read included makefiles.  Fixes Savannah bug #13401.
     617
     618        * ar.c (ar_name): Ensure that targets with empty parens aren't
     619        considered archive member references: archive members must have a
     620        non-empty "member" string.  Fixes Savannah bug #18435.
     621
     622        * function.c (string_glob): Rely on multi_glob() to determine
     623        whether files exist or not.  Remove call to file_exists_p() which
     624        is not always correct.  Fixes Savannah bug #21231.
     625        * read.c (multi_glob): Add a new argument EXISTS_ONLY; if true
     626        then only files that really exist will be returned.
     627        * dep.h: Add new argument to multi_glob().
     628        * rule.c (install_pattern_rule): Ditto.
     629        * read.c (eval): Ditto.
     630        * main.c (main): Ditto.
     631        * implicit.c (pattern_search): Ditto.
     632        * file.c (parse_prereqs): Ditto.
     633        * default.c (set_default_suffixes): Ditto.
     634
     6352009-06-09  Paul Smith  <[email protected]>
     636
     637        * commands.c (set_file_variables): If always_make_flag is set,
     638        always add the prereq to $?.  Fixes Savannah bug #17825.
     639
     640        * remake.c (update_file_1): When rebuilding deps of FILE, also try
     641        to rebuild the deps of all the also_make targets for that file.
     642        Fixes Savannah bug #19108.
     643
     644        * implicit.c (pattern_search): Undo test for is_target, added by
     645        BorisK on 21 Sep 2004.  This goes against step 5c in the "Implicit
     646        Rule Search Algorithm".  Fixes Savannah bug #17752.
     647
     648        * main.c (clean_jobserver): Clear the jobserver_fds options and
     649        set job_slots to the default when we clean up.
     650        (define_makeflags): Return the new MAKEFLAGS value.
     651        (main): Reset MAKEFLAGS in the environment when we re-exec.
     652        Fixes Savannah bug #18124.
     653
     6542009-06-08  Paul Smith  <[email protected]>
     655
     656        * read.c (eval): Collapse continuations post-semicolon on target-
     657        specific variables.  Fixes Savannah bug #17521.
     658
     6592009-06-07  Paul Smith  <[email protected]>
     660
     661        * job.c (reap_children): For older systems without waitpid() (are
     662        there any of these left?) run wait(2) inside EINTRLOOP to handle
     663        EINTR errors.  Fixes Savannah bug #16401.
     664
     665        * (various): Debug message cleanup.  Fixes Savannah bug #16469.
     666
     667        * main.c: Fix bsd_signal() typedef.  Fixes Savannah bug #16473.
     668
     669        * file.c (snap_deps): Set SNAPPED_DEPS at the start of snapping,
     670        not the end, to catch second expansion $(eval ...) defining new
     671        target/prereq relationships during snap_deps.
     672        Fixes Savannah bug #24622.
     673
     674        * read.c (record_files): The second-expansion "f->updating" hack
     675        was not completely correct: if assumed that the target with
     676        commands always had prerequisites; if one didn't then the ordering
     677        was messed up.  Fixed for now to use f->updating to decide whether
     678        to preserve the last element in the deps list... but this whole
     679        area of constructing and reversing the deps list is too confusing
     680        and needs to be reworked.  Fixes Savannah bug #21198.
     681
     6822009-06-06  Paul Smith  <[email protected]>
     683
     684        * hash.c (hash_insert): Remove useless test for NULL.
     685        Fixes Savannah bug #21823.
     686
     687        * make.h: Move SET_STACK_SIZE determination to make.h.
     688        * main.c (main): New global variable, STACK_LIMIT, holds the
     689        original stack limit when make was started.
     690        * job.c (start_job_command): Reset the stack limit, if we changed it.
     691        Fixes Savannah bug #22010.
     692
     693        * remake.c (check_dep): Only set the target's state to not-started
     694        if it's not already running.  Found this while testing -j10 builds
     695        of glibc: various targets were being rebuilt multiple times.
     696        Fix from Knut St. Osmundsen; fixes a problem reported in Savannah
     697        bug #15919.
     698
     699        * read.c (multi_glob): Don't pass GLOB_NOCHECK to glob(3); instead
     700        handle the GLOB_NOMATCH error.  This is to work around Sourceware.org
     701        Bugzilla bug 10246.
     702
     7032009-06-04  Paul Smith  <[email protected]>
     704
     705        * read.c (eval): Skip initial whitespace (ffeed, vtab, etc.)
     706
     707        * maintMakefile: Modify access of config and gnulib Savannah
     708        modules to use GIT instead of CVS.
     709
     710        * main.c (main): Initialize the LENGTH field in SHELL_VAR.
     711        Fixes Savannah bug #24655.
     712
     713        * read.c (eval_buffer): Don't dereference reading_file if it's NULL;
     714        this can happen during some invocations of $(eval ...) for example.
     715        Fixes Savannah bug #24588.  Patch by Lars Jessen <[email protected]>
     716
     7172009-06-02  Paul Smith  <[email protected]>
     718
     719        * configure.in: Check for fileno()
     720        * read.c (eval_makefile): If fileno() is available, set CLOSE_ON_EXEC
     721        for the makefile file so invocations of $(shell ...) don't inherit it.
     722        Fixes Savannah bug #24277.
     723
     7242009-06-01  Paul Smith  <[email protected]>
     725
     726        * main.c (main): The previous fix for .DEFAULT_GOAL had issues;
     727        expansion was handled incorrectly.  Rework the default goal
     728        handling to save the variable only.  Remove default_goal_file and
     729        default_goal_name.
     730        * read.c (eval): Check default_goal_var, not default_goal_name.
     731        * read.c (record_target_var): Don't check default_goal_file here.
     732
     7332009-05-31  Paul Smith  <[email protected]>
     734
     735        * main.c (main): Expand the .DEFAULT_GOAL variable before using
     736        it, and if the multi_glob() returns nothing (say it expanded to
     737        nothing but spaces) then don't crash.  Fixes Savannah bug #25697.
     738
     739        * doc/make.texi (Quick Reference): Add $(if ..), $(or ..), and
     740        $(and ..) to the reference.  Fixes Savannah bug #25694.
     741
     742        * make.1: Be clear that some recipes will be executed even with -n.
     743        * doc/make.texi: Ditto.  Fixes Savannah bug #25460.
     744
     745        * doc/make.texi (Override Directive): Make more clear how
     746        overrides and appends interact.
     747        Elucidates part of Savannah bug #26207.
     748
     749        * read.c (record_target_var): Don't reset the origin on
     750        target-specific variables; try_variable_definition() will handle
     751        this correctly.  Fixes Savannah bug #26207.
     752
     753        * maintMakefile (do-po-update): Copy PO files into $(top_srcdir).
     754        Fixes Savannah bug #25712.
     755
     756        * implicit.c (pattern_search): Keep a pointer to the beginning of
     757        the filename and save that instead of the constructed pointer.
     758        Fixes Savannah bug #26593.
     759        Patch by Mark Seaborn <[email protected]>
     760
     7612009-05-30  Paul Smith  <[email protected]>
     762
     763        * doc/make.texi (Multi-Line): Add a description of the new abilities
     764        of define/endef.  Rename "Sequences" to "Multi-Line" and fix some
     765        "command sequence" vs. "recipe" syntax.
     766        * read.c (do_define): Modify to allow assignment tokens (=, :=, etc.)
     767        after a define, to create variables with those flavors.
     768
     7692009-05-25  Paul Smith  <[email protected]>
     770
     771        Reworked the parser for variable assignments to allow multiple
     772        modifiers, and in any order.  Also allows variable and
     773        prerequisites to be modifier names ('export', 'private', etc.)
     774
     775        * NEWS: Add notes about user-visible changes.
     776
     777        * read.c (struct vmodifiers): Remember what modifiers were seen.
     778        (parse_var_assignment): New function to parse variable assignments.
     779        (eval): Call the new function.  Handle variable assignments earlier.
     780
     781        * variable.c (parse_variable_definition): Only parse; don't create var.
     782        (assign_variable_definition): Call parse, then create the var.
     783
     7842009-05-24  Paul Smith  <[email protected]>
     785
     786        * doc/make.texi: Fix the ISBN for the GNU make manual.  Incorrect
     787        value noticed by Hans Stol <[email protected]>.
     788
     7892009-03-14  Eli Zaretskii  <[email protected]>
     790
     791        * w32/pathstuff.c (convert_Path_to_windows32): Fix last change.
     792        Fixes Savannah bug #25412.
     793
     794        * w32/subproc/sub_proc.c <top level>: Update Copyright years.  Add
     795        prototype for xmalloc.
     796        (find_file): Accept 3 arguments PATH_VAR, FULL_FNAME, and FULL_LEN
     797        instead of an LPOFSTRUCT pointer.  Use xmalloc instead of malloc.
     798        Loop over an array of extensions, instead of duplicating the same
     799        code inline.  Use SearchPath followed by CreateFile, instead of
     800        the obsolete OpenFile.  Fixes Savannah bug #17277.
     801        (process_begin): Find $(PATH) in `envp', and pass a pointer to it
     802        to `find_file'.  Fixes Savannah bug #25662.
     803
     8042009-03-07  Eli Zaretskii  <[email protected]>
     805
     806        * function.c (func_shell): Don't close pipedes[1] if it is -1.
     807        Fixes Savannah bug #20495.
     808
     8092009-02-28  Ralf Wildenhues  <address@hidden>
     810
     811        * doc/make.texi (Instead of Execution): Document interaction of
     812        -t with phony targets.
     813
     8142009-02-23  Ramon Garcia  <[email protected]>
     815
     816        Introduce a new keyword "private" which applies to target-specific
     817        variables and prevents their values from being inherited.
     818
     819        * variable.h (struct variable): Add private_var flag to each variable.
     820        Add a flag to specify which list entry switches to the parent target.
     821        * variable.c (define_variable_in_set): Initialize private_var flag.
     822        (lookup_variable): Skip private variables in parent contexts.
     823        (initialize_file_variables): Set next_is_parent appropriately.
     824        (print_variable): Show the private_var flag.
     825        * read.c (eval): Recognize the private keyword.
     826        (record_target_var): Set private_var.
     827        * doc/make.texi (Suppressing Inheritance): Add documentation.
     828
     8292008-10-26  Paul Smith  <[email protected]>
     830
     831        * configure.in: Check for strndup().
     832        * misc.c (xstrndup): Rename savestring to xstrndup.  Use strndup
     833        if it's available.
     834        * make.h: Rename savestring to xstrndup.
     835        * commands.c (chop_commands): Ditto.
     836        * function.c (func_foreach): Ditto.
     837        * read.c (eval, record_files): Ditto.
     838        * variable.c (define_variable_in_set): Ditto.
     839
    18402008-09-30  Eli Zaretskii  <[email protected]>
    2841
     
    8161655
    8171656        * make.1: Fix some display errors and document all existing options.
    818         Patch provided by Mike Frysinger <[email protected]>.
     1657        Patch by Mike Frysinger <[email protected]>.
    8191658
    82016592005-12-11  Paul D. Smith  <[email protected]>
     
    31644003
    31654004
    3166 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    3167 Foundation, Inc.
     4005Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
     4006Software Foundation, Inc.
    31684007This file is part of GNU Make.
    31694008
  • trunk/src/kmk/ChangeLog.1

    r1993 r2591  
    49844984
    49854985Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    4986 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation,
    4987 Inc.
     49861998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 Free
     4987Software Foundation, Inc.
    49884988This file is part of GNU Make.
    49894989
  • trunk/src/kmk/Makefile.DOS.template

    r1993 r2591  
    33#
    44# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
    5 # 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     5# 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    66# This file is part of GNU Make.
    77#
     
    8686man_MANS =      make.1
    8787
    88 INCLUDES =      -I$(srcdir)/glob -DLIBDIR=\"c:/djgpp/lib\" -DINCLUDEDIR=\"c:/djgpp/include\" -DLOCALEDIR=\"$(localedir)\"
     88INCLUDES =      -I$(srcdir)/glob -DLIBDIR=\"$(prefix)$(libdir)\" -DINCLUDEDIR=\"$(prefix)$(includedir)\" -DLOCALEDIR=\"$(prefix)$(localedir)\"
    8989
    9090BUILT_SOURCES = README build.sh-in
     
    9292EXTRA_DIST =    $(BUILT_SOURCES) $(man_MANS) README.customs remote-cstms.c  make-stds.texi texinfo.tex SCOPTIONS SMakefile  Makefile.ami README.Amiga config.ami amiga.c amiga.h  NMakefile README.DOS configh.dos configure.bat makefile.com  README.W32 build_w32.bat config.h-W32 subproc.bat make.lnk  config.h-vms makefile.vms readme.vms vmsdir.h vmsfunctions.c  vmsify.c
    9393
    94 SUBDIRS =       glob
     94SUBDIRS =       glob doc
    9595mkinstalldirs = ${exec_prefix}/bin/gmkdir -p
    9696CONFIG_HEADER = config.h
     
    116116TEXI2DVI = texi2dvi
    117117TEXINFO_TEX = $(srcdir)/config/texinfo.tex
    118 INFO_DEPS = make.info
    119 DVIS = make.dvi
     118INFO_DEPS = doc/make.info
     119DVIS = doc/make.dvi
    120120TEXINFOS = doc/make.texi
    121121noinst_TEXINFOS = doc/fdl.texi doc/make-stds.texi
    122122man1dir = $(mandir)/man1
    123123MANS = $(man_MANS)
    124 
    125 TEXI2HTML = texi2html
    126 TEXI2HTML_FLAGS = -split_chapter
    127124
    128125NROFF = nroff
     
    192189# Documentation
    193190
    194 make.info: doc/make.texi
    195 make.dvi: doc/make.texi
     191make.info: make.texi
     192make.dvi: make.texi
     193make.ps: make.dvi make.texi
     194make.html: make.texi
    196195
    197196
     
    201200        @command.com /c if exist make.info* del make.info*
    202201        @command.com /c if exist make.i* del make.i*
    203         $(MAKEINFO) -I$(srcdir)/doc --no-split $< -o ./$@
     202        $(MAKEINFO) -I$(srcdir) --no-split $< -o ./$@
    204203
    205204.texi:
    206205        @command.com /c if exist make.info* del make.info*
    207206        @command.com /c if exist make.i* del make.i*
    208         $(MAKEINFO) -I$(srcdir)/doc --no-split $< -o ./$@
     207        $(MAKEINFO) -I$(srcdir) --no-split $< -o ./$@
    209208
    210209.texi.dvi:
    211         TEXINPUTS="$(srcdir)/doc;$$TEXINPUTS"    MAKEINFO='$(MAKEINFO) -I $(srcdir)/doc' $(TEXI2DVI) $<
     210        TEXINPUTS="$(srcdir);$$TEXINPUTS"    MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
    212211
    213212.dvi.ps:
     
    216215# Other documentation formats
    217216
    218 html: make_1.html
    219 
    220 make_1.html: $(TEXINFOS) $(noinst_TEXINFOS)
    221         $(TEXI2HTML) $(TEXI2HTML_FLAGS) $(srcdir)/doc/make.texi
     217html: html-recursive
     218
     219.texi.html:
     220        @command.com /c if exist make.html* del make.html*
     221        $(MAKEINFO) --html -I$(srcdir) --no-split $< -o ./$@
    222222
    223223install-info-am: $(INFO_DEPS)
    224224        @$(NORMAL_INSTALL)
    225225        $(mkinstalldirs) $(DESTDIR)$(infodir)
    226         @for file in $(INFO_DEPS); do    d=$(srcdir);    for ifile in `cd $$d && echo $$file`; do      if test -f $$d/$$ifile; then        echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; else : ; fi;    done;  done
     226        @for file in $(INFO_DEPS); do    iifile=`echo $$file | sed "s|doc/||"`;    d=$(srcdir);    for ifile in `cd $$d && echo $$file`; do      if test -f $$d/$$ifile; then        echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$iifile"; $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$iifile; else : ; fi;    done;  done
    227227        @$(POST_INSTALL)
    228         @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then    for file in $(INFO_DEPS); do      echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";     install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;   done;  else : ; fi
     228        @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then    for file in $(INFO_DEPS); do    iifile=`echo $$file | sed "s|doc/||"`;      echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$iifile";     install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$iifile || :;   done;  else : ; fi
    229229
    230230uninstall-info:
     
    238238
    239239mostlyclean-aminfo:
    240         -rm -f make.aux make.cp make.cps make.dvi make.fn make.fns make.ky \
    241           make.kys make.ps make.log make.pg make.toc make.tp make.tps \
    242           make.vr make.vrs make.op make.tr make.cv make.cn
     240        -rm -f $(srcdir)/doc/make.aux $(srcdir)/doc/make.cp $(srcdir)/doc/make.cps $(srcdir)/doc/make.dvi \
     241          $(srcdir)/doc/make.fn $(srcdir)/doc/make.fns $(srcdir)/doc/make.ky $(srcdir)/doc/make.kys \
     242          $(srcdir)/doc/make.ps $(srcdir)/doc/make.log $(srcdir)/doc/make.pg $(srcdir)/doc/make.toc \
     243          $(srcdir)/doc/make.tp $(srcdir)/doc/make.tps $(srcdir)/doc/make.vr $(srcdir)/doc/make.vrs \
     244          $(srcdir)/doc/make.op $(srcdir)/doc/make.tr $(srcdir)/doc/make.cv $(srcdir)/doc/make.cn \
     245          $(srcdir)/doc/make.html
    243246
    244247clean-aminfo:
     
    292295# a single directory, yell bloody murder.
    293296all-recursive:
    294 ifeq ($(words $(SUBDIRS)), 1)
     297ifeq ($(findstring glob, $(SUBDIRS)), glob)
    295298        @command.com /c if not exist glob\\nul md glob
    296         @echo Making all in $(SUBDIRS)
    297         $(MAKE) -C $(SUBDIRS) -f ../Makefile INCLUDES='-I$(srcdir) -I$(srcdir)/glob' DEFS='-I.. -I$(srcdir)' VPATH=$(srcdir)/glob libglob.a
    298 else
    299         @echo FATAL: There is more than one directory in "($(SUBDIRS))"
    300         @$(EXIT_FAIL)
     299        @echo Making all in glob
     300        $(MAKE) -C glob -f ../Makefile INCLUDES='-I$(srcdir) -I$(srcdir)/glob' DEFS='-I.. -I$(srcdir)' VPATH=$(srcdir)/glob libglob.a
    301301endif
    302302
     
    311311mostlyclean-recursive clean-recursive distclean-recursive \
    312312maintainer-clean-recursive check-recursive:
    313 ifeq ($(words $(SUBDIRS)), 1)
    314         @echo Making $(shell echo $@ | sed s/-recursive//) in $(SUBDIRS)
    315         $(MAKE) -C $(SUBDIRS) -f ../Makefile $(shell echo $@ | sed s/-recursive//)-am
     313ifeq ($(words $(SUBDIRS)), 2)
     314        @echo Making $(shell echo $@ | sed s/-recursive//) in glob
     315        $(MAKE) -C glob -f ../Makefile $(shell echo $@ | sed s/-recursive//)-am
     316        @echo Making $(shell echo $@ | sed s/-recursive//) in doc
     317        $(MAKE) -C doc -f ../Makefile $(shell echo $@ | sed s/-recursive//)-am
    316318else
    317         @echo FATAL: There is more than one directory in "($(SUBDIRS))"
     319        @echo FATAL: There is more than two directory in "($(SUBDIRS))"
    318320        @$(EXIT_FAIL)
    319321endif
     
    323325
    324326tags-recursive:
    325 ifeq ($(words $(SUBDIRS)), 1)
     327ifeq ($(words $(SUBDIRS)), 2)
    326328        $(MAKE) tags-in-glob
    327329else
    328         @echo FATAL: There is more than one directory in "($(SUBDIRS))"
     330        @echo FATAL: There is more than two directory in "($(SUBDIRS))"
    329331        @$(EXIT_FAIL)
    330332endif
     
    377379        $(MAKE) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook
    378380
    379 info: $(INFO_DEPS) info-recursive
    380 dvi: $(DVIS) dvi-recursive
     381info: info-recursive
     382info-recursive:
     383ifeq ($(findstring doc, $(SUBDIRS)), doc)
     384        @command.com /c if not exist doc\\nul md doc
     385        @echo Making all in doc
     386        $(MAKE) -C doc -f ../Makefile VPATH=$(srcdir)/doc make.info
     387endif
     388
     389dvi: dvi-recursive
     390dvi-recursive:
     391ifeq ($(findstring doc, $(SUBDIRS)), doc)
     392        @command.com /c if not exist doc\\nul md doc
     393        @echo Making all in doc
     394        $(MAKE) -C doc -f ../Makefile VPATH=$(srcdir)/doc make.dvi
     395endif
     396
     397ps: ps-recursive
     398ps-recursive:
     399ifeq ($(findstring doc, $(SUBDIRS)), doc)
     400        @command.com /c if not exist doc\\nul md doc
     401        @echo Making all in doc
     402        $(MAKE) -C doc -f ../Makefile VPATH=$(srcdir)/doc make.ps
     403endif
     404
     405html-recursive:
     406ifeq ($(findstring doc, $(SUBDIRS)), doc)
     407        @command.com /c if not exist doc\\nul md doc
     408        @echo Making all in doc
     409        $(MAKE) -C doc -f ../Makefile VPATH=$(srcdir)/doc make.html
     410endif
     411
    381412check: all-am check-recursive check-local
    382413        @:
     
    385416        $(MAKE) all-recursive
    386417
    387 all-am: Makefile $(INFO_DEPS) $(PROGRAMS) config.h
     418all-am: Makefile $(PROGRAMS) config.h info
    388419
    389420install-exec-am: install-binPROGRAMS
  • trunk/src/kmk/Makefile.am

    r2548 r2591  
    22#
    33# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    4 # 2007 Free Software Foundation, Inc.
     4# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    55# This file is part of GNU Make.
    66#
  • trunk/src/kmk/Makefile.ami

    r1993 r2591  
    55#
    66# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    7 # 2005, 2006, 2007 Free Software Foundation, Inc.
     7# 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    88# This file is part of GNU Make.
    99#
  • trunk/src/kmk/NEWS

    r1993 r2591  
    11GNU make NEWS                                               -*-indented-text-*-
    22  History of user-visible changes.
    3   1 April 2006
     3  28 July 2010
    44
    55See the end of this file for copyrights and conditions.
     
    1111
    1212
    13 Version 3.81.90
     13Version 3.82
     14
     15A complete list of bugs fixed in this version is available here:
     16
     17http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=104&set=custom
    1418
    1519* Compiling GNU make now requires a conforming ISO C 1989 compiler and
    1620  standard runtime library.
     21
     22* WARNING: Future backward-incompatibility!
     23  Wildcards are not documented as returning sorted values, but up to and
     24  including this release the results have been sorted and some makefiles are
     25  apparently depending on that.  In the next release of GNU make, for
     26  performance reasons, we may remove that sorting.  If your makefiles
     27  require sorted results from wildcard expansions, use the $(sort ...)
     28  function to request it explicitly.
     29
     30* WARNING: Backward-incompatibility!
     31  The POSIX standard for make was changed in the 2008 version in a
     32  fundamentally incompatible way: make is required to invoke the shell as if
     33  the '-e' flag were provided.  Because this would break many makefiles that
     34  have been written to conform to the original text of the standard, the
     35  default behavior of GNU make remains to invoke the shell with simply '-c'.
     36  However, any makefile specifying the .POSIX special target will follow the
     37  new POSIX standard and pass '-e' to the shell.  See also .SHELLFLAGS
     38  below.
     39
     40* WARNING: Backward-incompatibility!
     41  The '$?' variable now contains all prerequisites that caused the target to
     42  be considered out of date, even if they do not exist (previously only
     43  existing targets were provided in $?).
     44
     45* WARNING: Backward-incompatibility!
     46  As a result of parser enhancements, three backward-compatibility issues
     47  exist: first, a prerequisite containing an "=" cannot be escaped with a
     48  backslash any longer.  You must create a variable containing an "=" and
     49  use that variable in the prerequisite.  Second, variable names can no
     50  longer contain whitespace, unless you put the whitespace in a variable and
     51  use the variable.  Third, in previous versions of make it was sometimes
     52  not flagged as an error for explicit and pattern targets to appear in the
     53  same rule.  Now this is always reported as an error.
     54
     55* WARNING: Backward-incompatibility!
     56  The pattern-specific variables and pattern rules are now applied in the
     57  shortest stem first order instead of the definition order (variables
     58  and rules with the same stem length are still applied in the definition
     59  order). This produces the usually-desired behavior where more specific
     60  patterns are preferred. To detect this feature search for 'shortest-stem'
     61  in the .FEATURES special variable.
     62
     63* WARNING: Backward-incompatibility!
     64  The library search behavior has changed to be compatible with the standard
     65  linker behavior. Prior to this version for prerequisites specified using
     66  the -lfoo syntax make first searched for libfoo.so in the current
     67  directory, vpath directories, and system directories. If that didn't yield
     68  a match, make then searched for libfoo.a in these directories. Starting
     69  with this version make searches first for libfoo.so and then for libfoo.a
     70  in each of these directories in order.
     71
     72* New command line option: --eval=STRING causes STRING to be evaluated as
     73  makefile syntax (akin to using the $(eval ...) function).  The evaluation
     74  is performed after all default rules and variables are defined, but before
     75  any makefiles are read.
    1776
    1877* New special variable: .RECIPEPREFIX allows you to reset the recipe
    1978  introduction character from the default (TAB) to something else.  The
    2079  first character of this variable value is the new recipe introduction
    21   character.  If the variable is set to the empty string, TAB is used
    22   again.  It can be set and reset at will; rules will be parsed
    23   according to the current value.
     80  character.  If the variable is set to the empty string, TAB is used again.
     81  It can be set and reset at will; recipes will use the value active when
     82  they were first parsed.  To detect this feature check the value of
     83  $(.RECIPEPREFIX).
     84
     85* New special variable: .SHELLFLAGS allows you to change the options passed
     86  to the shell when it invokes recipes.  By default the value will be "-c"
     87  (or "-ec" if .POSIX is set).
     88
     89* New special target: .ONESHELL instructs make to invoke a single instance
     90  of the shell and provide it with the entire recipe, regardless of how many
     91  lines it contains.  As a special feature to allow more straightforward
     92  conversion of makefiles to use .ONESHELL, any recipe line control
     93  characters ('@', '+', or '-') will be removed from the second and
     94  subsequent recipe lines.  This happens _only_ if the SHELL value is deemed
     95  to be a standard POSIX-style shell.  If not, then no interior line control
     96  characters are removed (as they may be part of the scripting language used
     97  with the alternate SHELL).
     98
     99* New variable modifier 'private': prefixing a variable assignment with the
     100  modifier 'private' suppresses inheritance of that variable by
     101  prerequisites.  This is most useful for target- and pattern-specific
     102  variables.
     103
     104* New make directive: 'undefine' allows you to undefine a variable so that
     105  it appears as if it was never set. Both $(flavor) and $(origin) functions
     106  will return 'undefined' for such a variable. To detect this feature search
     107  for 'undefine' in the .FEATURES special variable.
     108
     109* The parser for variable assignments has been enhanced to allow multiple
     110  modifiers ('export', 'override', 'private') on the same line as variables,
     111  including define/endef variables, and in any order.  Also, it is possible
     112  to create variables and targets named as these modifiers.
     113
     114* The 'define' make directive now allows a variable assignment operator
     115  after the variable name, to allow for simple, conditional, or appending
     116  multi-line variable assignment.
    24117
    25118
     
    60153
    61154* WARNING: Backward-incompatibility!
    62 
    63155  In order to comply with POSIX, the way in which GNU make processes
    64156  backslash-newline sequences in recipes has changed.  If your makefiles
     
    10591151-------------------------------------------------------------------------------
    10601152Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    1061 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    1062 Foundation, Inc.
    1063 This file is part of GNU Make.
     11531998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     11542010 Free Software Foundation, Inc.  This file is part of GNU Make.
    10641155
    10651156GNU Make is free software; you can redistribute it and/or modify it under the
  • trunk/src/kmk/NMakefile.template

    r1993 r2591  
    55#
    66# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    7 # 2006, 2007 Free Software Foundation, Inc.
     7# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    88# This file is part of GNU Make.
    99#
     
    3434
    3535LDFLAGS_debug = w32\subproc\WinDebug\subproc.lib /NOLOGO /SUBSYSTEM:console\
    36         /INCREMENTAL:no /PDB:WinDebug/make.pdb /MACHINE:I386 \
    37         /OUT:WinDebug/make.exe /DEBUG
     36        /INCREMENTAL:no /PDB:WinDebug/make.pdb /OUT:WinDebug/make.exe /DEBUG
    3837LDFLAGS_release = w32\subproc\WinRel\subproc.lib /NOLOGO /SUBSYSTEM:console\
    39         /INCREMENTAL:no /MACHINE:I386 /OUT:WinRel/make.exe
     38        /INCREMENTAL:no /OUT:WinRel/make.exe
    4039
    4140all: config.h subproc Release Debug
  • trunk/src/kmk/README.Amiga

    r1993 r2591  
    6464-------------------------------------------------------------------------------
    6565Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    66 2005, 2006, 2007 Free Software Foundation, Inc.
     662005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    6767This file is part of GNU Make.
    6868
  • trunk/src/kmk/README.DOS.template

    r1993 r2591  
    327327-------------------------------------------------------------------------------
    328328Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    329 2006, 2007 Free Software Foundation, Inc.
     3292006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    330330This file is part of GNU Make.
    331331
  • trunk/src/kmk/README.OS2.template

    r1993 r2591  
    162162
    163163-------------------------------------------------------------------------------
    164 Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     164Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
     165Foundation, Inc.
    165166This file is part of GNU Make.
    166167
  • trunk/src/kmk/README.W32.template

    r1993 r2591  
    275275-------------------------------------------------------------------------------
    276276Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    277 2006, 2007, 2008 Free Software Foundation, Inc.
     2772006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    278278This file is part of GNU Make.
    279279
  • trunk/src/kmk/README.customs

    r1993 r2591  
    9898
    9999-------------------------------------------------------------------------------
    100 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free
    101 Software Foundation, Inc.
     100Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
     1012009, 2010 Free Software Foundation, Inc.
    102102This file is part of GNU Make.
    103103
  • trunk/src/kmk/README.cvs

    r1993 r2591  
    22
    33-------------------------------------------------------------------------------
    4 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    5 This file is part of GNU Make.
     4Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
     5Software Foundation, Inc.  This file is part of GNU Make.
    66
    77GNU Make is free software; you can redistribute it and/or modify it under the
     
    211211make check
    212212
     213Or, for a debugging version:
     214
     215autoreconf -i && ./configure CFLAGS=-g && make update && make && make check
     216
    213217Or, all-in-one:
    214218
  • trunk/src/kmk/README.template

    r1993 r2591  
    174174-------------------------------------------------------------------------------
    175175Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    176 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    177 Foundation, Inc.
     1761998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     1772010 Free Software Foundation, Inc.
    178178This file is part of GNU Make.
    179179
  • trunk/src/kmk/SMakefile.template

    r1993 r2591  
    55#
    66# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    7 # 2005, 2006, 2007 Free Software Foundation, Inc.
     7# 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    88# This file is part of GNU Make.
    99#
  • trunk/src/kmk/TODO.private

    r1993 r2591  
    6666
    6767 3) Multi-token pattern rule matching (allow %1/%2.c : %1/obj/%2.o,
    68     etc., or something like that).  I have an implementation of this
    69     already, it just needs some refinement... maybe.  Additionally I
    70     think it only works for static pattern rules; it might need to be
    71     fixed up to work with normal pattern rules, too.
     68    etc., or something like that).  Maybe using regex?
    7269
    7370 4) Provide a .TARGETS variable, containing the names of the targets
     
    130127
    131128-------------------------------------------------------------------------------
    132 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    133 Free Software Foundation, Inc.
     129Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
     1302007, 2008, 2009, 2010 Free Software Foundation, Inc.
    134131This file is part of GNU Make.
    135132
  • trunk/src/kmk/acinclude.m4

    r1993 r2591  
    22dnl
    33dnl Automake will incorporate this into its generated aclocal.m4.
    4 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    5 dnl Free Software Foundation, Inc.
     4dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
     5dnl 2008, 2009, 2010 Free Software Foundation, Inc.
    66dnl This file is part of GNU Make.
    77dnl
  • trunk/src/kmk/amiga.c

    r1993 r2591  
    11/* Running commands on Amiga
    22Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    3 2005, 2006, 2007 Free Software Foundation, Inc.
     32005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/amiga.h

    r1993 r2591  
    11/* Definitions for amiga specific things
    22Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    3 2005, 2006, 2007 Free Software Foundation, Inc.
     32005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/ar.c

    r1993 r2591  
    11/* Interface to `ar' archives for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
     5
    56This file is part of GNU Make.
    67
     
    2526#include <fnmatch.h>
    2627
    27 /* Return nonzero if NAME is an archive-member reference, zero if not.
    28    An archive-member reference is a name like `lib(member)'.
     28/* Return nonzero if NAME is an archive-member reference, zero if not.  An
     29   archive-member reference is a name like `lib(member)' where member is a
     30   non-empty string.
    2931   If a name like `lib((entry))' is used, a fatal error is signaled at
    3032   the attempt to use this unsupported feature.  */
     
    4042
    4143  end = p + strlen (p) - 1;
    42   if (*end != ')')
     44  if (*end != ')' || end == p + 1)
    4345    return 0;
    4446
     
    199201    {
    200202      /* We have a match.  Add it to the chain.  */
    201       struct nameseq *new = xmalloc (state->size);
    202       memset (new, '\0', state->size);
    203       new->name = strcache_add (concat (state->arname, mem, ")"));
     203      struct nameseq *new = xcalloc (state->size);
     204      new->name = strcache_add (concat (4, state->arname, "(", mem, ")"));
    204205      new->next = state->chain;
    205206      state->chain = new;
     
    216217{
    217218  const char *p;
    218   int open = 0;
     219  int opened = 0;
    219220
    220221  for (p = pattern; *p != '\0'; ++p)
     
    231232
    232233      case '[':
    233         open = 1;
     234        opened = 1;
    234235        break;
    235236
    236237      case ']':
    237         if (open)
     238        if (opened)
    238239          return 1;
    239240        break;
     
    252253  struct nameseq *n;
    253254  const char **names;
    254   char *name;
    255255  unsigned int i;
    256256
     
    260260  /* Scan the archive for matches.
    261261     ar_glob_match will accumulate them in STATE.chain.  */
    262   i = strlen (arname);
    263   name = alloca (i + 2);
    264   memcpy (name, arname, i);
    265   name[i] = '(';
    266   name[i + 1] = '\0';
    267   state.arname = name;
     262  state.arname = arname;
    268263  state.pattern = member_pattern;
    269264  state.size = size;
     
    282277
    283278  /* Sort them alphabetically.  */
    284   qsort (names, i, sizeof (*names), alpha_compare);
     279  /* MSVC erroneously warns without a cast here.  */
     280  qsort ((void *)names, i, sizeof (*names), alpha_compare);
    285281
    286282  /* Put them back into the chain in the sorted order.  */
  • trunk/src/kmk/arscan.c

    r2546 r2591  
    11/* Library function for scanning an archive file.
    22Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    6767  if (! (status & 1))
    6868    {
    69       error (NILF, _("lbr$set_module failed to extract module info, status = %d"),
     69      error (NILF, _("lbr$set_module() failed to extract module info, status = %d"),
    7070             status);
    7171
     
    8282   * know if this causes problems in other VMS environments.
    8383   */
    84   val = decc$fix_time (&mhd->mhd$l_datim) + timezone - daylight*3600;
     84  {
     85    /* Modified by M. Gehre at 11-JAN-2008 because old formula is wrong:
     86     * val = decc$fix_time (&mhd->mhd$l_datim) + timezone - daylight*3600;
     87     * a) daylight specifies, if the timezone has daylight saving enabled, not
     88     *    if it is active
     89     * b) what we need is the information, if daylight saving was active, if
     90     *    the library module was replaced. This information we get using the
     91     *    localtime function
     92     */
     93
     94    struct tm *tmp;
     95
     96    /* Conversion from VMS time to C time */
     97    val = decc$fix_time (&mhd->mhd$l_datim);
     98
     99    /*
     100     * Conversion from local time (stored in library) to GMT (needed for gmake)
     101     * Note: The tm_gmtoff element is a VMS extension to the ANSI standard.
     102     */
     103    tmp = localtime (&val);
     104    val -= tmp->tm_gmtoff;
     105  }
    85106#endif
    86107
     
    152173  if (! (status & 1))
    153174    {
    154       error (NILF, _("lbr$ini_control failed with status = %d"),status);
     175      error (NILF, _("lbr$ini_control() failed with status = %d"), status);
    155176      return -2;
    156177    }
    157178
    158   libdesc.dsc$a_pointer = archive;
     179  /* there is no such descriptor with "const char *dsc$a_pointer" */
     180  libdesc.dsc$a_pointer = (char *)archive;
    159181  libdesc.dsc$w_length = strlen (archive);
    160182
     
    251273  };
    252274# endif
     275# define TOCHAR(_m)     (_m)
    253276#else
    254277/* These should allow us to read Windows (VC++) libraries (according to Frank
     
    267290# define ar_uid     UserID
    268291# define ar_gid     GroupID
     292/* In Windows the member names have type BYTE so we must cast them.  */
     293# define TOCHAR(_m)     ((char *)(_m))
    269294#endif
    270295
     
    610635
    611636#ifndef M_XENIX
    612         sscanf (member_header.ar_mode, "%o", &eltmode);
    613         eltsize = atol (member_header.ar_size);
     637        sscanf (TOCHAR (member_header.ar_mode), "%o", &eltmode);
     638        eltsize = atol (TOCHAR (member_header.ar_size));
    614639#else   /* Xenix.  */
    615640        eltmode = (unsigned short int) member_header.ar_mode;
     
    621646                       member_offset + AR_HDR_SIZE, eltsize,
    622647#ifndef M_XENIX
    623                        atol (member_header.ar_date),
    624                        atoi (member_header.ar_uid),
    625                        atoi (member_header.ar_gid),
     648                       atol (TOCHAR (member_header.ar_date)),
     649                       atoi (TOCHAR (member_header.ar_uid)),
     650                       atoi (TOCHAR (member_header.ar_gid)),
    626651#else   /* Xenix.  */
    627652                       member_header.ar_date,
     
    794819  for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++)
    795820    ar_hdr.ar_date[ui] = ' ';
    796   sprintf (ar_hdr.ar_date, "%ld", (long int) statbuf.st_mtime);
     821  sprintf (TOCHAR (ar_hdr.ar_date), "%ld", (long int) statbuf.st_mtime);
    797822#ifdef AIAMAG
    798823  ar_hdr.ar_date[strlen(ar_hdr.ar_date)] = ' ';
  • trunk/src/kmk/build.template

    r1993 r2591  
    44
    55# Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
    6 # 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     6# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    77# This file is part of GNU Make.
    88#
  • trunk/src/kmk/build_w32.bat

    r1993 r2591  
    1 <<<<<<< .working
    21@echo off
    32rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    4 rem 2006 Free Software Foundation, Inc.
     3rem 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    54rem This file is part of GNU Make.
     5rem
     6rem GNU Make is free software; you can redistribute it and/or modify it under
     7rem the terms of the GNU General Public License as published by the Free
     8rem Software Foundation; either version 3 of the License, or (at your option)
     9rem any later version.
     10rem
     11rem GNU Make is distributed in the hope that it will be useful, but WITHOUT
     12rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13rem FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for.
     14rem more details.
     15rem
     16rem You should have received a copy of the GNU General Public License along
     17rem with this program.  If not, see <http://www.gnu.org/licenses/>.
    618
    7 rem GNU Make is free software; you can redistribute it and/or modify it under the
    8 rem terms of the GNU General Public License as published by the Free Software
    9 rem Foundation; either version 2, or (at your option) any later version.
    10 
    11 rem GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
    12 rem WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    13 rem A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
    14 
    15 rem You should have received a copy of the GNU General Public License along with
    16 rem GNU Make; see the file COPYING.  If not, write to the Free Software
    17 rem Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18 
     19if exist config.h.W32 GoTo NotCVS
     20sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.in > config.h.W32.sed
     21echo s,%%PACKAGE%%,make,g >> config.h.W32.sed
     22sed -f config.h.W32.sed config.h.W32.template > config.h.W32
     23:NotCVS
    1924if not exist config.h copy config.h.W32 config.h
    2025cd w32\subproc
     
    9095echo off
    9196echo "Linking WinDebug/%make%.exe"
    92 rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\windebug\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /MACHINE:I386 /OUT:.\WinDebug/%make%.exe .\WinDebug/variable.obj  .\WinDebug/rule.obj  .\WinDebug/remote-stub.obj  .\WinDebug/commands.obj  .\WinDebug/file.obj  .\WinDebug/getloadavg.obj  .\WinDebug/default.obj  .\WinDebug/signame.obj  .\WinDebug/expand.obj  .\WinDebug/dir.obj  .\WinDebug/main.obj  .\WinDebug/getopt1.obj  .\WinDebug/job.obj  .\WinDebug/read.obj  .\WinDebug/version.obj  .\WinDebug/getopt.obj  .\WinDebug/arscan.obj  .\WinDebug/remake.obj  .\WinDebug/hash.obj  .\WinDebug/strcache.obj  .\WinDebug/misc.obj  .\WinDebug/ar.obj  .\WinDebug/function.obj  .\WinDebug/vpath.obj  .\WinDebug/implicit.obj  .\WinDebug/dirent.obj  .\WinDebug/glob.obj  .\WinDebug/fnmatch.obj  .\WinDebug/pathstuff.obj
     97rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\windebug\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /OUT:.\WinDebug/%make%.exe .\WinDebug/variable.obj  .\WinDebug/rule.obj  .\WinDebug/remote-stub.obj  .\WinDebug/commands.obj  .\WinDebug/file.obj  .\WinDebug/getloadavg.obj  .\WinDebug/default.obj  .\WinDebug/signame.obj  .\WinDebug/expand.obj  .\WinDebug/dir.obj  .\WinDebug/main.obj  .\WinDebug/getopt1.obj  .\WinDebug/job.obj  .\WinDebug/read.obj  .\WinDebug/version.obj  .\WinDebug/getopt.obj  .\WinDebug/arscan.obj  .\WinDebug/remake.obj  .\WinDebug/hash.obj  .\WinDebug/strcache.obj  .\WinDebug/misc.obj  .\WinDebug/ar.obj  .\WinDebug/function.obj  .\WinDebug/vpath.obj  .\WinDebug/implicit.obj  .\WinDebug/dirent.obj  .\WinDebug/glob.obj  .\WinDebug/fnmatch.obj  .\WinDebug/pathstuff.obj
    9398echo kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\windebug\subproc.lib >>link.dbg
    94 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /MACHINE:I386 /OUT:.\WinDebug/%make%.exe @link.dbg
     99link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /OUT:.\WinDebug/%make%.exe @link.dbg
    95100if not exist .\WinDebug/%make%.exe echo "WinDebug build failed"
    96101if exist .\WinDebug/%make%.exe echo "WinDebug build succeeded!"
     
    157162echo off
    158163echo "Linking WinRel/%make%.exe"
    159 rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\winrel\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /MACHINE:I386 /OUT:.\WinRel/%make%.exe .\WinRel/variable.obj  .\WinRel/rule.obj  .\WinRel/remote-stub.obj  .\WinRel/commands.obj  .\WinRel/file.obj  .\WinRel/getloadavg.obj  .\WinRel/default.obj  .\WinRel/signame.obj  .\WinRel/expand.obj  .\WinRel/dir.obj  .\WinRel/main.obj  .\WinRel/getopt1.obj  .\WinRel/job.obj  .\WinRel/read.obj  .\WinRel/version.obj  .\WinRel/getopt.obj  .\WinRel/arscan.obj  .\WinRel/remake.obj  .\WinRel/misc.obj  .\WinRel/hash.obj  .\WinRel/strcache.obj  .\WinRel/ar.obj  .\WinRel/function.obj  .\WinRel/vpath.obj  .\WinRel/implicit.obj  .\WinRel/dirent.obj  .\WinRel/glob.obj  .\WinRel/fnmatch.obj  .\WinRel/pathstuff.obj
     164rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\winrel\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /OUT:.\WinRel/%make%.exe .\WinRel/variable.obj  .\WinRel/rule.obj  .\WinRel/remote-stub.obj  .\WinRel/commands.obj  .\WinRel/file.obj  .\WinRel/getloadavg.obj  .\WinRel/default.obj  .\WinRel/signame.obj  .\WinRel/expand.obj  .\WinRel/dir.obj  .\WinRel/main.obj  .\WinRel/getopt1.obj  .\WinRel/job.obj  .\WinRel/read.obj  .\WinRel/version.obj  .\WinRel/getopt.obj  .\WinRel/arscan.obj  .\WinRel/remake.obj  .\WinRel/misc.obj  .\WinRel/hash.obj  .\WinRel/strcache.obj  .\WinRel/ar.obj  .\WinRel/function.obj  .\WinRel/vpath.obj  .\WinRel/implicit.obj  .\WinRel/dirent.obj  .\WinRel/glob.obj  .\WinRel/fnmatch.obj  .\WinRel/pathstuff.obj
    160165echo kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\winrel\subproc.lib >>link.rel
    161 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /MACHINE:I386 /OUT:.\WinRel/%make%.exe @link.rel
    162 if not exist .\WinRel/%make%.exe echo "WinRel build failed"
    163 if exist .\WinRel/%make%.exe echo "WinRel build succeeded!"
    164 set make=
    165 GoTo BuildEnd
    166 :GCCBuild
    167 echo on
    168 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c variable.c
    169 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c rule.c
    170 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c remote-stub.c
    171 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c commands.c
    172 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c file.c
    173 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getloadavg.c
    174 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c default.c
    175 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c signame.c
    176 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c expand.c
    177 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c dir.c
    178 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c main.c
    179 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getopt1.c
    180 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c job.c
    181 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c read.c
    182 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c version.c
    183 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c getopt.c
    184 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c arscan.c
    185 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c remake.c
    186 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c hash.c
    187 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c strcache.c
    188 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c misc.c
    189 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ar.c
    190 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c function.c
    191 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c vpath.c
    192 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c implicit.c
    193 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./glob/glob.c -o glob.o
    194 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./glob/fnmatch.c -o fnmatch.o
    195 gcc -mthreads -Wall -gstabs+ -ggdb3 -O2 -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H -c ./w32/pathstuff.c -o pathstuff.o
    196 gcc -mthreads -gstabs+ -ggdb3 -o gnumake.exe variable.o rule.o remote-stub.o commands.o file.o getloadavg.o default.o signame.o expand.o dir.o main.o getopt1.o job.o read.o version.o getopt.o arscan.o remake.o misc.o hash.o strcache.o ar.o function.o vpath.o implicit.o glob.o fnmatch.o pathstuff.o w32_misc.o sub_proc.o w32err.o -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
    197 :BuildEnd
    198 echo on
    199 =======
    200 @echo off
    201 rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    202 rem 2006, 2007 Free Software Foundation, Inc.
    203 rem This file is part of GNU Make.
    204 rem
    205 rem GNU Make is free software; you can redistribute it and/or modify it under
    206 rem the terms of the GNU General Public License as published by the Free
    207 rem Software Foundation; either version 3 of the License, or (at your option)
    208 rem any later version.
    209 rem
    210 rem GNU Make is distributed in the hope that it will be useful, but WITHOUT
    211 rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    212 rem FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for.
    213 rem more details.
    214 rem
    215 rem You should have received a copy of the GNU General Public License along
    216 rem with this program.  If not, see <http://www.gnu.org/licenses/>.
    217 
    218 if exist config.h.W32 GoTo NotCVS
    219 sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.in > config.h.W32.sed
    220 echo s,%%PACKAGE%%,make,g >> config.h.W32.sed
    221 sed -f config.h.W32.sed config.h.W32.template > config.h.W32
    222 :NotCVS
    223 if not exist config.h copy config.h.W32 config.h
    224 cd w32\subproc
    225 echo "Creating the subproc library"
    226 %ComSpec% /c build.bat %1
    227 cd ..\..
    228 
    229 if exist link.dbg del link.dbg
    230 if exist link.rel del link.rel
    231 echo "Creating GNU Make for Windows 9X/NT/2K/XP"
    232 if "%1" == "gcc" GoTo GCCBuild
    233 set make=gnumake
    234 echo on
    235 if not exist .\WinDebug\nul mkdir .\WinDebug
    236 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D TIVOLI /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c variable.c
    237 echo WinDebug\variable.obj >>link.dbg
    238 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c rule.c
    239 echo WinDebug\rule.obj >>link.dbg
    240 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c remote-stub.c
    241 echo WinDebug\remote-stub.obj >>link.dbg
    242 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c commands.c
    243 echo WinDebug\commands.obj >>link.dbg
    244 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c file.c
    245 echo WinDebug\file.obj >>link.dbg
    246 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c getloadavg.c
    247 echo WinDebug\getloadavg.obj >>link.dbg
    248 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c default.c
    249 echo WinDebug\default.obj >>link.dbg
    250 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c signame.c
    251 echo WinDebug\signame.obj >>link.dbg
    252 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c expand.c
    253 echo WinDebug\expand.obj >>link.dbg
    254 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c dir.c
    255 echo WinDebug\dir.obj >>link.dbg
    256 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c main.c
    257 echo WinDebug\main.obj >>link.dbg
    258 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c getopt1.c
    259 echo WinDebug\getopt1.obj >>link.dbg
    260 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c job.c
    261 echo WinDebug\job.obj >>link.dbg
    262 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c read.c
    263 echo WinDebug\read.obj >>link.dbg
    264 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c version.c
    265 echo WinDebug\version.obj >>link.dbg
    266 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c getopt.c
    267 echo WinDebug\getopt.obj >>link.dbg
    268 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c arscan.c
    269 echo WinDebug\arscan.obj >>link.dbg
    270 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c hash.c
    271 echo WinDebug\hash.obj >>link.dbg
    272 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c strcache.c
    273 echo WinDebug\strcache.obj >>link.dbg
    274 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c remake.c
    275 echo WinDebug\remake.obj >>link.dbg
    276 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c misc.c
    277 echo WinDebug\misc.obj >>link.dbg
    278 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c ar.c
    279 echo WinDebug\ar.obj >>link.dbg
    280 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c function.c
    281 echo WinDebug\function.obj >>link.dbg
    282 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c vpath.c
    283 echo WinDebug\vpath.obj >>link.dbg
    284 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c implicit.c
    285 echo WinDebug\implicit.obj >>link.dbg
    286 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c  .\w32\compat\dirent.c
    287 echo WinDebug\dirent.obj >>link.dbg
    288 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c  .\glob\glob.c
    289 echo WinDebug\glob.obj >>link.dbg
    290 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c  .\glob\fnmatch.c
    291 echo WinDebug\fnmatch.obj >>link.dbg
    292 cl.exe /nologo /MT /W4 /GX /Zi /YX /Od /I . /I glob /I w32/include /D _DEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinDebug/ /Fp.\WinDebug/%make%.pch /Fo.\WinDebug/ /Fd.\WinDebug/%make%.pdb /c  .\w32\pathstuff.c
    293 echo WinDebug\pathstuff.obj >>link.dbg
    294 echo off
    295 echo "Linking WinDebug/%make%.exe"
    296 rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\windebug\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /MACHINE:I386 /OUT:.\WinDebug/%make%.exe .\WinDebug/variable.obj  .\WinDebug/rule.obj  .\WinDebug/remote-stub.obj  .\WinDebug/commands.obj  .\WinDebug/file.obj  .\WinDebug/getloadavg.obj  .\WinDebug/default.obj  .\WinDebug/signame.obj  .\WinDebug/expand.obj  .\WinDebug/dir.obj  .\WinDebug/main.obj  .\WinDebug/getopt1.obj  .\WinDebug/job.obj  .\WinDebug/read.obj  .\WinDebug/version.obj  .\WinDebug/getopt.obj  .\WinDebug/arscan.obj  .\WinDebug/remake.obj  .\WinDebug/hash.obj  .\WinDebug/strcache.obj  .\WinDebug/misc.obj  .\WinDebug/ar.obj  .\WinDebug/function.obj  .\WinDebug/vpath.obj  .\WinDebug/implicit.obj  .\WinDebug/dirent.obj  .\WinDebug/glob.obj  .\WinDebug/fnmatch.obj  .\WinDebug/pathstuff.obj
    297 echo kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\windebug\subproc.lib >>link.dbg
    298 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:.\WinDebug/%make%.pdb /DEBUG /MACHINE:I386 /OUT:.\WinDebug/%make%.exe @link.dbg
    299 if not exist .\WinDebug/%make%.exe echo "WinDebug build failed"
    300 if exist .\WinDebug/%make%.exe echo "WinDebug build succeeded!"
    301 if not exist .\WinRel\nul mkdir .\WinRel
    302 echo on
    303 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /D TIVOLI /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c variable.c
    304 echo WinRel\variable.obj >>link.rel
    305 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c rule.c
    306 echo WinRel\rule.obj >>link.rel
    307 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c remote-stub.c
    308 echo WinRel\remote-stub.obj >>link.rel
    309 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c commands.c
    310 echo WinRel\commands.obj >>link.rel
    311 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c file.c
    312 echo WinRel\file.obj >>link.rel
    313 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c getloadavg.c
    314 echo WinRel\getloadavg.obj >>link.rel
    315 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c default.c
    316 echo WinRel\default.obj >>link.rel
    317 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c signame.c
    318 echo WinRel\signame.obj >>link.rel
    319 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c expand.c
    320 echo WinRel\expand.obj >>link.rel
    321 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c dir.c
    322 echo WinRel\dir.obj >>link.rel
    323 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c main.c
    324 echo WinRel\main.obj >>link.rel
    325 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c getopt1.c
    326 echo WinRel\getopt1.obj >>link.rel
    327 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c job.c
    328 echo WinRel\job.obj >>link.rel
    329 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c read.c
    330 echo WinRel\read.obj >>link.rel
    331 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c version.c
    332 echo WinRel\version.obj >>link.rel
    333 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c getopt.c
    334 echo WinRel\getopt.obj >>link.rel
    335 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c arscan.c
    336 echo WinRel\arscan.obj >>link.rel
    337 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c remake.c
    338 echo WinRel\remake.obj >>link.rel
    339 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c hash.c
    340 echo WinRel\hash.obj >>link.rel
    341 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c strcache.c
    342 echo WinRel\strcache.obj >>link.rel
    343 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c misc.c
    344 echo WinRel\misc.obj >>link.rel
    345 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c ar.c
    346 echo WinRel\ar.obj >>link.rel
    347 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c function.c
    348 echo WinRel\function.obj >>link.rel
    349 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c vpath.c
    350 echo WinRel\vpath.obj >>link.rel
    351 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c implicit.c
    352 echo WinRel\implicit.obj >>link.rel
    353 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c  .\w32\compat\dirent.c
    354 echo WinRel\dirent.obj >>link.rel
    355 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c  .\glob\glob.c
    356 echo WinRel\glob.obj >>link.rel
    357 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c  .\glob\fnmatch.c
    358 echo WinRel\fnmatch.obj >>link.rel
    359 cl.exe /nologo /MT /W4 /GX /YX /O2 /I . /I glob /I w32/include /D NDEBUG /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR.\WinRel/ /Fp.\WinRel/%make%.pch /Fo.\WinRel/ /c  .\w32\pathstuff.c
    360 echo WinRel\pathstuff.obj >>link.rel
    361 echo off
    362 echo "Linking WinRel/%make%.exe"
    363 rem link.exe kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\winrel\subproc.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /MACHINE:I386 /OUT:.\WinRel/%make%.exe .\WinRel/variable.obj  .\WinRel/rule.obj  .\WinRel/remote-stub.obj  .\WinRel/commands.obj  .\WinRel/file.obj  .\WinRel/getloadavg.obj  .\WinRel/default.obj  .\WinRel/signame.obj  .\WinRel/expand.obj  .\WinRel/dir.obj  .\WinRel/main.obj  .\WinRel/getopt1.obj  .\WinRel/job.obj  .\WinRel/read.obj  .\WinRel/version.obj  .\WinRel/getopt.obj  .\WinRel/arscan.obj  .\WinRel/remake.obj  .\WinRel/misc.obj  .\WinRel/hash.obj  .\WinRel/strcache.obj  .\WinRel/ar.obj  .\WinRel/function.obj  .\WinRel/vpath.obj  .\WinRel/implicit.obj  .\WinRel/dirent.obj  .\WinRel/glob.obj  .\WinRel/fnmatch.obj  .\WinRel/pathstuff.obj
    364 echo kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib w32\subproc\winrel\subproc.lib >>link.rel
    365 link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /MACHINE:I386 /OUT:.\WinRel/%make%.exe @link.rel
     166link.exe /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:.\WinRel/%make%.pdb /OUT:.\WinRel/%make%.exe @link.rel
    366167if not exist .\WinRel/%make%.exe echo "WinRel build failed"
    367168if exist .\WinRel/%make%.exe echo "WinRel build succeeded!"
     
    401202:BuildEnd
    402203echo on
    403 >>>>>>> .merge-right.r1992
  • trunk/src/kmk/commands.c

    r2027 r2591  
    11/* Command processing for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    4444
    4545
     46#ifndef CONFIG_WITH_STRCACHE2
     47
     48static unsigned long
     49dep_hash_1 (const void *key)
     50{
     51  const struct dep *d = key;
     52  return_STRING_HASH_1 (dep_name (d));
     53}
     54
     55static unsigned long
     56dep_hash_2 (const void *key)
     57{
     58  const struct dep *d = key;
     59  return_STRING_HASH_2 (dep_name (d));
     60}
     61
     62static int
     63dep_hash_cmp (const void *x, const void *y)
     64{
     65  const struct dep *dx = x;
     66  const struct dep *dy = y;
     67  return strcmp (dep_name (dx), dep_name (dy));
     68}
     69
     70
     71#else  /* CONFIG_WITH_STRCACHE2 */
     72
     73/* Exploit the fact that all names are in the string cache. This means equal
     74   names shall have the same storage and there is no need for hashing or
     75   comparing. Use the address as the first hash, avoiding any touching of
     76   the name, and the length as the second. */
     77
     78static unsigned long
     79dep_hash_1 (const void *key)
     80{
     81  const char *name = dep_name ((struct dep const *) key);
     82  assert (strcache2_is_cached (&file_strcache, name));
     83  return (size_t) name / sizeof(void *);
     84}
     85
     86static unsigned long
     87dep_hash_2 (const void *key)
     88{
     89  const char *name = dep_name ((struct dep const *) key);
     90  return strcache2_get_len (&file_strcache, name);
     91}
     92
     93static int
     94dep_hash_cmp (const void *x, const void *y)
     95{
     96  struct dep *dx = (struct dep *) x;
     97  struct dep *dy = (struct dep *) y;
     98  const char *dxname = dep_name (dx);
     99  const char *dyname = dep_name (dy);
     100  int cmp = dxname == dyname ? 0 : 1;
     101
     102  /* check preconds: both cached and the cache contains no duplicates. */
     103  assert (strcache2_is_cached (&file_strcache, dxname));
     104  assert (strcache2_is_cached (&file_strcache, dyname));
     105  assert (cmp == 0 || strcmp (dxname, dyname) != 0);
     106
     107  /* If the names are the same but ignore_mtimes are not equal, one of these
     108     is an order-only prerequisite and one isn't.  That means that we should
     109     remove the one that isn't and keep the one that is.  */
     110
     111  if (!cmp && dx->ignore_mtime != dy->ignore_mtime)
     112    dx->ignore_mtime = dy->ignore_mtime = 0;
     113
     114  return cmp;
     115}
     116
     117#endif /* CONFIG_WITH_STRCACHE2 */
     118
    46119/* Set FILE's automatic variables up.  */
    47120
     
    53126#endif
    54127{
    55   const struct dep *d;
     128  struct dep *d;
    56129  const char *at, *percent, *star, *less;
    57130#ifdef CONFIG_WITH_STRCACHE2
     
    138211    if (!d->ignore_mtime)
    139212      {
    140         less = dep_name (d);
     213        if (!d->need_2nd_expansion)
     214          less = dep_name (d);
    141215        break;
    142216      }
     
    214288    unsigned int len;
    215289
     290    struct hash_table dep_hash;
     291    void **slot;
     292
    216293    /* Compute first the value for $+, which is supposed to contain
    217294       duplicate dependencies as they were listed in the makefile.  */
    218295
    219296    plus_len = 0;
     297    bar_len = 0;
    220298    for (d = file->deps; d != 0; d = d->next)
    221299      if (! d->ignore_mtime)
     300      {
     301        if (!d->need_2nd_expansion)
     302          {
    222303#ifndef CONFIG_WITH_STRCACHE2
    223         plus_len += strlen (dep_name (d)) + 1;
    224 #else
    225         plus_len += strcache2_get_len (&file_strcache, dep_name (d)) + 1;
    226 #endif
     304            if (d->ignore_mtime)
     305              bar_len += strlen (dep_name (d)) + 1;
     306            else
     307              plus_len += strlen (dep_name (d)) + 1;
     308#else
     309            if (d->ignore_mtime)
     310              bar_len += strcache2_get_len (&file_strcache, dep_name (d)) + 1;
     311            else
     312              plus_len += strcache2_get_len (&file_strcache, dep_name (d)) + 1;
     313#endif
     314          }
     315      }
     316
     317    if (bar_len == 0)
     318      bar_len++;
    227319    if (plus_len == 0)
    228320      plus_len++;
     
    230322    if (plus_len > plus_max)
    231323      plus_value = xrealloc (plus_value, plus_max = plus_len);
     324
    232325    cp = plus_value;
    233326
    234327    qmark_len = plus_len + 1;   /* Will be this or less.  */
    235328    for (d = file->deps; d != 0; d = d->next)
    236       if (! d->ignore_mtime)
     329      if (! d->ignore_mtime && ! d->need_2nd_expansion)
    237330        {
    238331          const char *c = dep_name (d);
     
    255348          cp += len;
    256349          *cp++ = FILE_LIST_SEPARATOR;
    257           if (! d->changed)
     350          if (! (d->changed || always_make_flag))
    258351            qmark_len -= len + 1;       /* Don't space in $? for this one.  */
    259352        }
     
    263356    cp[cp > plus_value ? -1 : 0] = '\0';
    264357    DEFINE_VARIABLE ("+", 1, plus_value);
    265 
    266     /* Make sure that no dependencies are repeated.  This does not
    267        really matter for the purpose of updating targets, but it
    268        might make some names be listed twice for $^ and $?.  */
    269 
    270     uniquize_deps (file->deps);
    271 
    272     bar_len = 0;
    273     for (d = file->deps; d != 0; d = d->next)
    274       if (d->ignore_mtime)
    275 #ifndef CONFIG_WITH_STRCACHE2
    276         bar_len += strlen (dep_name (d)) + 1;
    277 #else
    278         bar_len += strcache2_get_len (&file_strcache, dep_name (d)) + 1;
    279 #endif
    280     if (bar_len == 0)
    281       bar_len++;
    282358
    283359    /* Compute the values for $^, $?, and $|.  */
     
    293369    bp = bar_value;
    294370
     371    /* Make sure that no dependencies are repeated in $^, $?, and $|.  It
     372       would be natural to combine the next two loops but we can't do it
     373       because of a situation where we have two dep entries, the first
     374       is order-only and the second is normal (see below).  */
     375
     376    hash_init (&dep_hash, 500, dep_hash_1, dep_hash_2, dep_hash_cmp);
     377
    295378    for (d = file->deps; d != 0; d = d->next)
    296379      {
    297         const char *c = dep_name (d);
    298 
     380        if (d->need_2nd_expansion)
     381          continue;
     382
     383        slot = hash_find_slot (&dep_hash, d);
     384        if (HASH_VACANT (*slot))
     385          hash_insert_at (&dep_hash, d, slot);
     386        else
     387          {
     388            /* Check if the two prerequisites have different ignore_mtime.
     389               If so then we need to "upgrade" one that is order-only.  */
     390
     391            struct dep* hd = (struct dep*) *slot;
     392
     393            if (d->ignore_mtime != hd->ignore_mtime)
     394              d->ignore_mtime = hd->ignore_mtime = 0;
     395          }
     396      }
     397
     398    for (d = file->deps; d != 0; d = d->next)
     399      {
     400        const char *c;
     401
     402        if (d->need_2nd_expansion || hash_find_item (&dep_hash, d) != d)
     403          continue;
     404
     405        c = dep_name (d);
    299406#ifndef NO_ARCHIVES
    300         if (ar_name (c))
     407        if (ar_name (c))
    301408          {
    302409            c = strchr (c, '(') + 1;
     
    313420        if (d->ignore_mtime)
    314421          {
    315             memcpy (bp, c, len);
     422            memcpy (bp, c, len);
    316423            bp += len;
    317424            *bp++ = FILE_LIST_SEPARATOR;
    318425          }
    319426        else
    320           {
     427          {
    321428            memcpy (cp, c, len);
    322429            cp += len;
    323430            *cp++ = FILE_LIST_SEPARATOR;
    324             if (d->changed)
     431            if (d->changed || always_make_flag)
    325432              {
    326433                memcpy (qp, c, len);
     
    331438      }
    332439
     440    hash_free (&dep_hash, 0);
     441
    333442    /* Kill the last spaces and define the variables.  */
    334443
     
    352461      file->org_deps = copy_dep_chain (file->deps);
    353462
    354       uniquize_deps (file->deps);
     463      /** @todo do uniquize_deps (file->deps); in the $(dep-* ) functions, it'll
     464       *        save even more space that way. */
    355465   }
    356466#endif /* CONFIG_WITH_LAZY_DEPS_VARS */
     
    365475chop_commands (struct commands *cmds)
    366476{
    367   const char *p;
    368477  unsigned int nlines, idx;
    369478  char **lines;
     
    375484    return;
    376485
    377   /* Chop CMDS->commands up into lines in CMDS->command_lines.
    378          Also set the corresponding CMDS->lines_flags elements,
    379          and the CMDS->any_recurse flag.  */
    380 
    381   nlines = 5;
    382   lines = xmalloc (5 * sizeof (char *));
    383   idx = 0;
    384   p = cmds->commands;
    385   while (*p != '\0')
    386     {
    387       const char *end = p;
    388     find_end:;
    389       end = strchr (end, '\n');
    390       if (end == 0)
    391         end = p + strlen (p);
    392       else if (end > p && end[-1] == '\\')
     486  /* Chop CMDS->commands up into lines in CMDS->command_lines.  */
     487
     488  if (one_shell)
     489    {
     490      int l = strlen (cmds->commands);
     491
     492      nlines = 1;
     493      lines = xmalloc (nlines * sizeof (char *));
     494      lines[0] = xstrdup (cmds->commands);
     495
     496      /* Strip the trailing newline.  */
     497      if (l > 0 && lines[0][l-1] == '\n')
     498        lines[0][l-1] = '\0';
     499    }
     500  else
     501    {
     502      const char *p;
     503
     504      nlines = 5;
     505      lines = xmalloc (nlines * sizeof (char *));
     506      idx = 0;
     507      p = cmds->commands;
     508      while (*p != '\0')
    393509        {
    394           int backslash = 1;
    395           const char *b;
    396           for (b = end - 2; b >= p && *b == '\\'; --b)
    397             backslash = !backslash;
    398           if (backslash)
     510          const char *end = p;
     511        find_end:;
     512          end = strchr (end, '\n');
     513          if (end == 0)
     514            end = p + strlen (p);
     515          else if (end > p && end[-1] == '\\')
    399516            {
    400               ++end;
    401               goto find_end;
     517              int backslash = 1;
     518              const char *b;
     519              for (b = end - 2; b >= p && *b == '\\'; --b)
     520                backslash = !backslash;
     521              if (backslash)
     522                {
     523                  ++end;
     524                  goto find_end;
     525                }
    402526            }
     527
     528          if (idx == nlines)
     529            {
     530              nlines += 2;
     531              lines = xrealloc (lines, nlines * sizeof (char *));
     532            }
     533          lines[idx++] = xstrndup (p, end - p);
     534          p = end;
     535          if (*p != '\0')
     536            ++p;
    403537        }
    404538
    405       if (idx == nlines)
     539      if (idx != nlines)
    406540        {
    407           nlines += 2;
     541          nlines = idx;
    408542          lines = xrealloc (lines, nlines * sizeof (char *));
    409543        }
    410       lines[idx++] = savestring (p, end - p);
    411       p = end;
    412       if (*p != '\0')
    413         ++p;
    414     }
    415 
    416   if (idx != nlines)
    417     {
    418       nlines = idx;
    419       lines = xrealloc (lines, nlines * sizeof (char *));
    420     }
     544    }
     545
     546  /* Finally, set the corresponding CMDS->lines_flags elements and the
     547     CMDS->any_recurse flag.  */
    421548
    422549  cmds->ncommand_lines = nlines;
     
    429556  cmds->lines_flags = xmalloc (nlines * sizeof (cmds->lines_flags[0]));
    430557#endif
     558
    431559  for (idx = 0; idx < nlines; ++idx)
    432560    {
    433561      int flags = 0;
    434 
    435       for (p = lines[idx];
    436 #ifndef CONFIG_WITH_COMMANDS_FUNC
    437             isblank ((unsigned char)*p) || *p == '-' || *p == '@' || *p == '+';
    438 #else
    439            isblank ((unsigned char)*p) || *p == '-' || *p == '@' || *p == '+' || *p == '%';
    440 #endif
    441            ++p)
    442         switch (*p)
     562      const char *p = lines[idx];
     563
     564      while (isblank (*p) || *p == '-' || *p == '@' || *p == '+' IF_WITH_COMMANDS_FUNC(|| *p == '%'))
     565        switch (*(p++))
    443566          {
    444567          case '+':
  • trunk/src/kmk/commands.h

    r2056 r2591  
    11/* Definition of data structures describing shell commands for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
  • trunk/src/kmk/config

    • Property svn:ignore
      •  

        old new  
        11*.m4
        22config.*
         3mkinstalldirs
         4texinfo.tex
         5mdate-sh
         6compile
         7depcomp
         8install-sh
         9missing
         10
        311Makefile
        412Makefile.in
  • trunk/src/kmk/config.ami.template

    r1993 r2591  
    11/* config.h -- hand-massaged for Amiga                                  -*-C-*-
    22Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    3 2005, 2006, 2007 Free Software Foundation, Inc.
     32005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/config.h-vms.template

    r1993 r2591  
    22
    33Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    4 2006, 2007 Free Software Foundation, Inc.
     42006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    7676/* Define to 1 if you don't have vprintf but do have _doprnt.  */
    7777/* #undef HAVE_DOPRNT */
     78
     79/* Define to 1 if you have the fdopen function.  */
     80#define HAVE_FDOPEN 1
    7881
    7982/* Define to 1 if your system has a working fnmatch function.  */
     
    290293
    291294/* Define to 1 if you have the strcasecmp function.  */
    292 /* #undef HAVE_STRCASECMP */
     295#define HAVE_STRCASECMP 1
    293296
    294297/* Define to 1 if you have the strcmpi function.  */
  • trunk/src/kmk/config.h.W32.template

    r2134 r2591  
    22
    33Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    4 2006, 2007 Free Software Foundation, Inc.
     42006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    2525# pragma warning(disable:4131) /* uses old-style declarator */
    2626# pragma warning(disable:4702) /* unreachable code */
     27# define _CRT_SECURE_NO_WARNINGS  /* function or variable may be unsafe */
     28# define _CRT_NONSTDC_NO_WARNINGS /* functions w/o a leading underscore */
    2729#endif
    2830
     
    228230
    229231/* Define to 1 if you have the `strcmpi' function. */
    230 #define HAVE_STRCMPI 1
     232/* #undef HAVE_STRCMPI */
    231233
    232234/* Define to 1 if you have the `stricmp' function. */
    233 /* #undef HAVE_STRICMP */
     235#define HAVE_STRICMP 1
     236
     237/* Define to 1 if you have the `strncasecmp' function. */
     238/* #undef HAVE_STRNCASECMP */
     239
     240/* Define to 1 if you have the `strncmpi' function. */
     241/* #undef HAVE_STRNCMPI */
     242
     243/* Define to 1 if you have the `strnicmp' function. */
     244#define HAVE_STRNICMP 1
    234245
    235246/* Define to 1 if you have the `strchr' function. */
     
    427438/* GCC 4.x reportedly defines pid_t.  */
    428439#ifndef _PID_T_
     440#ifdef _WIN64
     441#define pid_t __int64
     442#else
    429443#define pid_t int
     444#endif
    430445#endif
    431446
  • trunk/src/kmk/config.h.darwin

    r2145 r2591  
    4141/* Define to 1 if you have the `bsd_signal' function. */
    4242#define HAVE_BSD_SIGNAL 1
     43#define HAVE_DECL_BSD_SIGNAL 1
    4344
    4445/* Use case insensitive file names */
     
    7980#define HAVE_FDOPEN 1
    8081
     82/* Define to 1 if you have the `fileno' function. */
     83#define HAVE_FILENO 1
     84
    8185/* Define to 1 if you have the `fork' function. */
    8286#define HAVE_FORK 1
     
    202206/* #undef HAVE_STRCMPI */
    203207
     208/* Define to 1 if you have the `strncasecmp' function. */
     209#define HAVE_STRNCASECMP 1
     210
     211/* Define to 1 if you have the `strncmpi' function. */
     212/* #undef HAVE_STRNCMPI */
     213
     214/* Define to 1 if you have the `strncmp' function. */
     215/* #undef HAVE_STRNICMP */
     216
    204217/* Define to 1 if you have the `strcoll' function and it is properly defined.
    205218   */
     
    208221/* Define to 1 if you have the `strdup' function. */
    209222#define HAVE_STRDUP 1
     223
     224/* Define to 1 if you have the `strndup' function. */
     225/* #undef HAVE_STRNDUP  */
    210226
    211227/* Define to 1 if you have the `strerror' function. */
     
    315331
    316332/* Define to the full name and version of this package. */
    317 #define PACKAGE_STRING "GNU make 3.81.90"
     333#define PACKAGE_STRING "GNU make 3.82"
    318334
    319335/* Define to the one symbol short name of this package. */
     
    321337
    322338/* Define to the version of this package. */
    323 #define PACKAGE_VERSION "3.81.90"
     339#define PACKAGE_VERSION "3.82"
    324340
    325341/* Define to the character that separates directories in PATH. */
     
    374390
    375391/* Version number of package */
    376 #define VERSION "3.81.90"
     392#define VERSION "3.82"
    377393
    378394/* Use platform specific coding */
  • trunk/src/kmk/config.h.freebsd

    r2134 r2591  
    319319
    320320/* Define to the full name and version of this package. */
    321 #define PACKAGE_STRING "GNU make 3.81.90"
     321#define PACKAGE_STRING "GNU make 3.82"
    322322
    323323/* Define to the one symbol short name of this package. */
     
    325325
    326326/* Define to the version of this package. */
    327 #define PACKAGE_VERSION "3.81.90"
     327#define PACKAGE_VERSION "3.82"
    328328
    329329/* Define to the character that separates directories in PATH. */
     
    378378
    379379/* Version number of package */
    380 #define VERSION "3.81.90"
     380#define VERSION "3.82"
    381381
    382382/* Use platform specific coding */
  • trunk/src/kmk/config.h.haiku

    r2546 r2591  
    315315
    316316/* Define to the full name and version of this package. */
    317 #define PACKAGE_STRING "GNU make 3.81.90"
     317#define PACKAGE_STRING "GNU make 3.82"
    318318
    319319/* Define to the one symbol short name of this package. */
     
    324324
    325325/* Define to the version of this package. */
    326 #define PACKAGE_VERSION "3.81.90"
     326#define PACKAGE_VERSION "3.82"
    327327
    328328/* Define to the character that separates directories in PATH. */
     
    391391
    392392/* Version number of package */
    393 #define VERSION "3.81.90"
     393#define VERSION "3.82"
    394394
    395395/* Use platform specific coding */
  • trunk/src/kmk/config.h.linux

    r2134 r2591  
    315315
    316316/* Define to the full name and version of this package. */
    317 #define PACKAGE_STRING "GNU make 3.81.90"
     317#define PACKAGE_STRING "GNU make 3.82"
    318318
    319319/* Define to the one symbol short name of this package. */
     
    321321
    322322/* Define to the version of this package. */
    323 #define PACKAGE_VERSION "3.81.90"
     323#define PACKAGE_VERSION "3.82"
    324324
    325325/* Define to the character that separates directories in PATH. */
     
    374374
    375375/* Version number of package */
    376 #define VERSION "3.81.90"
     376#define VERSION "3.82"
    377377
    378378/* Use platform specific coding */
  • trunk/src/kmk/config.h.os2

    r2134 r2591  
    332332
    333333/* Define to the full name and version of this package. */
    334 #define PACKAGE_STRING "GNU make 3.81"
     334#define PACKAGE_STRING "GNU make 3.82"
    335335
    336336/* Define to the one symbol short name of this package. */
     
    338338
    339339/* Define to the version of this package. */
    340 #define PACKAGE_VERSION "3.81"
     340#define PACKAGE_VERSION "3.82"
    341341
    342342/* Define to 1 if the C compiler supports function prototypes. */
  • trunk/src/kmk/config.h.solaris

    r2134 r2591  
    315315
    316316/* Define to the full name and version of this package. */
    317 #define PACKAGE_STRING "GNU make 3.81.90"
     317#define PACKAGE_STRING "GNU make 3.82"
    318318
    319319/* Define to the one symbol short name of this package. */
     
    321321
    322322/* Define to the version of this package. */
    323 #define PACKAGE_VERSION "3.81.90"
     323#define PACKAGE_VERSION "3.82"
    324324
    325325/* Define to the character that separates directories in PATH. */
     
    374374
    375375/* Version number of package */
    376 #define VERSION "3.81.90"
     376#define VERSION "3.82"
    377377
    378378/* Use platform specific coding */
  • trunk/src/kmk/config.h.win

    r2178 r2591  
    344344
    345345/* Define to the full name and version of this package. */
    346 #define PACKAGE_STRING "GNU make 3.81.90"
     346#define PACKAGE_STRING "GNU make 3.82"
    347347
    348348/* Define to the one symbol short name of this package. */
     
    350350
    351351/* Define to the version of this package. */
    352 #define PACKAGE_VERSION "3.81.90"
     352#define PACKAGE_VERSION "3.82"
    353353
    354354/* Define to 1 if the C compiler supports function prototypes. */
     
    400400
    401401/* Version number of package */
    402 #define VERSION "3.81.90"
     402#define VERSION "3.82"
    403403
    404404/* Define if using the dmalloc debugging malloc package */
  • trunk/src/kmk/config/ChangeLog

    r1993 r2591  
    3030
    3131
    32 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     32Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
     33Foundation, Inc.
    3334This file is part of GNU Make.
    3435
  • trunk/src/kmk/config/Makefile.am

    r1993 r2591  
    11# -*-Makefile-*-, or close enough
    2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
    3 # Inc.
     2# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
     3# Software Foundation, Inc.
    44# This file is part of GNU Make.
    55#
  • trunk/src/kmk/config/dospaths.m4

    r1993 r2591  
    33#
    44# Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
    5 # 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     5# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    66# This file is part of GNU Make.
    77#
  • trunk/src/kmk/configh.dos.template

    r1993 r2591  
    22
    33Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
    4 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     42004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    1717this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1818
     19/* Include this header to make __DJGPP_MINOR__ available because DJGPP ports
     20   of GCC 4.3.0 and later no longer do it automatically.  */
     21#include <sys/version.h>
     22
    1923/* Many things are defined already by a system header.  */
    2024#include <sys/config.h>
     
    2226#if __DJGPP__ > 2 || __DJGPP_MINOR__ > 1
    2327
    24 /* Define to 1 if `sys_siglist' is declared by <signal.h>. */
     28/* Define to 1 if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
    2529# define SYS_SIGLIST_DECLARED 1
    2630
     
    108112#define PROTOTYPES 1
    109113
    110 /* Define to 1 if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
    111 #define SYS_SIGLIST_DECLARED 1
    112 
    113114/* Version number of package */
    114115#define VERSION "%VERSION%"
  • trunk/src/kmk/configure.bat

    r1993 r2591  
    1 <<<<<<< .working
    21@echo off
    32rem Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
    4 rem 2004, 2005, 2006 Free Software Foundation, Inc.
    5 rem This file is part of GNU Make.
    6 
    7 rem GNU Make is free software; you can redistribute it and/or modify it under
    8 rem the terms of the GNU General Public License as published by the Free
    9 rem Software Foundation; either version 2, or (at your option) any later
    10 rem version.
    11 
    12 rem GNU Make is distributed in the hope that it will be useful, but WITHOUT
    13 rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    14 rem FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    15 rem more details.
    16 
    17 rem You should have received a copy of the GNU General Public License along
    18 rem with GNU Make; see the file COPYING.  If not, write to the Free Software
    19 rem Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20 
    21 echo Configuring MAKE for DJGPP
    22 
    23 rem The SmallEnv trick protects against too small environment block,
    24 rem in which case the values will be truncated and the whole thing
    25 rem goes awry.  COMMAND.COM will say "Out of environment space", but
    26 rem many people don't care, so we force them to care by refusing to go.
    27 
    28 rem Where is the srcdir?
    29 set XSRC=.
    30 if not "%XSRC%"=="." goto SmallEnv
    31 if "%1%"=="" goto SrcDone
    32 set XSRC=%1
    33 if not "%XSRC%"=="%1" goto SmallEnv
    34 
    35 :SrcDone
    36 
    37 update %XSRC%/configh.dos ./config.h
    38 
    39 rem Do they have Make?
    40 redir -o junk.$$$ -eo make -n -f NUL
    41 rem REDIR will return 1 if it cannot run Make.
    42 rem If it can run Make, it will usually return 2,
    43 rem but 0 is also OK with us.
    44 if errorlevel 2 goto MakeOk
    45 if not errorlevel 1 goto MakeOk
    46 if exist junk.$$$ del junk.$$$
    47 echo No Make program found--use DOSBUILD.BAT to build Make.
    48 goto End
    49 
    50 rem They do have Make.  Generate the Makefile.
    51 
    52 :MakeOk
    53 del junk.$$$
    54 update %XSRC%/Makefile.DOS ./Makefile
    55 echo Done.
    56 if not "%XSRC%"=="." echo Invoke Make thus: "make srcdir=%XSRC%"
    57 goto End
    58 
    59 :SmallEnv
    60 echo Your environment is too small.  Please enlarge it and run me again.
    61 
    62 :End
    63 set XRSC=
    64 =======
    65 @echo off
    66 rem Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
    67 rem 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     3rem 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    684rem This file is part of GNU Make.
    695rem
     
    12460:End
    12561set XRSC=
    126 >>>>>>> .merge-right.r1992
  • trunk/src/kmk/configure.in

    r2134 r2591  
    22#
    33# Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
    4 # 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     4# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    55# This file is part of GNU Make.
    66#
     
    1818# this program.  If not, see <http://www.gnu.org/licenses/>.
    1919
    20 AC_INIT([GNU make],[3.81.90],[[email protected]])
     20AC_INIT([GNU make],[3.82],[[email protected]])
    2121
    2222AC_PREREQ(2.59)
    23 AC_REVISION([[$Id: configure.in,v 1.148 2007/07/04 19:35:17 psmith Exp $]])
     23AC_REVISION([[$Id: configure.in,v 1.156 2010/07/28 05:39:50 psmith Exp $]])
    2424
    2525# Autoconf setup
     
    149149fi
    150150
    151 AC_CHECK_FUNCS( strdup mkstemp mktemp fdopen \
    152                 bsd_signal dup2 getcwd realpath sigsetmask sigaction \
     151AC_CHECK_FUNCS( strdup strndup mkstemp mktemp fdopen fileno \
     152                dup2 getcwd realpath sigsetmask sigaction \
    153153                getgroups seteuid setegid setlinebuf setreuid setregid \
    154154                getrlimit setrlimit setvbuf pipe strerror strsignal \
    155155                lstat readlink atexit)
    156156
     157# We need to check declarations, not just existence, because on Tru64 this
     158# function is not declared without special flags, which themselves cause
     159# other problems.  We'll just use our own.
     160AC_CHECK_DECLS([bsd_signal], [], [], [[#include <signal.h>]])
     161
    157162AC_FUNC_SETVBUF_REVERSED
    158163
     
    160165# It doesn't hurt much to use our own if we can't find it so I don't
    161166# make the effort here.
    162 AC_CHECK_FUNCS(strcasecmp strcmpi stricmp)
     167AC_CHECK_FUNCS(strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp)
    163168
    164169# strcoll() is used by the GNU glob library
     
    349354# Check the system to see if it provides GNU glob.  If not, use our
    350355# local version.
    351 
    352356AC_MSG_CHECKING(if system libc has GNU glob)
    353357AC_CACHE_VAL(make_cv_sys_gnu_glob, [
     
    366370 ], [AC_MSG_RESULT(yes)
    367371make_cv_sys_gnu_glob=yes], [AC_MSG_RESULT([no; using local copy])
    368 AC_SUBST(GLOBINC) GLOBINC='-I$(srcdir)/glob'
    369 AC_SUBST(GLOBLIB) GLOBLIB=glob/libglob.a
    370372make_cv_sys_gnu_glob=no])])
     373if test "$make_cv_sys_gnu_glob" = no; then
     374  GLOBINC='-I$(srcdir)/glob'
     375  GLOBLIB=glob/libglob.a
     376fi
     377AC_SUBST(GLOBINC)
     378AC_SUBST(GLOBLIB)
     379
    371380# Tell automake about this, so it can build the right .c files.
    372381AM_CONDITIONAL(USE_LOCAL_GLOB, test "$make_cv_sys_gnu_glob" = no)
  • trunk/src/kmk/debug.h

    r1993 r2591  
    11/* Debugging macros and interface.
    2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free
    3 Software Foundation, Inc.
     2Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
     32009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/default.c

    r2056 r2591  
    11/* Data base of default implicit rules for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    550550
    551551  if (no_builtin_rules_flag)
    552     define_variable ("SUFFIXES", 8, "", o_default, 0);
     552    define_variable_cname ("SUFFIXES", "", o_default, 0);
    553553  else
    554554    {
    555555      char *p = default_suffixes;
    556       suffix_file->deps = (struct dep *)
    557 #ifndef CONFIG_WITH_ALLOC_CACHES
    558         multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
    559                     sizeof (struct dep));
    560 #else
    561         multi_glob (parse_file_seq (&p, '\0', &dep_cache, 1), &dep_cache);
    562 #endif
    563       define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
     556      suffix_file->deps = enter_prereqs(PARSE_FILE_SEQ (&p, struct dep, '\0',
     557                                                        NULL, 0),
     558                                        NULL);
     559      define_variable_cname ("SUFFIXES", default_suffixes, o_default, 0);
    564560    }
    565561}
  • trunk/src/kmk/dep.h

    r1993 r2591  
    11/* Definitions of dependency data structures for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    4444    unsigned int staticpattern : 1;
    4545    unsigned int need_2nd_expansion : 1;
     46    unsigned int dontcare : 1;
     47
    4648#ifdef CONFIG_WITH_INCLUDEDEP
    4749    unsigned int includedep : 1;
     
    5961
    6062
     63#define PARSEFS_NONE    (0x0000)
     64#define PARSEFS_NOSTRIP (0x0001)
     65#define PARSEFS_NOAR    (0x0002)
     66#define PARSEFS_NOGLOB  (0x0004)
     67#define PARSEFS_EXISTS  (0x0008)
     68#define PARSEFS_NOCACHE (0x0010)
     69
    6170#ifndef CONFIG_WITH_ALLOC_CACHES
    62 struct nameseq *multi_glob (struct nameseq *chain, unsigned int size);
     71#define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
     72            (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f))
    6373#else
    64 struct nameseq *multi_glob (struct nameseq *chain, struct alloccache *cache);
     74# define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
     75            (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f), \
     76                                  &PARSE_FILE_SEQ_IGNORE_ ## _t ## _cache)
     77# define PARSE_FILE_SEQ_IGNORE_struct
    6578#endif
     79
    6680#ifdef VMS
    67 struct nameseq *parse_file_seq ();
     81void *parse_file_seq ();
    6882#else
    69 # ifndef CONFIG_WITH_ALLOC_CACHES
    70 struct nameseq *parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip);
    71 # else
    72 struct nameseq *parse_file_seq (char **stringp, int stopchar, struct alloccache *cache, int strip);
    73 # endif
     83void *parse_file_seq (char **stringp, unsigned int size,
     84                      int stopchar, const char *prefix, int flags
     85                      IF_WITH_ALLOC_CACHES_PARAM(struct alloccache *cache));
    7486#endif
     87
    7588char *tilde_expand (const char *name);
    7689
     
    7992#endif
    8093
    81 #define dep_name(d) ((d)->name == 0 ? (d)->file->name : (d)->name)
     94#define dep_name(d)     ((d)->name == 0 ? (d)->file->name : (d)->name)
    8295
    83 struct dep *alloc_dep (void);
    84 void free_dep (struct dep *d);
     96
     97#ifndef CONFIG_WITH_ALLOC_CACHES
     98#define alloc_dep()     (xcalloc (sizeof (struct dep)))
     99#define free_ns(_n)     free (_n)
     100#define free_dep(_d)    free_ns (_d)
     101#else
     102#define alloc_dep()     alloccache_calloc (&dep_cache)
     103#define free_ns(_n)     alloccache_free (&nameseq_cache, _n)
     104#define free_dep(_d)    alloccache_free (&dep_cache, _d)
     105#endif
     106
    85107struct dep *copy_dep_chain (const struct dep *d);
    86108void free_dep_chain (struct dep *d);
    87109void free_ns_chain (struct nameseq *n);
    88110struct dep *read_all_makefiles (const char **makefiles);
    89 #ifndef CONFIG_WITH_VALUE_LENGTH
    90 int eval_buffer (char *buffer);
    91 #else
    92 int eval_buffer (char *buffer, char *eos);
    93 #endif
     111void eval_buffer (char *buffer IF_WITH_VALUE_LENGTH(COMMA char *eos));
    94112int update_goal_chain (struct dep *goals);
    95 void uniquize_deps (struct dep *);
    96113
    97114#ifdef CONFIG_WITH_INCLUDEDEP
     
    100117void eval_include_dep (const char *name, struct floc *f, enum incdep_op op);
    101118void incdep_flush_and_term (void);
    102 
    103 /* read.c */
    104 void record_files (struct nameseq *filenames, const char *pattern,
    105                    const char *pattern_percent, struct dep *deps,
    106                    unsigned int cmds_started, char *commands,
    107                    unsigned int commands_idx, int two_colon,
    108                    const struct floc *flocp);
    109119#endif
    110120
  • trunk/src/kmk/dir.c

    r1993 r2591  
    11/* Directory hashing for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    2424# define NAMLEN(dirent) strlen((dirent)->d_name)
    2525# ifdef VMS
    26 char *vmsify (char *name, int type);
     26/* its prototype is in vmsdir.h, which is not needed for HAVE_DIRENT_H */
     27const char *vmsify (const char *name, int type);
    2728# endif
    2829#else
     
    133134  static PATH_VAR (new_filename);
    134135  char *df;
    135   int i;
    136136
    137137  if (filename == 0)
     
    139139
    140140  df = new_filename;
    141 
    142   /* First, transform the name part.  */
    143141  while (*filename != '\0')
    144142    {
     
    156154
    157155static int
    158 vms_hash (char *name)
     156vms_hash (const char *name)
    159157{
    160158  int h = 0;
     
    182180/* fake stat entry for a directory */
    183181static int
    184 vmsstat_dir (char *name, struct stat *st)
     182vmsstat_dir (const char *name, struct stat *st)
    185183{
    186184  char *s;
     
    195193  if (s)
    196194    {
     195      /* to keep the compiler happy we said "const char *name", now we cheat */
    197196      *s++ = 0;
    198197      st->st_dev = (char *)vms_hash (name);
     
    203202    {
    204203      st->st_dev = 0;
    205       s = name;
    206       h = vms_hash (s);
     204      h = vms_hash (name);
    207205    }
    208206
     
    496494#else
    497495  p = name + strlen (name);
     496# if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
     497  dir_key.name = strcache_add_len (downcase(name), p - name);
     498# else
    498499  dir_key.name = strcache_add_len (name, p - name);
     500# endif
    499501  dir_slot = (struct directory **) hash_find_slot_strcached (&directories, &dir_key);
    500502#endif
     
    516518#endif
    517519#ifndef CONFIG_WITH_STRCACHE2
     520#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
     521      dir->name = strcache_add_len (downcase(name), p - name);
     522#else
    518523      dir->name = strcache_add_len (name, p - name);
    519 #else
     524#endif
     525#else  /* CONFIG_WITH_STRCACHE2 */
    520526      dir->name = dir_key.name;
    521 #endif
     527#endif /* CONFIG_WITH_STRCACHE2 */
    522528      hash_insert_at (&directories, dir, dir_slot);
    523529      /* The directory is not in the name hash table.
     
    826832      dirfile_slot = (struct dirfile **) hash_find_slot (&dir->dirfiles, &dirfile_key);
    827833#else
     834# if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
     835      dirfile_key.name = strcache_add_len (downcase(d->d_name), len);
     836# else
    828837      dirfile_key.name = strcache_add_len (d->d_name, len);
     838# endif
    829839      dirfile_key.length = len;
    830840      dirfile_slot = (struct dirfile **) hash_find_slot_strcached (&dir->dirfiles, &dirfile_key);
     
    844854#endif
    845855#ifndef CONFIG_WITH_STRCACHE2
     856#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
     857          df->name = strcache_add_len (downcase(d->d_name), len);
     858#else
    846859          df->name = strcache_add_len (d->d_name, len);
    847 #else
     860#endif
     861#else  /* CONFIG_WITH_STRCACHE2 */
    848862          df->name = dirfile_key.name;
    849 #endif
     863#endif /* CONFIG_WITH_STRCACHE2 */
    850864          df->length = len;
    851865          df->impossible = 0;
     
    854868      /* Check if the name matches the one we're searching for.  */
    855869#ifndef CONFIG_WITH_STRCACHE2
    856       if (filename != 0 && strieq (d->d_name, filename))
     870      if (filename != 0 && patheq (d->d_name, filename))
    857871#else
    858872      if (filename != 0 && dirfile_key.name == filename)
     
    10101024
    10111025  if (dir->contents == 0)
    1012     {
    1013       /* The directory could not be stat'd.  We allocate a contents
    1014          structure for it, but leave it out of the contents hash table.  */
     1026    /* The directory could not be stat'd.  We allocate a contents
     1027       structure for it, but leave it out of the contents hash table.  */
    10151028#ifndef CONFIG_WITH_ALLOC_CACHES
    1016       dir->contents = xmalloc (sizeof (struct directory_contents));
    1017 #else
    1018       dir->contents = alloccache_alloc (&directory_contents_cache);
    1019 #endif
    1020       memset (dir->contents, '\0', sizeof (struct directory_contents));
    1021     }
     1029    dir->contents = xcalloc (sizeof (struct directory_contents));
     1030#else
     1031    dir->contents = alloccache_calloc (&directory_contents_cache);
     1032#endif
    10221033
    10231034  if (dir->contents->dirfiles.ht_vec == 0)
     
    10401051#endif
    10411052  new->length = strlen (filename);
     1053#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
     1054  new->name = strcache_add_len (downcase(filename), new->length);
     1055#else
    10421056  new->name = strcache_add_len (filename, new->length);
     1057#endif
    10431058  new->impossible = 1;
    10441059#ifndef CONFIG_WITH_STRCACHE2
  • trunk/src/kmk/doc

    • Property svn:ignore
      •  

        old new  
        11Makefile
        22Makefile.in
         3version.texi
        34fdl.texi
        45make-stds.texi
         
        2021make.ps
        2122make.pdf
         23stamp-vti
  • trunk/src/kmk/doc/Makefile.am

    r1993 r2591  
    11# -*-Makefile-*-, or close enough
    2 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    3 # Foundation, Inc.
     2# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     3# 2010 Free Software Foundation, Inc.
    44# This file is part of GNU Make.
    55#
  • trunk/src/kmk/doc/make.texi

    r1993 r2591  
    44
    55@include version.texi
    6 @set EDITION 0.70
    7 @set RCSID $Id: make.texi,v 1.52 2008/05/18 15:11:40 psmith Exp $
     6@set EDITION 0.71
     7@set RCSID $Id: make.texi,v 1.66 2010/07/19 07:10:54 psmith Exp $
    88
    99@settitle GNU @code{make}
     
    1414@syncodeindex pg cp
    1515@c FSF publishers: format makebook.texi instead of using this file directly.
    16 @c ISBN provided by Lisa M. Opus Goldstein <[email protected]>, 5 May 2004
    17 @set ISBN 1-882114-83-5
     16@c ISBN confirmed by Jasimin Huang <[email protected]> on 25 Mar 2009
     17@set ISBN 1-882114-83-3
    1818@c %**end of header
    1919
     
    2727
    2828Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
    29 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007
    30 Free Software Foundation, Inc.
     291996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007,
     302008, 2009, 2010 Free Software Foundation, Inc.
    3131
    3232@quotation
     
    3939License.''
    4040
    41 (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
    42 this GNU Manual. Buying copies from GNU Press supports the FSF in
     41(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
     42modify this GNU manual.  Buying copies from the FSF supports it in
    4343developing GNU and promoting software freedom.''
    4444@end quotation
     
    202202* Interrupts::                  What happens when a recipe is interrupted.
    203203* Recursion::                   Invoking @code{make} from makefiles.
    204 * Sequences::                   Defining canned recipes.
     204* Canned Recipes::              Defining canned recipes.
    205205* Empty Recipes::               Defining useful, do-nothing recipes.
    206206
     
    234234* Override Directive::          How to set a variable in the makefile even if
    235235                                  the user has set it with a command argument.
    236 * Defining::                    An alternate way to set a variable
    237                                   to a verbatim string.
     236* Multi-Line::                  An alternate way to set a variable
     237                                  to a multi-line string.
    238238* Environment::                 Variable values can come from the environment.
    239239* Target-specific::             Variable values can be defined on a per-target
     
    241241* Pattern-specific::            Target-specific variable values can be applied
    242242                                  to a group of targets that match a pattern.
     243* Suppressing Inheritance::     Suppress inheritance of variables.
    243244* Special Variables::           Variables with special meaning or behavior.
    244245
     
    524525
    525526@cindex tabs in rules
    526 A @dfn{recipe} is an action that @code{make} carries out.
    527 A recipe may have more than one command, each on its own line.
    528 @strong{Please note:} you need to put a tab character at the beginning of
    529 every command line!  This is an obscurity that catches the unwary.  If
    530 you prefer to prefix your recipes with a character other than tab,
    531 you can set the @code{.CMDPREFIX} variable to an alternate character
    532 (@pxref{Special Variables}).
     527A @dfn{recipe} is an action that @code{make} carries out.  A recipe
     528may have more than one command, either on the same line or each on its
     529own line.  @strong{Please note:} you need to put a tab character at
     530the beginning of every recipe line!  This is an obscurity that catches
     531the unwary.  If you prefer to prefix your recipes with a character
     532other than tab, you can set the @code{.RECIPEPREFIX} variable to an
     533alternate character (@pxref{Special Variables}).
    533534
    534535Usually a recipe is in a rule with prerequisites and serves to create a
     
    629630prerequisites.  These recipes say how to update the target file.  A
    630631tab character (or whatever character is specified by the
    631 @code{.CMDPREFIX} variable; @pxref{Special Variables}) must come at
     632@code{.RECIPEPREFIX} variable; @pxref{Special Variables}) must come at
    632633the beginning of every line in the recipe to distinguish recipes from
    633634other lines in the makefile.  (Bear in mind that @code{make} does not
    634635know anything about how the recipes work.  It is up to you to supply
    635636recipes that will update the target file properly.  All @code{make}
    636 does is execute the commands in the recipe you have specified when the
    637 target file needs to be updated.)@refill
     637does is execute the recipe you have specified when the target file
     638needs to be updated.)@refill
    638639@cindex recipe
    639640
     
    996997@item
    997998Defining a variable from a verbatim string containing multiple lines
    998 (@pxref{Defining, ,Defining Variables Verbatim}).
     999(@pxref{Multi-Line, ,Defining Multi-Line Variables}).
    9991000@end itemize
    10001001
     
    10971098Extra spaces are allowed and ignored at the beginning of the line, but
    10981099the first character must not be a tab (or the value of
    1099 @code{.CMDPREFIX})---if the line begins with a tab, it will be
     1100@code{.RECIPEPREFIX})---if the line begins with a tab, it will be
    11001101considered a recipe line.  Whitespace is required between
    11011102@code{include} and the file names, and between file names; extra
     
    11711172
    11721173If you want @code{make} to simply ignore a makefile which does not exist
    1173 and cannot be remade, with no error message, use the @w{@code{-include}}
     1174or cannot be remade, with no error message, use the @w{@code{-include}}
    11741175directive instead of @code{include}, like this:
    11751176
     
    11791180
    11801181This acts like @code{include} in every way except that there is no
    1181 error (not even a warning) if any of the @var{filenames} do not exist.
     1182error (not even a warning) if any of the @var{filenames} (or any
     1183prerequisites of any of the @var{filenames}) do not exist or cannot be
     1184remade.
     1185
    11821186For compatibility with some other @code{make} implementations,
    11831187@code{sinclude} is another name for @w{@code{-include}}.
     
    11911195If the environment variable @code{MAKEFILES} is defined, @code{make}
    11921196considers its value as a list of names (separated by whitespace) of
    1193 additional makefiles to be read before the others.  This works much like
    1194 the @code{include} directive: various directories are searched for those
    1195 files (@pxref{Include, ,Including Other Makefiles}).  In addition, the
    1196 default goal is never taken from one of these makefiles and it is not an
    1197 error if the files listed in @code{MAKEFILES} are not found.@refill
     1197additional makefiles to be read before the others.  This works much
     1198like the @code{include} directive: various directories are searched
     1199for those files (@pxref{Include, ,Including Other Makefiles}).  In
     1200addition, the default goal is never taken from one of these makefiles
     1201(or any makefile included by them) and it is not an error if the files
     1202listed in @code{MAKEFILES} are not found.@refill
    11981203
    11991204@cindex recursion, and @code{MAKEFILES} variable
     
    12691274
    12701275When you use the @samp{-t} or @samp{--touch} option
    1271 (@pxref{Instead of Execution, ,Instead of Executing the Recipe}),
     1276(@pxref{Instead of Execution, ,Instead of Executing Recipes}),
    12721277you would not want to use an out-of-date makefile to decide which
    12731278targets to touch.  So the @samp{-t} option has no effect on updating
     
    13871392define @var{immediate}
    13881393  @var{deferred}
     1394endef
     1395
     1396define @var{immediate} =
     1397  @var{deferred}
     1398endef
     1399
     1400define @var{immediate} ?=
     1401  @var{deferred}
     1402endef
     1403
     1404define @var{immediate} :=
     1405  @var{immediate}
     1406endef
     1407
     1408define @var{immediate} +=
     1409  @var{deferred} or @var{immediate}
    13891410endef
    13901411@end example
     
    17481769@cindex tab character (in commands)
    17491770The @var{recipe} lines start with a tab character (or the first
    1750 character in the value of the @code{.CMDPREFIX} variable;
     1771character in the value of the @code{.RECIPEPREFIX} variable;
    17511772@pxref{Special Variables}).  The first recipe line may appear on the line
    17521773after the prerequisites, with a tab character, or may appear on the
     
    18021823GNU @code{make}: normal prerequisites such as described in the
    18031824previous section, and @dfn{order-only} prerequisites.  A normal
    1804 prerequisite makes two statements: first, it imposes an order of
    1805 execution of recipes: any recipes necessary to build any of a
    1806 target's prerequisites will be fully executed before any recipe
    1807 necessary to build the target.  Second, it imposes a dependency
    1808 relationship: if any prerequisite is newer than the target, then the
    1809 target is considered out-of-date and must be rebuilt.
     1825prerequisite makes two statements: first, it imposes an order in which
     1826recipes will be invoked: the recipes for all prerequisites of a target
     1827will be completed before the recipe for the target is run.  Second, it
     1828imposes a dependency relationship: if any prerequisite is newer than
     1829the target, then the target is considered out-of-date and must be
     1830rebuilt.
    18101831
    18111832Normally, this is exactly what you want: if a target's prerequisite is
     
    19491970@noindent
    19501971then the value of the variable @code{objects} is the actual string
    1951 @samp{*.o}.  However, if you use the value of @code{objects} in a target,
    1952 prerequisite, or recipe, wildcard expansion will take place at that time.
    1953 To set @code{objects} to the expansion, instead use:
     1972@samp{*.o}.  However, if you use the value of @code{objects} in a
     1973target or prerequisite, wildcard expansion will take place there.  If
     1974you use the value of @code{objects} in a recipe, the shell may perform
     1975wildcard expansion when the recipe runs.  To set @code{objects} to the
     1976expansion, instead use:
    19541977
    19551978@example
     
    24032426
    24042427When a prerequisite's name has the form @samp{-l@var{name}}, @code{make}
    2405 handles it specially by searching for the file @file{lib@var{name}.so} in
    2406 the current directory, in directories specified by matching @code{vpath}
     2428handles it specially by searching for the file @file{lib@var{name}.so},
     2429and, if it is not found, for the file @file{lib@var{name}.a} in the current
     2430directory, in directories specified by matching @code{vpath}
    24072431search paths and the @code{VPATH} search path, and then in the
    24082432directories @file{/lib}, @file{/usr/lib}, and @file{@var{prefix}/lib}
     
    24102434@code{make} behave as if @var{prefix} is defined to be the root of the
    24112435DJGPP installation tree).
    2412 
    2413 If that file is not found, then the file @file{lib@var{name}.a} is
    2414 searched for, in the same directories as above.
    24152436
    24162437For example, if there is a @file{/usr/lib/libcurses.a} library on your
     
    24352456@samp{-l@var{name}} is seen, @code{make} will replace the percent in
    24362457each pattern in the list with @var{name} and perform the above directory
    2437 searches using that library filename.  If no library is found, the next
    2438 word in the list will be used.
     2458searches using each library filename.
    24392459
    24402460The default value for @code{.LIBPATTERNS} is @samp{lib%.so lib%.a},
     
    28542874recipes in parallel (unless its makefile also contains this target).
    28552875Any prerequisites on this target are ignored.
     2876
     2877@findex .ONESHELL
     2878@item .ONESHELL
     2879@cindex recipe execution, single invocation
     2880
     2881If @code{.ONESHELL} is mentioned as a target, then when a target is
     2882built all lines of the recipe will be given to a single invocation of
     2883the shell rather than each line being invoked separately
     2884(@pxref{Execution, ,Recipe Execution}).
     2885
     2886@findex .POSIX
     2887@item .POSIX
     2888@cindex POSIX-conforming mode, setting
     2889
     2890If @code{.POSIX} is mentioned as a target, then the makefile will be
     2891parsed and run in POSIX-conforming mode.  This does @emph{not} mean
     2892that only POSIX-conforming makefiles will be accepted: all advanced
     2893GNU @code{make} features are still available.  Rather, this target
     2894causes @code{make} to behave as required by POSIX in those areas
     2895where @code{make}'s default behavior differs.
     2896
     2897In particular, if this target is mentioned then recipes will be
     2898invoked as if the shell had been passed the @code{-e} flag: the first
     2899failing command in a recipe will cause the recipe to fail immediately.
    28562900@end table
    28572901
     
    31683212@cindex @code{::} rules (double-colon)
    31693213
    3170 @dfn{Double-colon} rules are rules written with @samp{::} instead of
    3171 @samp{:} after the target names.  They are handled differently from
    3172 ordinary rules when the same target appears in more than one rule.
     3214@dfn{Double-colon} rules are explicit rules written with @samp{::}
     3215instead of @samp{:} after the target names.  They are handled
     3216differently from ordinary rules when the same target appears in more
     3217than one rule.  Pattern rules with double-colons have an entirely
     3218different meaning (@pxref{Match-Anything Rules}).
    31733219
    31743220When a target appears in multiple rules, all the rules must be the same
     
    33513397Users use many different shell programs, but recipes in makefiles are
    33523398always interpreted by @file{/bin/sh} unless the makefile specifies
    3353 otherwise.  @xref{Execution, ,Command Execution}.
     3399otherwise.  @xref{Execution, ,Recipe Execution}.
    33543400
    33553401@menu
     
    33613407* Interrupts::                  What happens when a recipe is interrupted.
    33623408* Recursion::                   Invoking @code{make} from makefiles.
    3363 * Sequences::                   Defining canned recipes.
     3409* Canned Recipes::              Defining canned recipes.
    33643410* Empty Recipes::               Defining useful, do-nothing recipes.
    33653411@end menu
     
    33793425
    33803426Each line in the recipe must start with a tab (or the first character
    3381 in the value of the @code{.CMDPREFIX} variable; @pxref{Special
     3427in the value of the @code{.RECIPEPREFIX} variable; @pxref{Special
    33823428Variables}), except that the first recipe line may be attached to the
    33833429target-and-prerequisites line with a semicolon in between.  @emph{Any}
     
    36293675@cindex @code{--dry-run}
    36303676@cindex @code{--recon}
    3631 When @code{make} is given the flag @samp{-n} or @samp{--just-print}
    3632 it only echoes recipes, it won't execute them.  @xref{Options Summary,
    3633 ,Summary of Options}.  In this case and only this case, even the
    3634 recipe lines starting with @samp{@@} are printed.  This flag is useful for
    3635 finding out which recipes @code{make} thinks are necessary without
    3636 actually doing them.
     3677When @code{make} is given the flag @samp{-n} or @samp{--just-print} it
     3678only echoes most recipes, without executing them.  @xref{Options
     3679Summary, ,Summary of Options}.  In this case even the recipe lines
     3680starting with @samp{@@} are printed.  This flag is useful for finding
     3681out which recipes @code{make} thinks are necessary without actually
     3682doing them.
    36373683
    36383684@cindex @code{-s}
     
    36543700
    36553701When it is time to execute recipes to update a target, they are
    3656 executed by invoking a new subshell for each line of the recipe.  (In
    3657 practice, @code{make} may take shortcuts that do not affect the
    3658 results.)
     3702executed by invoking a new subshell for each line of the recipe,
     3703unless the @code{.ONESHELL} special target is in effect
     3704(@pxref{One Shell, ,Using One Shell})  (In practice, @code{make} may
     3705take shortcuts that do not affect the results.)
    36593706
    36603707@cindex @code{cd} (shell command)
     
    36843731
    36853732@menu
     3733* One Shell::                   One shell for all lines in a recipe
    36863734* Choosing the Shell::          How @code{make} chooses the shell used
    36873735                                  to run recipes.
    36883736@end menu
    36893737
    3690 @node Choosing the Shell,  , Execution, Execution
     3738@node One Shell, Choosing the Shell, Execution, Execution
     3739@subsection Using One Shell
     3740@cindex recipe lines, single shell
     3741@cindex @code{.ONESHELL}, use of
     3742@findex .ONESHELL
     3743
     3744Sometimes you would prefer that all the lines in the recipe be passed
     3745to a single invocation of the shell.  There are generally two
     3746situations where this is useful: first, it can improve performance in
     3747makefiles where recipes consist of many command lines, by avoiding
     3748extra processes.  Second, you might want newlines to be included in
     3749your recipe command (for example perhaps you are using a very
     3750different interpreter as your @code{SHELL}).  If the @code{.ONESHELL}
     3751special target appears anywhere in the makefile then @emph{all}
     3752recipe lines for each target will be provided to a single invocation
     3753of the shell.  Newlines between recipe lines will be preserved.  For
     3754example:
     3755
     3756@example
     3757.ONESHELL:
     3758foo : bar/lose
     3759        cd $(@@D)
     3760        gobble $(@@F) > ../$@@
     3761@end example
     3762
     3763@noindent
     3764would now work as expected even though the commands are on different
     3765recipe lines.
     3766
     3767If @code{.ONESHELL} is provided, then only the first line of the
     3768recipe will be checked for the special prefix characters (@samp{@@},
     3769@samp{-}, and @samp{+}).  Subsequent lines will include the special
     3770characters in the recipe line when the @code{SHELL} is invoked.  If
     3771you want your recipe to start with one of these special characters
     3772you'll need to arrange for them to not be the first characters on the
     3773first line, perhaps by adding a comment or similar.  For example, this
     3774would be a syntax error in Perl because the first @samp{@@} is removed
     3775by make:
     3776
     3777@example
     3778.ONESHELL:
     3779SHELL = /usr/bin/perl
     3780.SHELLFLAGS = -e
     3781show :
     3782        @@f = qw(a b c);
     3783        print "@@f\n";
     3784@end example
     3785
     3786@noindent
     3787However, either of these alternatives would work properly:
     3788
     3789@example
     3790.ONESHELL:
     3791SHELL = /usr/bin/perl
     3792.SHELLFLAGS = -e
     3793show :
     3794        # Make sure "@@" is not the first character on the first line
     3795        @@f = qw(a b c);
     3796        print "@@f\n";
     3797@end example
     3798
     3799@noindent
     3800or
     3801
     3802@example
     3803.ONESHELL:
     3804SHELL = /usr/bin/perl
     3805.SHELLFLAGS = -e
     3806show :
     3807        my @@f = qw(a b c);
     3808        print "@@f\n";
     3809@end example
     3810
     3811As a special feature, if @code{SHELL} is determined to be a
     3812POSIX-style shell, the special prefix characters in ``internal''
     3813recipe lines will @emph{removed} before the recipe is processed.  This
     3814feature is intended to allow existing makefiles to add the
     3815@code{.ONESHELL} special target and still run properly without
     3816extensive modifications.  Since the special prefix characters are not
     3817legal at the beginning of a line in a POSIX shell script this is not a
     3818loss in functionality.  For example, this works as expected:
     3819
     3820@example
     3821.ONESHELL:
     3822foo : bar/lose
     3823        @@cd $(@@D)
     3824        @@gobble $(@@F) > ../$@@
     3825@end example
     3826
     3827Even with this special feature, however, makefiles with
     3828@code{.ONESHELL} will behave differently in ways that could be
     3829noticeable.  For example, normally if any line in the recipe fails,
     3830that causes the rule to fail and no more recipe lines are processed.
     3831Under @code{.ONESHELL} a failure of any but the final recipe line will
     3832not be noticed by @code{make}.  You can modify @code{.SHELLFLAGS} to
     3833add the @code{-e} option to the shell which will cause any failure
     3834anywhere in the command line to cause the shell to fail, but this
     3835could itself cause your recipe to behave differently.  Ultimately you
     3836may need to harden your recipe lines to allow them to work with
     3837@code{.ONESHELL}.
     3838
     3839@node Choosing the Shell,  , One Shell, Execution
    36913840@subsection Choosing the Shell
    36923841@cindex shell, choosing the
    36933842@cindex @code{SHELL}, value of
     3843@cindex @code{.SHELLFLAGS}, value of
    36943844
    36953845@vindex SHELL
     3846@vindex .SHELLFLAGS
    36963847The program used as the shell is taken from the variable @code{SHELL}.
    36973848If this variable is not set in your makefile, the program
    3698 @file{/bin/sh} is used as the shell.
     3849@file{/bin/sh} is used as the shell.  The argument(s) passed to the
     3850shell are taken from the variable @code{.SHELLFLAGS}.  The default
     3851value of @code{.SHELLFLAGS} is @code{-c} normally, or @code{-ec} in
     3852POSIX-conforming mode.
    36993853
    37003854@cindex environment, @code{SHELL} in
     
    37863940on MS-DOS unaltered if you have e.g.@: @file{sh.exe} installed in some
    37873941directory along your @code{PATH}.
     3942
     3943@vindex SHELL
     3944@vindex .SHELLFLAGS
    37883945
    37893946@node Parallel, Errors, Execution, Recipes
     
    40144171times to prevent other sorts of trouble.
    40154172
    4016 @node Recursion, Sequences, Interrupts, Recipes
     4173@node Recursion, Canned Recipes, Interrupts, Recipes
    40174174@section Recursive Use of @code{make}
    40184175@cindex recursion
     
    43604517ensure that there are only @samp{N} jobs running at the same time
    43614518between them all.  Note that any job that is marked recursive
    4362 (@pxref{Instead of Execution, ,Instead of Executing the Recipes})
     4519(@pxref{Instead of Execution, ,Instead of Executing Recipes})
    43634520doesn't count against the total jobs (otherwise we could get @samp{N}
    43644521sub-@code{make}s running and have no slots left over for any real work!)
     
    44964653disable it.
    44974654
    4498 @node Sequences, Empty Recipes, Recursion, Recipes
     4655@node Canned Recipes, Empty Recipes, Recursion, Recipes
    44994656@section Defining Canned Recipes
    45004657@cindex canned recipes
     
    45094666not conflict with other variable names.
    45104667
    4511 Here is an example of defining a canned recipes:
    4512 
    4513 @example
    4514 define run-yacc
     4668Here is an example of defining a canned recipe:
     4669
     4670@example
     4671define run-yacc =
    45154672yacc $(firstword $^)
    45164673mv y.tab.c $@@
     
    45264683parentheses, variable names, and so on, all become part of the value of the
    45274684variable you are defining.
    4528 @xref{Defining, ,Defining Variables Verbatim},
     4685@xref{Multi-Line, ,Defining Multi-Line Variables},
    45294686for a complete explanation of @code{define}.
    45304687
     
    45674724
    45684725@example
    4569 define frobnicate
     4726define frobnicate =
    45704727@@echo "frobnicating target $@@"
    45714728frob-step-1 $< -o $@@-step-1
     
    45904747(@xref{Echoing, ,Recipe Echoing}, for a full explanation of @samp{@@}.)
    45914748
    4592 @node Empty Recipes,  , Sequences, Recipes
     4749@node Empty Recipes,  , Canned Recipes, Recipes
    45934750@section Using Empty Recipes
    45944751@cindex empty recipes
     
    46854842* Override Directive::          How to set a variable in the makefile even if
    46864843                                  the user has set it with a command argument.
    4687 * Defining::                    An alternate way to set a variable
    4688                                   to a verbatim string.
     4844* Multi-Line::                  An alternate way to set a variable
     4845                                  to a multi-line string.
     4846* Undefine Directive::          How to undefine a variable so that it appears
     4847                                  as if it was never set.
    46894848* Environment::                 Variable values can come from the environment.
    46904849* Target-specific::             Variable values can be defined on a per-target
     
    46924851* Pattern-specific::            Target-specific variable values can be applied
    46934852                                  to a group of targets that match a pattern.
     4853* Suppressing Inheritance::     Suppress inheritance of variables.
    46944854* Special Variables::           Variables with special meaning or behavior.
    46954855@end menu
     
    47614921Variables of this sort are defined by lines using @samp{=}
    47624922(@pxref{Setting, ,Setting Variables}) or by the @code{define} directive
    4763 (@pxref{Defining, ,Defining Variables Verbatim}).  The value you specify
     4923(@pxref{Multi-Line, ,Defining Multi-Line Variables}).  The value you specify
    47644924is installed verbatim; if it contains references to other variables,
    47654925these references are expanded whenever this variable is substituted (in
     
    51885348dir = foo
    51895349$(dir)_sources := $(wildcard $(dir)/*.c)
    5190 define $(dir)_print
     5350define $(dir)_print =
    51915351lpr $($(dir)_sources)
    51925352endef
     
    52175377You can specify a value in the makefile, either
    52185378with an assignment (@pxref{Setting, ,Setting Variables}) or with a
    5219 verbatim definition (@pxref{Defining, ,Defining Variables Verbatim}).@refill
     5379verbatim definition (@pxref{Multi-Line, ,Defining Multi-Line Variables}).@refill
    52205380
    52215381@item
     
    54255585value.
    54265586
    5427 @node Override Directive, Defining, Appending, Using Variables
     5587@node Override Directive, Multi-Line, Appending, Using Variables
    54285588@section The @code{override} Directive
    54295589@findex override
     
    54585618@xref{Appending, ,Appending More Text to Variables}.
    54595619
     5620Variable assignments marked with the @code{override} flag have a
     5621higher priority than all other assignments, except another
     5622@code{override}.  Subsequent assignments or appends to this variable
     5623which are not marked @code{override} will be ignored.
     5624
    54605625The @code{override} directive was not invented for escalation in the war
    54615626between makefiles and command arguments.  It was invented so you can alter
     
    54755640
    54765641@example
    5477 override define foo
     5642override define foo =
    54785643bar
    54795644endef
     
    54855650@end iftex
    54865651@ifnottex
    5487 @xref{Defining, ,Defining Variables Verbatim}.
     5652@xref{Multi-Line, ,Defining Multi-Line Variables}.
    54885653@end ifnottex
    54895654
    5490 @node Defining, Environment, Override Directive, Using Variables
    5491 @section Defining Variables Verbatim
     5655@node Multi-Line, Undefine Directive, Override Directive, Using Variables
     5656@section Defining Multi-Line Variables
    54925657@findex define
    54935658@findex endef
     5659@cindex multi-line variable definition
     5660@cindex variables, multi-line
    54945661@cindex verbatim variable definition
    54955662@cindex defining variables verbatim
     
    54985665Another way to set the value of a variable is to use the @code{define}
    54995666directive.  This directive has an unusual syntax which allows newline
    5500 characters to be included in the value, which is convenient for defining
    5501 both canned sequences of commands
    5502 (@pxref{Sequences, ,Defining Canned Command Sequences}), and also
    5503 sections of makefile syntax to use with @code{eval} (@pxref{Eval Function}).
    5504 
    5505 The @code{define} directive is followed on the same line by the name of the
    5506 variable and nothing more.  The value to give the variable appears on the
    5507 following lines.  The end of the value is marked by a line containing just
    5508 the word @code{endef}.  Aside from this difference in syntax, @code{define}
    5509 works just like @samp{=}: it creates a recursively-expanded variable
    5510 (@pxref{Flavors, ,The Two Flavors of Variables}).
    5511 The variable name may contain function and variable references, which
    5512 are expanded when the directive is read to find the actual variable name
     5667characters to be included in the value, which is convenient for
     5668defining both canned sequences of commands (@pxref{Canned Recipes,
     5669,Defining Canned Recipes}), and also sections of makefile syntax to
     5670use with @code{eval} (@pxref{Eval Function}).@refill
     5671
     5672The @code{define} directive is followed on the same line by the name
     5673of the variable being defined and an (optional) assignment operator,
     5674and nothing more.  The value to give the variable appears on the
     5675following lines.  The end of the value is marked by a line containing
     5676just the word @code{endef}.  Aside from this difference in syntax,
     5677@code{define} works just like any other variable definition.  The
     5678variable name may contain function and variable references, which are
     5679expanded when the directive is read to find the actual variable name
    55135680to use.
     5681
     5682You may omit the variable assignment operator if you prefer.  If
     5683omitted, @code{make} assumes it to be @samp{=} and creates a
     5684recursively-expanded variable (@pxref{Flavors, ,The Two Flavors of Variables}).
     5685When using a @samp{+=} operator, the value is appended to the previous
     5686value as with any other append operation: with a single space
     5687separating the old and new values.
    55145688
    55155689You may nest @code{define} directives: @code{make} will keep track of
     
    55185692prefix character are considered part of a recipe, so any @code{define}
    55195693or @code{endef} strings appearing on such a line will not be
    5520 considered @code{make} operators.
    5521 
    5522 @example
    5523 define two-lines
     5694considered @code{make} directives.
     5695
     5696@example
     5697define two-lines =
    55245698echo foo
    55255699echo $(bar)
     
    55515725
    55525726@example
    5553 override define two-lines
     5727override define two-lines =
    55545728foo
    55555729$(bar)
     
    55605734@xref{Override Directive, ,The @code{override} Directive}.
    55615735
    5562 @node Environment, Target-specific, Defining, Using Variables
     5736@node Undefine Directive, Environment, Multi-Line, Using Variables
     5737@section Undefining Variables
     5738@findex undefine
     5739@cindex undefining variable
     5740
     5741If you want to clear a variable, setting its value to empty is usually
     5742sufficient. Expanding such a variable will yield the same result (empty
     5743string) regardless of whether it was set or not. However, if you are
     5744using the @code{flavor} (@pxref{Flavor Function}) and
     5745@code{origin} (@pxref{Origin Function}) functions, there is a difference
     5746between a variable that was never set and a variable with an empty value.
     5747In such situations you may want to use the @code{undefine} directive to
     5748make a variable appear as if it was never set. For example:
     5749
     5750@example
     5751foo := foo
     5752bar = bar
     5753
     5754undefine foo
     5755undefine bar
     5756
     5757$(info $(origin foo))
     5758$(info $(flavor bar))
     5759@end example
     5760
     5761This example will print ``undefined'' for both variables.
     5762
     5763If you want to undefine a command-line variable definition, you can use
     5764the @code{override} directive together with @code{undefine}, similar to
     5765how this is done for variable definitions:
     5766
     5767@example
     5768override undefine CFLAGS
     5769@end example
     5770
     5771@node Environment, Target-specific, Undefine Directive, Using Variables
    55635772@section Variables from the Environment
    55645773
     
    56265835@end example
    56275836
    5628 @noindent
    5629 or like this:
    5630 
    5631 @example
    5632 @var{target} @dots{} : override @var{variable-assignment}
    5633 @end example
    5634 
    5635 @noindent
    5636 or like this:
    5637 
    5638 @example
    5639 @var{target} @dots{} : export @var{variable-assignment}
    5640 @end example
     5837Target-specific variable assignments can be prefixed with any or all of the
     5838special keywords @code{export}, @code{override}, or @code{private};
     5839these apply their normal behavior to this instance of the variable only.
    56415840
    56425841Multiple @var{target} values create a target-specific variable value for
     
    56845883ignore the target-specific values from any other targets.
    56855884
    5686 @node Pattern-specific, Special Variables, Target-specific, Using Variables
     5885@node Pattern-specific, Suppressing Inheritance, Target-specific, Using Variables
    56875886@section Pattern-specific Variable Values
    56885887@cindex pattern-specific variables
     
    56935892@code{make} supports pattern-specific variable values.  In this form,
    56945893the variable is defined for any target that matches the pattern
    5695 specified.  If a target matches more than one pattern, all the
    5696 matching pattern-specific variables are interpreted in the order in
    5697 which they were defined in the makefile, and collected together into
    5698 one set.  Variables defined in this way are searched after any
    5699 target-specific variables defined explicitly for that target, and
    5700 before target-specific variables defined for the parent target.
     5894specified.
    57015895
    57025896Set a pattern-specific variable value like this:
     
    57055899@var{pattern} @dots{} : @var{variable-assignment}
    57065900@end example
    5707 
    5708 @noindent
    5709 or like this:
    5710 
    5711 @example
    5712 @var{pattern} @dots{} : override @var{variable-assignment}
    5713 @end example
    5714 
    5715 @noindent
    57165901where @var{pattern} is a %-pattern.  As with target-specific variable
    57175902values, multiple @var{pattern} values create a pattern-specific variable
     
    57305915matching the pattern @code{%.o}.
    57315916
    5732 @node Special Variables,  , Pattern-specific, Using Variables
     5917If a target matches more than one pattern, the matching pattern-specific
     5918variables with longer stems are interpreted first. This results in more
     5919specific variables taking precedence over the more generic ones, for
     5920example:
     5921
     5922@example
     5923%.o: %.c
     5924        $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@
     5925
     5926lib/%.o: CFLAGS := -fPIC -g
     5927%.o: CFLAGS := -g
     5928
     5929all: foo.o lib/bar.o
     5930@end example
     5931
     5932In this example the first definition of the @code{CFLAGS} variable
     5933will be used to update @file{lib/bar.o} even though the second one
     5934also applies to this target. Pattern-specific variables which result
     5935in the same stem length are considered in the order in which they
     5936were defined in the makefile.
     5937
     5938Pattern-specific variables are searched after any target-specific
     5939variables defined explicitly for that target, and before target-specific
     5940variables defined for the parent target.
     5941
     5942@node Suppressing Inheritance, Special Variables, Pattern-specific, Using Variables
     5943@section Suppressing Inheritance
     5944@findex private
     5945@cindex suppressing inheritance
     5946@cindex inheritance, suppressing
     5947
     5948As described in previous sections, @code{make} variables are inherited
     5949by prerequisites.  This capability allows you to modify the behavior
     5950of a prerequisite based on which targets caused it to be rebuilt.  For
     5951example, you might set a target-specific variable on a @code{debug}
     5952target, then running @samp{make debug} will cause that variable to be
     5953inherited by all prerequisites of @code{debug}, while just running
     5954@samp{make all} (for example) would not have that assignment.
     5955
     5956Sometimes, however, you may not want a variable to be inherited.  For
     5957these situations, @code{make} provides the @code{private} modifier.
     5958Although this modifier can be used with any variable assignment, it
     5959makes the most sense with target- and pattern-specific variables.  Any
     5960variable marked @code{private} will be visible to its local target but
     5961will not be inherited by prerequisites of that target.  A global
     5962variable marked @code{private} will be visible in the global scope but
     5963will not be inherited by any target, and hence will not be visible
     5964in any recipe.
     5965
     5966As an example, consider this makefile:
     5967@example
     5968EXTRA_CFLAGS =
     5969
     5970prog: private EXTRA_CFLAGS = -L/usr/local/lib
     5971prog: a.o b.o
     5972@end example
     5973
     5974Due to the @code{private} modifier, @code{a.o} and @code{b.o} will not
     5975inherit the @code{EXTRA_CFLAGS} variable assignment from the
     5976@code{progs} target.
     5977
     5978@node Special Variables,  , Suppressing Inheritance, Using Variables
    57335979@comment  node-name,  next,  previous,  up
    57345980@section Other Special Variables
     
    58346080variable).  You should not set, modify, or export this variable.
    58356081
    5836 @vindex .CMDPREFIX @r{(change the recipe prefix character)}
    5837 @item .CMDPREFIX
     6082@vindex .RECIPEPREFIX @r{(change the recipe prefix character)}
     6083@item .RECIPEPREFIX
    58386084The first character of the value of this variable is used as the
    58396085character make assumes is introducing a recipe line.  If the variable
     
    58436089@example
    58446090@group
    5845 .CMDPREFIX = >
     6091.RECIPEPREFIX = >
    58466092all:
    58476093> @@echo Hello, world
     
    58496095@end example
    58506096
    5851 The value of @code{.CMDPREFIX} can be changed multiple times; once set
     6097The value of @code{.RECIPEPREFIX} can be changed multiple times; once set
    58526098it stays in effect for all rules parsed until it is modified.
    58536099
     
    71757421all: $(PROGRAMS)
    71767422
    7177 define PROGRAM_template
     7423define PROGRAM_template =
    71787424 $(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%)
    71797425 ALL_OBJS   += $$($(1)_OBJS)
     
    72287474@item environment
    72297475
    7230 if @var{variable} was defined as an environment variable and the
    7231 @samp{-e} option is @emph{not} turned on (@pxref{Options Summary, ,Summary of Options}).
     7476if @var{variable} was inherited from the environment provided to
     7477@code{make}.
    72327478
    72337479@item environment override
    72347480
    7235 if @var{variable} was defined as an environment variable and the
    7236 @w{@samp{-e}} option @emph{is} turned on (@pxref{Options Summary,
    7237 ,Summary of Options}).@refill
     7481if @var{variable} was inherited from the environment provided to
     7482@code{make}, and is overriding a setting for @var{variable} in the
     7483makefile as a result of the @w{@samp{-e}} option (@pxref{Options
     7484Summary, ,Summary of Options}).@refill
    72387485
    72397486@item file
     
    74767723The exit status is one if you use the @samp{-q} flag and @code{make}
    74777724determines that some target is not already up to date.
    7478 @xref{Instead of Execution, ,Instead of Executing the Recipes}.
     7725@xref{Instead of Execution, ,Instead of Executing Recipes}.
    74797726@end table
    74807727
     
    76537900
    76547901@node Instead of Execution, Avoiding Compilation, Goals, Running
    7655 @section Instead of Executing the Recipes
     7902@section Instead of Executing Recipes
    76567903@cindex execution, instead of
    76577904@cindex recipes, instead of executing
     
    76737920
    76747921``No-op''.  The activity is to print what recipe would be used to make
    7675 the targets up to date, but not actually execute it.
     7922the targets up to date, but not actually execute it.  Some recipes are
     7923still executed, even with this flag (@pxref{MAKE Variable, ,How the @code{MAKE} Variable Works}).
    76767924
    76777925@item -t
     
    77157963
    77167964With the @samp{-n} flag, @code{make} prints the recipe that it would
    7717 normally execute but does not execute it.
     7965normally execute but usually does not execute it.
    77187966
    77197967With the @samp{-t} flag, @code{make} ignores the recipes in the rules
     
    77417989not run unless they too begin with @samp{+} or contain @samp{$(MAKE)} or
    77427990@samp{$@{MAKE@}} (@xref{MAKE Variable, ,How the @code{MAKE} Variable Works}.)
     7991
     7992@cindex phony targets and recipe execution
     7993The @samp{-t} flag prevents phony targets (@pxref{Phony Targets}) from
     7994being updated, unless there are recipe lines beginning with @samp{+}
     7995or containing @samp{$(MAKE)} or @samp{$@{MAKE@}}.
    77437996
    77447997The @samp{-W} flag provides two features:
     
    80078260@xref{Environment, ,Variables from the Environment}.
    80088261
     8262@item --eval=@var{string}
     8263@cindex @code{--eval}
     8264@c Extra blank line here makes the table look better.
     8265
     8266Evaluate @var{string} as makefile syntax.  This is a command-line
     8267version of the @code{eval} function (@pxref{Eval Function}).  The
     8268evaluation is performed after the default rules and variables have
     8269been defined, but before any makefiles are read.
     8270
    80098271@item -f @var{file}
    80108272@cindex @code{-f}
     
    80908352@c Extra blank line here makes the table look better.
    80918353
    8092 Print the recipe that would be executed, but do not execute it.
    8093 @xref{Instead of Execution, ,Instead of Executing the Recipes}.
     8354Print the recipe that would be executed, but do not execute it (except
     8355in certain circumstances).
     8356@xref{Instead of Execution, ,Instead of Executing Recipes}.
    80948357
    80958358@item -o @var{file}
     
    81288391return an exit status that is zero if the specified targets are already
    81298392up to date, one if any remaking is required, or two if an error is
    8130 encountered.  @xref{Instead of Execution, ,Instead of Executing the
     8393encountered.  @xref{Instead of Execution, ,Instead of Executing
    81318394Recipes}.@refill
    81328395
     
    81908453instead of running their recipes.  This is used to pretend that the
    81918454recipes were done, in order to fool future invocations of
    8192 @code{make}.  @xref{Instead of Execution, ,Instead of Executing the Recipes}.
     8455@code{make}.  @xref{Instead of Execution, ,Instead of Executing Recipes}.
    81938456
    81948457@item -v
     
    82318494@code{make}, except that the modification time is changed only in the
    82328495imagination of @code{make}.
    8233 @xref{Instead of Execution, ,Instead of Executing the Recipes}.
     8496@xref{Instead of Execution, ,Instead of Executing Recipes}.
    82348497
    82358498@item --warn-undefined-variables
     
    84218684@pindex .c
    84228685@file{@var{n}.o} is made automatically from @file{@var{n}.c} with
    8423 a recipe of the form @samp{$(CC) -c $(CPPFLAGS) $(CFLAGS)}.@refill
     8686a recipe of the form @samp{$(CC) $(CPPFLAGS) $(CFLAGS) -c}.@refill
    84248687
    84258688@item Compiling C++ programs
     
    84318694@file{@var{n}.o} is made automatically from @file{@var{n}.cc},
    84328695@file{@var{n}.cpp}, or @file{@var{n}.C} with a recipe of the form
    8433 @samp{$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)}.  We encourage you to use the
     8696@samp{$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c}.  We encourage you to use the
    84348697suffix @samp{.cc} for C++ source files instead of @samp{.C}.@refill
    84358698
     
    84398702@pindex .p
    84408703@file{@var{n}.o} is made automatically from @file{@var{n}.p}
    8441 with the recipe @samp{$(PC) -c $(PFLAGS)}.@refill
     8704with the recipe @samp{$(PC) $(PFLAGS) -c}.@refill
    84428705
    84438706@item Compiling Fortran and Ratfor programs
     
    84548717@table @samp
    84558718@item .f
    8456 @samp{$(FC) -c $(FFLAGS)}.
     8719@samp{$(FC) $(FFLAGS) -c}.
    84578720@item .F
    8458 @samp{$(FC) -c $(FFLAGS) $(CPPFLAGS)}.
     8721@samp{$(FC) $(FFLAGS) $(CPPFLAGS) -c}.
    84598722@item .r
    8460 @samp{$(FC) -c $(FFLAGS) $(RFLAGS)}.
     8723@samp{$(FC) $(FFLAGS) $(RFLAGS) -c}.
    84618724@end table
    84628725
     
    84698732@table @samp
    84708733@item .F
    8471 @samp{$(FC) -F $(CPPFLAGS) $(FFLAGS)}.
     8734@samp{$(FC) $(CPPFLAGS) $(FFLAGS) -F}.
    84728735@item .r
    8473 @samp{$(FC) -F $(FFLAGS) $(RFLAGS)}.
     8736@samp{$(FC) $(FFLAGS) $(RFLAGS) -F}.
    84748737@end table
    84758738
     
    90669329pattern.  @xref{Last Resort}.
    90679330
     9331More than one pattern rule may match a target.  In this case
     9332@code{make} will choose the ``best fit'' rule.  @xref{Pattern Match,
     9333,How Patterns Match}.
     9334
    90689335@c !!! The end of of this paragraph should be rewritten.  --bob
    90699336Pattern rules may have more than one target.  Unlike normal rules,
     
    90819348@cindex target, multiple in pattern rule
    90829349
    9083 The order in which pattern rules appear in the makefile is important
    9084 since this is the order in which they are considered.
    9085 Of equally applicable
    9086 rules, only the first one found is used.  The rules you write take precedence
    9087 over those that are built in.  Note however, that a rule whose
    9088 prerequisites actually exist or are mentioned always takes priority over a
    9089 rule with prerequisites that must be made by chaining other implicit rules.
    9090 @cindex pattern rules, order of
    9091 @cindex order of pattern rules
    9092 
    90939350@node Pattern Examples, Automatic Variables, Pattern Intro, Pattern Rules
    90949351@subsection Pattern Rule Examples
     
    94039660@file{src/car}.@refill
    94049661
     9662@cindex pattern rules, order of
     9663@cindex order of pattern rules
     9664A pattern rule can be used to build a given file only if there is a
     9665target pattern that matches the file name, @emph{and} all
     9666prerequisites in that rule either exist or can be built.  The rules
     9667you write take precedence over those that are built in. Note however,
     9668that a rule whose prerequisites actually exist or are mentioned always
     9669takes priority over a rule with prerequisites that must be made by
     9670chaining other implicit rules.
     9671
     9672@cindex stem, shortest
     9673It is possible that more than one pattern rule will meet these
     9674criteria.  In that case, @code{make} will choose the rule with the
     9675shortest stem (that is, the pattern that matches most specifically).
     9676If more than one pattern rule has the shortest stem, @code{make} will
     9677choose the first one found in the makefile.
     9678
     9679This algorithm results in more specific rules being preferred over
     9680more generic ones; for example:
     9681
     9682@example
     9683%.o: %.c
     9684        $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@
     9685
     9686%.o : %.f
     9687        $(COMPILE.F) $(OUTPUT_OPTION) $<
     9688
     9689lib/%.o: lib/%.c
     9690        $(CC) -fPIC -c $(CFLAGS) $(CPPFLAGS) $< -o $@@
     9691@end example
     9692
     9693Given these rules and asked to build @file{bar.o} where both
     9694@file{bar.c} and @file{bar.f} exist, @code{make} will choose the first
     9695rule and compile @file{bar.c} into @file{bar.o}.  In the same
     9696situation where @file{bar.c} does not exist, then @code{make} will
     9697choose the second rule and compile @file{bar.f} into @file{bar.o}.
     9698
     9699If @code{make} is asked to build @file{lib/bar.o} and both
     9700@file{lib/bar.c} and @file{lib/bar.f} exist, then the third rule will
     9701be chosen since the stem for this rule (@samp{bar}) is shorter than
     9702the stem for the first rule (@samp{lib/bar}).  If @file{lib/bar.c}
     9703does not exist then the third rule is not eligible and the second rule
     9704will be used, even though the stem is longer.
     9705
    94059706@node Match-Anything Rules, Canceling Rules, Pattern Match, Pattern Rules
    94069707@subsection Match-Anything Pattern Rules
     
    1008410385The ``what if'' flag (@samp{-W} in GNU @code{make}) was (as far as we know)
    1008510386invented by Andrew Hume in @code{mk}.
    10086 @xref{Instead of Execution, ,Instead of Executing the Recipes}.
     10387@xref{Instead of Execution, ,Instead of Executing Recipes}.
    1008710388
    1008810389@item
     
    1010210403@item
    1010310404The special significance of @samp{+} characters preceding recipe lines
    10104 (@pxref{Instead of Execution, ,Instead of Executing the Recipes}) is
     10405(@pxref{Instead of Execution, ,Instead of Executing Recipes}) is
    1010510406mandated by @cite{IEEE Standard 1003.2-1992} (POSIX.2).
    1010610407
     
    1014710448@item
    1014810449Make verbatim variable definitions with @code{define}.
    10149 @xref{Defining, ,Defining Variables Verbatim}.
     10450@xref{Multi-Line, ,Defining Multi-Line Variables}.
    1015010451
    1015110452@item
     
    1035510656@table @code
    1035610657@item define @var{variable}
     10658@itemx define @var{variable} =
     10659@itemx define @var{variable} :=
     10660@itemx define @var{variable} +=
     10661@itemx define @var{variable} ?=
    1035710662@itemx endef
    10358 
    10359 Define a multi-line, recursively-expanded variable.@*
    10360 @xref{Sequences}.
     10663Define multi-line variables.@*
     10664@xref{Multi-Line}.
     10665
     10666@item undefine @var{variable}
     10667Undefining variables.@*
     10668@xref{Undefine Directive}.
    1036110669
    1036210670@item ifdef @var{variable}
     
    1037010678@itemx else
    1037110679@itemx endif
    10372 
    1037310680Conditionally evaluate part of the makefile.@*
    1037410681@xref{Conditionals}.
     
    1037710684@itemx -include @var{file}
    1037810685@itemx sinclude @var{file}
    10379 
    1038010686Include another makefile.@*
    1038110687@xref{Include, ,Including Other Makefiles}.
    1038210688
    10383 @item override @var{variable} = @var{value}
    10384 @itemx override @var{variable} := @var{value}
    10385 @itemx override @var{variable} += @var{value}
    10386 @itemx override @var{variable} ?= @var{value}
    10387 @itemx override define @var{variable}
    10388 @itemx endef
    10389 
     10689@item override @var{variable-assignment}
    1039010690Define a variable, overriding any previous definition, even one from
    1039110691the command line.@*
     
    1039310693
    1039410694@item export
    10395 
    1039610695Tell @code{make} to export all variables to child processes by default.@*
    1039710696@xref{Variables/Recursion, , Communicating Variables to a Sub-@code{make}}.
    1039810697
    1039910698@item export @var{variable}
    10400 @itemx export @var{variable} = @var{value}
    10401 @itemx export @var{variable} := @var{value}
    10402 @itemx export @var{variable} += @var{value}
    10403 @itemx export @var{variable} ?= @var{value}
     10699@itemx export @var{variable-assignment}
    1040410700@itemx unexport @var{variable}
    1040510701Tell @code{make} whether or not to export a particular variable to child
    1040610702processes.@*
    1040710703@xref{Variables/Recursion, , Communicating Variables to a Sub-@code{make}}.
     10704
     10705@item private @var{variable-assignment}
     10706Do not allow this variable assignment to be inherited by prerequisites.@*
     10707@xref{Suppressing Inheritance}.
    1040810708
    1040910709@item vpath @var{pattern} @var{path}
     
    1051510815
    1051610816@item $(error @var{text}@dots{})
    10517 
    1051810817When this function is evaluated, @code{make} generates a fatal error
    1051910818with the message @var{text}.@*
     
    1052110820
    1052210821@item $(warning @var{text}@dots{})
    10523 
    1052410822When this function is evaluated, @code{make} generates a warning with
    1052510823the message @var{text}.@*
     
    1052710825
    1052810826@item $(shell @var{command})
    10529 
    1053010827Execute a shell command and return its output.@*
    1053110828@xref{Shell Function, , The @code{shell} Function}.
    1053210829
    1053310830@item $(origin @var{variable})
    10534 
    1053510831Return a string describing how the @code{make} variable @var{variable} was
    1053610832defined.@*
     
    1053810834
    1053910835@item $(flavor @var{variable})
    10540 
    1054110836Return a string describing the flavor of the @code{make} variable
    1054210837@var{variable}.@*
     
    1054410839
    1054510840@item $(foreach @var{var},@var{words},@var{text})
    10546 
    1054710841Evaluate @var{text} with @var{var} bound to each word in @var{words},
    1054810842and concatenate the results.@*
    1054910843@xref{Foreach Function, ,The @code{foreach} Function}.
    1055010844
     10845@item $(if @var{condition},@var{then-part}[,@var{else-part}])
     10846Evaluate the condition @var{condition}; if it's non-empty substitute
     10847the expansion of the @var{then-part} otherwise substitute the
     10848expansion of the @var{else-part}.@*
     10849@xref{Conditional Functions, ,Functions for Conditionals}.
     10850
     10851@item $(or @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]])
     10852Evaluate each condition @var{conditionN} one at a time; substitute the
     10853first non-empty expansion.  If all expansions are empty, substitute
     10854the empty string.@*
     10855@xref{Conditional Functions, ,Functions for Conditionals}.
     10856
     10857@item $(and @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]])
     10858Evaluate each condition @var{conditionN} one at a time; if any
     10859expansion results in the empty string substitute the empty string.  If
     10860all expansions result in a non-empty string, substitute the expansion
     10861of the last @var{condition}.@*
     10862@xref{Conditional Functions, ,Functions for Conditionals}.
     10863
    1055110864@item $(call @var{var},@var{param},@dots{})
    10552 
    1055310865Evaluate the variable @var{var} replacing any references to @code{$(1)},
    1055410866@code{$(2)} with the first, second, etc.@: @var{param} values.@*
     
    1055610868
    1055710869@item $(eval @var{text})
    10558 
    1055910870Evaluate @var{text} then read the results as makefile commands.
    1056010871Expands to the empty string.@*
     
    1056210873
    1056310874@item $(value @var{var})
    10564 
    1056510875Evaluates to the contents of the variable @var{var}, with no expansion
    1056610876performed on it.@*
     
    1074711057second form of the error above.  Remember that every line in the
    1074811058recipe must begin with a tab character (unless you set
    10749 @code{.CMDPREFIX}; @pxref{Special Variables}).  Eight spaces do not
     11059@code{.RECIPEPREFIX}; @pxref{Special Variables}).  Eight spaces do not
    1075011060count.  @xref{Rule Syntax}.
    1075111061
     
    1100711317#### End of system configuration section. ####
    1100811318
    11009 SRC1 =  tar.c create.c extract.c buffer.c \
    11010         getoldopt.c update.c gnu.c mangle.c
    11011 SRC2 =  version.c list.c names.c diffarch.c \
    11012         port.c wildmat.c getopt.c
    11013 SRC3 =  getopt1.c regex.c getdate.y
    11014 SRCS =  $(SRC1) $(SRC2) $(SRC3)
    11015 OBJ1 =  tar.o create.o extract.o buffer.o \
    11016         getoldopt.o update.o gnu.o mangle.o
    11017 OBJ2 =  version.o list.o names.o diffarch.o \
    11018         port.o wildmat.o getopt.o
    11019 OBJ3 =  getopt1.o regex.o getdate.o $(RTAPELIB)
    11020 OBJS =  $(OBJ1) $(OBJ2) $(OBJ3)
     11319@group
     11320SRCS_C  = tar.c create.c extract.c buffer.c   \
     11321          getoldopt.c update.c gnu.c mangle.c \
     11322          version.c list.c names.c diffarch.c \
     11323          port.c wildmat.c getopt.c getopt1.c \
     11324          regex.c
     11325SRCS_Y  = getdate.y
     11326SRCS    = $(SRCS_C) $(SRCS_Y)
     11327OBJS    = $(SRCS_C:.c=.o) $(SRCS_Y:.y=.o) $(RTAPELIB)
     11328@end group
    1102111329@group
    1102211330AUX =   README COPYING ChangeLog Makefile.in  \
  • trunk/src/kmk/dosbuild.bat

    r1993 r2591  
    11@echo off
    2 rem Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    3 rem Free Software Foundation, Inc.
     2rem Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
     3rem 2008, 2009, 2010 Free Software Foundation, Inc.
    44rem This file is part of GNU Make.
    55rem
  • trunk/src/kmk/electric.c

    r2413 r2591  
    159159
    160160void *
    161 xcalloc (size_t size, size_t items)
     161xcalloc (unsigned size)
    162162{
    163163    void *result;
    164     result = xmalloc (size * items);
    165     return memset (result, 0, size * items);
     164    result = xmalloc (size);
     165    return memset (result, 0, size);
    166166}
    167167
  • trunk/src/kmk/electric.h

    r2413 r2591  
    3333
    3434void xfree (void *);
    35 void *xcalloc (size_t, size_t);
     35void *xcalloc (unsigned int);
    3636void *xmalloc (unsigned int);
    3737void *xrealloc (void *, unsigned int);
     
    3939
    4040#define free(a)         xfree(a)
    41 #define calloc(a,b)     xcalloc((a),(b))
     41#define calloc(a,b)     xcalloc((a) * (b))
    4242#define malloc(a)       xmalloc(a)
    4343#define realloc(a,b)    xrealloc((a),(b))
  • trunk/src/kmk/expand.c

    r2548 r2591  
    11/* Variable expansion functions for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    539539      if (*p == '\0')
    540540        break;
    541       else
    542         ++p;
     541
     542      ++p;
    543543    }
    544544
     
    845845{
    846846#ifndef CONFIG_WITH_VALUE_LENGTH
    847   char *tmp;
     847  char *tmp, *alloc = NULL;
     848  char *r;
    848849#endif
    849850
     
    855856    return allocated_variable_expand (str);
    856857
    857   tmp = alloca (end - str + 1);
     858  if (end - str + 1 > 1000)
     859    tmp = alloc = xmalloc (end - str + 1);
     860  else
     861    tmp = alloca (end - str + 1);
     862
    858863  memcpy (tmp, str, end - str);
    859864  tmp[end - str] = '\0';
    860865
    861   return allocated_variable_expand (tmp);
     866  r = allocated_variable_expand (tmp);
     867
     868  if (alloc)
     869    free (alloc);
     870
     871  return r;
    862872#else  /* CONFIG_WITH_VALUE_LENGTH */
    863873  if (!end)
     
    11031113  value = variable_expand_for_file (line, file);
    11041114
    1105 #if 0
    1106   /* Waste a little memory and save time.  */
    1107   value = xrealloc (value, strlen (value))
    1108 #endif
    1109 
    11101115  variable_buffer = obuf;
    11111116  variable_buffer_length = olen;
  • trunk/src/kmk/file.c

    r2024 r2591  
    11/* Target file management for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    119119      name += 2;
    120120#endif
    121   while (name[0] == '.' && name[1] == '/' && name[2] != '\0')
     121  while (name[0] == '.'
     122#ifdef HAVE_DOS_PATHS
     123         && (name[1] == '/' || name[1] == '\\')
     124#else
     125         && name[1] == '/'
     126#endif
     127         && name[2] != '\0')
    122128    {
    123129      name += 2;
    124       while (*name == '/')
     130      while (*name == '/'
     131#ifdef HAVE_DOS_PATHS
     132             || *name == '\\'
     133#endif
     134             )
    125135        /* Skip following slashes: ".//foo" is "foo", not "/foo".  */
    126136        ++name;
     
    230240
    231241#ifndef CONFIG_WITH_ALLOC_CACHES
    232   new = xmalloc (sizeof (struct file));
    233   memset (new, '\0', sizeof (struct file));
     242  new = xcalloc (sizeof (struct file));
    234243#else
    235244  new = alloccache_calloc (&file_cache);
     
    511520
    512521
     522/* Given a string containing prerequisites (fully expanded), break it up into
     523   a struct dep list.  Enter each of these prereqs into the file database.
     524 */
    513525struct dep *
    514 parse_prereqs (char *p)
    515 {
    516 #ifndef CONFIG_WITH_ALLOC_CACHES
    517   struct dep *new = (struct dep *)
    518     multi_glob (parse_file_seq (&p, '|', sizeof (struct dep), 1),
    519                 sizeof (struct dep));
    520 #else
    521   struct dep *new = (struct dep *)
    522     multi_glob (parse_file_seq (&p, '|', &dep_cache, 1), &dep_cache);
    523 #endif
     526split_prereqs (char *p)
     527{
     528  struct dep *new = PARSE_FILE_SEQ (&p, struct dep, '|', NULL, 0);
    524529
    525530  if (*p)
     
    530535
    531536      ++p;
    532 #ifndef CONFIG_WITH_ALLOC_CACHES
    533       ood = (struct dep *)
    534         multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
    535                     sizeof (struct dep));
    536 #else
    537       ood = (struct dep *)
    538         multi_glob (parse_file_seq (&p, '\0', &dep_cache, 1), &dep_cache);
    539 #endif
     537      ood = PARSE_FILE_SEQ (&p, struct dep, '\0', NULL, 0);
    540538
    541539      if (! new)
     
    556554}
    557555
     556/* Given a list of prerequisites, enter them into the file database.
     557   If STEM is set then first expand patterns using STEM.  */
     558struct dep *
     559enter_prereqs (struct dep *deps, const char *stem)
     560{
     561  struct dep *d1;
     562
     563  if (deps == 0)
     564    return 0;
     565
     566  /* If we have a stem, expand the %'s.  We use patsubst_expand to translate
     567     the prerequisites' patterns into plain prerequisite names.  */
     568  if (stem)
     569    {
     570      const char *pattern = "%";
     571      char *buffer = variable_expand ("");
     572      struct dep *dp = deps, *dl = 0;
     573
     574      while (dp != 0)
     575        {
     576          char *percent;
     577          int nl = strlen (dp->name) + 1;
     578          char *nm = alloca (nl);
     579          memcpy (nm, dp->name, nl);
     580          percent = find_percent (nm);
     581          if (percent)
     582            {
     583              char *o;
     584
     585              /* We have to handle empty stems specially, because that
     586                 would be equivalent to $(patsubst %,dp->name,) which
     587                 will always be empty.  */
     588              if (stem[0] == '\0')
     589                {
     590                  memmove (percent, percent+1, strlen (percent));
     591                  o = variable_buffer_output (buffer, nm, strlen (nm) + 1);
     592                }
     593              else
     594                o = patsubst_expand_pat (buffer, stem, pattern, nm,
     595                                         pattern+1, percent+1);
     596
     597              /* If the name expanded to the empty string, ignore it.  */
     598              if (buffer[0] == '\0')
     599                {
     600                  struct dep *df = dp;
     601                  if (dp == deps)
     602                    dp = deps = deps->next;
     603                  else
     604                    dp = dl->next = dp->next;
     605                  free_dep (df);
     606                  continue;
     607                }
     608
     609              /* Save the name.  */
     610              dp->name = strcache_add_len (buffer, o - buffer);
     611            }
     612          dp->stem = stem;
     613          dp->staticpattern = 1;
     614          dl = dp;
     615          dp = dp->next;
     616        }
     617    }
     618
     619  /* Enter them as files, unless they need a 2nd expansion.  */
     620  for (d1 = deps; d1 != 0; d1 = d1->next)
     621    {
     622      if (d1->need_2nd_expansion)
     623        continue;
     624
     625      d1->file = lookup_file (d1->name);
     626      if (d1->file == 0)
     627        d1->file = enter_file (d1->name);
     628      d1->staticpattern = 0;
     629      d1->name = 0;
     630    }
     631
     632  return deps;
     633}
     634
    558635/* Set the intermediate flag.  */
    559636
     
    570647{
    571648  struct dep *d;
    572   struct dep *old = f->deps;
     649  struct dep **dp;
    573650  const char *file_stem = f->stem;
    574   unsigned int last_dep_has_cmds = f->updating;
    575651  int initialized = 0;
    576652
    577653  f->updating = 0;
    578   f->deps = 0;
    579 
    580   for (d = old; d != 0; d = d->next)
    581     {
    582       struct dep *new, *d1;
     654
     655  /* Walk through the dependencies.  For any dependency that needs 2nd
     656     expansion, expand it then insert the result into the list.  */
     657  dp = &f->deps;
     658  d = f->deps;
     659  while (d != 0)
     660    {
    583661      char *p;
    584 #ifdef CONFIG_WITH_STRCACHE2
    585       unsigned int len;
    586 #endif
    587 
    588       if (! d->name)
    589         continue;
     662      struct dep *new, *next;
     663      char *name = (char *)d->name;
     664
     665      if (! d->name || ! d->need_2nd_expansion)
     666        {
     667          /* This one is all set already.  */
     668          dp = &d->next;
     669          d = d->next;
     670          continue;
     671        }
    590672
    591673#ifdef CONFIG_WITH_INCLUDEDEP
     
    597679      if (d->includedep)
    598680        {
    599           new = d1 = alloc_dep();
     681          struct dep *d1 = new = alloc_dep();
    600682          d1->staticpattern = 0;
    601683          d1->need_2nd_expansion = 0;
     
    618700        }
    619701      else
     702      {
     703#endif /* CONFIG_WITH_INCLUDEDEP */
     704
     705      /* If it's from a static pattern rule, convert the patterns into
     706         "$*" so they'll expand properly.  */
     707      if (d->staticpattern)
    620708        {
    621 #endif
    622 
    623       /* Create the dependency list.
    624          If we're not doing 2nd expansion, then it's just the name.  We will
    625          still need to massage it though.  */
    626       if (! d->need_2nd_expansion)
     709          char *o;
     710          d->name = o = variable_expand ("");
     711          o = subst_expand (o, name, "%", "$*", 1, 2, 0);
     712          *o = '\0';
     713          free (name);
     714#ifndef CONFIG_WITH_STRCACHE2
     715          d->name = name = xstrdup (variable_buffer); /* bird not d->name, can be reallocated */
     716#else
     717          d->name = strcache2_add (&file_strcache, variable_buffer, o - variable_buffer);
     718#endif
     719          d->staticpattern = 0;
     720        }
     721
     722      /* We're going to do second expansion so initialize file variables for
     723         the file. Since the stem for static pattern rules comes from
     724         individual dep lines, we will temporarily set f->stem to d->stem.  */
     725      if (!initialized)
    627726        {
    628           p = variable_expand ("");
    629 #ifndef CONFIG_WITH_STRCACHE2
    630           variable_buffer_output (p, d->name, strlen (d->name) + 1);
     727          initialize_file_variables (f, 0);
     728          initialized = 1;
     729        }
     730
     731      if (d->stem != 0)
     732        f->stem = d->stem;
     733
     734#if defined(CONFIG_WITH_COMMANDS_FUNC) || defined (CONFIG_WITH_DOT_MUST_MAKE)
     735      set_file_variables (f, 0 /* real call, f->deps == 0 so we're ok. */);
    631736#else
    632           len = strcache2_get_len (&file_strcache, d->name);
    633           variable_buffer_output (p, d->name, len + 1);
    634 #endif
    635           p = variable_buffer;
     737      set_file_variables (f);
     738#endif
     739
     740      p = variable_expand_for_file (d->name, f);
     741
     742      if (d->stem != 0)
     743        f->stem = file_stem;
     744
     745      /* At this point we don't need the name anymore: free it.  */
     746      free (name);
     747
     748      /* Parse the prerequisites and enter them into the file database.  */
     749      new = enter_prereqs (split_prereqs (p), d->stem);
     750
     751      /* If there were no prereqs here (blank!) then throw this one out.  */
     752      if (new == 0)
     753        {
     754          *dp = d->next;
     755          free_dep (d);
     756          d = *dp;
     757          continue;
    636758        }
    637       else
    638         {
    639           /* If it's from a static pattern rule, convert the patterns into
    640              "$*" so they'll expand properly.  */
    641           if (d->staticpattern)
    642             {
    643               char *o;
    644               char *buffer = variable_expand ("");
    645 
    646               o = subst_expand (buffer, d->name, "%", "$*", 1, 2, 0);
    647               buffer = variable_buffer; /* bird - variable_buffer may have been reallocated. */
    648 
    649               d->name = strcache_add_len (variable_buffer,
    650                                           o - variable_buffer);
    651               d->staticpattern = 0; /* Clear staticpattern so that we don't
    652                                        re-expand %s below. */
    653             }
    654 
    655           /* We are going to do second expansion so initialize file variables
    656              for the file. Since the stem for static pattern rules comes from
    657              individual dep lines, we will temporarily set f->stem to d->stem.
    658           */
    659           if (!initialized)
    660             {
    661               initialize_file_variables (f, 0);
    662               initialized = 1;
    663             }
    664 
    665           if (d->stem != 0)
    666             f->stem = d->stem;
    667 
    668 #if defined(CONFIG_WITH_COMMANDS_FUNC) || defined (CONFIG_WITH_DOT_MUST_MAKE)
    669           set_file_variables (f, 0 /* real call, f->deps == 0 so we're ok. */);
    670 #else
    671           set_file_variables (f);
    672 #endif
    673 
    674 #if !defined (CONFIG_WITH_VALUE_LENGTH) || !defined (CONFIG_WITH_STRCACHE2)
    675           p = variable_expand_for_file (d->name, f);
    676 #else
    677           len = strcache2_get_len (&file_strcache, d->name);
    678           p = variable_expand_for_file_2 (NULL, d->name, len, f, &len);
    679 #endif
    680 
    681           if (d->stem != 0)
    682             f->stem = file_stem;
    683         }
    684 
    685       /* Parse the prerequisites.  */
    686       new = parse_prereqs (p);
    687 
    688       /* If this dep list was from a static pattern rule, expand the %s.  We
    689          use patsubst_expand to translate the prerequisites' patterns into
    690          plain prerequisite names.  */
    691       if (new && d->staticpattern)
    692         {
    693           const char *pattern = "%";
    694           char *buffer = variable_expand ("");
    695           struct dep *dp = new, *dl = 0;
    696 
    697           while (dp != 0)
    698             {
    699               char *percent;
    700 #ifndef KMK
    701               int nl = strlen (dp->name) + 1;
    702               char *nm = alloca (nl);
    703               memcpy (nm, dp->name, nl);
    704               percent = find_percent (nm);
    705 #else  /* KMK - don't make a stack copy unless it's actually required! */
    706               unsigned int nl = strcache2_get_len (&file_strcache, dp->name);
    707               char *nm;
    708               percent = memchr (dp->name, '%', nl);
    709               if (percent)
    710                 {
    711                   nm = alloca (nl + 1);
    712                   memcpy (nm, dp->name, nl + 1);
    713                   percent = find_percent (nm);
    714                 }
    715 #endif /* KMK */
    716               if (percent)
    717                 {
    718                   char *o;
    719 
    720                   /* We have to handle empty stems specially, because that
    721                      would be equivalent to $(patsubst %,dp->name,) which
    722                      will always be empty.  */
    723                   if (d->stem[0] == '\0')
    724                     {
    725                       memmove (percent, percent+1, strlen (percent));
    726                       o = variable_buffer_output (buffer, nm, strlen (nm) + 1);
    727                     }
    728                   else
    729                     {
    730                       o = patsubst_expand_pat (buffer, d->stem, pattern, nm,
    731                                                pattern+1, percent+1);
    732                       o = variable_buffer_output (o, "", 1); /* bird fix - patsubst_expand_pat doesn't terminate,
    733                                                                 the if case does and strcache would appreciate it. */
    734                     }
    735                   buffer = variable_buffer; /* bird fix - variable_buffer may have been reallocated. */
    736 
    737 
    738                   /* If the name expanded to the empty string, ignore it.  */
    739                   if (buffer[0] == '\0')
    740                     {
    741                       struct dep *df = dp;
    742                       if (dp == new)
    743                         dp = new = new->next;
    744                       else
    745                         dp = dl->next = dp->next;
    746                       free_dep (df);
    747                       continue;
    748                     }
    749 
    750                   /* Save the name.  */
    751                   dp->name = strcache_add_len (buffer, o - buffer - 1); /* bird fix - don't include the terminator. */
    752                 }
    753               dl = dp;
    754               dp = dp->next;
    755             }
    756         }
    757 
    758       /* Enter them as files. */
    759       for (d1 = new; d1 != 0; d1 = d1->next)
    760         {
    761           d1->file = lookup_file (d1->name);
    762           if (d1->file == 0)
    763             d1->file = enter_file (d1->name);
    764           d1->name = 0;
    765           d1->staticpattern = 0;
    766           d1->need_2nd_expansion = 0;
    767         }
    768759
    769760#ifdef CONFIG_WITH_INCLUDEDEP
    770         }
    771 #endif
    772 
    773       /* Add newly parsed deps to f->deps. If this is the last dependency
    774          line and this target has commands then put it in front so the
    775          last dependency line (the one with commands) ends up being the
    776          first. This is important because people expect $< to hold first
    777          prerequisite from the rule with commands. If it is not the last
    778          dependency line or the rule does not have commands then link it
    779          at the end so it appears in makefile order.  */
    780 
    781       if (new != 0)
    782         {
    783           if (d->next == 0 && last_dep_has_cmds)
    784             {
    785               struct dep **d_ptr;
    786               for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next)
    787                 ;
    788 
    789               *d_ptr = f->deps;
    790               f->deps = new;
    791             }
    792           else
    793             {
    794               struct dep **d_ptr;
    795               for (d_ptr = &f->deps; *d_ptr; d_ptr = &(*d_ptr)->next)
    796                 ;
    797 
    798               *d_ptr = new;
    799             }
    800         }
    801     }
    802 
    803   free_dep_chain (old);
     761      }
     762#endif
     763
     764      /* Add newly parsed prerequisites.  */
     765      next = d->next;
     766      *dp = new;
     767      for (dp = &new->next, d = new->next; d != 0; dp = &d->next, d = d->next)
     768        ;
     769      *dp = next;
     770      d = *dp;
     771    }
     772}
     773
     774/* Reset the updating flag.  */
     775
     776static void
     777reset_updating (const void *item)
     778{
     779  struct file *f = (struct file *) item;
     780  f->updating = 0;
    804781}
    805782
     
    816793  struct file *f2;
    817794  struct dep *d;
    818   struct file **file_slot_0;
    819   struct file **file_slot;
    820   struct file **file_end;
    821 
    822   /* Perform second expansion and enter each dependency name as a file. */
    823 
    824   /* Expand .SUFFIXES first; it's dependencies are used for $$* calculation. */
    825   for (f = lookup_file (".SUFFIXES"); f != 0; f = f->prev)
    826     expand_deps (f);
     795
     796  /* Remember that we've done this.  Once we start snapping deps we can no
     797     longer define new targets.  */
     798  snapped_deps = 1;
    827799
    828800#ifdef CONFIG_WITH_2ND_TARGET_EXPANSION
     
    832804  if (second_target_expansion)
    833805    {
     806      struct file **file_slot_0, **file_end, **file_slot;
    834807# ifdef KMK /* turn on warnings here. */
    835808      int save = warn_undefined_variables_flag;
     
    862835#endif /* CONFIG_WITH_INCLUDEDEP */
    863836
    864   /* For every target that's not .SUFFIXES, expand its dependencies.
    865      We must use hash_dump (), because within this loop we might add new files
    866      to the table, possibly causing an in-situ table expansion.  */
    867   file_slot_0 = (struct file **) hash_dump (&files, 0, 0);
    868   file_end = file_slot_0 + files.ht_fill;
    869   for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
    870     for (f = *file_slot; f != 0; f = f->prev)
    871 #ifndef CONFIG_WITH_STRCACHE2
    872       if (strcmp (f->name, ".SUFFIXES") != 0)
    873 #else
    874       if (f->name != suffixes_strcached)
    875 #endif
     837  /* Perform second expansion and enter each dependency name as a file.  We
     838     must use hash_dump() here because within these loops we likely add new
     839     files to the table, possibly causing an in-situ table expansion.
     840
     841     We only need to do this if second_expansion has been defined; if it
     842     hasn't then all deps were expanded as the makefile was read in.  If we
     843     ever change make to be able to unset .SECONDARY_EXPANSION this will have
     844     to change.  */
     845
     846  if (second_expansion)
     847    {
     848      struct file **file_slot_0 = (struct file **) hash_dump (&files, 0, 0);
     849      struct file **file_end = file_slot_0 + files.ht_fill;
     850      struct file **file_slot;
     851      const char *suffixes;
     852
     853      /* Expand .SUFFIXES: its prerequisites are used for $$* calc.  */
     854      f = lookup_file (".SUFFIXES");
     855      suffixes = f ? f->name : 0;
     856      for (; f != 0; f = f->prev)
    876857        expand_deps (f);
     858
    877859#ifdef KMK
    878   /* This is a HACK to work around the still broken test #9 in
    879      features/double_colon.  It produces the wrong result if the build is
    880      parallel because of changed evaluation order.  Just make these
    881      problematic rules execute in single field till a proper fix is
    882      forthcomming...  */
    883 
    884   for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
    885     if (   (f = *file_slot) != 0
    886         && f->double_colon
    887         && (   f->double_colon != f
    888             || f->last != f))
    889       for (f2 = f->double_colon; f2 != 0; f2 = f2->prev)
    890         f2->command_flags |= COMMANDS_NOTPARALLEL;
     860      /* This is a HACK to work around the still broken test #9 in
     861         features/double_colon.  It produces the wrong result if the build is
     862         parallel because of changed evaluation order.  Just make these
     863         problematic rules execute in single field till a proper fix is
     864         forthcomming...  */
     865
     866      for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
     867        if (   (f = *file_slot) != 0
     868            && f->double_colon
     869            && (   f->double_colon != f
     870                || f->last != f))
     871          for (f2 = f->double_colon; f2 != 0; f2 = f2->prev)
     872            f2->command_flags |= COMMANDS_NOTPARALLEL;
    891873#endif /* KMK */
    892   free (file_slot_0);
     874
     875      /* For every target that's not .SUFFIXES, expand its prerequisites.  */
     876
     877      for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
     878        for (f = *file_slot; f != 0; f = f->prev)
     879          if (f->name != suffixes)
     880            expand_deps (f);
     881      free (file_slot_0);
     882    }
     883  else
     884    /* We're not doing second expansion, so reset updating.  */
     885    hash_map (&files, reset_updating);
    893886
    894887  /* Now manage all the special targets.  */
     
    985978  /* This needs more work: what if the user sets this in the makefile?
    986979  if (posix_pedantic)
    987     define_variable (STRING_SIZE_TUPLE("OUTPUT_OPTION"), "", o_default, 1);
     980    define_variable_cname ("OUTPUT_OPTION", "", o_default, 1);
    988981  */
    989982#endif
    990 
    991   /* Remember that we've done this. */
    992   snapped_deps = 1;
    993983}
    994984
     
    11211111/* Print the data base of files.  */
    11221112
     1113void
     1114print_prereqs (const struct dep *deps)
     1115{
     1116  const struct dep *ood = 0;
     1117
     1118  /* Print all normal dependencies; note any order-only deps.  */
     1119  for (; deps != 0; deps = deps->next)
     1120    if (! deps->ignore_mtime)
     1121      printf (" %s", dep_name (deps));
     1122    else if (! ood)
     1123      ood = deps;
     1124
     1125  /* Print order-only deps, if we have any.  */
     1126  if (ood)
     1127    {
     1128      printf (" | %s", dep_name (ood));
     1129      for (ood = ood->next; ood != 0; ood = ood->next)
     1130        if (ood->ignore_mtime)
     1131          printf (" %s", dep_name (ood));
     1132    }
     1133
     1134  putchar ('\n');
     1135}
     1136
    11231137static void
    11241138print_file (const void *item)
    11251139{
    11261140  const struct file *f = item;
    1127   struct dep *d;
    1128   struct dep *ood = 0;
    11291141
    11301142  putchar ('\n');
     
    11581170    printf ("%s:%s", f->name, f->double_colon ? ":" : "");
    11591171
    1160   /* Print all normal dependencies; note any order-only deps.  */
    1161   for (d = f->deps; d != 0; d = d->next)
    1162     if (! d->ignore_mtime)
    1163       printf (" %s", dep_name (d));
    1164     else if (! ood)
    1165       ood = d;
    1166 
    1167   /* Print order-only deps, if we have any.  */
    1168   if (ood)
    1169     {
    1170       printf (" | %s", dep_name (ood));
    1171       for (d = ood->next; d != 0; d = d->next)
    1172         if (d->ignore_mtime)
    1173           printf (" %s", dep_name (d));
    1174     }
    1175 
    1176   putchar ('\n');
     1172  print_prereqs (f->deps);
    11771173
    11781174#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     
    12061202  if (f->also_make != 0)
    12071203    {
     1204      const struct dep *d;
    12081205      fputs (_("#  Also makes:"), stdout);
    12091206      for (d = f->also_make; d != 0; d = d->next)
     
    13001297    do{\
    13011298        if (_p->_n && _p->_n[0] && !strcache_iscached (_p->_n)) \
    1302           printf ("%s: Field %s not cached: %s\n", _p->name, # _n, _p->_n); \
     1299          error (NULL, "%s: Field '%s' not cached: %s\n", _p->name, # _n, _p->_n); \
    13031300    }while(0)
    13041301
     
    13171314  for (d = f->deps; d != 0; d = d->next)
    13181315    {
    1319       VERIFY_CACHED (d, name);
     1316      if (! d->need_2nd_expansion)
     1317        VERIFY_CACHED (d, name);
    13201318      VERIFY_CACHED (d, stem);
    13211319    }
  • trunk/src/kmk/filedef.h

    r2001 r2591  
    11/* Definition of target file data structures for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    107107    unsigned int considered:1;  /* equal to 'considered' if file has been
    108108                                   considered on current scan of goal chain */
     109    unsigned int no_diag:1;     /* True if the file failed to update and no
     110                                   diagnostics has been issued (dontcare). */
     111
    109112#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    110113    unsigned int multi_maybe:1; /* Nonzero if this file isn't always updated
     
    117120                                  and the expanding done in snap_deps. */
    118121#endif
    119 
    120122  };
    121123
    122124
    123 extern struct file *default_goal_file, *suffix_file, *default_file;
    124 extern char **default_goal_name;
     125extern struct file *suffix_file, *default_file;
    125126
    126127
     
    130131#endif
    131132struct file *enter_file (const char *name);
    132 struct dep *parse_prereqs (char *prereqs);
     133struct dep *split_prereqs (char *prereqstr);
     134struct dep *enter_prereqs (struct dep *prereqs, const char *stem);
    133135void remove_intermediates (int sig);
    134136void snap_deps (void);
     
    139141void init_hash_files (void);
    140142char *build_target_list (char *old_list);
     143void print_prereqs (const struct dep *deps);
     144void print_file_data_base (void);
    141145
    142146#if FILE_TIMESTAMP_HI_RES
  • trunk/src/kmk/function.c

    r2574 r2591  
    11/* Builtin function expansion for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    514514  unsigned int idx;
    515515
    516 #ifndef CONFIG_WITH_ALLOC_CACHES
    517   chain = multi_glob (parse_file_seq
    518                       (&line, '\0', sizeof (struct nameseq),
    519                        /* We do not want parse_file_seq to strip `./'s.
    520                           That would break examples like:
    521                           $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)).  */
    522                        0),
    523                       sizeof (struct nameseq));
    524 #else  /* CONFIG_WITH_ALLOC_CACHES */
    525   chain = multi_glob (parse_file_seq
    526                       (&line, '\0', &nameseq_cache,
    527                        /* We do not want parse_file_seq to strip `./'s.
    528                           That would break examples like:
    529                           $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)).  */
    530                        0),
    531                       &nameseq_cache);
    532 #endif /* CONFIG_WITH_ALLOC_CACHES */
     516  chain = PARSE_FILE_SEQ (&line, struct nameseq, '\0', NULL,
     517                          /* We do not want parse_file_seq to strip `./'s.
     518                             That would break examples like:
     519                             $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)).  */
     520                          PARSEFS_NOSTRIP|PARSEFS_NOCACHE|PARSEFS_EXISTS);
    533521
    534522  if (result == 0)
     
    541529  while (chain != 0)
    542530    {
    543       const char *name = chain->name;
    544       unsigned int len = strlen (name);
    545 
    546531      struct nameseq *next = chain->next;
     532      unsigned int len = strlen (chain->name);
     533
     534      if (idx + len + 1 > length)
     535        {
     536          length += (len + 1) * 2;
     537          result = xrealloc (result, length);
     538        }
     539      memcpy (&result[idx], chain->name, len);
     540      idx += len;
     541      result[idx++] = ' ';
     542
     543      /* Because we used PARSEFS_NOCACHE above, we have to free() NAME.  */
     544      free ((char *)chain->name);
    547545#ifndef CONFIG_WITH_ALLOC_CACHES
    548546      free (chain);
     
    551549#endif
    552550      chain = next;
    553 
    554       /* multi_glob will pass names without globbing metacharacters
    555          through as is, but we want only files that actually exist.  */
    556       if (file_exists_p (name))
    557         {
    558           if (idx + len + 1 > length)
    559             {
    560               length += (len + 1) * 2;
    561               result = xrealloc (result, length);
    562             }
    563           memcpy (&result[idx], name, len);
    564           idx += len;
    565           result[idx++] = ' ';
    566         }
    567551    }
    568552
     
    13461330
    13471331      free (var->value);
    1348       var->value = savestring (p, len);
     1332      var->value = xstrndup (p, len);
    13491333
    13501334      result = allocated_variable_expand (body);
     
    22202204
    22212205void
    2222 windows32_openpipe (int *pipedes, int *pid_p, char **command_argv, char **envp)
     2206windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp)
    22232207{
    22242208  SECURITY_ATTRIBUTES saAttr;
     
    22412225                      TRUE,
    22422226                      DUPLICATE_SAME_ACCESS) == FALSE) {
    2243     fatal (NILF, _("create_child_process: DuplicateHandle(In) failed (e=%ld)\n"),
     2227    fatal (NILF, _("windows32_openpipe(): DuplicateHandle(In) failed (e=%ld)\n"),
    22442228           GetLastError());
    22452229
     
    22522236                      TRUE,
    22532237                      DUPLICATE_SAME_ACCESS) == FALSE) {
    2254     fatal (NILF, _("create_child_process: DuplicateHandle(Err) failed (e=%ld)\n"),
     2238    fatal (NILF, _("windows32_open_pipe(): DuplicateHandle(Err) failed (e=%ld)\n"),
    22552239           GetLastError());
    22562240  }
     
    22622246
    22632247  if (!hProcess)
    2264     fatal (NILF, _("windows32_openpipe (): process_init_fd() failed\n"));
     2248    fatal (NILF, _("windows32_openpipe(): process_init_fd() failed\n"));
    22652249
    22662250  /* make sure that CreateProcess() has Path it needs */
    22672251  sync_Path_environment();
     2252  /* `sync_Path_environment' may realloc `environ', so take note of
     2253     the new value.  */
     2254  envp = environ;
    22682255
    22692256  if (!process_begin(hProcess, command_argv, envp, command_argv[0], NULL)) {
     
    22722259
    22732260    /* set the pid for returning to caller */
    2274     *pid_p = (int) hProcess;
     2261    *pid_p = (pid_t) hProcess;
    22752262
    22762263  /* set up to read data from child */
    2277   pipedes[0] = _open_osfhandle((long) hChildOutRd, O_RDONLY);
     2264  pipedes[0] = _open_osfhandle((intptr_t) hChildOutRd, O_RDONLY);
    22782265
    22792266  /* this will be closed almost right away */
    2280   pipedes[1] = _open_osfhandle((long) hChildOutWr, O_APPEND);
     2267  pipedes[1] = _open_osfhandle((intptr_t) hChildOutWr, O_APPEND);
    22812268  } else {
    22822269    /* reap/cleanup the failed process */
     
    22932280    /* set status for return */
    22942281    pipedes[0] = pipedes[1] = -1;
    2295     *pid_p = -1;
     2282    *pid_p = (pid_t)-1;
    22962283  }
    22972284}
     
    23662353#ifndef _AMIGA
    23672354static char *
    2368 func_shell (char *o, char **argv, const char *funcname UNUSED)
     2355func_shell (char * volatile o, char **argv, const char *funcname UNUSED)
    23692356{
    23702357  char *batch_filename = NULL;
     
    23742361#endif
    23752362  char **command_argv;
    2376   const char *error_prefix;
     2363  const char * volatile error_prefix; /* bird: this volatile and the 'o' one, is for shutting up gcc warnings */
    23772364  char **envp;
    23782365  int pipedes[2];
    2379   int pid;
     2366  pid_t pid;
    23802367
    23812368#ifndef __MSDOS__
     
    24672454      free (command_argv);
    24682455
    2469       /* Close the write side of the pipe.  */
    2470 # ifdef _MSC_VER /* Avoid annoying msvcrt when debugging. (bird) */
    2471       if (pipedes[1] != -1)
    2472 # endif
    2473       close (pipedes[1]);
     2456      /* Close the write side of the pipe.  We test for -1, since
     2457         pipedes[1] is -1 on MS-Windows, and some versions of MS
     2458         libraries barf when `close' is called with -1.  */
     2459      if (pipedes[1] >= 0)
     2460        close (pipedes[1]);
    24742461#endif
    24752462
     
    34423429
    34433430
     3431#ifdef HAVE_DOS_PATHS
     3432#define IS_ABSOLUTE(n) (n[0] && n[1] == ':')
     3433#define ROOT_LEN 3
     3434#else
     3435#define IS_ABSOLUTE(n) (n[0] == '/')
     3436#define ROOT_LEN 1
     3437#endif
     3438
    34443439/* Return the absolute name of file NAME which does not contain any `.',
    34453440   `..' components nor any repeated path separators ('/').   */
     
    34533448  char *dest;
    34543449  const char *start, *end, *apath_limit;
     3450  unsigned long root_len = ROOT_LEN;
    34553451
    34563452  if (name[0] == '\0' || apath == NULL)
     
    34793475  apath_limit = apath + GET_PATH_MAX;
    34803476
    3481 #ifdef HAVE_DOS_PATHS /* bird added this */
    3482   if (isalpha(name[0]) && name[1] == ':')
    3483     {
    3484       /* drive spec */
    3485       apath[0] = toupper(name[0]);
    3486       apath[1] = ':';
    3487       apath[2] = '/';
    3488       name += 2;
    3489     }
    3490   else
    3491 #endif /* HAVE_DOS_PATHS */
    3492   if (name[0] != '/')
     3477  if (!IS_ABSOLUTE(name))
    34933478    {
    34943479      /* It is unlikely we would make it until here but just to make sure. */
     
    34983483      strcpy (apath, starting_directory);
    34993484
     3485#ifdef HAVE_DOS_PATHS
     3486      if (IS_PATHSEP(name[0]))
     3487        {
     3488          if (IS_PATHSEP(name[1]))
     3489            {
     3490              /* A UNC.  Don't prepend a drive letter.  */
     3491              apath[0] = name[0];
     3492              apath[1] = name[1];
     3493              root_len = 2;
     3494            }
     3495          /* We have /foo, an absolute file name except for the drive
     3496             letter.  Assume the missing drive letter is the current
     3497             drive, which we can get if we remove from starting_directory
     3498             everything past the root directory.  */
     3499          apath[root_len] = '\0';
     3500        }
     3501#endif
     3502
    35003503      dest = strchr (apath, '\0');
    35013504    }
    35023505  else
    35033506    {
    3504       apath[0] = '/';
    3505       dest = apath + 1;
     3507      strncpy (apath, name, root_len);
     3508      apath[root_len] = '\0';
     3509      dest = apath + root_len;
     3510      /* Get past the root, since we already copied it.  */
     3511      name += root_len;
     3512#ifdef HAVE_DOS_PATHS
     3513      if (!IS_PATHSEP(apath[2]))
     3514        {
     3515          /* Convert d:foo into d:./foo and increase root_len.  */
     3516          apath[2] = '.';
     3517          apath[3] = '/';
     3518          dest++;
     3519          root_len++;
     3520          /* strncpy above copied one character too many.  */
     3521          name--;
     3522        }
     3523      else
     3524        apath[2] = '/'; /* make sure it's a forward slash */
     3525#endif
    35063526    }
    35073527
     
    35113531
    35123532      /* Skip sequence of multiple path-separators.  */
    3513       while (*start == '/')
     3533      while (IS_PATHSEP(*start))
    35143534        ++start;
    35153535
    35163536      /* Find end of path component.  */
    3517       for (end = start; *end != '\0' && *end != '/'; ++end)
     3537      for (end = start; *end != '\0' && !IS_PATHSEP(*end); ++end)
    35183538        ;
    35193539
     
    35273547        {
    35283548          /* Back up to previous component, ignore if at root already.  */
    3529           if (dest > apath + 1)
    3530             while ((--dest)[-1] != '/');
     3549          if (dest > apath + root_len)
     3550            for (--dest; !IS_PATHSEP(dest[-1]); --dest);
    35313551        }
    35323552      else
    35333553        {
    3534           if (dest[-1] != '/')
     3554          if (!IS_PATHSEP(dest[-1]))
    35353555            *dest++ = '/';
    35363556
     
    35463566
    35473567  /* Unless it is root strip trailing separator.  */
    3548 #ifdef HAVE_DOS_PATHS /* bird (is this correct? what about UNC?) */
    3549   if (dest > apath + 1 + (apath[0] != '/') && dest[-1] == '/')
    3550 #else
    3551   if (dest > apath + 1 && dest[-1] == '/')
    3552 #endif
     3568  if (dest > apath + root_len && IS_PATHSEP(dest[-1]))
    35533569    --dest;
    35543570
     
    35673583  int doneany = 0;
    35683584  unsigned int len = 0;
     3585#ifndef HAVE_REALPATH
     3586  struct stat st;
     3587#endif
    35693588  PATH_VAR (in);
    35703589  PATH_VAR (out);
     
    35813600              realpath (in, out)
    35823601#else
    3583               abspath (in, out)
     3602              abspath (in, out) && stat (out, &st) == 0
    35843603#endif
    35853604             )
  • trunk/src/kmk/getloadavg.c

    r1993 r2591  
    11/* Get the system load averages.
    22Copyright (C) 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
    3 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    4 Free Software Foundation, Inc.
     31995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
     42008, 2009, 2010 Free Software Foundation, Inc.
    55
    66GNU Make is free software; you can redistribute it and/or modify it under the
  • trunk/src/kmk/getopt.c

    r1993 r2591  
    55
    66Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
    7 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    8 Foundation, Inc.
     71997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     82010 Free Software Foundation, Inc.
    99
    1010NOTE: The canonical source of this file is maintained with the GNU C Library.
     
    683683                {
    684684                  if (opterr)
    685                    if (argv[optind - 1][1] == '-')
    686                     /* --option */
    687                     fprintf (stderr,
    688                      _("%s: option `--%s' doesn't allow an argument\n"),
    689                      argv[0], pfound->name);
    690                    else
    691                     /* +option or -option */
    692                     fprintf (stderr,
    693                      _("%s: option `%c%s' doesn't allow an argument\n"),
    694                      argv[0], argv[optind - 1][0], pfound->name);
     685                    {
     686                      if (argv[optind - 1][1] == '-')
     687                        /* --option */
     688                        fprintf (stderr,
     689                         _("%s: option `--%s' doesn't allow an argument\n"),
     690                         argv[0], pfound->name);
     691                      else
     692                        /* +option or -option */
     693                        fprintf (stderr,
     694                         _("%s: option `%c%s' doesn't allow an argument\n"),
     695                         argv[0], argv[optind - 1][0], pfound->name);
     696                    }
    695697
    696698                  nextchar += strlen (nextchar);
  • trunk/src/kmk/getopt.h

    r1993 r2591  
    11/* Declarations for getopt.
    22Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
    3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
    4 Inc.
     31999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
     4Software Foundation, Inc.
    55
    66NOTE: The canonical source of this file is maintained with the GNU C Library.
  • trunk/src/kmk/getopt1.c

    r1993 r2591  
    11/* getopt_long and getopt_long_only entry points for GNU getopt.
    22Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55
    66NOTE: The canonical source of this file is maintained with the GNU C Library.
  • trunk/src/kmk/gettext.h

    r1993 r2591  
    11/* Convenience header for conditional use of GNU <libintl.h>.
    22Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/glob

    • Property svn:ignore
      --- 
      +++ 
      
  • trunk/src/kmk/glob/ChangeLog

    r1993 r2591  
     12008-09-28  Juan Manuel Guerrero  <[email protected]>
     2
     3        * glob.c (my_realloc) [__DJGPP__]: Don't define, and don't
     4        redefine realloc to call it, since the DJGPP's realloc handles
     5        NULL pointers correctly.
     6
    172007-12-22  Juan Manuel Guerrero  <[email protected]>  (tiny change)
    28
    3         * glob/glob.c [__GNU_LIBRARY__ && __DJGPP__]: Add a realloc
     9        * glob.c [__GNU_LIBRARY__ && __DJGPP__]: Add a realloc
    410        declaration that matches the one in the DJGPP libc.
    511
  • trunk/src/kmk/glob/glob.c

    r2001 r2591  
    183183#endif
    184184
    185 #if !defined(__GNU_LIBRARY__) && !defined(ELECTRIC_HEAP) && !defined(__APPLE__) /* bird (last two) */
     185#if !defined __GNU_LIBRARY__ && !defined __DJGPP__ && !defined ELECTRIC_HEAP && !defined __APPLE__ /* bird (last two) */
    186186# ifdef __GNUC__
    187187__inline
     
    192192static void *
    193193my_realloc (void *p, unsigned int n)
    194 #  elif defined(__DJGPP__)
    195 static void *
    196 my_realloc (void *p, size_t n)
    197194#  else
    198195static char *
     
    210207# define        realloc my_realloc
    211208# endif /* __SASC */
    212 #endif /* __GNU_LIBRARY__ */
     209#endif /* __GNU_LIBRARY__ || __DJGPP__ */
    213210
    214211
     
    390387          /* Allocate working buffer large enough for our work.  Note that
    391388            we have at least an opening and closing brace.  */
    392           size_t firstc;
     389          size_t firstc;  /* bird: correct type. */
    393390          char *alt_start;
    394391          const char *p;
  • trunk/src/kmk/hash.c

    r1993 r2591  
    11/* hash.c -- hash table maintenance
    2 Copyright (C) 1995, 1999, 2002 Free Software Foundation, Inc.
     2Copyright (C) 1995, 1999, 2002, 2010 Free Software Foundation, Inc.
    33Written by Greg McGary <[email protected]> <[email protected]>
    44
     
    5151  if (ht->ht_vec == 0)
    5252    {
    53       fprintf (stderr, _("can't allocate %ld bytes for hash table: memory exhausted"),
    54                ht->ht_size * sizeof(struct token *));
     53      fprintf (stderr, _("can't allocate %lu bytes for hash table: memory exhausted"),
     54               ht->ht_size * (unsigned long) sizeof (struct token *));
    5555      exit (1);
    5656    }
     
    252252{
    253253  void **slot = hash_find_slot (ht, item);
    254   const void *old_item = slot ? *slot : 0;
     254  const void *old_item = *slot;
    255255  hash_insert_at (ht, item, slot);
    256256  return (void *)((HASH_VACANT (old_item)) ? 0 : old_item);
  • trunk/src/kmk/hash.h

    r1993 r2591  
    11/* hash.h -- decls for hash table
    2 Copyright (C) 1995, 1999, 2002 Free Software Foundation, Inc.
     2Copyright (C) 1995, 1999, 2002, 2010 Free Software Foundation, Inc.
    33Written by Greg McGary <[email protected]> <[email protected]>
    44
     
    9898/* hash and comparison macros for case-sensitive string keys. */
    9999
     100/* Due to the strcache, it's not uncommon for the string pointers to
     101   be identical.  Take advantage of that to short-circuit string compares.  */
     102
    100103#define STRING_HASH_1(KEY, RESULT) do { \
    101104  unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
     
    121124
    122125#define STRING_COMPARE(X, Y, RESULT) do { \
    123   RESULT = strcmp ((X), (Y)); \
     126    RESULT = (X) == (Y) ? 0 : strcmp ((X), (Y)); \
    124127} while (0)
    125128#define return_STRING_COMPARE(X, Y) do { \
    126   return strcmp ((X), (Y)); \
     129  return (X) == (Y) ? 0 : strcmp ((X), (Y)); \
    127130} while (0)
    128131
     
    157160
    158161#define STRING_N_COMPARE(X, Y, N, RESULT) do { \
    159   RESULT = strncmp ((X), (Y), (N)); \
     162  RESULT = (X) == (Y) ? 0 : strncmp ((X), (Y), (N)); \
    160163} while (0)
    161164#define return_STRING_N_COMPARE(X, Y, N) do { \
    162   return strncmp ((X), (Y), (N)); \
     165  return (X) == (Y) ? 0 : strncmp ((X), (Y), (N)); \
    163166} while (0)
    164167
     
    190193
    191194#define ISTRING_COMPARE(X, Y, RESULT) do { \
    192   RESULT = strcasecmp ((X), (Y)); \
     195  RESULT = (X) == (Y) ? 0 : strcasecmp ((X), (Y)); \
    193196} while (0)
    194197#define return_ISTRING_COMPARE(X, Y) do { \
    195   return strcasecmp ((X), (Y)); \
     198  return (X) == (Y) ? 0 : strcasecmp ((X), (Y)); \
    196199} while (0)
    197200
  • trunk/src/kmk/implicit.c

    r2024 r2591  
    11/* Implicit rule searching for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    4949    return 1;
    5050
    51 #ifndef NO_ARCHIVES
     51#ifndef NO_ARCHIVES
    5252  /* If this is an archive member reference, use just the
    5353     archive member name to search for implicit rules.  */
     
    5757           _("Looking for archive-member implicit rule for `%s'.\n"));
    5858      if (pattern_search (file, 1, depth, 0))
    59         return 1;
     59        return 1;
    6060    }
    6161#endif
     
    6464}
    6565
    66 
    67 
    68 #ifdef CONFIG_WITH_ALLOC_CACHES
    69 struct alloccache idep_cache;
    70 #endif
    71 
    72 /* Struct idep captures information about implicit prerequisites
    73    that come from implicit rules. */
    74 struct idep
    75 {
    76   struct idep *next;              /* struct dep -compatible interface */
    77   const char *name;               /* name of the prerequisite */
    78   struct file *intermediate_file; /* intermediate file, 0 otherwise */
    79   const char *intermediate_pattern; /* pattern for intermediate file */
    80   unsigned char had_stem;         /* had % substituted with stem */
    81   unsigned char ignore_mtime;     /* ignore_mtime flag */
    82 };
    83 
    84 static void
    85 free_idep_chain (struct idep *p)
    86 {
    87   struct idep *n;
    88 
    89   for (; p != 0; p = n)
    90     {
    91       n = p->next;
    92 #ifndef CONFIG_WITH_ALLOC_CACHES
    93       free (p);
    94 #else
    95       alloccache_free (&idep_cache, p);
    96 #endif
    97     }
    98 }
    9966
    10067
     
    10370   length of the word.  */
    10471
    105 static char *
     72static const char *
    10673get_next_word (const char *buffer, unsigned int *length)
    10774{
     
    181148    *length = p - beg;
    182149
    183   return (char *)beg;
     150  return beg;
     151}
     152
     153/* This structure stores information about the expanded prerequisites for a
     154   pattern rule.  NAME is always set to the strcache'd name of the prereq.
     155   FILE and PATTERN will be set for intermediate files only.  IGNORE_MTIME is
     156   copied from the prerequisite we expanded.
     157 */
     158struct patdeps
     159  {
     160    const char *name;
     161    const char *pattern;
     162    struct file *file;
     163    unsigned int ignore_mtime : 1;
     164  };
     165
     166/* This structure stores information about pattern rules that we need
     167   to try.
     168*/
     169struct tryrule
     170  {
     171    struct rule *rule;
     172
     173    /* Index of the target in this rule that matched the file. */
     174    unsigned int matches;
     175
     176    /* Stem length for this match. */
     177    unsigned int stemlen;
     178
     179    /* Definition order of this rule. Used to implement stable sort.*/
     180    unsigned int order;
     181
     182    /* Nonzero if the LASTSLASH logic was used in matching this rule. */
     183    char checked_lastslash;
     184  };
     185
     186int
     187stemlen_compare (const void *v1, const void *v2)
     188{
     189  const struct tryrule *r1 = v1;
     190  const struct tryrule *r2 = v2;
     191  int r = r1->stemlen - r2->stemlen;
     192  return r != 0 ? r : (int)(r1->order - r2->order);
    184193}
    185194
     
    209218
    210219  /* The last slash in FILENAME (or nil if there is none).  */
    211   char *lastslash;
     220  const char *lastslash;
    212221
    213222  /* This is a file-object used as an argument in
    214223     recursive calls.  It never contains any data
    215224     except during a recursive call.  */
    216   struct file *intermediate_file = 0;
    217 
    218   /* This linked list records all the prerequisites actually
    219      found for a rule along with some other useful information
    220      (see struct idep for details). */
    221   struct idep* deps = 0;
    222 
    223   /* 1 if we need to remove explicit prerequisites, 0 otherwise. */
    224   unsigned int remove_explicit_deps = 0;
     225  struct file *int_file = 0;
     226
     227  /* List of dependencies found recursively.  */
     228  struct patdeps *deplist
     229    = xmalloc (max_pattern_deps * sizeof (struct patdeps));
     230  struct patdeps *pat = deplist;
     231
     232  /* All the prerequisites actually found for a rule, after expansion. */
     233  struct dep *deps;
    225234
    226235  /* Names of possible dependencies are constructed in this buffer.  */
     
    233242
    234243  /* Buffer in which we store all the rules that are possibly applicable.  */
    235   struct rule **tryrules = xmalloc (num_pattern_rules * max_pattern_targets
    236                                     * sizeof (struct rule *));
     244  struct tryrule *tryrules = xmalloc (num_pattern_rules * max_pattern_targets
     245                                      * sizeof (struct tryrule));
    237246
    238247  /* Number of valid elements in TRYRULES.  */
    239248  unsigned int nrules;
    240249
    241   /* The numbers of the rule targets of each rule
    242      in TRYRULES that matched the target file.  */
    243   unsigned int *matches = alloca (num_pattern_rules * sizeof (unsigned int));
    244 
    245   /* Each element is nonzero if LASTSLASH was used in
    246      matching the corresponding element of TRYRULES.  */
    247   char *checked_lastslash = alloca (num_pattern_rules * sizeof (char));
    248 
    249250  /* The index in TRYRULES of the rule we found.  */
    250251  unsigned int foundrule;
     
    252253  /* Nonzero if should consider intermediate files as dependencies.  */
    253254  int intermed_ok;
     255
     256  /* Nonzero if we have initialized file variables for this target.  */
     257  int file_vars_initialized = 0;
    254258
    255259  /* Nonzero if we have matched a pattern-rule target
     
    257261  int specific_rule_matched = 0;
    258262
     263  struct dep dep_simple;
     264
    259265  unsigned int ri;  /* uninit checks OK */
    260266  struct rule *rule;
    261   struct dep *dep, *expl_d;
    262 
    263   struct idep *d;
    264   struct idep **id_ptr;
    265   struct dep **d_ptr;
     267
     268  char *pathdir = NULL;
     269  unsigned long pathlen;
    266270
    267271  PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */
    268272
    269 #ifdef CONFIG_WITH_ALLOC_CACHES
    270   if (!idep_cache.size)
    271     alloccache_init (&idep_cache, sizeof (struct idep), "idep", NULL, NULL);
    272 #endif
    273 
    274 #ifndef NO_ARCHIVES
     273#ifndef NO_ARCHIVES
    275274  if (archive || ar_name (filename))
    276275    lastslash = 0;
     
    279278    {
    280279      /* Set LASTSLASH to point at the last slash in FILENAME
    281         but not counting any slash at the end.  (foo/bar/ counts as
    282         bar/ in directory foo/, not empty in directory foo/bar/.)  */
     280        but not counting any slash at the end.  (foo/bar/ counts as
     281        bar/ in directory foo/, not empty in directory foo/bar/.)  */
    283282#ifdef VMS
    284283      lastslash = strrchr (filename, ']');
    285284      if (lastslash == 0)
    286         lastslash = strrchr (filename, ':');
     285        lastslash = strrchr (filename, ':');
    287286#else
    288287      lastslash = strrchr (filename, '/');
    289288#ifdef HAVE_DOS_PATHS
    290289      /* Handle backslashes (possibly mixed with forward slashes)
    291         and the case of "d:file".  */
     290        and the case of "d:file".  */
    292291      {
    293         char *bslash = strrchr (filename, '\\');
    294         if (lastslash == 0 || bslash > lastslash)
    295           lastslash = bslash;
    296         if (lastslash == 0 && filename[0] && filename[1] == ':')
    297           lastslash = (char *)filename + 1;
     292        char *bslash = strrchr (filename, '\\');
     293        if (lastslash == 0 || bslash > lastslash)
     294          lastslash = bslash;
     295        if (lastslash == 0 && filename[0] && filename[1] == ':')
     296          lastslash = filename + 1;
    298297      }
    299298#endif
    300299#endif
    301300      if (lastslash != 0 && lastslash[1] == '\0')
    302         lastslash = 0;
     301        lastslash = 0;
    303302    }
    304303
    305   /* First see which pattern rules match this target
    306      and may be considered.  Put them in TRYRULES.  */
     304  pathlen = lastslash - filename + 1;
     305
     306  /* First see which pattern rules match this target and may be considered.
     307     Put them in TRYRULES.  */
    307308
    308309  nrules = 0;
     
    312313
    313314      /* If the pattern rule has deps but no commands, ignore it.
    314         Users cancel built-in rules by redefining them without commands.  */
     315        Users cancel built-in rules by redefining them without commands.  */
    315316      if (rule->deps != 0 && rule->cmds == 0)
    316         continue;
     317        continue;
    317318
    318319      /* If this rule is in use by a parent pattern_search,
    319         don't use it here.  */
     320        don't use it here.  */
    320321      if (rule->in_use)
    321         {
    322           DBS (DB_IMPLICIT, (_("Avoiding implicit rule recursion.\n")));
    323           continue;
    324         }
     322        {
     323          DBS (DB_IMPLICIT, (_("Avoiding implicit rule recursion.\n")));
     324          continue;
     325        }
    325326
    326327      for (ti = 0; ti < rule->num; ++ti)
    327         {
    328           const char *target = rule->targets[ti];
    329           const char *suffix = rule->suffixes[ti];
    330           int check_lastslash;
    331 
    332           /* Rules that can match any filename and are not terminal
    333              are ignored if we're recursing, so that they cannot be
    334              intermediate files.  */
    335           if (recursions > 0 && target[1] == '\0' && !rule->terminal)
    336             continue;
    337 
    338           if (rule->lens[ti] > namelen)
    339             /* It can't possibly match.  */
    340             continue;
    341 
    342           /* From the lengths of the filename and the pattern parts,
    343              find the stem: the part of the filename that matches the %.  */
    344           stem = filename + (suffix - target - 1);
    345           stemlen = namelen - rule->lens[ti] + 1;
    346 
    347           /* Set CHECK_LASTSLASH if FILENAME contains a directory
    348              prefix and the target pattern does not contain a slash.  */
     328        {
     329          const char *target = rule->targets[ti];
     330          const char *suffix = rule->suffixes[ti];
     331          int check_lastslash;
     332
     333          /* Rules that can match any filename and are not terminal
     334             are ignored if we're recursing, so that they cannot be
     335             intermediate files.  */
     336          if (recursions > 0 && target[1] == '\0' && !rule->terminal)
     337            continue;
     338
     339          if (rule->lens[ti] > namelen)
     340            /* It can't possibly match.  */
     341            continue;
     342
     343          /* From the lengths of the filename and the pattern parts,
     344             find the stem: the part of the filename that matches the %.  */
     345          stem = filename + (suffix - target - 1);
     346          stemlen = namelen - rule->lens[ti] + 1;
     347
     348          /* Set CHECK_LASTSLASH if FILENAME contains a directory
     349             prefix and the target pattern does not contain a slash.  */
    349350
    350351          check_lastslash = 0;
     
    366367#endif
    367368            }
    368           if (check_lastslash)
    369             {
    370               /* If so, don't include the directory prefix in STEM here.  */
    371               unsigned int difference = lastslash - filename + 1;
    372               if (difference > stemlen)
    373                 continue;
    374               stemlen -= difference;
    375               stem += difference;
    376             }
    377 
    378           /* Check that the rule pattern matches the text before the stem.  */
    379           if (check_lastslash)
    380             {
    381               if (stem > (lastslash + 1)
    382                   && !strneq (target, lastslash + 1, stem - lastslash - 1))
    383                 continue;
    384             }
    385           else if (stem > filename
    386                    && !strneq (target, filename, stem - filename))
    387             continue;
    388 
    389           /* Check that the rule pattern matches the text after the stem.
    390              We could test simply use streq, but this way we compare the
    391              first two characters immediately.  This saves time in the very
    392              common case where the first character matches because it is a
    393              period.  */
    394           if (*suffix != stem[stemlen]
    395               || (*suffix != '\0' && !streq (&suffix[1], &stem[stemlen + 1])))
    396             continue;
    397 
    398           /* Record if we match a rule that not all filenames will match.  */
    399           if (target[1] != '\0')
    400             specific_rule_matched = 1;
    401 
    402           /* A rule with no dependencies and no commands exists solely to set
    403              specific_rule_matched when it matches.  Don't try to use it.  */
    404           if (rule->deps == 0 && rule->cmds == 0)
    405             continue;
    406 
    407           /* Record this rule in TRYRULES and the index of the matching
    408              target in MATCHES.  If several targets of the same rule match,
    409              that rule will be in TRYRULES more than once.  */
    410           tryrules[nrules] = rule;
    411           matches[nrules] = ti;
    412           checked_lastslash[nrules] = check_lastslash;
    413           ++nrules;
    414         }
     369          if (check_lastslash)
     370            {
     371              /* If so, don't include the directory prefix in STEM here.  */
     372              if (pathlen > stemlen)
     373                continue;
     374              stemlen -= pathlen;
     375              stem += pathlen;
     376            }
     377
     378          /* Check that the rule pattern matches the text before the stem.  */
     379          if (check_lastslash)
     380            {
     381              if (stem > (lastslash + 1)
     382                  && !strneq (target, lastslash + 1, stem - lastslash - 1))
     383                continue;
     384            }
     385          else if (stem > filename
     386                   && !strneq (target, filename, stem - filename))
     387            continue;
     388
     389          /* Check that the rule pattern matches the text after the stem.
     390             We could test simply use streq, but this way we compare the
     391             first two characters immediately.  This saves time in the very
     392             common case where the first character matches because it is a
     393             period.  */
     394          if (*suffix != stem[stemlen]
     395              || (*suffix != '\0' && !streq (&suffix[1], &stem[stemlen + 1])))
     396            continue;
     397
     398          /* Record if we match a rule that not all filenames will match.  */
     399          if (target[1] != '\0')
     400            specific_rule_matched = 1;
     401
     402          /* A rule with no dependencies and no commands exists solely to set
     403             specific_rule_matched when it matches.  Don't try to use it.  */
     404          if (rule->deps == 0 && rule->cmds == 0)
     405            continue;
     406
     407          /* Record this rule in TRYRULES and the index of the matching
     408             target in MATCHES.  If several targets of the same rule match,
     409             that rule will be in TRYRULES more than once.  */
     410          tryrules[nrules].rule = rule;
     411          tryrules[nrules].matches = ti;
     412          tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0);
     413          tryrules[nrules].order = nrules;
     414          tryrules[nrules].checked_lastslash = check_lastslash;
     415          ++nrules;
     416        }
    415417    }
     418
     419  /* Bail out early if we haven't found any rules. */
     420  if (nrules == 0)
     421    goto done;
     422
     423  /* Sort the rules to place matches with the shortest stem first. This
     424     way the most specific rules will be tried first. */
     425  if (nrules > 1)
     426    qsort (tryrules, nrules, sizeof (struct tryrule), stemlen_compare);
    416427
    417428  /* If we have found a matching rule that won't match all filenames,
     
    419430  if (specific_rule_matched)
    420431    for (ri = 0; ri < nrules; ++ri)
    421       if (!tryrules[ri]->terminal)
    422         {
    423           unsigned int j;
    424           for (j = 0; j < tryrules[ri]->num; ++j)
    425             if (tryrules[ri]->targets[j][1] == '\0')
     432      if (!tryrules[ri].rule->terminal)
     433        {
     434          unsigned int j;
     435          for (j = 0; j < tryrules[ri].rule->num; ++j)
     436            if (tryrules[ri].rule->targets[j][1] == '\0')
    426437              {
    427                 tryrules[ri] = 0;
     438                tryrules[ri].rule = 0;
    428439                break;
    429440              }
    430         }
    431 
    432   /* We are going to do second expansion so initialize file variables
    433      for the rule. */
    434   initialize_file_variables (file, 0);
     441        }
    435442
    436443  /* Try each rule once without intermediate files, then once with them.  */
    437   for (intermed_ok = 0; intermed_ok == !!intermed_ok; ++intermed_ok)
     444  for (intermed_ok = 0; intermed_ok < 2; ++intermed_ok)
    438445    {
    439       /* Try each pattern rule till we find one that applies.
    440          If it does, expand its dependencies (as substituted)
    441          and chain them in DEPS.  */
    442 
     446      pat = deplist;
     447
     448      /* Try each pattern rule till we find one that applies.  If it does,
     449         expand its dependencies (as substituted) and chain them in DEPS.  */
    443450      for (ri = 0; ri < nrules; ri++)
    444         {
    445           struct file *f;
     451        {
     452          struct dep *dep;
     453          int check_lastslash;
    446454          unsigned int failed = 0;
    447           int check_lastslash;
    448455          int file_variables_set = 0;
    449 
    450           rule = tryrules[ri];
    451 
    452           remove_explicit_deps = 0;
    453 
    454           /* RULE is nil when we discover that a rule,
    455              already placed in TRYRULES, should not be applied.  */
    456           if (rule == 0)
    457             continue;
    458 
    459           /* Reject any terminal rules if we're
    460              looking to make intermediate files.  */
    461           if (intermed_ok && rule->terminal)
    462             continue;
    463 
    464           /* Mark this rule as in use so a recursive
    465              pattern_search won't try to use it.  */
    466           rule->in_use = 1;
    467 
    468           /* From the lengths of the filename and the matching pattern parts,
    469              find the stem: the part of the filename that matches the %.  */
    470           stem = filename
    471             + (rule->suffixes[matches[ri]] - rule->targets[matches[ri]]) - 1;
    472           stemlen = namelen - rule->lens[matches[ri]] + 1;
    473           check_lastslash = checked_lastslash[ri];
    474           if (check_lastslash)
    475             {
    476               stem += lastslash - filename + 1;
    477               stemlen -= (lastslash - filename) + 1;
    478             }
    479 
    480           DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
     456          unsigned int deps_found = 0;
     457          /* NPTR points to the part of the prereq we haven't processed.  */
     458          const char *nptr = 0;
     459          const char *dir = NULL;
     460          int order_only = 0;
     461          unsigned int matches;
     462
     463          rule = tryrules[ri].rule;
     464
     465          /* RULE is nil when we discover that a rule, already placed in
     466             TRYRULES, should not be applied.  */
     467          if (rule == 0)
     468            continue;
     469
     470          /* Reject any terminal rules if we're looking to make intermediate
     471             files.  */
     472          if (intermed_ok && rule->terminal)
     473            continue;
     474
     475          /* From the lengths of the filename and the matching pattern parts,
     476             find the stem: the part of the filename that matches the %.  */
     477          matches = tryrules[ri].matches;
     478          stem = filename + (rule->suffixes[matches]
     479                             - rule->targets[matches]) - 1;
     480          stemlen = (namelen - rule->lens[matches]) + 1;
     481          check_lastslash = tryrules[ri].checked_lastslash;
     482          if (check_lastslash)
     483            {
     484              stem += pathlen;
     485              stemlen -= pathlen;
     486
     487              /* We need to add the directory prefix, so set it up.  */
     488              if (! pathdir)
     489                {
     490                  pathdir = alloca (pathlen + 1);
     491                  memcpy (pathdir, filename, pathlen);
     492                  pathdir[pathlen] = '\0';
     493                }
     494              dir = pathdir;
     495            }
     496
     497          DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
    481498                             (int) stemlen, stem));
    482499
    483500          strncpy (stem_str, stem, stemlen);
    484501          stem_str[stemlen] = '\0';
     502
     503          /* If there are no prerequisites, then this rule matches.  */
     504          if (rule->deps == 0)
     505            break;
    485506
    486507          /* Temporary assign STEM to file->stem (needed to set file
     
    488509          file->stem = stem_str;
    489510
    490           /* Try each dependency; see if it "exists".  */
    491 
    492           for (dep = rule->deps; dep != 0; dep = dep->next)
    493             {
    494               unsigned int len;
     511          /* Mark this rule as in use so a recursive pattern_search won't try
     512             to use it.  */
     513          rule->in_use = 1;
     514
     515          /* Try each prerequisite; see if it exists or can be created.  We'll
     516             build a list of prereq info in DEPLIST.  Due to 2nd expansion we
     517             may have to process multiple prereqs for a single dep entry.  */
     518
     519          pat = deplist;
     520          dep = rule->deps;
     521          nptr = dep_name (dep);
     522          while (1)
     523            {
     524              struct dep *dl, *d;
    495525              char *p;
    496               char *p2;
    497               unsigned int order_only = 0; /* Set if '|' was seen. */
    498 
    499               /* In an ideal world we would take the dependency line,
    500                  substitute the stem, re-expand the whole line and chop it
    501                  into individual prerequisites. Unfortunately this won't work
    502                  because of the "check_lastslash" twist.  Instead, we will
    503                  have to go word by word, taking $()'s into account, for each
    504                  word we will substitute the stem, re-expand, chop it up, and,
    505                  if check_lastslash != 0, add the directory part to each
     526
     527              /* If we're out of name to parse, start the next prereq.  */
     528              if (! nptr)
     529                {
     530                  dep = dep->next;
     531                  if (dep == 0)
     532                    break;
     533                  nptr = dep_name (dep);
     534                }
     535
     536              /* If we don't need a second expansion, just replace the %.  */
     537              if (! dep->need_2nd_expansion)
     538                {
     539                  dep_simple = *dep;
     540                  dep_simple.next = 0;
     541                  p = strchr (nptr, '%');
     542                  if (p == 0)
     543                    dep_simple.name = nptr;
     544                  else
     545                    {
     546                      char *o = depname;
     547                      if (check_lastslash)
     548                        {
     549                          memcpy (o, filename, pathlen);
     550                          o += pathlen;
     551                        }
     552                      memcpy (o, nptr, p - nptr);
     553                      o += p - nptr;
     554                      memcpy (o, stem_str, stemlen);
     555                      o += stemlen;
     556                      strcpy (o, p + 1);
     557                      dep_simple.name = strcache_add (depname);
     558                    }
     559                  dl = &dep_simple;
     560
     561                  /* We've used up this dep, so next time get a new one.  */
     562                  nptr = 0;
     563                  ++deps_found;
     564                }
     565
     566              /* We have to perform second expansion on this prereq.  In an
     567                 ideal world we would take the dependency line, substitute the
     568                 stem, re-expand the whole line and chop it into individual
     569                 prerequisites.  Unfortunately this won't work because of the
     570                 "check_lastslash" twist.  Instead, we will have to go word by
     571                 word, taking $()'s into account.  For each word we will
     572                 substitute the stem, re-expand, chop it up, and, if
     573                 check_lastslash != 0, add the directory part to each
    506574                 resulting prerequisite.  */
    507 
    508               p = get_next_word (dep->name, &len);
    509 
    510               while (1)
     575              else
    511576                {
    512577                  int add_dir = 0;
    513                   int had_stem = 0;
    514 
     578                  unsigned int len;
     579
     580                  nptr = get_next_word (nptr, &len);
     581                  if (nptr == 0)
     582                    continue;
     583
     584                  /* See this is a transition to order-only prereqs.  */
     585                  if (! order_only && len == 1 && nptr[0] == '|')
     586                    {
     587                      order_only = 1;
     588                      nptr += len;
     589                      continue;
     590                    }
     591
     592                  /* If the dependency name has %, substitute the stem.  If we
     593                     just replace % with the stem value then later, when we do
     594                     the 2nd expansion, we will re-expand this stem value
     595                     again.  This is not good if you have certain characters
     596                     in your stem (like $).
     597
     598                     Instead, we will replace % with $* and allow the second
     599                     expansion to take care of it for us.  This way (since $*
     600                     is a simple variable) there won't be additional
     601                     re-expansion of the stem.  */
     602
     603                  p = lindex (nptr, nptr + len, '%');
    515604                  if (p == 0)
    516                     break; /* No more words */
    517 
    518                   /* Is there a pattern in this prerequisite?  */
    519 
    520                   for (p2 = p; p2 < p + len && *p2 != '%'; ++p2)
    521                     ;
    522 
    523                   if (dep->need_2nd_expansion)
    524                     {
    525                       /* If the dependency name has %, substitute the stem.
    526 
    527                          Watch out, we are going to do something tricky
    528                          here. If we just replace % with the stem value,
    529                          later, when we do the second expansion, we will
    530                          re-expand this stem value once again. This is not
    531                          good especially if you have certain characters in
    532                          your stem (like $).
    533 
    534                          Instead, we will replace % with $* and allow the
    535                          second expansion to take care of it for us. This way
    536                          (since $* is a simple variable) there won't be
    537                          additional re-expansion of the stem.  */
    538 
    539                       if (p2 < p + len)
    540                         {
    541                           unsigned int i = p2 - p;
    542                           memcpy (depname, p, i);
    543                           memcpy (depname + i, "$*", 2);
    544                           memcpy (depname + i + 2, p2 + 1, len - i - 1);
    545                           depname[len + 2 - 1] = '\0';
    546 
    547                           if (check_lastslash)
    548                             add_dir = 1;
    549 
    550                           had_stem = 1;
    551                         }
    552                       else
    553                         {
    554                           memcpy (depname, p, len);
    555                           depname[len] = '\0';
    556                         }
    557 
    558                       /* Set file variables. Note that we cannot do it once
    559                          at the beginning of the function because of the stem
    560                          value.  */
    561                       if (!file_variables_set)
    562                         {
     605                    {
     606                      memcpy (depname, nptr, len);
     607                      depname[len] = '\0';
     608                    }
     609                  else
     610                    {
     611                      unsigned int i = p - nptr;
     612                      memcpy (depname, nptr, i);
     613                      memcpy (depname + i, "$*", 2);
     614                      memcpy (depname + i + 2, p + 1, len - i - 1);
     615                      depname[len + 2 - 1] = '\0';
     616
     617                      if (check_lastslash)
     618                        add_dir = 1;
     619                    }
     620
     621                  /* Initialize and set file variables if we haven't already
     622                     done so. */
     623                  if (!file_vars_initialized)
     624                    {
     625                      initialize_file_variables (file, 0);
    563626#if defined(CONFIG_WITH_COMMANDS_FUNC) || defined (CONFIG_WITH_DOT_MUST_MAKE)
    564                           set_file_variables (file, 0 /* real call */);
     627                      set_file_variables (file, 0 /* real call */);
    565628#else
    566                           set_file_variables (file);
     629                      set_file_variables (file);
    567630#endif
    568                           file_variables_set = 1;
    569                         }
    570 
    571                       p2 = variable_expand_for_file (depname, file);
    572                     }
    573                   else
    574                     {
    575                        if (p2 < p + len)
    576                         {
    577                           unsigned int i = p2 - p;
    578                           memcpy (depname, p, i);
    579                           memcpy (depname + i, stem_str, stemlen);
    580                           memcpy (depname + i + stemlen, p2 + 1, len - i - 1);
    581                           depname[len + stemlen - 1] = '\0';
    582 
    583                           if (check_lastslash)
    584                             add_dir = 1;
    585 
    586                           had_stem = 1;
    587                         }
    588                       else
    589                         {
    590                           memcpy (depname, p, len);
    591                           depname[len] = '\0';
    592                         }
    593 
    594                        p2 = depname;
    595                     }
    596 
    597                   /* Parse the dependencies. */
    598 
    599                   while (1)
    600                     {
    601                       id_ptr = &deps;
    602 
    603                       for (; *id_ptr; id_ptr = &(*id_ptr)->next)
    604                         ;
    605 
    606 #ifndef CONFIG_WITH_ALLOC_CACHES
    607                       *id_ptr = (struct idep *)
    608                         multi_glob (
    609                           parse_file_seq (&p2,
    610                                           order_only ? '\0' : '|',
    611                                           sizeof (struct idep),
    612                                           1), sizeof (struct idep));
    613 #else
    614                       *id_ptr = (struct idep *)
    615                         multi_glob (
    616                           parse_file_seq (&p2,
    617                                           order_only ? '\0' : '|',
    618                                           &idep_cache, 1),
    619                           &idep_cache);
    620 #endif
    621 
    622                       /* @@ It would be nice to teach parse_file_seq or
    623                          multi_glob to add prefix. This would save us some
    624                          reallocations. */
    625 
    626                       if (order_only || add_dir || had_stem)
    627                         {
    628                           unsigned long l = lastslash - filename + 1;
    629 
    630                           for (d = *id_ptr; d != 0; d = d->next)
    631                             {
    632                               if (order_only)
    633                                 d->ignore_mtime = 1;
    634 
    635                               if (add_dir)
    636                                 {
    637                                   char *n = alloca (strlen (d->name) + l + 1);
    638                                   memcpy (n, filename, l);
    639                                   memcpy (n+l, d->name, strlen (d->name) + 1);
    640                                   d->name = strcache_add (n);
    641                                 }
    642 
    643                               if (had_stem)
    644                                 d->had_stem = 1;
    645                             }
    646                         }
    647 
    648                       if (!order_only && *p2)
     631                      file_vars_initialized = 1;
     632                    }
     633                  /* Update the stem value in $* for this rule.  */
     634                  else if (!file_variables_set)
     635                    {
     636                      define_variable_for_file (
     637                        "*", 1, file->stem, o_automatic, 0, file);
     638                      file_variables_set = 1;
     639                    }
     640
     641                  /* Perform the 2nd expansion.  */
     642                  p = variable_expand_for_file (depname, file);
     643
     644                  /* Parse the expanded string. */
     645                  dl = PARSE_FILE_SEQ (&p, struct dep, order_only ? '\0' : '|',
     646                                       add_dir ? dir : NULL, 0);
     647
     648                  for (d = dl; d != NULL; d = d->next)
     649                    {
     650                      ++deps_found;
     651                      if (order_only)
     652                        d->ignore_mtime = 1;
     653                    }
     654
     655                  /* Set up for the next word.  */
     656                  nptr += len;
     657                }
     658
     659              /* If there are more than max_pattern_deps prerequisites (due to
     660                 2nd expansion), reset it and realloc the arrays.  */
     661
     662              if (deps_found > max_pattern_deps)
     663                {
     664                  unsigned int l = pat - deplist;
     665                  deplist = xrealloc (deplist,
     666                                      deps_found * sizeof (struct patdeps));
     667                  pat = deplist + l;
     668                  max_pattern_deps = deps_found;
     669                }
     670
     671              /* Go through the nameseq and handle each as a prereq name.  */
     672              for (d = dl; d != 0; d = d->next)
     673                {
     674                  struct dep *expl_d;
     675                  int is_rule = d->name == dep_name (dep);
     676
     677                  if (file_impossible_p (d->name))
     678                    {
     679                      /* If this prereq has already been ruled "impossible",
     680                         then the rule fails.  Don't bother trying it on the
     681                         second pass either since we know that will fail.  */
     682                      DBS (DB_IMPLICIT,
     683                           (is_rule
     684                            ? _("Rejecting impossible rule prerequisite `%s'.\n")
     685                            : _("Rejecting impossible implicit prerequisite `%s'.\n"),
     686                            d->name));
     687                      tryrules[ri].rule = 0;
     688
     689                      failed = 1;
     690                      break;
     691                    }
     692
     693                  memset (pat, '\0', sizeof (struct patdeps));
     694                  pat->ignore_mtime = d->ignore_mtime;
     695
     696                  DBS (DB_IMPLICIT,
     697                       (is_rule
     698                        ? _("Trying rule prerequisite `%s'.\n")
     699                        : _("Trying implicit prerequisite `%s'.\n"), d->name));
     700
     701                  /* If this prereq is also explicitly mentioned for FILE,
     702                     skip all tests below since it must be built no matter
     703                     which implicit rule we choose. */
     704
     705                  for (expl_d = file->deps; expl_d != 0; expl_d = expl_d->next)
     706                    if (streq (dep_name (expl_d), d->name))
     707                      break;
     708                  if (expl_d != 0)
     709                    {
     710                      (pat++)->name = d->name;
     711                      continue;
     712                    }
     713
     714                  /* The DEP->changed flag says that this dependency resides
     715                     in a nonexistent directory.  So we normally can skip
     716                     looking for the file.  However, if CHECK_LASTSLASH is
     717                     set, then the dependency file we are actually looking for
     718                     is in a different directory (the one gotten by prepending
     719                     FILENAME's directory), so it might actually exist.  */
     720
     721                  /* @@ dep->changed check is disabled. */
     722                  if (lookup_file (d->name) != 0
     723                      /*|| ((!dep->changed || check_lastslash) && */
     724                      || file_exists_p (d->name))
     725                    {
     726                      (pat++)->name = d->name;
     727                      continue;
     728                    }
     729
     730                  /* This code, given FILENAME = "lib/foo.o", dependency name
     731                     "lib/foo.c", and VPATH=src, searches for
     732                     "src/lib/foo.c".  */
     733                  {
     734                    const char *vname = vpath_search (d->name, 0, NULL, NULL);
     735                    if (vname)
    649736                      {
    650                         ++p2;
    651                         order_only = 1;
     737                        DBS (DB_IMPLICIT,
     738                             (_("Found prerequisite `%s' as VPATH `%s'\n"),
     739                              d->name, vname));
     740                        (pat++)->name = d->name;
    652741                        continue;
    653742                      }
    654 
    655                       break;
    656                     }
    657 
    658                   p += len;
    659                   p = get_next_word (p, &len);
    660                 }
    661             }
    662 
    663           /* Reset the stem in FILE. */
    664 
    665           file->stem = 0;
    666 
    667           /* @@ This loop can be combined with the previous one. I do
    668              it separately for now for transparency.*/
    669 
    670           for (d = deps; d != 0; d = d->next)
    671             {
    672               const char *name = d->name;
    673 
    674               if (file_impossible_p (name))
    675                 {
    676                   /* If this dependency has already been ruled "impossible",
    677                      then the rule fails and don't bother trying it on the
    678                      second pass either since we know that will fail too.  */
    679                   DBS (DB_IMPLICIT,
    680                        (d->had_stem
    681                         ? _("Rejecting impossible implicit prerequisite `%s'.\n")
    682                         : _("Rejecting impossible rule prerequisite `%s'.\n"),
    683                         name));
    684                   tryrules[ri] = 0;
    685 
     743                  }
     744
     745                  /* We could not find the file in any place we should look.
     746                     Try to make this dependency as an intermediate file, but
     747                     only on the second pass.  */
     748
     749                  if (intermed_ok)
     750                    {
     751                      DBS (DB_IMPLICIT,
     752                           (_("Looking for a rule with intermediate file `%s'.\n"),
     753                            d->name));
     754
     755                      if (int_file == 0)
     756                        int_file = alloca (sizeof (struct file));
     757                      memset (int_file, '\0', sizeof (struct file));
     758                      int_file->name = d->name;
     759
     760                      if (pattern_search (int_file,
     761                                          0,
     762                                          depth + 1,
     763                                          recursions + 1))
     764                        {
     765                          pat->pattern = int_file->name;
     766                          int_file->name = d->name;
     767                          pat->file = int_file;
     768                          (pat++)->name = d->name;
     769                          int_file = 0;
     770                          continue;
     771                        }
     772
     773                      /* If we have tried to find P as an intermediate file
     774                         and failed, mark that name as impossible so we won't
     775                         go through the search again later.  */
     776                      if (int_file->variables)
     777                        free_variable_set (int_file->variables);
     778                      if (int_file->pat_variables)
     779                        free_variable_set (int_file->pat_variables);
     780                      file_impossible (d->name);
     781                    }
     782
     783                  /* A dependency of this rule does not exist. Therefore, this
     784                     rule fails.  */
    686785                  failed = 1;
    687786                  break;
    688787                }
    689788
    690               DBS (DB_IMPLICIT,
    691                    (d->had_stem
    692                     ? _("Trying implicit prerequisite `%s'.\n")
    693                     : _("Trying rule prerequisite `%s'.\n"), name));
    694 
    695               /* If this prerequisite also happened to be explicitly mentioned
    696                  for FILE skip all the test below since it it has to be built
    697                  anyway, no matter which implicit rule we choose. */
    698 
    699               for (expl_d = file->deps; expl_d != 0; expl_d = expl_d->next)
    700                 if (streq (dep_name (expl_d), name))
    701                   break;
    702               if (expl_d != 0)
    703                 continue;
    704 
    705               /* The DEP->changed flag says that this dependency resides in a
    706                  nonexistent directory.  So we normally can skip looking for
    707                  the file.  However, if CHECK_LASTSLASH is set, then the
    708                  dependency file we are actually looking for is in a different
    709                  directory (the one gotten by prepending FILENAME's directory),
    710                  so it might actually exist.  */
    711 
    712               /* @@ dep->changed check is disabled. */
    713               if (((f = lookup_file (name)) != 0 && f->is_target)
    714                   /*|| ((!dep->changed || check_lastslash) && */
    715                   || file_exists_p (name))
    716                 continue;
    717 
    718               /* This code, given FILENAME = "lib/foo.o", dependency name
    719                  "lib/foo.c", and VPATH=src, searches for "src/lib/foo.c".  */
    720               {
    721                 const char *vname = vpath_search (name, 0);
    722                 if (vname)
    723                   {
    724                     DBS (DB_IMPLICIT,
    725                          (_("Found prerequisite `%s' as VPATH `%s'\n"),
    726                           name, vname));
    727                     continue;
    728                   }
    729               }
    730 
    731 
    732               /* We could not find the file in any place we should look.  Try
    733                  to make this dependency as an intermediate file, but only on
    734                  the second pass.  */
    735 
    736               if (intermed_ok)
    737                 {
    738                   if (intermediate_file == 0)
    739                     intermediate_file = alloca (sizeof (struct file));
    740 
    741                   DBS (DB_IMPLICIT,
    742                        (_("Looking for a rule with intermediate file `%s'.\n"),
    743                         name));
    744 
    745                   memset (intermediate_file, '\0', sizeof (struct file));
    746                   intermediate_file->name = name;
    747                   if (pattern_search (intermediate_file,
    748                                       0,
    749                                       depth + 1,
    750                                       recursions + 1))
    751                     {
    752                       d->intermediate_pattern = intermediate_file->name;
    753                       intermediate_file->name = strcache_add (name);
    754                       d->intermediate_file = intermediate_file;
    755                       intermediate_file = 0;
    756 
    757                       continue;
    758                     }
    759 
    760                   /* If we have tried to find P as an intermediate
    761                      file and failed, mark that name as impossible
    762                      so we won't go through the search again later.  */
    763                   if (intermediate_file->variables)
    764                     free_variable_set (intermediate_file->variables);
    765                   file_impossible (name);
    766                 }
    767 
    768               /* A dependency of this rule does not exist. Therefore,
    769                  this rule fails.  */
    770               failed = 1;
    771               break;
     789              /* Free the ns chain.  */
     790              if (dl != &dep_simple)
     791                free_dep_chain (dl);
     792
     793              if (failed)
     794                break;
    772795            }
    773796
     797          /* Reset the stem in FILE. */
     798
     799          file->stem = 0;
     800
    774801          /* This rule is no longer `in use' for recursive searches.  */
    775           rule->in_use = 0;
    776 
    777           if (failed)
    778             {
    779               /* This pattern rule does not apply. If some of its
    780                  dependencies succeeded, free the data structure
    781                  describing them.  */
    782               free_idep_chain (deps);
    783               deps = 0;
    784             }
    785           else
    786             /* This pattern rule does apply.  Stop looking for one.  */
    787             break;
    788         }
    789 
    790       /* If we found an applicable rule without
    791          intermediate files, don't try with them.  */
     802          rule->in_use = 0;
     803
     804          if (! failed)
     805            /* This pattern rule does apply.  Stop looking for one.  */
     806            break;
     807
     808          /* This pattern rule does not apply. If some of its dependencies
     809             succeeded, free the data structure describing them.  */
     810          /* free_idep_chain (deps); */
     811          deps = 0;
     812        }
     813
     814      /* If we found an applicable rule without intermediate files, don't try
     815         with them.  */
    792816      if (ri < nrules)
    793         break;
     817        break;
    794818
    795819      rule = 0;
    796820    }
    797821
    798   /* RULE is nil if the loop went all the way
    799      through the list and everything failed.  */
     822  /* RULE is nil if the loop went through the list but everything failed.  */
    800823  if (rule == 0)
    801824    goto done;
     
    803826  foundrule = ri;
    804827
    805   /* If we are recursing, store the pattern that matched
    806      FILENAME in FILE->name for use in upper levels.  */
     828  /* If we are recursing, store the pattern that matched FILENAME in
     829     FILE->name for use in upper levels.  */
    807830
    808831  if (recursions > 0)
    809832    /* Kludge-o-matic */
    810     file->name = rule->targets[matches[foundrule]];
    811 
    812   /* FOUND_FILES lists the dependencies for the rule we found.
    813      This includes the intermediate files, if any.
    814      Convert them into entries on the deps-chain of FILE.  */
    815 
    816   if (remove_explicit_deps)
     833    file->name = rule->targets[tryrules[foundrule].matches];
     834
     835  /* DEPLIST lists the prerequisites for the rule we found.  This includes the
     836     intermediate files, if any.  Convert them into entries on the deps-chain
     837     of FILE.  */
     838
     839  while (pat-- > deplist)
    817840    {
    818       /* Remove all the dependencies that didn't come from
    819          this implicit rule. */
    820 
    821       dep = file->deps;
    822       while (dep != 0)
     841      struct dep *dep;
     842      const char *s;
     843
     844      if (pat->file != 0)
    823845        {
    824           struct dep *next = dep->next;
    825           free_dep (dep);
    826           dep = next;
    827         }
    828       file->deps = 0;
    829   }
    830 
    831   expl_d = file->deps; /* We will add them at the end. */
    832   d_ptr = &file->deps;
    833 
    834   for (d = deps; d != 0; d = d->next)
    835     {
    836       const char *s;
    837 
    838       if (d->intermediate_file != 0)
    839         {
    840           /* If we need to use an intermediate file,
    841              make sure it is entered as a target, with the info that was
    842              found for it in the recursive pattern_search call.
    843              We know that the intermediate file did not already exist as
    844              a target; therefore we can assume that the deps and cmds
    845              of F below are null before we change them.  */
    846 
    847           struct file *imf = d->intermediate_file;
    848           register struct file *f = lookup_file (imf->name);
     846          /* If we need to use an intermediate file, make sure it is entered
     847             as a target, with the info that was found for it in the recursive
     848             pattern_search call.  We know that the intermediate file did not
     849             already exist as a target; therefore we can assume that the deps
     850             and cmds of F below are null before we change them.  */
     851
     852          struct file *imf = pat->file;
     853          struct file *f = lookup_file (imf->name);
    849854
    850855          /* We don't want to delete an intermediate file that happened
     
    854859            f->precious = 1;
    855860          else
    856             f = enter_file (strcache_add (imf->name));
    857 
    858           f->deps = imf->deps;
    859           f->cmds = imf->cmds;
    860           f->stem = imf->stem;
     861            f = enter_file (imf->name);
     862
     863          f->deps = imf->deps;
     864          f->cmds = imf->cmds;
     865          f->stem = imf->stem;
     866          f->variables = imf->variables;
     867          f->pat_variables = imf->pat_variables;
     868          f->pat_searched = imf->pat_searched;
    861869          f->also_make = imf->also_make;
    862870          f->is_target = 1;
    863 
    864           if (!f->precious)
     871          f->intermediate = 1;
     872          f->tried_implicit = 1;
     873
     874          imf = lookup_file (pat->pattern);
     875          if (imf != 0 && imf->precious)
     876            f->precious = 1;
     877
     878          for (dep = f->deps; dep != 0; dep = dep->next)
    865879            {
    866               imf = lookup_file (d->intermediate_pattern);
    867               if (imf != 0 && imf->precious)
    868                 f->precious = 1;
     880              dep->file = enter_file (dep->name);
     881              dep->name = 0;
     882              dep->file->tried_implicit |= dep->changed;
    869883            }
    870 
    871           f->intermediate = 1;
    872           f->tried_implicit = 1;
    873           for (dep = f->deps; dep != 0; dep = dep->next)
    874             {
    875               dep->file = enter_file (dep->name);
    876               dep->name = 0;
    877               dep->file->tried_implicit |= dep->changed;
    878             }
    879         }
     884        }
    880885
    881886      dep = alloc_dep ();
    882       dep->ignore_mtime = d->ignore_mtime;
    883       s = d->name; /* Hijacking the name. */
    884       d->name = 0;
    885       if (recursions == 0)
    886         {
    887           dep->file = lookup_file (s);
    888           if (dep->file == 0)
    889             dep->file = enter_file (s);
    890         }
     887      dep->ignore_mtime = pat->ignore_mtime;
     888      s = strcache_add (pat->name);
     889      if (recursions)
     890        dep->name = s;
    891891      else
    892         dep->name = s;
    893 
    894       if (d->intermediate_file == 0 && tryrules[foundrule]->terminal)
    895         {
    896           /* If the file actually existed (was not an intermediate file),
    897              and the rule that found it was a terminal one, then we want
    898              to mark the found file so that it will not have implicit rule
    899              search done for it.  If we are not entering a `struct file' for
    900              it now, we indicate this with the `changed' flag.  */
    901           if (dep->file == 0)
    902             dep->changed = 1;
    903           else
    904             dep->file->tried_implicit = 1;
    905         }
    906 
    907       *d_ptr = dep;
    908       d_ptr = &dep->next;
     892        {
     893          dep->file = lookup_file (s);
     894          if (dep->file == 0)
     895            dep->file = enter_file (s);
     896        }
     897
     898      if (pat->file == 0 && tryrules[foundrule].rule->terminal)
     899        {
     900          /* If the file actually existed (was not an intermediate file), and
     901             the rule that found it was a terminal one, then we want to mark
     902             the found file so that it will not have implicit rule search done
     903             for it.  If we are not entering a `struct file' for it now, we
     904             indicate this with the `changed' flag.  */
     905          if (dep->file == 0)
     906            dep->changed = 1;
     907          else
     908            dep->file->tried_implicit = 1;
     909        }
     910
     911      dep->next = file->deps;
     912      file->deps = dep;
    909913    }
    910914
    911   *d_ptr = expl_d;
    912 
    913   if (!checked_lastslash[foundrule])
     915  if (!tryrules[foundrule].checked_lastslash)
    914916    {
    915       /* Always allocate new storage, since STEM might be
    916          on the stack for an intermediate file.  */
     917      /* Always allocate new storage, since STEM might be on the stack for an
     918         intermediate file.  */
    917919      file->stem = strcache_add_len (stem, stemlen);
    918920      fullstemlen = stemlen;
     
    924926
    925927      /* We want to prepend the directory from
    926         the original FILENAME onto the stem.  */
     928        the original FILENAME onto the stem.  */
    927929      fullstemlen = dirlen + stemlen;
    928930      sp = alloca (fullstemlen + 1);
     
    942944  /* Set precious flag. */
    943945  {
    944     struct file *f = lookup_file (rule->targets[matches[foundrule]]);
     946    struct file *f = lookup_file (rule->targets[tryrules[foundrule].matches]);
    945947    if (f && f->precious)
    946948      file->precious = 1;
     
    952954  if (rule->num > 1)
    953955    for (ri = 0; ri < rule->num; ++ri)
    954       if (ri != matches[foundrule])
    955         {
    956           char *p = alloca (rule->lens[ri] + fullstemlen + 1);
    957           struct file *f;
    958           struct dep *new = alloc_dep ();
    959 
    960           /* GKM FIMXE: handle '|' here too */
    961           memcpy (p, rule->targets[ri],
     956      if (ri != tryrules[foundrule].matches)
     957        {
     958          char *nm = alloca (rule->lens[ri] + fullstemlen + 1);
     959          char *p = nm;
     960          struct file *f;
     961          struct dep *new = alloc_dep ();
     962
     963          /* GKM FIMXE: handle '|' here too */
     964          memcpy (p, rule->targets[ri],
    962965                  rule->suffixes[ri] - rule->targets[ri] - 1);
    963           p += rule->suffixes[ri] - rule->targets[ri] - 1;
    964           memcpy (p, file->stem, fullstemlen);
    965           p += fullstemlen;
    966           memcpy (p, rule->suffixes[ri],
     966          p += rule->suffixes[ri] - rule->targets[ri] - 1;
     967          memcpy (p, file->stem, fullstemlen);
     968          p += fullstemlen;
     969          memcpy (p, rule->suffixes[ri],
    967970                  rule->lens[ri] - (rule->suffixes[ri] - rule->targets[ri])+1);
    968           new->name = strcache_add (p);
    969           new->file = enter_file (new->name);
    970           new->next = file->also_make;
    971 
    972           /* Set precious flag. */
    973           f = lookup_file (rule->targets[ri]);
    974           if (f && f->precious)
     971          new->name = strcache_add (nm);
     972          new->file = enter_file (new->name);
     973          new->next = file->also_make;
     974
     975          /* Set precious flag. */
     976          f = lookup_file (rule->targets[ri]);
     977          if (f && f->precious)
    975978            new->file->precious = 1;
    976979
    977           /* Set the is_target flag so that this file is not treated
    978              as intermediate by the pattern rule search algorithm and
     980          /* Set the is_target flag so that this file is not treated as
     981             intermediate by the pattern rule search algorithm and
    979982             file_exists_p cannot pick it up yet.  */
    980983          new->file->is_target = 1;
    981984
    982           file->also_make = new;
    983         }
     985          file->also_make = new;
     986        }
    984987
    985988 done:
    986   free_idep_chain (deps);
    987989  free (tryrules);
     990  free (deplist);
    988991
    989992  return rule != 0;
  • trunk/src/kmk/incdep.c

    r2546 r2591  
    114114};
    115115
    116 struct incdep_recorded_files
    117 {
    118     struct incdep_recorded_files *next;
     116struct incdep_recorded_file
     117{
     118    struct incdep_recorded_file *next;
    119119
    120120    /* the parameters */
    121121    struct strcache2_entry *filename_entry; /* dep strcache; converted to a nameseq record. */
    122     const char *pattern;                    /* NULL */
    123     const char *pattern_percent;            /* NULL */
    124122    struct dep *deps;                       /* All the names are dep strcache entries. */
    125     unsigned int cmds_started;              /* 0 */
    126     char *commands;                         /* NULL */
    127     unsigned int commands_idx;              /* 0 */
    128     int two_colon;                          /* 0 */
    129123    const struct floc *flocp;               /* NILF */
    130124};
     
    149143  struct incdep_variable_def *recorded_variable_defs_tail;
    150144
    151   struct incdep_recorded_files *recorded_files_head;
    152   struct incdep_recorded_files *recorded_files_tail;
     145  struct incdep_recorded_file *recorded_file_head;
     146  struct incdep_recorded_file *recorded_file_tail;
    153147#endif
    154148
     
    232226static void incdep_flush_it (struct floc *);
    233227static void eval_include_dep_file (struct incdep *, struct floc *);
     228static void incdep_commit_recorded_file (const char *filename, struct dep *deps,
     229                                         const struct floc *flocp);
    234230
    235231
     
    501497  assert (!cur->recorded_variables_in_set_head);
    502498  assert (!cur->recorded_variable_defs_head);
    503   assert (!cur->recorded_files_head);
     499  assert (!cur->recorded_file_head);
    504500#endif
    505501
     
    727723          if (rec_size < sizeof (struct incdep_variable_def))
    728724            rec_size = sizeof (struct incdep_variable_def);
    729           if (rec_size < sizeof (struct incdep_recorded_files))
    730             rec_size = sizeof (struct incdep_recorded_files);
     725          if (rec_size < sizeof (struct incdep_recorded_file))
     726            rec_size = sizeof (struct incdep_recorded_file);
    731727          alloccache_init (&incdep_rec_caches[i], rec_size, "incdep rec",
    732728                           incdep_cache_allocator, (void *)(size_t)i);
     
    849845  struct incdep_variable_in_set *rec_vis;
    850846  struct incdep_variable_def *rec_vd;
    851   struct incdep_recorded_files *rec_f;
     847  struct incdep_recorded_file *rec_f;
    852848
    853849  /* define_variable_in_set */
     
    898894  /* record_files */
    899895
    900   rec_f = cur->recorded_files_head;
    901   cur->recorded_files_head = cur->recorded_files_tail = NULL;
     896  rec_f = cur->recorded_file_head;
     897  cur->recorded_file_head = cur->recorded_file_tail = NULL;
    902898  if (rec_f)
    903899    do
     
    905901        void *free_me = rec_f;
    906902        struct dep *dep;
    907         struct nameseq *filenames;
    908903
    909904        for (dep = rec_f->deps; dep; dep = dep->next)
    910905          dep->name = incdep_flush_strcache_entry ((struct strcache2_entry *)dep->name);
    911906
    912         filenames = (struct nameseq *) alloccache_alloc (&nameseq_cache);
    913         filenames->next = 0;
    914         filenames->name = incdep_flush_strcache_entry (rec_f->filename_entry);
    915 
    916         record_files (filenames,
    917                       rec_f->pattern,
    918                       rec_f->pattern_percent,
    919                       rec_f->deps,
    920                       rec_f->cmds_started,
    921                       rec_f->commands,
    922                       rec_f->commands_idx,
    923                       rec_f->two_colon,
    924                       rec_f->flocp);
     907        incdep_commit_recorded_file (incdep_flush_strcache_entry (rec_f->filename_entry),
     908                                     rec_f->deps,
     909                                     rec_f->flocp);
    925910
    926911        rec_f = rec_f->next;
     
    10741059}
    10751060
    1076 /* Record files.*/
     1061/* Similar to record_files in read.c, only much much simpler. */
    10771062static void
    1078 incdep_record_files (struct incdep *cur,
    1079                      const char *filename, const char *pattern,
    1080                      const char *pattern_percent, struct dep *deps,
    1081                      unsigned int cmds_started, char *commands,
    1082                      unsigned int commands_idx, int two_colon,
    1083                      const struct floc *flocp)
     1063incdep_commit_recorded_file (const char *filename, struct dep *deps,
     1064                             const struct floc *flocp)
     1065{
     1066  struct file *f;
     1067
     1068  /* Perform some validations. */
     1069  if (filename[0] == '.'
     1070      && (   streq(filename, ".POSIX")
     1071          || streq(filename, ".EXPORT_ALL_VARIABLES")
     1072          || streq(filename, ".INTERMEDIATE")
     1073          || streq(filename, ".LOW_RESOLUTION_TIME")
     1074          || streq(filename, ".NOTPARALLEL")
     1075          || streq(filename, ".ONESHELL")
     1076          || streq(filename, ".PHONY")
     1077          || streq(filename, ".PRECIOUS")
     1078          || streq(filename, ".SECONDARY")
     1079          || streq(filename, ".SECONDTARGETEXPANSION")
     1080          || streq(filename, ".SILENT")
     1081          || streq(filename, ".SHELLFLAGS")
     1082          || streq(filename, ".SUFFIXES")
     1083         )
     1084     )
     1085    {
     1086      error (flocp, _("reserved filename '%s' used in dependency file, ignored"), filename);
     1087      return;
     1088    }
     1089
     1090  /* Lookup or create an entry in the database. */
     1091  f = enter_file (filename);
     1092  if (f->double_colon)
     1093    {
     1094      error (flocp, _("dependency file '%s' has a double colon entry already, ignoring"), filename);
     1095      return;
     1096    }
     1097  f->is_target = 1;
     1098
     1099  /* Append dependencies. */
     1100  deps = enter_prereqs (deps, NULL);
     1101  if (deps)
     1102    {
     1103      struct dep *last = f->deps;
     1104      if (!last)
     1105        f->deps = deps;
     1106      else
     1107        {
     1108          while (last->next)
     1109            last = last->next;
     1110          last->next = deps;
     1111        }
     1112    }
     1113}
     1114
     1115/* Record a file.*/
     1116static void
     1117incdep_record_file (struct incdep *cur,
     1118                    const char *filename,
     1119                    struct dep *deps,
     1120                    const struct floc *flocp)
    10841121{
    10851122  if (cur->worker_tid == -1)
    1086     {
    1087       struct nameseq *filenames = (struct nameseq *) alloccache_alloc (&nameseq_cache);
    1088       filenames->next = 0;
    1089       filenames->name = filename;
    1090       record_files (filenames, pattern, pattern_percent, deps, cmds_started,
    1091                     commands, commands_idx, two_colon, flocp);
    1092     }
     1123    incdep_commit_recorded_file (filename, deps, flocp);
    10931124#ifdef PARSE_IN_WORKER
    10941125  else
    10951126    {
    1096       struct incdep_recorded_files *rec =
    1097         (struct incdep_recorded_files *) incdep_alloc_rec (cur);
     1127      struct incdep_recorded_file *rec =
     1128        (struct incdep_recorded_file *) incdep_alloc_rec (cur);
    10981129
    10991130      rec->filename_entry = (struct strcache2_entry *)filename;
    1100       rec->pattern = pattern;
    1101       rec->pattern_percent = pattern_percent;
    11021131      rec->deps = deps;
    1103       rec->cmds_started = cmds_started;
    1104       rec->commands = commands;
    1105       rec->commands_idx = commands_idx;
    1106       rec->two_colon = two_colon;
    11071132      rec->flocp = flocp;
    11081133
    11091134      rec->next = NULL;
    1110       if (cur->recorded_files_tail)
    1111         cur->recorded_files_tail->next = rec;
     1135      if (cur->recorded_file_tail)
     1136        cur->recorded_file_tail->next = rec;
    11121137      else
    1113         cur->recorded_files_head = rec;
    1114       cur->recorded_files_tail = rec;
     1138        cur->recorded_file_head = rec;
     1139      cur->recorded_file_tail = rec;
    11151140    }
    11161141#endif
     
    15311556
    15321557              /* enter the file with its dependencies. */
    1533               incdep_record_files (curdep,
    1534                                    filename, NULL, NULL, deps, 0, NULL, 0, 0, f);
     1558              incdep_record_file (curdep, filename, deps, f);
    15351559            }
    15361560        }
     
    16301654       cur->recorded_variable_defs_head = NULL;
    16311655       cur->recorded_variable_defs_tail = NULL;
    1632        cur->recorded_files_head = NULL;
    1633        cur->recorded_files_tail = NULL;
     1656       cur->recorded_file_head = NULL;
     1657       cur->recorded_file_tail = NULL;
    16341658#endif
    16351659
  • trunk/src/kmk/job.c

    r2564 r2591  
    11/* Job execution and handling for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    182182#endif  /* Don't have `union wait'.  */
    183183
    184 #ifndef HAVE_UNISTD_H
     184#if !defined(HAVE_UNISTD_H) && !defined(WINDOWS32)
    185185# ifndef _MSC_VER /* bird */
    186186int dup2 ();
     
    196196#endif
    197197
     198/* Different systems have different requirements for pid_t.
     199   Plus we have to support gettext string translation... Argh.  */
     200static const char *
     201pid2str (pid_t pid)
     202{
     203  static char pidstring[100];
     204#if defined(WINDOWS32) && (__GNUC__ > 3 || _MSC_VER > 1300)
     205  /* %Id is only needed for 64-builds, which were not supported by
     206      older versions of Windows compilers.  */
     207  sprintf (pidstring, "%Id", pid);
     208#else
     209  sprintf (pidstring, "%lu", (unsigned long) pid);
     210#endif
     211  return pidstring;
     212}
     213
    198214int getloadavg (double loadavg[], int nelem);
    199215int start_remote_job (char **argv, char **envp, int stdin_fd, int *is_remote,
     
    248264 */
    249265int
    250 w32_kill(int pid, int sig)
     266w32_kill(pid_t pid, int sig)
    251267{
    252268  return ((process_kill((HANDLE)pid, sig) == TRUE) ? 0 : -1);
     
    261277{
    262278  const char *const ext = unixy ? "sh" : "bat";
    263   const char *error = NULL;
     279  const char *error_string = NULL;
    264280  char temp_path[MAXPATHLEN]; /* need to know its length */
    265281  unsigned path_size = GetTempPath(sizeof temp_path, temp_path);
     
    307323          else
    308324            {
    309               error = map_windows32_error_to_string (er);
     325              error_string = map_windows32_error_to_string (er);
    310326              break;
    311327            }
     
    316332          char *const path = xmalloc (final_size);
    317333          memcpy (path, temp_path, final_size);
    318           *fd = _open_osfhandle ((long)h, 0);
     334          *fd = _open_osfhandle ((intptr_t)h, 0);
    319335          if (unixy)
    320336            {
     
    330346
    331347  *fd = -1;
    332   if (error == NULL)
    333     error = _("Cannot create a temporary file\n");
    334   fatal (NILF, error);
     348  if (error_string == NULL)
     349    error_string = _("Cannot create a temporary file\n");
     350  fatal (NILF, error_string);
    335351
    336352  /* not reached */
     
    383399#endif /* __EMX__ */
    384400
     401/* determines whether path looks to be a Bourne-like shell. */
     402int
     403is_bourne_compatible_shell (const char *path)
     404{
     405  /* list of known unix (Bourne-like) shells */
     406  const char *unix_shells[] = {
     407    "sh",
     408    "bash",
     409    "ksh",
     410    "rksh",
     411    "zsh",
     412    "ash",
     413    "dash",
     414    NULL
     415  };
     416  unsigned i, len;
     417
     418  /* find the rightmost '/' or '\\' */
     419  const char *name = strrchr (path, '/');
     420  char *p = strrchr (path, '\\');
     421
     422  if (name && p)    /* take the max */
     423    name = (name > p) ? name : p;
     424  else if (p)       /* name must be 0 */
     425    name = p;
     426  else if (!name)   /* name and p must be 0 */
     427    name = path;
     428
     429  if (*name == '/' || *name == '\\') name++;
     430
     431  /* this should be able to deal with extensions on Windows-like systems */
     432  for (i = 0; unix_shells[i] != NULL; i++) {
     433    len = strlen(unix_shells[i]);
     434#if defined(WINDOWS32) || defined(__MSDOS__)
     435    if ((strncasecmp (name, unix_shells[i], len) == 0) &&
     436      (strlen(name) >= len && (name[len] == '\0' || name[len] == '.')))
     437#else
     438    if ((strncmp (name, unix_shells[i], len) == 0) &&
     439      (strlen(name) >= len && name[len] == '\0'))
     440#endif
     441        return 1; /* a known unix-style shell */
     442  }
     443
     444  /* if not on the list, assume it's not a Bourne-like shell */
     445  return 0;
     446}
     447
    385448
    386449
     
    537600            {
    538601              completed_child = c;
    539               DB (DB_JOBS, (_("builtin child 0x%08lx (%s) PID %ld %s Status %ld\n"),
    540                             (unsigned long int) c, c->file->name,
    541                             (long) c->pid, c->remote ? _(" (remote)") : "",
     602              DB (DB_JOBS, (_("builtin child %p (%s) PID %s %s Status %ld\n"),
     603                            (void *)c, c->file->name,
     604                            pid2str (c->pid), c->remote ? _(" (remote)") : "",
    542605                            (long) c->status));
    543606            }
    544607          else
    545608#endif
    546           DB (DB_JOBS, (_("Live child 0x%08lx (%s) PID %ld %s\n"),
    547                         (unsigned long int) c, c->file->name,
    548                         (long) c->pid, c->remote ? _(" (remote)") : ""));
     609          DB (DB_JOBS, (_("Live child %p (%s) PID %s %s\n"),
     610                        (void *)c, c->file->name, pid2str (c->pid),
     611                        c->remote ? _(" (remote)") : ""));
    549612#ifdef VMS
    550613          break;
     
    681744                  }
    682745                else
    683                   DB (DB_VERBOSE, ("Main thread handle = 0x%08lx\n",
    684                                    (unsigned long)main_thread));
     746                  DB (DB_VERBOSE, ("Main thread handle = %p\n", main_thread));
    685747              }
    686748
     
    745807
    746808      DB (DB_JOBS, (child_failed
    747                     ? _("Reaping losing child 0x%08lx PID %ld %s\n")
    748                     : _("Reaping winning child 0x%08lx PID %ld %s\n"),
    749                     (unsigned long int) c, (long) c->pid,
    750                     c->remote ? _(" (remote)") : ""));
     809                    ? _("Reaping losing child %p PID %s %s\n")
     810                    : _("Reaping winning child %p PID %s %s\n"),
     811                    (void *)c, pid2str (c->pid), c->remote ? _(" (remote)") : ""));
    751812
    752813      if (c->sh_batch_file) {
     
    859920        notice_finished_file (c->file);
    860921
    861       DB (DB_JOBS, (_("Removing child 0x%08lx PID %ld%s from chain.\n"),
    862                     (unsigned long int) c, (long) c->pid,
    863                     c->remote ? _(" (remote)") : ""));
     922      DB (DB_JOBS, (_("Removing child %p PID %s%s from chain.\n"),
     923                    (void *)c, pid2str (c->pid), c->remote ? _(" (remote)") : ""));
    864924
    865925      /* Block fatal signals while frobnicating the list, so that
     
    908968#endif
    909969  if (!jobserver_tokens)
    910     fatal (NILF, "INTERNAL: Freeing child 0x%08lx (%s) but no tokens left!\n",
    911            (unsigned long int) child, child->file->name);
     970    fatal (NILF, "INTERNAL: Freeing child %p (%s) but no tokens left!\n",
     971           (void *)child, child->file->name);
    912972
    913973  /* If we're using the jobserver and this child is not the only outstanding
     
    925985        pfatal_with_name (_("write jobserver"));
    926986
    927       DB (DB_JOBS, (_("Released token for child 0x%08lx (%s).\n"),
    928                     (unsigned long int) child, child->file->name));
     987      DB (DB_JOBS, (_("Released token for child %p (%s).\n"),
     988                    (void *)child, child->file->name));
    929989    }
    930990
     
    10311091  rval = sigaction (SIGCLD, &sa, NULL);
    10321092#endif
    1033   if (rval != 0) 
     1093  if (rval != 0)
    10341094    fprintf (stderr, "sigaction: %s (%d)\n", strerror (errno), errno);
    10351095#if defined SIGALRM
     
    10621122  static int bad_stdin = -1;
    10631123#endif
    1064   register char *p;
    1065   int flags;
     1124  char *p;
     1125  /* Must be volatile to silence bogus GCC warning about longjmp/vfork.  */
     1126  /*volatile*/ int flags;
    10661127#ifdef VMS
    10671128  char *argv;
    10681129#else
    10691130  char **argv;
     1131  char ** volatile volatile_argv;
     1132  int volatile volatile_flags;
    10701133#endif
    10711134
     
    12291292      unixy_shell       /* the test is complicated and we already did it */
    12301293#else
    1231       (argv[0] && !strcmp (argv[0], "/bin/sh"))
    1232 #endif
    1233       && (argv[1]
    1234           && argv[1][0] == '-' && argv[1][1] == 'c' && argv[1][2] == '\0')
     1294      (argv[0] && is_bourne_compatible_shell(argv[0]))
     1295#endif
     1296      && (argv[1] && argv[1][0] == '-'
     1297        &&
     1298            ((argv[1][1] == 'c' && argv[1][2] == '\0')
     1299          ||
     1300             (argv[1][1] == 'e' && argv[1][2] == 'c' && argv[1][3] == '\0')))
    12351301      && (argv[2] && argv[2][0] == ':' && argv[2][1] == '\0')
    12361302      && argv[3] == NULL)
     
    14351501
    14361502#else  /* !__EMX__ */
     1503      volatile_argv  = argv;            /* shut up gcc */
     1504      volatile_flags = flags;           /* ditto */
    14371505
    14381506      child->pid = vfork ();
    14391507      environ = parent_environ; /* Restore value child may have clobbered.  */
     1508      argv = volatile_argv;             /* shut up gcc */
    14401509      if (child->pid == 0)
    14411510        {
     
    14451514          /* If we aren't running a recursive command and we have a jobserver
    14461515             pipe, close it before exec'ing.  */
    1447           if (!(flags & COMMANDS_RECURSE) && job_fds[0] >= 0)
     1516          if (!(volatile_flags & COMMANDS_RECURSE) && job_fds[0] >= 0)
    14481517            {
    14491518              close (job_fds[0]);
     
    14521521          if (job_rfd >= 0)
    14531522            close (job_rfd);
     1523
     1524#ifdef SET_STACK_SIZE
     1525          /* Reset limits, if necessary.  */
     1526          if (stack_limit.rlim_cur)
     1527            setrlimit (RLIMIT_STACK, &stack_limit);
     1528#endif
    14541529
    14551530          child_execute_job (child->good_stdin ? 0 : bad_stdin, 1,
     
    15531628
    15541629      if (hPID != INVALID_HANDLE_VALUE)
    1555         child->pid = (int) hPID;
     1630        child->pid = (pid_t) hPID;
    15561631      else {
    15571632        int i;
     
    16751750    case cs_running:
    16761751      c->next = children;
    1677       DB (DB_JOBS, (_("Putting child 0x%08lx (%s) PID %ld%s on the chain.\n"),
    1678                     (unsigned long int) c, c->file->name,
    1679                     (long) c->pid, c->remote ? _(" (remote)") : ""));
     1752      DB (DB_JOBS, (_("Putting child %p (%s) PID %s%s on the chain.\n"),
     1753                    (void *)c, c->file->name, pid2str (c->pid),
     1754                    c->remote ? _(" (remote)") : ""));
    16801755      children = c;
    16811756      /* One more job slot is in use.  */
     
    18201895         Copy the remaining uninteresting text to the output.  */
    18211896      if (out != in)
    1822         strcpy (out, in);
     1897        memmove (out, in, strlen (in) + 1);
    18231898
    18241899      /* Finally, expand the line.  */
     
    18301905     `struct child', and add that to the chain.  */
    18311906
    1832   c = xmalloc (sizeof (struct child));
    1833   memset (c, '\0', sizeof (struct child));
     1907  c = xcalloc (sizeof (struct child));
    18341908  c->file = file;
    18351909  c->command_lines = lines;
     
    19352009        if (got_token == 1)
    19362010          {
    1937             DB (DB_JOBS, (_("Obtained token for child 0x%08lx (%s).\n"),
    1938                           (unsigned long int) c, c->file->name));
     2011            DB (DB_JOBS, (_("Obtained token for child %p (%s).\n"),
     2012                          (void *)c, c->file->name));
    19392013            break;
    19402014          }
     
    22882362      int i;
    22892363      fprintf(stderr,
    2290               _("process_easy() failed failed to launch process (e=%ld)\n"),
     2364              _("process_easy() failed to launch process (e=%ld)\n"),
    22912365              process_last_err(hPID));
    22922366      for (i = 0; argv[i]; i++)
     
    23172391          break;
    23182392      else
     2393        {
     2394          char *pidstr = xstrdup (pid2str ((pid_t)hWaitPID));
     2395
    23192396          fprintf(stderr,
    2320                   _("make reaped child pid %ld, still waiting for pid %ld\n"),
    2321                   (DWORD)hWaitPID, (DWORD)hPID);
     2397                  _("make reaped child pid %s, still waiting for pid %s\n"),
     2398                  pidstr, pid2str ((pid_t)hPID));
     2399          free (pidstr);
     2400        }
    23222401    }
    23232402
     
    24782557static char **
    24792558construct_command_argv_internal (char *line, char **restp, char *shell,
    2480                                  char *ifs, int flags,
     2559                                 char *shellflags, char *ifs, int flags,
    24812560                                 char **batch_filename_ptr)
    24822561{
     
    25192598                                 "continue", "export", "read", "readonly",
    25202599                                 "shift", "times", "trap", "switch", "unset",
    2521                                  0 };
     2600                                 "ulimit", 0 };
    25222601
    25232602  char *sh_chars;
     
    25612640#elif defined (WINDOWS32)
    25622641  static char sh_chars_dos[] = "\"|&<>";
    2563   static char *sh_cmds_dos[] = { "break", "call", "cd", "chcp", "chdir", "cls",
    2564                              "copy", "ctty", "date", "del", "dir", "echo",
    2565                              "erase", "exit", "for", "goto", "if", "if", "md",
    2566                              "mkdir", "path", "pause", "prompt", "rd", "rem",
    2567                              "ren", "rename", "rmdir", "set", "shift", "time",
    2568                              "type", "ver", "verify", "vol", ":", 0 };
     2642  static char *sh_cmds_dos[] = { "assoc", "break", "call", "cd", "chcp",
     2643                                 "chdir", "cls", "color", "copy", "ctty",
     2644                                 "date", "del", "dir", "echo", "echo.",
     2645                                 "endlocal", "erase", "exit", "for", "ftype",
     2646                                 "goto", "if", "if", "md", "mkdir", "path",
     2647                                 "pause", "prompt", "rd", "rem", "ren",
     2648                                 "rename", "rmdir", "set", "setlocal",
     2649                                 "shift", "time", "title", "type", "ver",
     2650                                 "verify", "vol", ":", 0 };
    25692651  static char sh_chars_sh[] = "#;\"*?[]&|<>(){}$`^";
    25702652  static char *sh_cmds_sh[] = { "cd", "eval", "exec", "exit", "login",
     
    25882670                             "login", "logout", "read", "readonly", "set",
    25892671                             "shift", "switch", "test", "times", "trap",
    2590                              "umask", "wait", "while", 0 };
     2672                             "ulimit", "umask", "unset", "wait", "while", 0 };
    25912673# ifdef HAVE_DOS_PATHS
    25922674  /* This is required if the MSYS/Cygwin ports (which do not define
     
    27272809      if (*ap != ' ' && *ap != '\t' && *ap != '\n')
    27282810        goto slow;
     2811
     2812  if (shellflags != 0)
     2813    if (shellflags[0] != '-'
     2814        || ((shellflags[1] != 'c' || shellflags[2] != '\0')
     2815            && (shellflags[1] != 'e' || shellflags[2] != 'c' || shellflags[3] != '\0')))
     2816      goto slow;
    27292817
    27302818  i = strlen (line) + 1;
     
    28102898        goto slow;
    28112899#endif /* !KMK */
     2900      else if (one_shell && *p == '\n')
     2901        /* In .ONESHELL mode \n is a separator like ; or && */
     2902        goto slow;
    28122903#ifdef  __MSDOS__
    28132904      else if (*p == '.' && p[1] == '.' && p[2] == '.' && p[3] != '.')
     
    30323123    return 0;
    30333124#endif /* WINDOWS32 */
     3125
    30343126  {
    30353127    /* SHELL may be a multi-word command.  Construct a command line
    3036        "SHELL -c LINE", with all special chars in LINE escaped.
     3128       "$(SHELL) $(.SHELLFLAGS) LINE", with all special chars in LINE escaped.
    30373129       Then recurse, expanding this command line to get the final
    30383130       argument list.  */
    30393131
    30403132    unsigned int shell_len = strlen (shell);
    3041 #ifndef VMS
    3042     static char minus_c[] = " -c ";
    3043 #else
    3044     static char minus_c[] = "";
    3045 #endif
    30463133    unsigned int line_len = strlen (line);
    3047 
    3048     char *new_line = alloca (shell_len + (sizeof (minus_c)-1)
    3049                              + (line_len*2) + 1);
     3134    unsigned int sflags_len = strlen (shellflags);
    30503135    char *command_ptr = NULL; /* used for batch_mode_shell mode */
     3136    char *new_line;
    30513137
    30523138# ifdef __EMX__ /* is this necessary? */
    30533139    if (!unixy_shell)
    3054       minus_c[1] = '/'; /* " /c " */
     3140      shellflags[0] = '/'; /* "/c" */
    30553141# endif
    30563142
     3143    /* In .ONESHELL mode we are allowed to throw the entire current
     3144        recipe string at a single shell and trust that the user
     3145        has configured the shell and shell flags, and formatted
     3146        the string, appropriately. */
     3147    if (one_shell)
     3148      {
     3149        /* If the shell is Bourne compatible, we must remove and ignore
     3150           interior special chars [@+-] because they're meaningless to
     3151           the shell itself. If, however, we're in .ONESHELL mode and
     3152           have changed SHELL to something non-standard, we should
     3153           leave those alone because they could be part of the
     3154           script. In this case we must also leave in place
     3155           any leading [@+-] for the same reason.  */
     3156
     3157        /* Remove and ignore interior prefix chars [@+-] because they're
     3158             meaningless given a single shell. */
     3159#if defined __MSDOS__ || defined (__EMX__)
     3160        if (unixy_shell)     /* the test is complicated and we already did it */
     3161#else
     3162        if (is_bourne_compatible_shell(shell))
     3163#endif
     3164          {
     3165            const char *f = line;
     3166            char *t = line;
     3167
     3168            /* Copy the recipe, removing and ignoring interior prefix chars
     3169               [@+-]: they're meaningless in .ONESHELL mode.  */
     3170            while (f[0] != '\0')
     3171              {
     3172                int esc = 0;
     3173
     3174                /* This is the start of a new recipe line.
     3175                   Skip whitespace and prefix characters.  */
     3176                while (isblank (*f) || *f == '-' || *f == '@' || *f == '+')
     3177                  ++f;
     3178
     3179                /* Copy until we get to the next logical recipe line.  */
     3180                while (*f != '\0')
     3181                  {
     3182                    *(t++) = *(f++);
     3183                    if (f[-1] == '\\')
     3184                      esc = !esc;
     3185                    else
     3186                      {
     3187                        /* On unescaped newline, we're done with this line.  */
     3188                        if (f[-1] == '\n' && ! esc)
     3189                          break;
     3190
     3191                        /* Something else: reset the escape sequence.  */
     3192                        esc = 0;
     3193                      }
     3194                  }
     3195              }
     3196            *t = '\0';
     3197          }
     3198
     3199        new_argv = xmalloc (4 * sizeof (char *));
     3200        new_argv[0] = xstrdup(shell);
     3201        new_argv[1] = xstrdup(shellflags);
     3202        new_argv[2] = line;
     3203        new_argv[3] = NULL;
     3204        return new_argv;
     3205      }
     3206
     3207    new_line = alloca (shell_len + 1 + sflags_len + 1
     3208                             + (line_len*2) + 1);
    30573209    ap = new_line;
    30583210    memcpy (ap, shell, shell_len);
    30593211    ap += shell_len;
    3060     memcpy (ap, minus_c, sizeof (minus_c) - 1);
    3061     ap += sizeof (minus_c) - 1;
     3212    *(ap++) = ' ';
     3213    memcpy (ap, shellflags, sflags_len);
     3214    ap += sflags_len;
     3215    *(ap++) = ' ';
    30623216    command_ptr = ap;
    30633217    for (p = line; *p != '\0'; ++p)
     
    31093263        *ap++ = *p;
    31103264      }
    3111     if (ap == new_line + shell_len + sizeof (minus_c) - 1)
     3265    if (ap == new_line + shell_len + sflags_len + 2)
    31123266      /* Line was empty.  */
    31133267      return 0;
     
    31613315    } else
    31623316#endif /* WINDOWS32 */
     3317
    31633318    if (unixy_shell)
    3164       new_argv = construct_command_argv_internal (new_line, 0, 0, 0, flags, 0);
     3319      new_argv = construct_command_argv_internal (new_line, 0, 0, 0, 0, flags, 0);
     3320
    31653321#ifdef __EMX__
    31663322    else if (!unixy_shell)
     
    31733329        char *q = new_line;
    31743330        memcpy (new_line, line, line_len + 1);
    3175         /* replace all backslash-newline combination and also following tabs */
    3176         while (*q != '\0')
     3331        /* Replace all backslash-newline combination and also following tabs.
     3332           Important: stop at the first '\n' because that's what the loop above
     3333           did. The next line starting at restp[0] will be executed during the
     3334           next call of this function. */
     3335        while (*q != '\0' && *q != '\n')
    31773336          {
    31783337            if (q[0] == '\\' && q[1] == '\n')
     
    32353394           cannot backslash-escape the special characters (see above).  */
    32363395        new_argv = xmalloc (sizeof (char *));
    3237         line_len = strlen (new_line) - shell_len - sizeof (minus_c) + 1;
     3396        line_len = strlen (new_line) - shell_len - sflags_len - 2;
    32383397        new_argv[0] = xmalloc (line_len + 1);
    32393398        strncpy (new_argv[0],
    3240                  new_line + shell_len + sizeof (minus_c) - 1, line_len);
     3399                 new_line + shell_len + sflags_len + 2, line_len);
    32413400        new_argv[0][line_len] = '\0';
    32423401      }
     
    32703429                        int cmd_flags, char **batch_filename_ptr)
    32713430{
    3272   char *shell, *ifs;
     3431  char *shell, *ifs, *shellflags;
    32733432  char **argv;
    32743433
     
    33753534#endif /* __EMX__ */
    33763535
     3536    shellflags = allocated_variable_expand_for_file ("$(.SHELLFLAGS)", file);
    33773537    ifs = allocated_variable_expand_for_file ("$(IFS)", file);
    33783538
     
    34003560    unixy_shell = 1;
    34013561    batch_mode_shell = 0;
    3402     argv = construct_command_argv_internal (line, restp, shell, ifs,
     3562    argv = construct_command_argv_internal (line, restp, shell, shellflags, ifs,
    34033563                                            cmd_flags, batch_filename_ptr);
    34043564    batch_mode_shell = saved_batch_mode_shell;
     
    34103570  else
    34113571#endif /* CONFIG_WITH_KMK_BUILTIN */
    3412   argv = construct_command_argv_internal (line, restp, shell, ifs,
     3572  argv = construct_command_argv_internal (line, restp, shell, shellflags, ifs,
    34133573                                          cmd_flags, batch_filename_ptr);
    34143574
    34153575  free (shell);
     3576  free (shellflags);
    34163577  free (ifs);
    34173578#endif /* !VMS */
     
    34373598  return fd;
    34383599}
    3439 #endif /* !HAPE_DUP2 && !_AMIGA */
     3600#endif /* !HAVE_DUP2 && !_AMIGA */
    34403601
    34413602#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
  • trunk/src/kmk/job.h

    r2101 r2591  
    11/* Definitions for managing subprocesses in GNU Make.
    22Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    3 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     32002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
     4Foundation, Inc.
    45This file is part of GNU Make.
    56
     
    5455    int efn;                    /* Completion event flag number */
    5556    int cstatus;                /* Completion status */
     57    char *comname;              /* Temporary command file name */
    5658#endif
    5759    char *sh_batch_file;        /* Script file for shell commands */
     
    7476extern struct child *children;
    7577
     78int is_bourne_compatible_shell(const char *path);
    7679void new_job (struct file *file);
    7780void reap_children (int block, int err);
  • trunk/src/kmk/kmkbuiltin.c

    r2413 r2591  
    120120        if (!argv[argc])
    121121        {
    122             printf("kmk_builtin: out of memory. argc=%d len=%d\n", argc, pszEnd - pszCmd + 1);
     122            printf("kmk_builtin: out of memory. argc=%d len=%d\n", argc, (int)(pszEnd - pszCmd + 1));
    123123            break;
    124124        }
  • trunk/src/kmk/kmkbuiltin/cmp_util.c

    r2113 r2591  
    363363
    364364        bytes_read = read(fd1, b1, blk_sz);
    365         if (bytes_read != blk_sz)
     365        if (bytes_read != (off_t)blk_sz)
    366366            goto l_read_error;
    367367
    368368        bytes_read = read(fd2, b2, blk_sz);
    369         if (bytes_read != blk_sz)
     369        if (bytes_read != (off_t)blk_sz)
    370370            goto l_read_error;
    371371
  • trunk/src/kmk/kmkbuiltin/darwin.c

    r2413 r2591  
    2929#include "config.h"
    3030#include <sys/stat.h>
     31#include <sys/time.h>
    3132#include <unistd.h>
    3233
  • trunk/src/kmk/kmkbuiltin/echo.c

    r2113 r2591  
    3939#endif /* not lint */
    4040#include <sys/cdefs.h>
    41 //__FBSDID("$FreeBSD: src/bin/echo/echo.c,v 1.17 2004/04/06 20:06:46 markm Exp $");
     41/*__FBSDID("$FreeBSD: src/bin/echo/echo.c,v 1.17 2004/04/06 20:06:46 markm Exp $");*/
    4242#endif
    4343
  • trunk/src/kmk/kmkbuiltin/expr.c

    r2121 r2591  
    281281}
    282282
     283#ifdef __GNUC__
     284__attribute__((noreturn))
     285#endif
    283286static void
    284287error(void)
  • trunk/src/kmk/kmkbuiltin/kDepObj.c

    r2413 r2591  
    274274
    275275        /* process selected record types. */
    276         dprintf(("%#07x: %#04x %#05x\n", (const KU8*)pHdr - pbFile, pHdr->bType, pHdr->cbRec));
     276        dprintf(("%#07" KUPTR_PRI ": %#04x %#05x\n", (const KU8*)pHdr - pbFile, pHdr->bType, pHdr->cbRec));
    277277        switch (pHdr->bType)
    278278        {
     
    692692        if (off + 8 > cbSrcFiles)
    693693        {
    694             fprintf(stderr, "%s: CV source file entry at %08" KX32_PRI " is too long; cbSrcFiles=%#" KSIZE_PRI "\n",
     694            fprintf(stderr, "%s: CV source file entry at %08" KX32_PRI " is too long; cbSrcFiles=%#" KX32_PRI "\n",
    695695                    argv0, off, cbSrcFiles);
    696696            return 1;
     
    701701        if (off + cbSrc > cbSrcFiles)
    702702        {
    703             fprintf(stderr, "%s: CV source file entry at %08" KX32_PRI " is too long; cbSrc=%#" KX32_PRI " cbSrcFiles=%#" KSIZE_PRI "\n",
     703            fprintf(stderr, "%s: CV source file entry at %08" KX32_PRI " is too long; cbSrc=%#" KX32_PRI " cbSrcFiles=%#" KX32_PRI "\n",
    704704                    argv0, off, cbSrc, cbSrcFiles);
    705705            return 1;
  • trunk/src/kmk/kmkbuiltin/kbuild_version.c

    r2413 r2591  
    5353
    5454    printf("%.*s - kBuild version %d.%d.%d (r%u)\n",
    55            tmp - argv0, argv0,
     55           (int)(tmp - argv0), argv0,
    5656           KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, KBUILD_VERSION_PATCH,
    5757           KBUILD_SVN_REV);
  • trunk/src/kmk/kmkbuiltin/printf.c

    r2141 r2591  
    207207        (void)funcname;
    208208        if (rc != 0)
    209                 fatal (NILF, _("$(%s): failure rc=%d\n"), rc);
     209                fatal (NILF, _("$(%s): failure rc=%d\n"), funcname, rc);
    210210        return o;
    211211}
  • trunk/src/kmk/main.c

    r2549 r2591  
    11/* Argument parsing and main program of GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    8181void print_dir_data_base (void);
    8282void print_rule_data_base (void);
    83 void print_file_data_base (void);
    8483void print_vpath_data_base (void);
    8584
     
    110109static void decode_switches (int argc, char **argv, int env);
    111110static void decode_env_switches (char *envar, unsigned int len);
    112 static void define_makeflags (int all, int makefile);
     111static const char *define_makeflags (int all, int makefile);
    113112static char *quote_for_env (char *out, const char *in);
    114113static void initialize_global_hash_tables (void);
     
    265264static struct stringlist *makefiles = 0;
    266265
     266/* Size of the stack when we started.  */
     267
     268#ifdef SET_STACK_SIZE
     269struct rlimit stack_limit;
     270#endif
     271
     272
    267273/* Number of job slots (commands that can be run at once).  */
    268274
     
    309315
    310316static struct stringlist *new_files = 0;
     317
     318/* List of strings to be eval'd.  */
     319static struct stringlist *eval_strings = 0;
    311320
    312321/* If nonzero, we should just print usage and exit.  */
     
    382391  -e, --environment-overrides\n\
    383392                              Environment variables override makefiles.\n"),
     393    N_("\
     394  --eval=STRING               Evaluate STRING as a makefile statement.\n"),
    384395    N_("\
    385396  -f FILE, --file=FILE, --makefile=FILE\n\
     
    544555    { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
    545556      "warn-undefined-variables" },
     557    { CHAR_MAX+6, string, &eval_strings, 1, 0, 0, 0, 0, "eval" },
    546558    { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
    547559  };
     
    596608unsigned int makelevel;
    597609
    598 /* First file defined in the makefile whose name does not
    599    start with `.'.  This is the default to remake if the
    600    command line does not specify.  */
    601 
    602 struct file *default_goal_file;
    603 
    604 /* Pointer to the value of the .DEFAULT_GOAL special
    605    variable.  */
    606 char ** default_goal_name;
     610/* Pointer to the value of the .DEFAULT_GOAL special variable.
     611   The value will be the name of the goal to remake if the command line
     612   does not override it.  It can be set by the makefile, or else it's
     613   the first target defined in the makefile whose name does not start
     614   with '.'.  */
     615
     616struct variable * default_goal_var;
    607617
    608618/* Pointer to structure for the file .DEFAULT
     
    622632int second_expansion;
    623633
     634/* Nonzero if we have seen the '.ONESHELL' target.
     635   This causes the entire recipe to be handed to SHELL
     636   as a single string, potentially containing newlines.  */
     637
     638int one_shell;
     639
    624640#ifdef CONFIG_WITH_2ND_TARGET_EXPANSION
    625641/* Nonzero if we have seen the '.SECONDTARGETEXPANSION' target.
     
    630646
    631647#ifndef CONFIG_WITH_EXTENDED_NOTPARALLEL
     648
    632649/* Nonzero if we have seen the `.NOTPARALLEL' target.
    633650   This turns off parallel builds for this invocation of make.  */
     
    667684#endif
    668685
    669 #if !defined HAVE_BSD_SIGNAL && !defined bsd_signal
     686#if !HAVE_DECL_BSD_SIGNAL && !defined bsd_signal
    670687# if !defined HAVE_SIGACTION
    671688#  define bsd_signal signal
    672689# else
    673 typedef RETSIGTYPE (*bsd_signal_ret_t) ();
     690typedef RETSIGTYPE (*bsd_signal_ret_t) (int);
    674691
    675692static bsd_signal_ret_t
     
    924941    {
    925942      sprintf(errmsg,
    926               _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x%lx)\n"),
    927               prg, exrec->ExceptionCode, (DWORD)exrec->ExceptionAddress);
     943              _("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x%p)\n"),
     944              prg, exrec->ExceptionCode, exrec->ExceptionAddress);
    928945      fprintf(stderr, errmsg);
    929946      exit(255);
     
    931948
    932949  sprintf(errmsg,
    933           _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = %lx\n"),
     950          _("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = 0x%p\n"),
    934951          prg, exrec->ExceptionCode, exrec->ExceptionFlags,
    935           (DWORD)exrec->ExceptionAddress);
     952          exrec->ExceptionAddress);
    936953
    937954  if (exrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION
     
    939956    sprintf(&errmsg[strlen(errmsg)],
    940957            (exrec->ExceptionInformation[0]
    941              ? _("Access violation: write operation at address %lx\n")
    942              : _("Access violation: read operation at address %lx\n")),
    943             exrec->ExceptionInformation[1]);
     958             ? _("Access violation: write operation at address 0x%p\n")
     959             : _("Access violation: read operation at address 0x%p\n")),
     960            (PVOID)exrec->ExceptionInformation[1]);
    944961
    945962  /* turn this on if we want to put stuff in the event log too */
     
    10151032    sprintf (sh_path, "%s", search_token);
    10161033    default_shell = xstrdup (w32ify (sh_path, 0));
    1017     DB (DB_VERBOSE,
    1018         (_("find_and_set_shell setting default_shell = %s\n"), default_shell));
     1034    DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
     1035                    default_shell));
    10191036    sh_found = 1;
    10201037  } else if (!no_default_sh_exe &&
     
    10261043    sprintf (sh_path, "%s", search_token);
    10271044    default_shell = xstrdup (w32ify (sh_path, 0));
    1028     DB (DB_VERBOSE,
    1029         (_("find_and_set_shell setting default_shell = %s\n"), default_shell));
     1045    DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
     1046                    default_shell));
    10301047    sh_found = 1;
    10311048  } else {
     
    10681085      if (sh_found)
    10691086        DB (DB_VERBOSE,
    1070             (_("find_and_set_shell path search set default_shell = %s\n"),
     1087            (_("find_and_set_shell() path search set default_shell = %s\n"),
    10711088             default_shell));
    10721089    }
     
    13831400
    13841401    /* Set the stack limit huge so that alloca does not fail.  */
    1385     if (getrlimit (RLIMIT_STACK, &rlim) == 0)
     1402    if (getrlimit (RLIMIT_STACK, &rlim) == 0
     1403        && rlim.rlim_cur > 0 && rlim.rlim_cur < rlim.rlim_max)
    13861404      {
     1405        stack_limit = rlim;
    13871406        rlim.rlim_cur = rlim.rlim_max;
    13881407        setrlimit (RLIMIT_STACK, &rlim);
    13891408      }
     1409    else
     1410      stack_limit.rlim_cur = 0;
    13901411  }
    13911412#endif
     
    14021423#endif
    14031424
    1404   default_goal_file = 0;
    14051425  reading_file = 0;
    14061426
     
    14191439  /* Set up gettext/internationalization support.  */
    14201440  setlocale (LC_ALL, "");
     1441  /* The cast to void shuts up compiler warnings on systems that
     1442     disable NLS.  */
    14211443#ifdef LOCALEDIR /* bird */
    1422   bindtextdomain (PACKAGE, LOCALEDIR);
    1423   textdomain (PACKAGE);
     1444  (void)bindtextdomain (PACKAGE, LOCALEDIR);
     1445  (void)textdomain (PACKAGE);
    14241446#endif
    14251447
     
    14321454#define ADD_SIG(sig)    fatal_signal_mask |= sigmask (sig)
    14331455#else
    1434 #define ADD_SIG(sig)
     1456#define ADD_SIG(sig)    (void)sig      /* Needed to avoid warnings in MSVC.  */
    14351457#endif
    14361458#endif
     
    15871609
    15881610  /* Initialize the special variables.  */
    1589   define_variable (".VARIABLES", 10, "", o_default, 0)->special = 1;
    1590   /* define_variable (".TARGETS", 8, "", o_default, 0)->special = 1; */
    1591   define_variable (".RECIPEPREFIX", 13, "", o_default, 0)->special = 1;
    1592 
    1593   /* Set up .FEATURES */
    1594   define_variable (".FEATURES", 9,
    1595                    "target-specific order-only second-expansion else-if",
    1596                    o_default, 0);
     1611  define_variable_cname (".VARIABLES", "", o_default, 0)->special = 1;
     1612  /* define_variable_cname (".TARGETS", "", o_default, 0)->special = 1; */
     1613  define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1;
     1614  define_variable_cname (".SHELLFLAGS", "-c", o_default, 0);
     1615
     1616  /* Set up .FEATURES
     1617     We must do this in multiple calls because define_variable_cname() is
     1618     a macro and some compilers (MSVC) don't like conditionals in macros.  */
     1619  {
     1620    const char *features = "target-specific order-only second-expansion"
     1621                           " else-if shortest-stem undefine"
    15971622#ifndef NO_ARCHIVES
    1598   do_variable_definition (NILF, ".FEATURES", "archives",
    1599                           o_default, f_append, 0);
     1623                           " archives"
    16001624#endif
    16011625#ifdef MAKE_JOBSERVER
    1602   do_variable_definition (NILF, ".FEATURES", "jobserver",
    1603                           o_default, f_append, 0);
     1626                           " jobserver"
    16041627#endif
    16051628#ifdef MAKE_SYMLINKS
    1606   do_variable_definition (NILF, ".FEATURES", "check-symlink",
    1607                           o_default, f_append, 0);
     1629                           " check-symlink"
    16081630#endif
    16091631#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    1610   do_variable_definition (NILF, ".FEATURES", "explicit-multitarget",
    1611                           o_default, f_append, 0);
     1632                           " explicit-multitarget"
    16121633#endif
    16131634#ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
    1614   do_variable_definition (NILF, ".FEATURES", "prepend-assignment",
    1615                           o_default, f_append, 0);
    1616 #endif
     1635                           " prepend-assignment"
     1636#endif
     1637                           ;
     1638
     1639    define_variable_cname (".FEATURES", features, o_default, 0);
     1640  }
    16171641
    16181642#ifdef KMK
     
    16751699                shell_var.name = v->name;
    16761700#endif
    1677                 shell_var.length = 5; /* bird - gotta set the length too! */
     1701                shell_var.length = 5;
    16781702#ifndef CONFIG_WITH_VALUE_LENGTH
    16791703                shell_var.value = xstrdup (ep + 1);
    16801704#else
    1681                 shell_var.value = savestring (v->value, v->value_length);
     1705                shell_var.value = xstrndup (v->value, v->value_length);
    16821706                shell_var.value_length = v->value_length;
    16831707#endif
    1684 
    16851708              }
    16861709
     
    16991722     */
    17001723    if (!unix_path)
    1701       define_variable("PATH", 4,
    1702                       windows32_path ? windows32_path : "",
    1703                       o_env, 1)->export = v_export;
     1724      define_variable_cname ("PATH", windows32_path ? windows32_path : "",
     1725                             o_env, 1)->export = v_export;
    17041726#endif
    17051727#else /* For Amiga, read the ENV: device, ignoring all dirs */
     
    17471769#endif
    17481770#endif /* !KMK */
     1771
    17491772  decode_switches (argc, argv, 0);
     1773
    17501774#ifdef WINDOWS32
    17511775  if (suspend_flag) {
     
    18151839# endif
    18161840      )
    1817     argv[0] = xstrdup (concat (current_directory, "/", argv[0]));
     1841    argv[0] = xstrdup (concat (3, current_directory, "/", argv[0]));
    18181842#else  /* !__MSDOS__ */
    18191843  if (current_directory[0] != '\0'
     
    18241848#endif
    18251849      )
    1826     argv[0] = xstrdup (concat (current_directory, "/", argv[0]));
     1850    argv[0] = xstrdup (concat (3, current_directory, "/", argv[0]));
    18271851#endif /* !__MSDOS__ */
    18281852#endif /* WINDOWS32 */
     
    18311855  /* The extra indirection through $(MAKE_COMMAND) is done
    18321856     for hysterical raisins.  */
    1833   (void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);
    1834   (void) define_variable ("MAKE", 4, "$(MAKE_COMMAND)", o_default, 1);
     1857  define_variable_cname ("MAKE_COMMAND", argv[0], o_default, 0);
     1858  define_variable_cname ("MAKE", "$(MAKE_COMMAND)", o_default, 1);
    18351859#ifdef KMK
    18361860  (void) define_variable ("KMK", 3, argv[0], o_default, 1);
     
    18731897      /* Define an unchangeable variable with a name that no POSIX.2
    18741898         makefile could validly use for its own variable.  */
    1875       (void) define_variable ("-*-command-variables-*-", 23,
    1876                               value, o_automatic, 0);
     1899      define_variable_cname ("-*-command-variables-*-", value, o_automatic, 0);
    18771900
    18781901      /* Define the variable; this will not override any user definition.
     
    18831906         a reference to this hidden variable is written instead. */
    18841907#ifdef KMK
    1885       (void) define_variable ("KMK_OVERRIDES", 13,
    1886                               "${-*-command-variables-*-}", o_env, 1);
     1908      define_variable_cname ("KMK_OVERRIDES", "${-*-command-variables-*-}",
     1909                            o_env, 1);
    18871910#else
    1888       (void) define_variable ("MAKEOVERRIDES", 13,
    1889                               "${-*-command-variables-*-}", o_env, 1);
     1911      define_variable_cname ("MAKEOVERRIDES", "${-*-command-variables-*-}",
     1912                            o_env, 1);
    18901913#endif
    18911914    }
     
    20582081    }
    20592082
    2060   (void) define_variable ("CURDIR", 6, current_directory, o_file, 0);
     2083  define_variable_cname ("CURDIR", current_directory, o_file, 0);
    20612084
    20622085  /* Read any stdin makefiles into temporary files.  */
     
    21982221  default_file = enter_file (strcache_add (".DEFAULT"));
    21992222
    2200   {
    2201     struct variable *v = define_variable (".DEFAULT_GOAL", 13, "", o_file, 0);
    2202     default_goal_name = &v->value;
    2203   }
     2223  default_goal_var = define_variable_cname (".DEFAULT_GOAL", "", o_file, 0);
     2224
     2225  /* Evaluate all strings provided with --eval.
     2226     Also set up the $(-*-eval-flags-*-) variable.  */
     2227
     2228  if (eval_strings)
     2229    {
     2230      char *p, *value;
     2231      unsigned int i;
     2232      unsigned int len = sizeof ("--eval=") * eval_strings->idx;
     2233
     2234      for (i = 0; i < eval_strings->idx; ++i)
     2235        {
     2236#ifndef CONFIG_WITH_VALUE_LENGTH
     2237          p = xstrdup (eval_strings->list[i]);
     2238          len += 2 * strlen (p);
     2239          eval_buffer (p);
     2240#else
     2241          unsigned int sub_len = strlen(eval_strings->list[i]);
     2242          p = xstrndup (eval_strings->list[i], sub_len);
     2243          len += 2 * sub_len;
     2244          eval_buffer (p, p + sub_len);
     2245#endif
     2246          free (p);
     2247        }
     2248
     2249      p = value = alloca (len);
     2250      for (i = 0; i < eval_strings->idx; ++i)
     2251        {
     2252          strcpy (p, "--eval=");
     2253          p += strlen (p);
     2254          p = quote_for_env (p, eval_strings->list[i]);
     2255          *(p++) = ' ';
     2256        }
     2257      p[-1] = '\0';
     2258
     2259      define_variable_cname ("-*-eval-flags-*-", value, o_automatic, 0);
     2260    }
    22042261
    22052262  /* Read all the makefiles.  */
     
    22642321
    22652322  if (jobserver_fds)
    2266   {
    2267     const char *cp;
    2268     unsigned int ui;
    2269 
    2270     for (ui=1; ui < jobserver_fds->idx; ++ui)
    2271       if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui]))
    2272         fatal (NILF, _("internal error: multiple --jobserver-fds options"));
    2273 
    2274     /* Now parse the fds string and make sure it has the proper format.  */
    2275 
    2276     cp = jobserver_fds->list[0];
    2277 
    2278     if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2)
    2279       fatal (NILF,
    2280              _("internal error: invalid --jobserver-fds string `%s'"), cp);
    2281 
    2282     DB (DB_JOBS,
    2283         (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1]));
    2284 
    2285     /* The combination of a pipe + !job_slots means we're using the
    2286        jobserver.  If !job_slots and we don't have a pipe, we can start
    2287        infinite jobs.  If we see both a pipe and job_slots >0 that means the
    2288        user set -j explicitly.  This is broken; in this case obey the user
    2289        (ignore the jobserver pipe for this make) but print a message.  */
    2290 
    2291     if (job_slots > 0)
    2292       error (NILF,
    2293              _("warning: -jN forced in submake: disabling jobserver mode."));
    2294 
    2295     /* Create a duplicate pipe, that will be closed in the SIGCHLD
    2296        handler.  If this fails with EBADF, the parent has closed the pipe
    2297        on us because it didn't think we were a submake.  If so, print a
    2298        warning then default to -j1.  */
    2299 
    2300     else if ((job_rfd = dup (job_fds[0])) < 0)
    2301       {
    2302         if (errno != EBADF)
    2303           pfatal_with_name (_("dup jobserver"));
    2304 
     2323    {
     2324      const char *cp;
     2325      unsigned int ui;
     2326
     2327      for (ui=1; ui < jobserver_fds->idx; ++ui)
     2328        if (!streq (jobserver_fds->list[0], jobserver_fds->list[ui]))
     2329          fatal (NILF, _("internal error: multiple --jobserver-fds options"));
     2330
     2331      /* Now parse the fds string and make sure it has the proper format.  */
     2332
     2333      cp = jobserver_fds->list[0];
     2334
     2335      if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2)
     2336        fatal (NILF,
     2337               _("internal error: invalid --jobserver-fds string `%s'"), cp);
     2338
     2339      DB (DB_JOBS,
     2340          (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1]));
     2341
     2342      /* The combination of a pipe + !job_slots means we're using the
     2343         jobserver.  If !job_slots and we don't have a pipe, we can start
     2344         infinite jobs.  If we see both a pipe and job_slots >0 that means the
     2345         user set -j explicitly.  This is broken; in this case obey the user
     2346         (ignore the jobserver pipe for this make) but print a message.  */
     2347
     2348      if (job_slots > 0)
    23052349        error (NILF,
    2306                _("warning: jobserver unavailable: using -j1.  Add `+' to parent make rule."));
    2307         job_slots = 1;
    2308       }
    2309 
    2310     if (job_slots > 0)
    2311       {
    2312         close (job_fds[0]);
    2313         close (job_fds[1]);
    2314         job_fds[0] = job_fds[1] = -1;
    2315         free (jobserver_fds->list);
    2316         free (jobserver_fds);
    2317         jobserver_fds = 0;
    2318       }
    2319   }
     2350               _("warning: -jN forced in submake: disabling jobserver mode."));
     2351
     2352      /* Create a duplicate pipe, that will be closed in the SIGCHLD
     2353         handler.  If this fails with EBADF, the parent has closed the pipe
     2354         on us because it didn't think we were a submake.  If so, print a
     2355         warning then default to -j1.  */
     2356
     2357      else if ((job_rfd = dup (job_fds[0])) < 0)
     2358        {
     2359          if (errno != EBADF)
     2360            pfatal_with_name (_("dup jobserver"));
     2361
     2362          error (NILF,
     2363                 _("warning: jobserver unavailable: using -j1.  Add `+' to parent make rule."));
     2364          job_slots = 1;
     2365        }
     2366
     2367      if (job_slots > 0)
     2368        {
     2369          close (job_fds[0]);
     2370          close (job_fds[1]);
     2371          job_fds[0] = job_fds[1] = -1;
     2372          free (jobserver_fds->list);
     2373          free (jobserver_fds);
     2374          jobserver_fds = 0;
     2375        }
     2376    }
    23202377
    23212378  /* If we have >1 slot but no jobserver-fds, then we're a top-level make.
     
    24352492      FILE_TIMESTAMP *makefile_mtimes = 0;
    24362493      unsigned int mm_idx = 0;
    2437       char **nargv = argv;
    2438       int nargc = argc;
     2494      char **nargv;
     2495      int nargc;
    24392496      int orig_db_level = db_level;
    24402497      int status;
     
    26052662                if (strneq (argv[i], "-f", 2)) /* XXX */
    26062663                  {
    2607                     char *p = &argv[i][2];
    2608                     if (*p == '\0')
     2664                    if (argv[i][2] == '\0')
    26092665                      /* This cast is OK since we never modify argv.  */
    26102666                      argv[++i] = (char *) makefiles->list[j];
    26112667                    else
    2612                       argv[i] = xstrdup (concat ("-f", makefiles->list[j], ""));
     2668                      argv[i] = xstrdup (concat (2, "-f", makefiles->list[j]));
    26132669                    ++j;
    26142670                  }
     
    26162672
    26172673          /* Add -o option for the stdin temporary file, if necessary.  */
     2674          nargc = argc;
    26182675          if (stdin_nm)
    26192676            {
    26202677              nargv = xmalloc ((nargc + 2) * sizeof (char *));
    26212678              memcpy (nargv, argv, argc * sizeof (char *));
    2622               nargv[nargc++] = xstrdup (concat ("-o", stdin_nm, ""));
     2679              nargv[nargc++] = xstrdup (concat (2, "-o", stdin_nm));
    26232680              nargv[nargc] = 0;
    26242681            }
     2682          else
     2683            nargv = argv;
    26252684
    26262685          if (directories != 0 && directories->idx > 0)
     
    26392698
    26402699          ++restarts;
     2700
     2701          /* Reset makeflags in case they were changed.  */
     2702          {
     2703            const char *pv = define_makeflags (1, 1);
     2704            char *p = alloca (sizeof ("MAKEFLAGS=") + strlen (pv) + 1);
     2705            sprintf (p, "MAKEFLAGS=%s", pv);
     2706            putenv (p);
     2707          }
    26412708
    26422709          if (ISDB (DB_BASIC))
     
    27582825    perror_with_name (_("unlink (temporary file): "), stdin_nm);
    27592826
     2827  /* If there were no command-line goals, use the default.  */
     2828  if (goals == 0)
     2829    {
     2830      char *p;
     2831
     2832      if (default_goal_var->recursive)
     2833        p = variable_expand (default_goal_var->value);
     2834      else
     2835        {
     2836          p = variable_buffer_output (variable_buffer, default_goal_var->value,
     2837                                      strlen (default_goal_var->value));
     2838          *p = '\0';
     2839          p = variable_buffer;
     2840        }
     2841
     2842      if (*p != '\0')
     2843        {
     2844          struct file *f = lookup_file (p);
     2845
     2846          /* If .DEFAULT_GOAL is a non-existent target, enter it into the
     2847             table and let the standard logic sort it out. */
     2848          if (f == 0)
     2849            {
     2850              struct nameseq *ns;
     2851              ns = PARSE_FILE_SEQ (&p, struct nameseq, '\0', NULL, 0);
     2852              if (ns)
     2853                {
     2854                  /* .DEFAULT_GOAL should contain one target. */
     2855                  if (ns->next != 0)
     2856                    fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));
     2857
     2858#ifndef CONFIG_WITH_VALUE_LENGTH
     2859                  f = enter_file (strcache_add (ns->name));
     2860#else
     2861                  f = enter_file (ns->name);
     2862#endif
     2863
     2864                  ns->name = 0; /* It was reused by enter_file(). */
     2865                  free_ns_chain (ns);
     2866                }
     2867            }
     2868
     2869          if (f)
     2870            {
     2871              goals = alloc_dep ();
     2872              goals->file = f;
     2873            }
     2874        }
     2875    }
     2876  else
     2877    lastgoal->next = 0;
     2878
     2879
     2880  if (!goals)
     2881    {
     2882      if (read_makefiles == 0)
     2883        fatal (NILF, _("No targets specified and no makefile found"));
     2884
     2885      fatal (NILF, _("No targets"));
     2886    }
     2887
     2888  /* Update the goals.  */
     2889
     2890  DB (DB_BASIC, (_("Updating goal targets....\n")));
     2891
    27602892  {
    27612893    int status;
    2762 
    2763     /* If there were no command-line goals, use the default.  */
    2764     if (goals == 0)
    2765       {
    2766         if (**default_goal_name != '\0')
    2767           {
    2768             if (default_goal_file == 0 ||
    2769                 strcmp (*default_goal_name, default_goal_file->name) != 0)
    2770               {
    2771                 default_goal_file = lookup_file (*default_goal_name);
    2772 
    2773                 /* In case user set .DEFAULT_GOAL to a non-existent target
    2774                    name let's just enter this name into the table and let
    2775                    the standard logic sort it out. */
    2776                 if (default_goal_file == 0)
    2777                   {
    2778                     struct nameseq *ns;
    2779                     char *p = *default_goal_name;
    2780 
    2781 #ifndef CONFIG_WITH_ALLOC_CACHES
    2782                     ns = multi_glob (
    2783                       parse_file_seq (&p, '\0', sizeof (struct nameseq), 1),
    2784                       sizeof (struct nameseq));
    2785 #else
    2786                     ns = multi_glob (
    2787                       parse_file_seq (&p, '\0', &nameseq_cache, 1),
    2788                       &nameseq_cache);
    2789 #endif
    2790 
    2791                     /* .DEFAULT_GOAL should contain one target. */
    2792                     if (ns->next != 0)
    2793                       fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));
    2794 
    2795 #ifndef CONFIG_WITH_VALUE_LENGTH
    2796                     default_goal_file = enter_file (strcache_add (ns->name));
    2797 #else
    2798                     default_goal_file = enter_file (ns->name);
    2799 #endif
    2800 
    2801                     ns->name = 0; /* It was reused by enter_file(). */
    2802                     free_ns_chain (ns);
    2803                   }
    2804               }
    2805 
    2806             goals = alloc_dep ();
    2807             goals->file = default_goal_file;
    2808           }
    2809       }
    2810     else
    2811       lastgoal->next = 0;
    2812 
    2813 
    2814     if (!goals)
    2815       {
    2816         if (read_makefiles == 0)
    2817           fatal (NILF, _("No targets specified and no makefile found"));
    2818 
    2819         fatal (NILF, _("No targets"));
    2820       }
    2821 
    2822     /* Update the goals.  */
    2823 
    2824     DB (DB_BASIC, (_("Updating goal targets....\n")));
    28252894
    28262895    switch (update_goal_chain (goals))
     
    29333002    /* Ignore plain `-' for compatibility.  */
    29343003    return;
    2935 #ifndef CONFIG_WITH_VALUE_LENGTH
    2936   v = try_variable_definition (0, arg, o_command, 0);
    2937 #else
    2938   v = try_variable_definition (0, arg, NULL, o_command, 0);
    2939 #endif
     3004  v = try_variable_definition (0, arg IF_WITH_VALUE_LENGTH_PARAM(NULL), o_command, 0);
    29403005  if (v != 0)
    29413006    {
     
    29993064            value = vp;
    30003065          }
    3001         define_variable ("MAKECMDGOALS", 12, value, o_default, 0);
     3066        define_variable_cname ("MAKECMDGOALS", value, o_default, 0);
    30023067      }
    30033068    }
     
    31103175                  else if (*optarg == '\0')
    31113176                    {
    3112                       error (NILF, _("the `-%c' option requires a non-empty string argument"),
    3113                              cs->c);
     3177                      char opt[2] = "c";
     3178                      const char *op = opt;
     3179
     3180                      if (short_option (cs->c))
     3181                        opt[0] = cs->c;
     3182                      else
     3183                        op = cs->long_name;
     3184
     3185                      error (NILF, _("the `%s%s' option requires a non-empty string argument"),
     3186                             short_option (cs->c) ? "-" : "--", op);
    31143187                      bad = 1;
    31153188                    }
     
    31283201                    {
    31293202                      sl->max += 5;
    3130                       sl->list = xrealloc ((void *)sl->list, /* bird */
     3203                      /* MSVC erroneously warns without a cast here.  */
     3204                      sl->list = xrealloc ((void *)sl->list,
    31313205                                           sl->max * sizeof (char *));
    31323206                    }
     
    32753349       need permanent storage for this in case decode_switches saves
    32763350       pointers into the value.  */
    3277     argv[1] = xstrdup (concat ("-", argv[1], ""));
     3351    argv[1] = xstrdup (concat (2, "-", argv[1]));
    32783352
    32793353  /* Parse those words.  */
     
    33073381   Don't include options with the `no_makefile' flag set if MAKEFILE.  */
    33083382
    3309 static void
     3383static const char *
    33103384define_makeflags (int all, int makefile)
    33113385{
     
    33133387  static const char ref[] = "$(KMK_OVERRIDES)";
    33143388#else
    3315   static const char ref[] = "$(MAKEOVERRIDES)";
    3316 #endif
    3317   static const char posixref[] = "$(-*-command-variables-*-)";
    3318   register const struct command_switch *cs;
     3389  static /*<- bird*/ const char ref[] = "$(MAKEOVERRIDES)";
     3390#endif
     3391  static /*<- bird*/ const char posixref[] = "$(-*-command-variables-*-)";
     3392  static /*<- bird*/ const char evalref[] = "$(-*-eval-flags-*-)";
     3393  const struct command_switch *cs;
    33193394  char *flagstring;
    33203395  register char *p;
     
    33373412#define ADD_FLAG(ARG, LEN) \
    33383413  do {                                                                        \
    3339     struct flag *new = alloca (sizeof (struct flag));                         \
     3414    struct flag *new = alloca (sizeof (struct flag));                         \
    33403415    new->cs = cs;                                                             \
    33413416    new->arg = (ARG);                                                         \
     
    33453420      ++flagslen;               /* Just a single flag letter.  */             \
    33463421    else                                                                      \
    3347       flagslen += 1 + 1 + 1 + 1 + 3 * (LEN); /* " -x foo" */                  \
     3422      /* " -x foo", plus space to expand "foo".  */                           \
     3423      flagslen += 1 + 1 + 1 + 1 + (3 * (LEN));                                \
    33483424    if (!short_option (cs->c))                                                \
    33493425      /* This switch has no single-letter version, so we use the long.  */    \
     
    34343510        }
    34353511
    3436   flagslen += 4 + sizeof posixref; /* Four more for the possible " -- ".  */
     3512  /* Four more for the possible " -- ".  */
     3513  flagslen += 4 + sizeof (posixref) + sizeof (evalref);
    34373514
    34383515#undef  ADD_FLAG
     
    35073584  /* Since MFLAGS is not parsed for flags, there is no reason to
    35083585     override any makefile redefinition.  */
    3509   (void) define_variable ("MFLAGS", 6, flagstring, o_env, 1);
     3586  define_variable_cname ("MFLAGS", flagstring, o_env, 1);
    35103587#endif /* !KMK */
     3588
     3589  /* Write a reference to -*-eval-flags-*-, which contains all the --eval
     3590     flag options.  */
     3591  if (eval_strings)
     3592    {
     3593      if (p == &flagstring[1])
     3594        /* No flags written, so elide the leading dash already written.  */
     3595        p = flagstring;
     3596      else
     3597        *p++ = ' ';
     3598      memcpy (p, evalref, sizeof (evalref) - 1);
     3599      p += sizeof (evalref) - 1;
     3600    }
    35113601
    35123602  if (all && command_variables != 0)
     
    35353625      if (posix_pedantic)
    35363626        {
    3537           memcpy (p, posixref, sizeof posixref - 1);
    3538           p += sizeof posixref - 1;
     3627          memcpy (p, posixref, sizeof (posixref) - 1);
     3628          p += sizeof (posixref) - 1;
    35393629        }
    35403630      else
    35413631        {
    3542           memcpy (p, ref, sizeof ref - 1);
    3543           p += sizeof ref - 1;
     3632          memcpy (p, ref, sizeof (ref) - 1);
     3633          p += sizeof (ref) - 1;
    35443634        }
    35453635    }
     
    35553645  *p = '\0';
    35563646
     3647  /* If there are switches, omit the leading dash unless it is a single long
     3648     option with two leading dashes.  */
     3649  if (flagstring[0] == '-' && flagstring[1] != '-')
     3650    ++flagstring;
     3651
    35573652#ifdef KMK
    3558   v = define_variable ("KMK_FLAGS", 9,
    3559                        /* If there are switches, omit the leading dash
    3560                           unless it is a single long option with two
    3561                           leading dashes.  */
    3562                        &flagstring[(flagstring[0] == '-'
    3563                                     && flagstring[1] != '-')
    3564                                    ? 1 : 0],
    3565                        /* This used to use o_env, but that lost when a
    3566                           makefile defined MAKEFLAGS.  Makefiles set
    3567                           MAKEFLAGS to add switches, but we still want
    3568                           to redefine its value with the full set of
    3569                           switches.  Of course, an override or command
    3570                           definition will still take precedence.  */
    3571                        o_file, 1);
     3653  v = define_variable_cname ("KMK_FLAGS", flagstring,
     3654                             /* This used to use o_env, but that lost when a
     3655                                makefile defined MAKEFLAGS.  Makefiles set
     3656                                MAKEFLAGS to add switches, but we still want
     3657                                to redefine its value with the full set of
     3658                                switches.  Of course, an override or command
     3659                                definition will still take precedence.  */
     3660                             o_file, 1);
    35723661#else
    3573   v = define_variable ("MAKEFLAGS", 9,
    3574                        /* If there are switches, omit the leading dash
    3575                           unless it is a single long option with two
    3576                           leading dashes.  */
    3577                        &flagstring[(flagstring[0] == '-'
    3578                                     && flagstring[1] != '-')
    3579                                    ? 1 : 0],
    3580                        /* This used to use o_env, but that lost when a
    3581                           makefile defined MAKEFLAGS.  Makefiles set
    3582                           MAKEFLAGS to add switches, but we still want
    3583                           to redefine its value with the full set of
    3584                           switches.  Of course, an override or command
    3585                           definition will still take precedence.  */
    3586                        o_file, 1);
    3587 #endif
     3662  v = define_variable_cname ("MAKEFLAGS", flagstring,
     3663                             /* This used to use o_env, but that lost when a
     3664                                makefile defined MAKEFLAGS.  Makefiles set
     3665                                MAKEFLAGS to add switches, but we still want
     3666                                to redefine its value with the full set of
     3667                                switches.  Of course, an override or command
     3668                                definition will still take precedence.  */
     3669                             o_file, 1);
     3670#endif
     3671
    35883672  if (! all)
    35893673    /* The first time we are called, set MAKEFLAGS to always be exported.
     
    35973681    char val[32];
    35983682    sprintf (val, "%u", job_slots);
    3599     define_variable ("KMK_OPTS_JOBS", sizeof("KMK_OPTS_JOBS") - 1,
    3600                      val, o_default, 1);
    3601     define_variable ("KMK_OPTS_KEEP_GOING", sizeof("KMK_OPTS_KEEP_GOING") - 1,
    3602                      keep_going_flag ? "1" : "0", o_default, 1);
    3603     define_variable ("KMK_OPTS_JUST_PRINT", sizeof("KMK_OPTS_JUST_PRINT") - 1,
    3604                      just_print_flag ? "1" : "0", o_default, 1);
    3605     define_variable ("KMK_OPTS_PRETTY_COMMAND_PRINTING", sizeof("KMK_OPTS_PRETTY_COMMAND_PRINTING") - 1,
    3606                      pretty_command_printing ? "1" : "0", o_default, 1);
     3683    define_variable_cname ("KMK_OPTS_JOBS", val, o_default, 1);
     3684    define_variable_cname ("KMK_OPTS_KEEP_GOING", keep_going_flag ? "1" : "0", o_default, 1);
     3685    define_variable_cname ("KMK_OPTS_JUST_PRINT", just_print_flag ? "1" : "0", o_default, 1);
     3686    define_variable_cname ("KMK_OPTS_PRETTY_COMMAND_PRINTING",
     3687                           pretty_command_printing ? "1" : "0", o_default, 1);
    36073688    sprintf (val, "%u", process_priority);
    3608     define_variable ("KMK_OPTS_PRORITY", sizeof("KMK_OPTS_PRORITY") - 1,
    3609                      val, o_default, 1);
     3689    define_variable_cname ("KMK_OPTS_PRORITY", val, o_default, 1);
    36103690    sprintf (val, "%u", process_affinity);
    3611     define_variable ("KMK_OPTS_AFFINITY", sizeof("KMK_OPTS_AFFINITY") - 1,
    3612                      val, o_default, 1);
    3613 #if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS)
    3614     define_variable ("KMK_OPTS_STATISTICS", sizeof("KMK_OPTS_STATISTICS") - 1,
    3615                      make_expensive_statistics ? "1" : "0", o_default, 1);
     3691    define_variable_cname ("KMK_OPTS_AFFINITY", val, o_default, 1);
     3692# if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS)
     3693    define_variable_cname ("KMK_OPTS_STATISTICS", make_expensive_statistics ? "1" : "0",
     3694                           o_default, 1);
    36163695# endif
    3617 #ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     3696# ifdef CONFIG_WITH_PRINT_TIME_SWITCH
    36183697    sprintf (val, "%u", print_time_min);
    3619     define_variable ("KMK_OPTS_PRINT_TIME", sizeof("KMK_OPTS_PRINT_TIME") - 1,
    3620                      val, o_default, 1);
    3621 #endif
     3698    define_variable_cname ("KMK_OPTS_PRINT_TIME", val, o_default, 1);
     3699# endif
    36223700  }
    36233701#endif
     3702
     3703  return v->value;
    36243704}
    36253705
     
    36613741     word "Copyright", so it hardly seems worth it.  */
    36623742
    3663   printf ("%sCopyright (C) 2007  Free Software Foundation, Inc.\n", precede);
     3743  printf ("%sCopyright (C) 2010  Free Software Foundation, Inc.\n", precede);
    36643744
    36653745  printf (_("%sLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
     
    38183898
    38193899      close (job_fds[0]);
     3900
     3901      /* Clean out jobserver_fds so we don't pass this information to any
     3902         sub-makes.  Also reset job_slots since it will be put on the command
     3903         line, not in MAKEFLAGS.  */
     3904      job_slots = default_job_slots;
     3905      if (jobserver_fds)
     3906        {
     3907          /* MSVC erroneously warns without a cast here.  */
     3908          free ((void *)jobserver_fds->list);
     3909          free (jobserver_fds);
     3910          jobserver_fds = 0;
     3911        }
    38203912    }
    38213913}
     
    38823974         of relative pathnames fail.  */
    38833975      if (directory_before_chdir != 0)
    3884         chdir (directory_before_chdir);
     3976        {
     3977          /* If it fails we don't care: shut up GCC.  */
     3978          int _x;
     3979          _x = chdir (directory_before_chdir);
     3980        }
    38853981
    38863982#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
  • trunk/src/kmk/maintMakefile

    r2421 r2591  
    148148          && (cd "$$tmppo" \
    149149                && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) \
    150           && cp "$$tmppo"/*.po po && rm -rf "$$tmppo"
     150          && cp "$$tmppo"/*.po $(top_srcdir)/po && rm -rf "$$tmppo"
    151151        cd po && $(MAKE) update-po
    152152        $(MAKE) po-check
    153153
    154154po-update:
    155         if test -d "po"; then \
    156           $(MAKE) do-po-update; \
    157         fi
     155        [ -d "po" ] && $(MAKE) do-po-update
    158156
    159157# -------------------------- #
     
    165163# regularly updated from the specified URL.
    166164
    167 savannah-url = http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~
     165cvs-url = http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~
     166git-url = http://git.savannah.gnu.org/cgit
    168167target = $(patsubst get-%,%,$@)
    169168
    170 config-url = $(savannah-url)/config/config/$(patsubst get-config/%,%,$@)
     169config-url = $(git-url)/config.git/plain/$(patsubst get-config/%,%,$@)
    171170get-config/config.guess get-config/config.sub:
    172171        @echo $(WGET) $(config-url) -O $(target) \
     
    174173          && $(move_if_change)
    175174
    176 gnulib-url = $(savannah-url)/gnulib/gnulib/build-aux/$(patsubst get-config/%,%,$@)
     175gnulib-url = $(git-url)/gnulib.git/plain/build-aux/$(patsubst get-config/%,%,$@)
    177176get-config/texinfo.tex:
    178177        @echo $(WGET) $(gnulib-url) -O $(target) \
     
    180179          && $(move_if_change)
    181180
    182 gnustandards-url = $(savannah-url)/gnustandards/gnustandards/$(patsubst get-doc/%,%,$@)
     181gnustandards-url = $(cvs-url)/gnustandards/gnustandards/$(patsubst get-doc/%,%,$@)
    183182get-doc/make-stds.texi get-doc/fdl.texi:
    184183        @echo $(WGET) $(gnustandards-url) -O $(target) \
     
    186185          && $(move_if_change)
    187186
    188 .PHONY: cvs-update
    189 cvs-update: get-config/texinfo.tex get-config/config.guess get-config/config.sub get-doc/make-stds.texi get-doc/fdl.texi
     187.PHONY: scm-update
     188scm-update: get-config/texinfo.tex get-config/config.guess get-config/config.sub get-doc/make-stds.texi get-doc/fdl.texi
    190189
    191190
     
    195194
    196195.PHONY: update
    197 update: po-update cvs-update
     196update: po-update scm-update
    198197
    199198
     
    209208
    210209changelog-check:
    211         if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
     210        if head $(top_srcdir)/ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
    212211          :; \
    213212        else \
     
    251250        @echo "Creating directive file '$@':"
    252251        @( \
    253            echo 'verstion: 1.1'; \
     252           echo 'version: 1.1'; \
    254253           echo 'directory: make'; \
    255254           echo 'filename: $*'; \
     
    262261
    263262FTPPUT = ncftpput
    264 gnu-url = ftp-upload.gnu.org /incoming
     263gnu-upload-host = ftp-upload.gnu.org
     264gnu-upload-dir  = /incoming
     265
    265266
    266267UPLOADS = upload-alpha upload-ftp
    267268.PHONY: $(UPLOADS)
    268269$(UPLOADS): $(DIST_ARCHIVES) $(DIST_ARCHIVES_SIG) $(DIST_ARCHIVES_DIRECTIVE)
    269         $(FTPPUT) "$(gnu-url)/$(@:upload-%=%)" $^
     270        $(FTPPUT) "$(gnu-upload-host)" "$(gnu-upload-dir)/$(@:upload-%=%)" $^
    270271
    271272
    272273# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    273 # 2007 Free Software Foundation, Inc.
     274# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    274275# This file is part of GNU Make.
    275276#
  • trunk/src/kmk/make.1

    r1993 r2591  
    224224.TP 0.5i
    225225.BR \-n , " \-\-just\-print" , " \-\-dry\-run" , " \-\-recon"
    226 Print the commands that would be executed, but do not execute them.
     226Print the commands that would be executed, but do not execute them (except in
     227certain circumstances).
    227228.TP 0.5i
    228229\fB\-o\fR \fIfile\fR, \fB\-\-old\-file\fR=\fIfile\fR, \fB\-\-assume\-old\fR=\fIfile\fR
  • trunk/src/kmk/make.h

    r2548 r2591  
    11/* Miscellaneous global declarations and portability cruft for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    2424#define HAVE_CONFIG_H 1
    2525
     26/* Specify we want GNU source code.  This must be defined before any
     27   system headers are included.  */
     28
     29#define _GNU_SOURCE 1
     30
    2631/* AIX requires this to be the first thing in the file.  */
    27 #ifndef __GNUC__
    28 # if HAVE_ALLOCA_H
    29 #  include <alloca.h>
    30 # else
    31 #  ifdef _AIX
     32#if HAVE_ALLOCA_H
     33# include <alloca.h>
     34#else
     35# ifdef _AIX
    3236 #pragma alloca
    33 #  else
     37# else
     38#  if !defined(__GNUC__) && !defined(WINDOWS32)
    3439#   ifndef alloca /* predefined by HP cc +Olibcalls */
    3540char *alloca ();
     
    3742#  endif
    3843# endif
    39 #elif defined(__sun__) && defined (HAVE_ALLOCA_H) /* bird: kill warnings. */
    40 # include <alloca.h>
    41 #endif
    42 
    43 
    44 /* Specify we want GNU source code.  This must be defined before any
    45    system headers are included.  */
    46 
    47 #define _GNU_SOURCE 1
     44#endif
    4845
    4946
     
    240237#endif
    241238
     239/* bird - start */
     240#define COMMA ,
     241#ifdef CONFIG_WITH_VALUE_LENGTH
     242# define IF_WITH_VALUE_LENGTH(a_Expr)           a_Expr
     243# define IF_WITH_VALUE_LENGTH_PARAM(a_Expr)     , a_Expr
     244#else
     245# define IF_WITH_VALUE_LENGTH(a_Expr)
     246# define IF_WITH_VALUE_LENGTH_PARAM(a_Expr)
     247#endif
     248
     249#ifdef CONFIG_WITH_ALLOC_CACHES
     250# define IF_WITH_ALLOC_CACHES(a_Expr)           a_Expr
     251# define IF_WITH_ALLOC_CACHES_PARAM(a_Expr)     , a_Expr
     252#else
     253# define IF_WITH_ALLOC_CACHES(a_Expr)
     254# define IF_WITH_ALLOC_CACHES_PARAM(a_Expr)
     255#endif
     256
     257#ifdef CONFIG_WITH_COMMANDS_FUNC
     258# define IF_WITH_COMMANDS_FUNC(a_Expr)          a_Expr
     259# define IF_WITH_COMMANDS_FUNC_PARAM(a_Expr)    , a_Expr
     260#else
     261# define IF_WITH_COMMANDS_FUNC(a_Expr)
     262# define IF_WITH_COMMANDS_FUNC_PARAM(a_Expr)
     263#endif
     264
     265/* bird - end */
     266
    242267
    243268#ifndef CHAR_BIT
     
    363388#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
    364389
    365 #ifndef iAPX286
    366 # define streq(a, b) \
     390/* Test if two strings are equal. Is this worthwhile?  Should be profiled.  */
     391#define streq(a, b) \
    367392   ((a) == (b) || \
    368393    (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
    369 # ifdef HAVE_CASE_INSENSITIVE_FS
    370 #  define strieq(a, b) \
     394
     395/* Test if two strings are equal, but match case-insensitively on systems
     396   which have case-insensitive filesystems.  Should only be used for
     397   filenames!  */
     398#ifdef HAVE_CASE_INSENSITIVE_FS
     399# define patheq(a, b) \
    371400    ((a) == (b) \
    372401     || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
    373402         && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
    374 # else
    375 #  define strieq(a, b) streq(a, b)
    376 # endif
    377 #else
    378 /* Buggy compiler can't handle this.  */
    379 # define streq(a, b) (strcmp ((a), (b)) == 0)
    380 # define strieq(a, b) (strcmp ((a), (b)) == 0)
    381 #endif
     403#else
     404# define patheq(a, b) streq(a, b)
     405#endif
     406
    382407#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
    383408
     
    425450
    426451void sync_Path_environment (void);
    427 int w32_kill (int pid, int sig);
     452int w32_kill (pid_t pid, int sig);
    428453char *end_of_token_w32 (const char *s, char stopchar);
    429454int find_and_set_default_shell (const char *token);
     
    435460extern int unixy_shell;
    436461#endif  /* WINDOWS32 */
     462
     463#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
     464# define SET_STACK_SIZE
     465#endif
     466#ifdef SET_STACK_SIZE
     467# include <sys/resource.h>
     468struct rlimit stack_limit;
     469#endif
    437470
    438471struct floc
     
    475508
    476509#if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
     510const char *concat (unsigned int, ...);
    477511void message (int prefix, const char *fmt, ...)
    478512              __attribute__ ((__format__ (__printf__, 2, 3)));
     
    482516                   __attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
    483517#else
     518const char *concat ();
    484519void message ();
    485520void error ();
     
    491526void pfatal_with_name (const char *) __attribute__ ((noreturn));
    492527void perror_with_name (const char *, const char *);
    493 char *savestring (const char *, unsigned int);
    494 char *concat (const char *, const char *, const char *);
    495528void *xmalloc (unsigned int);
     529void *xcalloc (unsigned int);
    496530void *xrealloc (void *, unsigned int);
    497531char *xstrdup (const char *);
     532char *xstrndup (const char *, unsigned int);
    498533#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
    499534void print_heap_stats (void);
     
    553588void build_vpath_lists (void);
    554589void construct_vpath_list (char *pattern, char *dirpath);
    555 const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr);
     590const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
     591                          unsigned int* vpath_index, unsigned int* path_index);
    556592int gpath_search (const char *file, unsigned int len);
    557593
     
    696732#endif
    697733
     734#if !HAVE_STRNCASECMP
     735# if HAVE_STRNICMP
     736#  define strncasecmp strnicmp
     737# elif HAVE_STRNCMPI
     738#  define strncasecmp strncmpi
     739# else
     740/* Create our own, in misc.c */
     741int strncasecmp (const char *s1, const char *s2, int n);
     742# endif
     743#endif
     744
    698745extern const struct floc *reading_file;
    699746extern const struct floc **expanding_var;
     
    709756extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
    710757extern int second_expansion, clock_skew_detected, rebuilding_makefiles;
     758extern int one_shell;
     759
    711760#ifdef CONFIG_WITH_2ND_TARGET_EXPANSION
    712761extern int second_target_expansion;
  • trunk/src/kmk/makefile.com

    r1993 r2591  
    140140$!-----------------------------------------------------------------------------
    141141$!Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    142 $!2006, 2007 Free Software Foundation, Inc.
     142$!2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    143143$!This file is part of GNU Make.
    144144$!
  • trunk/src/kmk/makefile.vms

    r1993 r2591  
    22#
    33# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    4 # 2006, 2007 Free Software Foundation, Inc.
     4# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    55# This file is part of GNU Make.
    66#
  • trunk/src/kmk/misc.c

    r2548 r2591  
    11/* Miscellaneous generic support functions for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    166166      ++in;
    167167
    168       /* If the newline is quoted, discard following whitespace
    169          and any preceding whitespace; leave just one space.  */
     168      /* If the newline is escaped, discard following whitespace leaving just
     169         one space.  POSIX requires that each backslash/newline/following
     170         whitespace sequence be reduced to a single space.  */
    170171      if (backslash)
    171172        {
    172173          in = next_token (in);
     174          /* Removing this loop will fix Savannah bug #16670: do we want to? */
    173175          while (out > line && isblank ((unsigned char)out[-1]))
    174176            --out;
     
    218220
    219221
    220 /* Return a string whose contents concatenate those of s1, s2, s3.
     222/* Return a string whose contents concatenate the NUM strings provided
    221223   This string lives in static, re-used memory.  */
    222224
    223 char *
    224 concat (const char *s1, const char *s2, const char *s3)
    225 {
    226   unsigned int len1, len2, len3;
     225const char *
     226#if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
     227concat (unsigned int num, ...)
     228#else
     229concat (num, va_alist)
     230     unsigned int num;
     231     va_dcl
     232#endif
     233{
    227234  static unsigned int rlen = 0;
    228235  static char *result = NULL;
    229 
    230   len1 = (s1 && *s1 != '\0') ? strlen (s1) : 0;
    231   len2 = (s2 && *s2 != '\0') ? strlen (s2) : 0;
    232   len3 = (s3 && *s3 != '\0') ? strlen (s3) : 0;
    233 
    234   if (len1 + len2 + len3 + 1 > rlen)
    235     result = xrealloc (result, (rlen = len1 + len2 + len3 + 10));
    236 
    237   if (len1)
    238     memcpy (result, s1, len1);
    239   if (len2)
    240     memcpy (result + len1, s2, len2);
    241   if (len3)
    242     memcpy (result + len1 + len2, s3, len3);
    243 
    244   result[len1+len2+len3] = '\0';
     236  unsigned int ri = 0; /* bird: must be unsigned */
     237
     238#if USE_VARIADIC
     239  va_list args;
     240#endif
     241
     242  VA_START (args, num);
     243
     244  while (num-- > 0)
     245    {
     246      const char *s = va_arg (args, const char *);
     247      unsigned int l = s ? strlen (s) : 0;
     248
     249      if (l == 0)
     250        continue;
     251
     252      if (ri + l > rlen)
     253        {
     254          rlen = ((rlen ? rlen : 60) + l) * 2;
     255          result = xrealloc (result, rlen);
     256        }
     257
     258      memcpy (result + ri, s, l);
     259      ri += l;
     260    }
     261
     262  VA_END (args);
     263
     264  /* Get some more memory if we don't have enough space for the
     265     terminating '\0'.   */
     266  if (ri == rlen)
     267    {
     268      rlen = (rlen ? rlen : 60) * 2;
     269      result = xrealloc (result, rlen);
     270    }
     271
     272  result[ri] = '\0';
    245273
    246274  return result;
     
    397425
    398426#undef xmalloc
     427#undef xcalloc
    399428#undef xrealloc
    400429#undef xstrdup
     
    403432xmalloc (unsigned int size)
    404433{
    405   /* Make sure we don't allocate 0, for pre-ANSI libraries.  */
     434  /* Make sure we don't allocate 0, for pre-ISO implementations.  */
    406435  void *result = malloc (size ? size : 1);
    407436  if (result == 0)
     
    415444    make_stats_allocated += size;
    416445#endif
     446  return result;
     447}
     448
     449
     450void *
     451xcalloc (unsigned int size)
     452{
     453  /* Make sure we don't allocate 0, for pre-ISO implementations.  */
     454  void *result = calloc (size ? size : 1, 1);
     455  if (result == 0)
     456    fatal (NILF, _("virtual memory exhausted"));
    417457  return result;
    418458}
     
    432472#endif
    433473
    434   /* Some older implementations of realloc() don't conform to ANSI.  */
     474  /* Some older implementations of realloc() don't conform to ISO.  */
    435475  if (! size)
    436476    size = 1;
     
    480520
    481521char *
    482 savestring (const char *str, unsigned int length)
    483 {
    484   char *out = xmalloc (length + 1);
     522xstrndup (const char *str, unsigned int length)
     523{
     524  char *result;
     525
     526#if defined(HAVE_STRNDUP) && !defined(KMK)
     527  result = strndup (str, length);
     528  if (result == 0)
     529    fatal (NILF, _("virtual memory exhausted"));
     530#else
     531  result = xmalloc (length + 1);
    485532  if (length > 0)
    486     memcpy (out, str, length);
    487   out[length] = '\0';
    488   return out;
     533    strncpy (result, str, length);
     534  result[length] = '\0';
     535#endif
     536
     537  return result;
    489538}
    490539
     
    786835
    787836
    788 /* Allocate a new `struct dep' with all fields initialized to 0.   */
    789 
    790 struct dep *
    791 alloc_dep ()
    792 {
    793 #ifndef CONFIG_WITH_ALLOC_CACHES
    794   struct dep *d = xmalloc (sizeof (struct dep));
    795   memset (d, '\0', sizeof (struct dep));
    796   return d;
    797 #else
    798   return (struct dep *) alloccache_calloc (&dep_cache);
    799 #endif
    800 }
    801 
    802 
    803 /* Free `struct dep' along with `name' and `stem'.   */
    804 
    805 void
    806 free_dep (struct dep *d)
    807 {
    808 #ifndef CONFIG_WITH_ALLOC_CACHES
    809   free (d);
    810 #else
    811   alloccache_free (&dep_cache, d);
    812 #endif
    813 }
    814 
    815 /* Copy a chain of `struct dep', making a new chain
    816    with the same contents as the old one.  */
     837/* Copy a chain of `struct dep'.  For 2nd expansion deps, dup the name.  */
    817838
    818839struct dep *
     
    827848      struct dep *c = xmalloc (sizeof (struct dep));
    828849#else
    829       struct dep *c = (struct dep *) alloccache_alloc (&dep_cache);
     850      struct dep *c = alloccache_alloc(&dep_cache);
    830851#endif
    831852      memcpy (c, d, sizeof (struct dep));
     853
     854      /** @todo KMK: Check if we need this duplication! */
     855      if (c->need_2nd_expansion)
     856        c->name = xstrdup (c->name);
    832857
    833858      c->next = 0;
     
    852877      struct dep *df = d;
    853878      d = d->next;
    854 #ifndef CONFIG_WITH_ALLOC_CACHES
    855879      free_dep (df);
    856 #else
    857       alloccache_free (&dep_cache, df);
    858 #endif
    859880    }
    860881}
     
    903924      return (c1 - c2);
    904925    }
     926}
     927#endif
     928
     929#if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI
     930
     931/* If we don't have strncasecmp() (from POSIX), or anything that can
     932   substitute for it, define our own version.  */
     933
     934int
     935strncasecmp (const char *s1, const char *s2, int n)
     936{
     937  while (n-- > 0)
     938    {
     939      int c1 = (int) *(s1++);
     940      int c2 = (int) *(s2++);
     941
     942      if (isalpha (c1))
     943        c1 = tolower (c1);
     944      if (isalpha (c2))
     945        c2 = tolower (c2);
     946
     947      if (c1 != '\0' && c1 == c2)
     948        continue;
     949
     950      return (c1 - c2);
     951    }
     952
     953  return 0;
    905954}
    906955#endif
     
    12341283
    12351284  malloc_zone_statistics (NULL, &s);
    1236   printf (_("\n# CRT Heap: %zu bytes in use, in %u blocks, avg %zu bytes/block\n"),
    1237           s.size_in_use, s.blocks_in_use, s.size_in_use / s.blocks_in_use);
    1238   printf (_("#           %zu bytes max in use (high water mark)\n"),
    1239           s.max_size_in_use);
    1240   printf (_("#           %zu bytes reserved,  %zu bytes free (estimate)\n"),
    1241           s.size_allocated, s.size_allocated - s.size_in_use);
     1285  printf (_("\n# CRT Heap: %u bytes in use, in %u blocks, avg %u bytes/block\n"),
     1286          (unsigned)s.size_in_use, (unsigned)s.blocks_in_use,
     1287          (unsigned)(s.size_in_use / s.blocks_in_use));
     1288  printf (_("#           %u bytes max in use (high water mark)\n"),
     1289          (unsigned)s.max_size_in_use);
     1290  printf (_("#           %u bytes reserved,  %u bytes free (estimate)\n"),
     1291          (unsigned)s.size_allocated,
     1292          (unsigned)(s.size_allocated - s.size_in_use));
    12421293# endif /* __APPLE__ */
    12431294
     
    13741425format_elapsed_nano (char *buf, size_t size, big_int ts)
    13751426{
    1376   int sz;
     1427  unsigned sz;
    13771428  if (ts < 1000)
    13781429    sz = sprintf (buf, "%uns", (unsigned)ts);
     
    14071458    }
    14081459  if (sz >= size)
    1409     fatal (NILF, _("format_elapsed_nano buffer overflow: %d written, %d buffer"),
    1410            sz, size);
     1460    fatal (NILF, _("format_elapsed_nano buffer overflow: %u written, %lu buffer"),
     1461           sz, (unsigned long)size);
    14111462  return sz;
    14121463}
  • trunk/src/kmk/po

    • Property svn:ignore
      •  

        old new  
        33*.pot
        44*.po
         5
        56Makefile
        67Makefile.in
        78Makefile.in.in
         9Makevars.template
        810Rules-quot
         11stamp-po
        912*.sed
        1013*.sin
  • trunk/src/kmk/po/ChangeLog

    r1993 r2591  
     12009-09-16  Paul Smith  <[email protected]>
     2
     3        * LINGUAS: Added new translation for Italian (it).
     4
    152008-05-17  Paul Smith  <[email protected]>
    26
     
    6367
    6468
    65 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     69Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
     70Foundation, Inc.
    6671This file is part of GNU Make.
    6772
  • trunk/src/kmk/po/LINGUAS

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

    r1993 r2591  
    11# This is a -*-Makefile-*-
    2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
    3 # Inc.
     2# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
     3# Software Foundation, Inc.
    44# This file is part of GNU Make.
    55#
  • trunk/src/kmk/po/POTFILES.in

    r1993 r2591  
    11# List of source files containing translatable strings.
    2 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    3 # Foundation, Inc.
     2# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     3# 2010 Free Software Foundation, Inc.
    44# This file is part of GNU Make.
    55#
  • trunk/src/kmk/read.c

    r2548 r2591  
    11/* Reading and parsing of makefiles for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    6060    FILE *fp;           /* File, or NULL if this is an internal buffer.  */
    6161    struct floc floc;   /* Info on the file in fp (if any).  */
     62  };
     63
     64/* Track the modifiers we can have on variable assignments */
     65
     66struct vmodifiers
     67  {
     68    unsigned int assign_v:1;
     69    unsigned int define_v:1;
     70    unsigned int undefine_v:1;
     71    unsigned int export_v:1;
     72    unsigned int override_v:1;
     73    unsigned int private_v:1;
    6274  };
    6375
     
    149161
    150162static int eval_makefile (const char *filename, int flags);
    151 static int eval (struct ebuffer *buffer, int flags);
     163static void eval (struct ebuffer *buffer, int flags);
    152164
    153165static long readline (struct ebuffer *ebuf);
    154 static void do_define (char *name, unsigned int namelen,
    155                        enum variable_origin origin, struct ebuffer *ebuf);
     166static void do_undefine (char *name, enum variable_origin origin,
     167                         struct ebuffer *ebuf);
     168static struct variable *do_define (char *name IF_WITH_VALUE_LENGTH_PARAM(char *eos),
     169                                   enum variable_origin origin, struct ebuffer *ebuf);
    156170#ifndef CONFIG_WITH_VALUE_LENGTH
    157171static int conditional_line (char *line, int len, const struct floc *flocp);
     
    159173static int conditional_line (char *line, char *eol, int len, const struct floc *flocp);
    160174#endif
    161 #ifndef CONFIG_WITH_INCLUDEDEP
    162175static void record_files (struct nameseq *filenames, const char *pattern,
    163                           const char *pattern_percent, struct dep *deps,
     176                          const char *pattern_percent, char *depstr,
    164177                          unsigned int cmds_started, char *commands,
    165178                          unsigned int commands_idx, int two_colon,
    166179                          const struct floc *flocp);
    167 #endif /* !KMK */
    168180static void record_target_var (struct nameseq *filenames, char *defn,
    169                                enum variable_origin origin, int enabled,
     181                               enum variable_origin origin,
     182                               struct vmodifiers *vmod,
    170183                               const struct floc *flocp);
    171184static enum make_word_type get_next_mword (char *buffer, char *delim,
     
    198211
    199212
     213/* Compare a word, both length and contents.
     214   P must point to the word to be tested, and WLEN must be the length.
     215*/
     216#define word1eq(s)      (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
     217
     218
     219
    200220/* Read in all the makefiles and return the chain of their names.  */
    201221
     
    208228     we will be reading. */
    209229
    210   define_variable ("MAKEFILE_LIST", sizeof ("MAKEFILE_LIST")-1, "", o_file, 0);
     230  define_variable_cname ("MAKEFILE_LIST", "", o_file, 0);
    211231
    212232  DB (DB_BASIC, (_("Reading makefiles...\n")));
     
    320340              struct dep *d = alloc_dep ();
    321341              d->file = enter_file (strcache_add (*p));
    322               d->file->dontcare = 1;
     342              d->dontcare = 1;
    323343              /* Tell update_goal_chain to bail out as soon as this file is
    324344                 made, and main not to die if we can't make this file.  */
     
    388408  char *expanded = 0;
    389409  int makefile_errno;
    390   int r;
    391410
    392411  filename = strcache_add (filename);
     
    431450      for (i = 0; include_directories[i] != 0; ++i)
    432451        {
    433           const char *included = concat (include_directories[i], "/", filename);
     452          const char *included = concat (3, include_directories[i],
     453                                         "/", filename);
    434454          ebuf.fp = fopen (included, "r");
    435455          if (ebuf.fp)
     
    455475  deps->changed = flags;
    456476  if (flags & RM_DONTCARE)
    457     deps->file->dontcare = 1;
     477    deps->dontcare = 1;
    458478
    459479  if (expanded)
     
    470490      return 0;
    471491    }
     492
     493  /* Set close-on-exec to avoid leaking the makefile to children, such as
     494     $(shell ...).  */
     495#ifdef HAVE_FILENO
     496  CLOSE_ON_EXEC (fileno (ebuf.fp));
     497#endif
    472498
    473499  /* Add this makefile to the list. */
     
    506532  reading_file = &ebuf.floc;
    507533
    508   r = eval (&ebuf, !(flags & RM_NO_DEFAULT_GOAL));
     534  eval (&ebuf, !(flags & RM_NO_DEFAULT_GOAL));
    509535
    510536  reading_file = curfile;
     
    519545  free (ebuf.bufstart);
    520546  alloca (0);
    521   return r;
     547
     548  return 1;
    522549}
    523550
    524 int
     551void
    525552#ifndef CONFIG_WITH_VALUE_LENGTH
    526553eval_buffer (char *buffer)
     
    533560  struct conditionals new;
    534561  const struct floc *curfile;
    535   int r;
    536562
    537563  /* Evaluate the buffer */
     
    547573  ebuf.fp = NULL;
    548574
    549   ebuf.floc = *reading_file;
     575  if (reading_file)
     576    ebuf.floc = *reading_file;
     577  else
     578    ebuf.floc.filenm = NULL;
    550579
    551580  curfile = reading_file;
     
    554583  saved = install_conditionals (&new);
    555584
    556   r = eval (&ebuf, 1);
     585  eval (&ebuf, 1);
    557586
    558587  restore_conditionals (saved);
     
    561590
    562591  alloca (0);
    563   return r;
    564592}
    565593
    566594
     595/* Check LINE to see if it's a variable assignment or undefine.
     596
     597   It might use one of the modifiers "export", "override", "private", or it
     598   might be one of the conditional tokens like "ifdef", "include", etc.
     599
     600   If it's not a variable assignment or undefine, VMOD.V_ASSIGN is 0.
     601   Returns LINE.
     602
     603   Returns a pointer to the first non-modifier character, and sets VMOD
     604   based on the modifiers found if any, plus V_ASSIGN is 1.
     605 */
     606static char *
     607parse_var_assignment (const char *line, struct vmodifiers *vmod)
     608{
     609  const char *p;
     610  memset (vmod, '\0', sizeof (*vmod));
     611
     612  /* Find the start of the next token.  If there isn't one we're done.  */
     613  line = next_token (line);
     614  if (*line == '\0')
     615    return (char *)line;
     616
     617  p = line;
     618  while (1)
     619    {
     620      int wlen;
     621      const char *p2;
     622      enum variable_flavor flavor;
     623
     624      p2 = parse_variable_definition (p, &flavor);
     625
     626      /* If this is a variable assignment, we're done.  */
     627      if (p2)
     628        break;
     629
     630      /* It's not a variable; see if it's a modifier.  */
     631      p2 = end_of_token (p);
     632      wlen = p2 - p;
     633
     634      if (word1eq ("export"))
     635        vmod->export_v = 1;
     636      else if (word1eq ("override"))
     637        vmod->override_v = 1;
     638      else if (word1eq ("private"))
     639        vmod->private_v = 1;
     640      else if (word1eq ("define"))
     641        {
     642          /* We can't have modifiers after 'define' */
     643          vmod->define_v = 1;
     644          p = next_token (p2);
     645          break;
     646        }
     647      else if (word1eq ("undefine"))
     648        {
     649          /* We can't have modifiers after 'undefine' */
     650          vmod->undefine_v = 1;
     651          p = next_token (p2);
     652          break;
     653        }
     654      else
     655        /* Not a variable or modifier: this is not a variable assignment.  */
     656        return (char *)line;
     657
     658      /* It was a modifier.  Try the next word.  */
     659      p = next_token (p2);
     660      if (*p == '\0')
     661        return (char *)line;
     662    }
     663
     664  /* Found a variable assignment or undefine.  */
     665  vmod->assign_v = 1;
     666  return (char *)p;
     667}
     668
     669
    567670
    568671/* Read file FILENAME as a makefile and add its contents to the data base.
     
    570673   SET_DEFAULT is true if we are allowed to set the default goal.  */
    571674
    572 
    573 static int
     675static void
    574676eval (struct ebuffer *ebuf, int set_default)
    575677{
     
    583685  int no_targets = 0;           /* Set when reading a rule without targets.  */
    584686  struct nameseq *filenames = 0;
    585   struct dep *deps = 0;
     687  char *depstr = 0;
    586688  long nlines = 0;
    587689  int two_colon = 0;
     
    604706        {                                                                     \
    605707          fi.lineno = tgts_started;                                           \
    606           record_files (filenames, pattern, pattern_percent, deps          \
     708          record_files (filenames, pattern, pattern_percent, depstr,          \
    607709                        cmds_started, commands, commands_idx, two_colon,      \
    608710                        &fi);                                                 \
     711          filenames = 0;                                                      \
    609712        }                                                                     \
    610       filenames = 0;                                                          \
    611713      commands_idx = 0;                                                       \
    612714      no_targets = 0;                                                         \
     
    642744      char *p;
    643745      char *p2;
    644 
     746      struct vmodifiers vmod;
     747
     748      /* At the top of this loop, we are starting a brand new line.  */
    645749      /* Grab the next line to be evaluated */
    646750      ebuf->floc.lineno += nlines;
     
    672776
    673777          /* If there is no preceding rule line, don't treat this line
    674              as a command, even though it begins with a tab character.
     778             as a command, even though it begins with a recipe prefix.
    675779             SunOS 4 make appears to behave this way.  */
    676780
     
    711815        }
    712816
    713       /* This line is not a shell command line.  Don't worry about tabs.
     817      /* This line is not a shell command line.  Don't worry about whitespace.
    714818         Get more space if we need it; we don't need to preserve the current
    715819         contents of the buffer.  */
     
    720824          if (collapsed)
    721825            free (collapsed);
     826          /* Don't need xrealloc: we don't need to preserve the content.  */
    722827          collapsed = xmalloc (collapsed_length);
    723828        }
     
    736841#endif
    737842
    738       /* Compare a word, both length and contents. */
    739 #define word1eq(s)      (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
     843      /* Get rid if starting space (including formfeed, vtab, etc.)  */
    740844      p = collapsed;
    741845      while (isspace ((unsigned char)*p))
    742         ++p;
    743 
    744       if (*p == '\0')
    745         /* This line is completely empty--ignore it.  */
    746         continue;
    747 
    748       /* Find the end of the first token.  Note we don't need to worry about
    749        * ":" here since we compare tokens by length (so "export" will never
    750        * be equal to "export:").
    751        */
    752       for (p2 = p+1; *p2 != '\0' && !isspace ((unsigned char)*p2); ++p2)
    753         ;
    754       wlen = p2 - p;
    755 
    756       /* Find the start of the second token.  If it looks like a target or
    757          variable definition it can't be a preprocessor token so skip
    758          them--this allows variables/targets named `ifdef', `export', etc. */
    759       while (isspace ((unsigned char)*p2))
    760         ++p2;
    761 
    762       if ((p2[0] == ':' || p2[0] == '+' || p2[0] == '=') && p2[1] == '\0')
     846        ++p;
     847
     848      /* See if this is a variable assignment.  We need to do this early, to
     849         allow variables with names like 'ifdef', 'export', 'private', etc.  */
     850      p = parse_var_assignment(p, &vmod);
     851      if (vmod.assign_v)
    763852        {
    764           /* It can't be a preprocessor token so skip it if we're ignoring */
    765           if (ignoring)
    766             continue;
    767 
    768           goto skip_conditionals;
    769         }
    770 
    771       /* We must first check for conditional and `define' directives before
    772          ignoring anything, since they control what we will do with
    773          following lines.  */
    774 
    775       if (!in_ignored_define)
    776         {
    777 #ifndef CONFIG_WITH_VALUE_LENGTH
    778           int i = conditional_line (p, wlen, fstart);
    779 #else
    780           int i = conditional_line (p, eol, wlen, fstart);
    781 #endif
    782           if (i != -2)
     853          struct variable *v;
     854          enum variable_origin origin = vmod.override_v ? o_override : o_file;
     855
     856          /* If we're ignoring then we're done now.  */
     857          if (ignoring)
    783858            {
    784               if (i == -1)
    785                 fatal (fstart, _("invalid syntax in conditional"));
    786 
    787               ignoring = i;
     859              if (vmod.define_v)
     860                in_ignored_define = 1;
    788861              continue;
    789862            }
    790         }
    791 
    792       if (word1eq ("endef"))
     863
     864          if (vmod.undefine_v)
     865          {
     866            do_undefine (p, origin, ebuf);
     867
     868            /* This line has been dealt with.  */
     869            goto rule_complete;
     870          }
     871          else if (vmod.define_v)
     872            v = do_define (p IF_WITH_VALUE_LENGTH_PARAM(NULL), origin, ebuf);
     873          else
     874            v = try_variable_definition (fstart, p IF_WITH_VALUE_LENGTH_PARAM(NULL), origin, 0);
     875
     876          assert (v != NULL);
     877
     878          if (vmod.export_v)
     879            v->export = v_export;
     880          if (vmod.private_v)
     881            v->private_var = 1;
     882
     883          /* This line has been dealt with.  */
     884          goto rule_complete;
     885        }
     886
     887      /* If this line is completely empty, ignore it.  */
     888      if (*p == '\0')
     889        continue;
     890
     891      p2 = end_of_token (p);
     892      wlen = p2 - p;
     893      p2 = next_token (p2);
     894
     895      /* If we're in an ignored define, skip this line (but maybe get out).  */
     896      if (in_ignored_define)
    793897        {
    794           if (!in_ignored_define)
    795             fatal (fstart, _("extraneous `endef'"));
    796           in_ignored_define = 0;
     898          /* See if this is an endef line (plus optional comment).  */
     899          if (word1eq ("endef") && (*p2 == '\0' || *p2 == '#'))
     900            in_ignored_define = 0;
     901
    797902          continue;
    798903        }
    799904
    800       if (word1eq ("define"))
    801         {
    802           if (ignoring)
    803             in_ignored_define = 1;
    804           else
    805             {
    806               if (*p2 == '\0')
    807                 fatal (fstart, _("empty variable name"));
    808 
    809               /* Let the variable name be the whole rest of the line,
    810                  with trailing blanks stripped (comments have already been
    811                  removed), so it could be a complex variable/function
    812                  reference that might contain blanks.  */
    813               p = strchr (p2, '\0');
    814               while (isblank ((unsigned char)p[-1]))
    815                 --p;
    816               do_define (p2, p - p2, o_file, ebuf);
    817             }
    818           continue;
    819         }
    820 
    821       if (word1eq ("override"))
    822         {
    823           if (*p2 == '\0')
    824             error (fstart, _("empty `override' directive"));
    825 
    826           if (strneq (p2, "define", 6)
    827               && (isblank ((unsigned char)p2[6]) || p2[6] == '\0'))
    828             {
    829               if (ignoring)
    830                 in_ignored_define = 1;
    831               else
    832                 {
    833                   p2 = next_token (p2 + 6);
    834                   if (*p2 == '\0')
    835                     fatal (fstart, _("empty variable name"));
    836 
    837                   /* Let the variable name be the whole rest of the line,
    838                      with trailing blanks stripped (comments have already been
    839                      removed), so it could be a complex variable/function
    840                      reference that might contain blanks.  */
    841                   p = strchr (p2, '\0');
    842                   while (isblank ((unsigned char)p[-1]))
    843                     --p;
    844                   do_define (p2, p - p2, o_override, ebuf);
    845                 }
    846             }
    847           else if (!ignoring
     905      /* Check for conditional state changes.  */
     906      {
    848907#ifndef CONFIG_WITH_VALUE_LENGTH
    849                    && !try_variable_definition (fstart, p2, o_override, 0))
    850 #else
    851                    && !try_variable_definition (fstart, p2, eol, o_override, 0))
    852 #endif
    853             error (fstart, _("invalid `override' directive"));
    854 
    855           continue;
    856         }
     908        int i = conditional_line (p, wlen, fstart);
     909#else
     910        int i = conditional_line (p, eol, wlen, fstart);
     911#endif
     912        if (i != -2)
     913          {
     914            if (i == -1)
     915              fatal (fstart, _("invalid syntax in conditional"));
     916
     917            ignoring = i;
     918            continue;
     919          }
     920      }
     921
     922      /* Nothing to see here... move along.  */
     923      if (ignoring)
     924        continue;
     925
    857926#ifdef CONFIG_WITH_LOCAL_VARIABLES
    858 
    859927      if (word1eq ("local"))
    860928        {
     
    880948                  while (isblank ((unsigned char)p[-1]))
    881949                    --p;
    882                   do_define (p2, p - p2, o_local, ebuf);
     950                  do_define (p2 IF_WITH_VALUE_LENGTH_PARAM(p), o_local, ebuf);
    883951                }
    884952            }
    885953          else if (!ignoring
    886 # ifndef CONFIG_WITH_VALUE_LENGTH
    887                    && !try_variable_definition (fstart, p2, o_local, 0))
    888 # else
    889                    && !try_variable_definition (fstart, p2, eol, o_local, 0))
    890 # endif
     954                   && !try_variable_definition (fstart, p2 IF_WITH_VALUE_LENGTH_PARAM(eol), o_local, 0))
    891955            error (fstart, _("invalid `local' directive"));
    892956
     
    894958        }
    895959#endif /* CONFIG_WITH_LOCAL_VARIABLES */
    896 
    897       if (ignoring)
    898         /* Ignore the line.  We continue here so conditionals
    899            can appear in the middle of a rule.  */
    900         continue;
    901960
    902961#ifdef KMK
     
    918977
    919978#endif /* KMK */
    920       if (word1eq ("export"))
     979
     980      /* Manage the "export" keyword used outside of variable assignment
     981         as well as "unexport".  */
     982      if (word1eq ("export") || word1eq ("unexport"))
    921983        {
    922           /* 'export' by itself causes everything to be exported. */
     984          int exporting = *p == 'u' ? 0 : 1;
     985
     986          /* (un)export by itself causes everything to be (un)exported. */
    923987          if (*p2 == '\0')
    924             export_all_variables = 1;
     988            export_all_variables = exporting;
    925989          else
    926990            {
    927               struct variable *v;
    928 
     991              unsigned int l;
     992              const char *cp;
     993              char *ap;
     994
     995              /* Expand the line so we can use indirect and constructed
     996                 variable names in an (un)export command.  */
    929997#ifndef CONFIG_WITH_VALUE_LENGTH
    930               v = try_variable_definition (fstart, p2, o_file, 0);
    931 #else
    932               v = try_variable_definition (fstart, p2, eol, o_file, 0);
    933 #endif
    934               if (v != 0)
    935                 v->export = v_export;
    936               else
     998              cp = ap = allocated_variable_expand (p2);
     999#else
     1000              unsigned int buf_len;
     1001              cp = ap = allocated_variable_expand_3 (p2, eol - p2, NULL, &buf_len);
     1002#endif
     1003
     1004              for (p = find_next_token (&cp, &l); p != 0;
     1005                   p = find_next_token (&cp, &l))
    9371006                {
    938                   unsigned int l;
    939                   const char *cp;
    940                   char *ap;
    941 
    942                   /* Expand the line so we can use indirect and constructed
    943                      variable names in an export command.  */
     1007                  struct variable *v = lookup_variable (p, l);
     1008                  if (v == 0)
     1009                    v = define_variable_loc (p, l, "", o_file, 0, fstart);
     1010                  v->export = exporting ? v_export : v_noexport;
     1011                }
     1012
    9441013#ifndef CONFIG_WITH_VALUE_LENGTH
    945                   cp = ap = allocated_variable_expand (p2);
    946 #else
    947                   unsigned int buf_len;
    948                   cp = ap = allocated_variable_expand_3 (p2, eol - p2, NULL, &buf_len);
    949 #endif
    950 
    951                   for (p = find_next_token (&cp, &l); p != 0;
    952                        p = find_next_token (&cp, &l))
    953                     {
    954                       v = lookup_variable (p, l);
    955                       if (v == 0)
    956                         v = define_variable_loc (p, l, "", o_file, 0, fstart);
    957                       v->export = v_export;
    958                     }
    959 
    960 #ifndef CONFIG_WITH_VALUE_LENGTH
    961                   free (ap);
    962 #else
    963                   recycle_variable_buffer (ap, buf_len);
    964 #endif
    965                 }
     1014              free (ap);
     1015#else
     1016              recycle_variable_buffer (ap, buf_len);
     1017#endif
    9661018            }
    9671019          goto rule_complete;
    9681020        }
    9691021
    970       if (word1eq ("unexport"))
    971         {
    972           if (*p2 == '\0')
    973             export_all_variables = 0;
    974           else
    975             {
    976               unsigned int l;
    977               struct variable *v;
    978               const char *cp;
    979               char *ap;
    980 
    981               /* Expand the line so we can use indirect and constructed
    982                  variable names in an unexport command.  */
    983 #ifndef CONFIG_WITH_VALUE_LENGTH
    984               cp = ap = allocated_variable_expand (p2);
    985 #else
    986               unsigned int buf_len;
    987               cp = ap = allocated_variable_expand_3 (p2, eol - p2, NULL, &buf_len);
    988 #endif
    989 
    990               for (p = find_next_token (&cp, &l); p != 0;
    991                    p = find_next_token (&cp, &l))
    992                 {
    993                   v = lookup_variable (p, l);
    994                   if (v == 0)
    995                     v = define_variable_loc (p, l, "", o_file, 0, fstart);
    996 
    997                   v->export = v_noexport;
    998                 }
    999 
    1000 #ifndef CONFIG_WITH_VALUE_LENGTH
    1001               free (ap);
    1002 #else
    1003               recycle_variable_buffer (ap, buf_len);
    1004 #endif
    1005             }
    1006           goto rule_complete;
    1007         }
    1008 
    1009  skip_conditionals:
     1022      /* Handle the special syntax for vpath.  */
    10101023      if (word1eq ("vpath"))
    10111024        {
     
    10171030          if (p != 0)
    10181031            {
    1019               vpat = savestring (p, l);
     1032              vpat = xstrndup (p, l);
    10201033              p = find_next_token (&cp, &l);
    10211034              /* No searchpath means remove all previous
     
    10691082#endif /* CONFIG_WITH_INCLUDEDEP */
    10701083
     1084      /* Handle include and variants.  */
    10711085      if (word1eq ("include") || word1eq ("-include") || word1eq ("sinclude"))
    10721086        {
     
    10981112            }
    10991113
    1100           /* Parse the list of file names.  */
     1114          /* Parse the list of file names.  Don't expand archive references!  */
    11011115          p2 = p;
    1102 #ifndef CONFIG_WITH_ALLOC_CACHES
    1103           files = multi_glob (parse_file_seq (&p2, '\0',
    1104                                               sizeof (struct nameseq),
    1105                                               1),
    1106                               sizeof (struct nameseq));
    1107 #else
    1108           files = multi_glob (parse_file_seq (&p2, '\0', &nameseq_cache, 1),
    1109                               &nameseq_cache);
    1110 #endif
     1116          files = PARSE_FILE_SEQ (&p2, struct nameseq, '\0', NULL,
     1117                                  PARSEFS_NOAR);
    11111118#ifndef CONFIG_WITH_VALUE_LENGTH
    11121119          free (p);
     
    11301137              int r;
    11311138
    1132 #ifndef CONFIG_WITH_ALLOC_CACHES
    1133               free (files);
    1134 #else
    1135               alloccache_free (&nameseq_cache, files);
    1136 #endif
     1139              free_ns (files);
    11371140              files = next;
    11381141
    1139               r = eval_makefile (name, (RM_INCLUDED | RM_NO_TILDE
    1140                                         | (noerror ? RM_DONTCARE : 0)));
     1142              r = eval_makefile (name,
     1143                                 (RM_INCLUDED | RM_NO_TILDE
     1144                                  | (noerror ? RM_DONTCARE : 0)
     1145                                  | (set_default ? 0 : RM_NO_DEFAULT_GOAL)));
    11411146              if (!r && !noerror)
    11421147                error (fstart, "%s: %s", name, strerror (errno));
     
    11481153          goto rule_complete;
    11491154        }
    1150 
    1151 #ifndef CONFIG_WITH_VALUE_LENGTH
    1152       if (try_variable_definition (fstart, p, o_file, 0))
    1153 #else
    1154       if (try_variable_definition (fstart, p, eol, o_file, 0))
    1155 #endif
    1156         /* This line has been dealt with.  */
    1157         goto rule_complete;
    11581155
    11591156      /* This line starts with a tab but was not caught above because there
     
    11751172      {
    11761173        enum make_word_type wtype;
    1177         enum variable_origin v_origin;
    1178         int exported;
    11791174        char *cmdleft, *semip, *lb_next;
    11801175        unsigned int plen = 0;
     
    13471342           looking for targets.  */
    13481343        *colonp = '\0';
    1349 #ifndef CONFIG_WITH_ALLOC_CACHES
    1350         filenames = multi_glob (parse_file_seq (&p2, '\0',
    1351                                                 sizeof (struct nameseq),
    1352                                                 1),
    1353                                 sizeof (struct nameseq));
    1354 #else
    1355         filenames = multi_glob (parse_file_seq (&p2, '\0', &nameseq_cache, 1),
    1356                                 &nameseq_cache);
    1357 #endif
     1344        filenames = PARSE_FILE_SEQ (&p2, struct nameseq, '\0', NULL, 0);
    13581345        *p2 = ':';
    13591346
     
    13861373          }
    13871374
    1388         /* See if it's an "override" or "export" keyword; if so see if what
    1389            comes after it looks like a variable definition.  */
    1390 
    1391         wtype = get_next_mword (p2, NULL, &p, &wlen);
    1392 
    1393         v_origin = o_file;
    1394         exported = 0;
    1395         if (wtype == w_static)
    1396           {
    1397             if (word1eq ("override"))
    1398               {
    1399                 v_origin = o_override;
    1400                 wtype = get_next_mword (p+wlen, NULL, &p, &wlen);
    1401               }
    1402             else if (word1eq ("export"))
    1403               {
    1404                 exported = 1;
    1405                 wtype = get_next_mword (p+wlen, NULL, &p, &wlen);
    1406               }
    1407           }
    1408 
    1409         if (wtype != w_eol)
    1410           wtype = get_next_mword (p+wlen, NULL, NULL, NULL);
    1411 
    1412         if (wtype == w_varassign)
     1375        p2 = parse_var_assignment (p2, &vmod);
     1376        if (vmod.assign_v)
    14131377          {
    14141378            /* If there was a semicolon found, add it back, plus anything
     
    14181382                unsigned int l = p - variable_buffer;
    14191383                *(--semip) = ';';
     1384#ifndef CONFIG_WITH_VALUE_LENGTH
     1385                collapse_continuations (semip);
     1386#else
     1387                collapse_continuations (semip, strlen(semip)); /** @todo fix this */
     1388#endif
    14201389                variable_buffer_output (p2 + strlen (p2),
    14211390                                        semip, strlen (semip)+1);
    14221391                p = variable_buffer + l;
    14231392              }
    1424             record_target_var (filenames, p, v_origin, exported, fstart);
     1393            record_target_var (filenames, p2,
     1394                               vmod.override_v ? o_override : o_file,
     1395                               &vmod, fstart);
    14251396            filenames = 0;
    14261397            continue;
     
    14631434        while (p != 0 && p[-1] == '\\')
    14641435          {
    1465             register char *q = &p[-1];
    1466             register int backslash = 0;
     1436            char *q = &p[-1];
     1437            int backslash = 0;
    14671438            while (*q-- == '\\')
    14681439              backslash = !backslash;
     
    15071478          {
    15081479            struct nameseq *target;
    1509 #ifndef CONFIG_WITH_ALLOC_CACHES
    1510             target = parse_file_seq (&p2, ':', sizeof (struct nameseq), 1);
    1511 #else
    1512             target = parse_file_seq (&p2, ':', &nameseq_cache, 1);
    1513 #endif
     1480            target = PARSE_FILE_SEQ (&p2, struct nameseq, ':', NULL,
     1481                                     PARSEFS_NOGLOB);
    15141482            ++p2;
    15151483            if (target == 0)
     
    15211489            if (pattern_percent == 0)
    15221490              fatal (fstart, _("target pattern contains no `%%' (target `%s')"), target->name); /* bird */
    1523 #ifndef CONFIG_WITH_ALLOC_CACHES
    1524             free (target);
    1525 #else
    1526             alloccache_free (&nameseq_cache, target);
    1527 #endif
     1491            free_ns (target);
    15281492          }
    15291493        else
     
    15351499        strip_whitespace (&beg, &end);
    15361500
     1501        /* Put all the prerequisites here; they'll be parsed later.  */
    15371502        if (beg <= end && *beg != '\0')
    1538           {
    1539             /* Put all the prerequisites here; they'll be parsed later.  */
    1540             deps = alloc_dep ();
    1541 #ifndef CONFIG_WITH_VALUE_LENGTH
    1542             deps->name = strcache_add_len (beg, end - beg + 1);
    1543 #else  /* CONFIG_WITH_VALUE_LENGTH */
    1544             {
    1545               /* Make sure the strcache_add_len input is terminated so it
    1546                  doesn't have to make a temporary copy on the stack. */
    1547               char saved = end[1];
    1548               ((char *)end)[1] = '\0';
    1549               deps->name = strcache_add_len (beg, end - beg + 1);
    1550               ((char *)end)[1] = saved;
    1551             }
    1552 #endif /* CONFIG_WITH_VALUE_LENGTH */
    1553           }
     1503          depstr = xstrndup (beg, end - beg + 1);
    15541504        else
    1555           deps = 0;
     1505          depstr = 0;
    15561506
    15571507        commands_idx = 0;
     
    15871537           Because the target is not recorded until after ifeq directive is
    15881538           evaluated the .DEFAULT_GOAL does not contain foo yet as one
    1589            would expect. Because of this we have to move some of the logic
    1590            here.  */
    1591 
    1592         if (**default_goal_name == '\0' && set_default)
     1539           would expect. Because of this we have to move the logic here.  */
     1540
     1541        if (set_default && default_goal_var->value[0] == '\0')
    15931542          {
    15941543            const char *name;
     
    16801629    free (collapsed);
    16811630  free (commands);
    1682 
    1683   return 1;
    16841631}
    16851632
     
    17581705#endif /* CONFIG_WITH_VALUE_LENGTH */
    17591706
     1707/* Execute a `undefine' directive.
     1708   The undefine line has already been read, and NAME is the name of
     1709   the variable to be undefined. */
     1710
     1711static void
     1712do_undefine (char *name, enum variable_origin origin, struct ebuffer *ebuf)
     1713{
     1714  char *p, *var;
     1715
     1716  /* Expand the variable name and find the beginning (NAME) and end.  */
     1717  var = allocated_variable_expand (name);
     1718  name = next_token (var);
     1719  if (*name == '\0')
     1720    fatal (&ebuf->floc, _("empty variable name"));
     1721  p = name + strlen (name) - 1;
     1722  while (p > name && isblank ((unsigned char)*p))
     1723    --p;
     1724  p[1] = '\0';
     1725
     1726  undefine_variable_global (name, p - name + 1, origin);
     1727  free (var);
     1728}
     1729
    17601730/* Execute a `define' directive.
    17611731   The first line has already been read, and NAME is the name of
    17621732   the variable to be defined.  The following lines remain to be read.  */
    17631733
    1764 static void
    1765 do_define (char *name, unsigned int namelen,
     1734static struct variable *
     1735do_define (char *name IF_WITH_VALUE_LENGTH_PARAM(char *eos),
    17661736           enum variable_origin origin, struct ebuffer *ebuf)
    17671737{
     1738  struct variable *v;
     1739  enum variable_flavor flavor;
    17681740  struct floc defstart;
    1769   long nlines = 0;
    17701741  int nlevels = 1;
    17711742  unsigned int length = 100;
    17721743  char *definition = xmalloc (length);
    17731744  unsigned int idx = 0;
    1774   char *p;
    1775 
    1776   /* Expand the variable name.  */
    1777   char *var = alloca (namelen + 1);
    1778   memcpy (var, name, namelen);
    1779   var[namelen] = '\0';
    1780   var = variable_expand (var);
     1745  char *p, *var;
    17811746
    17821747  defstart = ebuf->floc;
    17831748
     1749  p = parse_variable_definition (name, &flavor);
     1750  if (p == NULL)
     1751    /* No assignment token, so assume recursive.  */
     1752    flavor = f_recursive;
     1753  else
     1754    {
     1755      if (*(next_token (p)) != '\0')
     1756        error (&defstart, _("extraneous text after `define' directive"));
     1757
     1758      /* Chop the string before the assignment token to get the name.  */
     1759      p[flavor == f_recursive ? -1 : -2] = '\0';
     1760    }
     1761
     1762  /* Expand the variable name and find the beginning (NAME) and end.  */
     1763  var = allocated_variable_expand (name);
     1764  name = next_token (var);
     1765  if (*name == '\0')
     1766    fatal (&defstart, _("empty variable name"));
     1767  p = name + strlen (name) - 1;
     1768  while (p > name && isblank ((unsigned char)*p))
     1769    --p;
     1770  p[1] = '\0';
     1771
     1772  /* Now read the value of the variable.  */
    17841773  while (1)
    17851774    {
    17861775      unsigned int len;
    17871776      char *line;
    1788 
    1789       nlines = readline (ebuf);
     1777      long nlines = readline (ebuf);
     1778
     1779      /* If there is nothing left to be eval'd, there's no 'endef'!!  */
     1780      if (nlines < 0)
     1781        fatal (&defstart, _("missing `endef', unterminated `define'"));
     1782
    17901783      ebuf->floc.lineno += nlines;
    1791 
    1792       /* If there is nothing left to eval, we're done. */
    1793       if (nlines < 0)
    1794         break;
    1795 
    17961784      line = ebuf->buffer;
    17971785
     
    18031791
    18041792      /* If the line doesn't begin with a tab, test to see if it introduces
    1805          another define, or ends one.  */
    1806 
    1807       /* Stop if we find an 'endef' */
     1793         another define, or ends one.  Stop if we find an 'endef' */
    18081794      if (line[0] != cmd_prefix)
    18091795        {
     
    18321818              ebuf->eol = remove_comments (p, ebuf->eol);
    18331819#endif
    1834               if (*next_token (p) != '\0')
     1820              if (*(next_token (p)) != '\0')
    18351821                error (&ebuf->floc,
    1836                        _("Extraneous text after `endef' directive"));
     1822                       _("extraneous text after `endef' directive"));
    18371823
    18381824              if (--nlevels == 0)
    1839                 {
    1840                   /* Define the variable.  */
    1841                   if (idx == 0)
    1842                     definition[0] = '\0';
    1843                   else
    1844                     definition[idx - 1] = '\0';
    1845 
    1846                   /* Always define these variables in the global set.  */
    1847                   define_variable_global (var, strlen (var), definition,
    1848                                           origin, 1, &defstart);
    1849                   free (definition);
    1850                   return;
    1851                 }
     1825                break;
    18521826            }
    18531827        }
    18541828
    1855       /* Otherwise add this line to the variable definition.  */
     1829      /* Add this line to the variable definition.  */
    18561830#ifndef CONFIG_WITH_VALUE_LENGTH
    18571831      len = strlen (line);
     
    18721846    }
    18731847
    1874   /* No `endef'!!  */
    1875   fatal (&defstart, _("missing `endef', unterminated `define'"));
    1876 
    1877   /* NOTREACHED */
    1878   return;
     1848  /* We've got what we need; define the variable.  */
     1849  if (idx == 0)
     1850    definition[0] = '\0';
     1851  else
     1852    definition[idx - 1] = '\0';
     1853
     1854  v = do_variable_definition (&defstart, name, definition, origin, flavor, 0);
     1855  free (definition);
     1856  free (var);
     1857  return (v);
    18791858}
    18801859
     
    22672246
    22682247
    2269 /* Remove duplicate dependencies in CHAIN.  */
    2270 #ifndef CONFIG_WITH_STRCACHE2
    2271 
    2272 static unsigned long
    2273 dep_hash_1 (const void *key)
    2274 {
    2275   return_STRING_HASH_1 (dep_name ((struct dep const *) key));
    2276 }
    2277 
    2278 static unsigned long
    2279 dep_hash_2 (const void *key)
    2280 {
    2281   return_STRING_HASH_2 (dep_name ((struct dep const *) key));
    2282 }
    2283 
    2284 static int
    2285 dep_hash_cmp (const void *x, const void *y)
    2286 {
    2287   struct dep *dx = (struct dep *) x;
    2288   struct dep *dy = (struct dep *) y;
    2289   int cmp = strcmp (dep_name (dx), dep_name (dy));
    2290 
    2291   /* If the names are the same but ignore_mtimes are not equal, one of these
    2292      is an order-only prerequisite and one isn't.  That means that we should
    2293      remove the one that isn't and keep the one that is.  */
    2294 
    2295   if (!cmp && dx->ignore_mtime != dy->ignore_mtime)
    2296     dx->ignore_mtime = dy->ignore_mtime = 0;
    2297 
    2298   return cmp;
    2299 }
    2300 
    2301 #else  /* CONFIG_WITH_STRCACHE2 */
    2302 
    2303 /* Exploit the fact that all names are in the string cache. This means equal
    2304    names shall have the same storage and there is no need for hashing or
    2305    comparing. Use the address as the first hash, avoiding any touching of
    2306    the name, and the length as the second. */
    2307 
    2308 static unsigned long
    2309 dep_hash_1 (const void *key)
    2310 {
    2311   const char *name = dep_name ((struct dep const *) key);
    2312   assert (strcache2_is_cached (&file_strcache, name));
    2313   return (size_t) name / sizeof(void *);
    2314 }
    2315 
    2316 static unsigned long
    2317 dep_hash_2 (const void *key)
    2318 {
    2319   const char *name = dep_name ((struct dep const *) key);
    2320   return strcache2_get_len (&file_strcache, name);
    2321 }
    2322 
    2323 static int
    2324 dep_hash_cmp (const void *x, const void *y)
    2325 {
    2326   struct dep *dx = (struct dep *) x;
    2327   struct dep *dy = (struct dep *) y;
    2328   const char *dxname = dep_name (dx);
    2329   const char *dyname = dep_name (dy);
    2330   int cmp = dxname == dyname ? 0 : 1;
    2331 
    2332   /* check preconds: both cached and the cache contains no duplicates. */
    2333   assert (strcache2_is_cached (&file_strcache, dxname));
    2334   assert (strcache2_is_cached (&file_strcache, dyname));
    2335   assert (cmp == 0 || strcmp (dxname, dyname) != 0);
    2336 
    2337   /* If the names are the same but ignore_mtimes are not equal, one of these
    2338      is an order-only prerequisite and one isn't.  That means that we should
    2339      remove the one that isn't and keep the one that is.  */
    2340 
    2341   if (!cmp && dx->ignore_mtime != dy->ignore_mtime)
    2342     dx->ignore_mtime = dy->ignore_mtime = 0;
    2343 
    2344   return cmp;
    2345 }
    2346 
    2347 #endif /* CONFIG_WITH_STRCACHE2 */
    2348 
    2349 void
    2350 uniquize_deps (struct dep *chain)
    2351 {
    2352   struct hash_table deps;
    2353   register struct dep **depp;
    2354 
    2355   hash_init (&deps, 500, dep_hash_1, dep_hash_2, dep_hash_cmp);
    2356 
    2357   /* Make sure that no dependencies are repeated.  This does not
    2358      really matter for the purpose of updating targets, but it
    2359      might make some names be listed twice for $^ and $?.  */
    2360 
    2361   depp = &chain;
    2362   while (*depp)
    2363     {
    2364       struct dep *dep = *depp;
    2365       struct dep **dep_slot = (struct dep **) hash_find_slot (&deps, dep);
    2366       if (HASH_VACANT (*dep_slot))
    2367         {
    2368           hash_insert_at (&deps, dep, dep_slot);
    2369           depp = &dep->next;
    2370         }
    2371       else
    2372         {
    2373           /* Don't bother freeing duplicates.
    2374              It's dangerous and little benefit accrues.  */
    2375           *depp = dep->next;
    2376         }
    2377     }
    2378 
    2379   hash_free (&deps, 0);
    2380 }
    2381 
    2382 
    23832248/* Record target-specific variable values for files FILENAMES.
    23842249   TWO_COLON is nonzero if a double colon was used.
     
    23922257static void
    23932258record_target_var (struct nameseq *filenames, char *defn,
    2394                    enum variable_origin origin, int exported,
     2259                   enum variable_origin origin, struct vmodifiers *vmod,
    23952260                   const struct floc *flocp)
    23962261{
     
    24122277
    24132278      nextf = filenames->next;
    2414 #ifndef CONFIG_WITH_ALLOC_CACHES
    2415       free (filenames);
    2416 #else
    2417       alloccache_free (&nameseq_cache, filenames);
    2418 #endif
     2279      free_ns (filenames);
    24192280
    24202281      /* If it's a pattern target, then add it to the pattern-specific
     
    24282289          /* I don't think this can fail since we already determined it was a
    24292290             variable definition.  */
    2430 #ifndef CONFIG_WITH_VALUE_LENGTH
    2431           v = parse_variable_definition (&p->variable, defn);
    2432 #else
    2433           v = parse_variable_definition (&p->variable, defn, NULL);
    2434 #endif
     2291          v = assign_variable_definition (&p->variable, defn IF_WITH_VALUE_LENGTH_PARAM(NULL));
    24352292          assert (v != 0);
    24362293
     2294          v->origin = origin;
    24372295          if (v->flavor == f_simple)
    24382296            v->value = allocated_variable_expand (v->value);
     
    24682326
    24692327          current_variable_set_list = f->variables;
    2470 #ifndef CONFIG_WITH_VALUE_LENGTH
    2471           v = try_variable_definition (flocp, defn, origin, 1);
    2472 #else
    2473           v = try_variable_definition (flocp, defn, NULL, origin, 1);
    2474 #endif
     2328          v = try_variable_definition (flocp, defn IF_WITH_VALUE_LENGTH_PARAM(NULL), origin, 1);
    24752329          if (!v)
    2476             error (flocp, _("Malformed target-specific variable definition"));
     2330            fatal (flocp, _("Malformed target-specific variable definition"));
    24772331          current_variable_set_list = global;
    24782332        }
    24792333
    24802334      /* Set up the variable to be *-specific.  */
    2481       v->origin = origin;
    24822335      v->per_target = 1;
    2483       v->export = exported ? v_export : v_default;
     2336      v->private_var = vmod->private_v;
     2337      v->export = vmod->export_v ? v_export : v_default;
    24842338
    24852339      /* If it's not an override, check to see if there was a command-line
    24862340         setting.  If so, reset the value.  */
    2487       if (origin != o_override)
     2341      if (v->origin != o_override)
    24882342        {
    24892343          struct variable *gv;
     
    25072361              v->value = xstrdup (gv->value);
    25082362#else
    2509               v->value = savestring (gv->value, gv->value_length);
     2363              v->value = xstrndup (gv->value, gv->value_length);
    25102364              v->value_length = gv->value_length;
    25112365#endif
     
    25302384   that are not incorporated into other data structures.  */
    25312385
    2532 #ifndef CONFIG_WITH_INCLUDEDEP
    25332386static void
    2534 #else
    2535 void
    2536 #endif
    25372387record_files (struct nameseq *filenames, const char *pattern,
    2538               const char *pattern_percent, struct dep *deps,
     2388              const char *pattern_percent, char *depstr,
    25392389              unsigned int cmds_started, char *commands,
    25402390              unsigned int commands_idx, int two_colon,
    25412391              const struct floc *flocp)
    25422392{
    2543   struct nameseq *nextf;
    2544   int implicit = 0;
    2545   unsigned int max_targets = 0, target_idx = 0;
    2546   const char **targets = 0, **target_percents = 0;
    2547   struct commands *cmds;
    25482393#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    25492394  struct file *prev_file = 0;
     
    25512396    multi_mode = !two_colon && !pattern ? m_unsettled : m_no;
    25522397#endif
     2398  struct commands *cmds;
     2399  struct dep *deps;
     2400  const char *implicit_percent;
     2401  const char *name;
    25532402
    25542403  /* If we've already snapped deps, that means we're in an eval being
     
    25592408    fatal (flocp, _("prerequisites cannot be defined in recipes"));
    25602409
     2410  /* Determine if this is a pattern rule or not.  */
     2411  name = filenames->name;
     2412  implicit_percent = find_percent_cached (&name);
     2413
     2414  /* If there's a recipe, set up a struct for it.  */
    25612415  if (commands_idx > 0)
    25622416    {
     
    25682422      cmds->fileinfo.filenm = flocp->filenm;
    25692423      cmds->fileinfo.lineno = cmds_started;
    2570       cmds->commands = savestring (commands, commands_idx);
     2424      cmds->commands = xstrndup (commands, commands_idx);
    25712425      cmds->command_lines = 0;
    25722426#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
     
    25752429    }
    25762430  else
    2577     cmds = 0;
    2578 
    2579   for (; filenames != 0; filenames = nextf)
     2431     cmds = 0;
     2432
     2433  /* If there's a prereq string then parse it--unless it's eligible for 2nd
     2434     expansion: if so, snap_deps() will do it.  */
     2435  if (depstr == 0)
     2436    deps = 0;
     2437  else if (second_expansion && strchr (depstr, '$'))
    25802438    {
    2581       const char *name = filenames->name;
     2439      deps = alloc_dep ();
     2440      deps->name = depstr;
     2441      deps->need_2nd_expansion = 1;
     2442      deps->staticpattern = pattern != 0;
     2443    }
     2444  else
     2445    {
     2446      deps = split_prereqs (depstr);
     2447      free (depstr);
     2448
     2449      /* We'll enter static pattern prereqs later when we have the stem.  We
     2450         don't want to enter pattern rules at all so that we don't think that
     2451         they ought to exist (make manual "Implicit Rule Search Algorithm",
     2452         item 5c).  */
     2453      if (! pattern && ! implicit_percent)
     2454        deps = enter_prereqs (deps, NULL);
     2455    }
     2456
     2457  /* For implicit rules, _all_ the targets must have a pattern.  That means we
     2458     can test the first one to see if we're working with an implicit rule; if
     2459     so we handle it specially. */
     2460
     2461  if (implicit_percent)
     2462    {
     2463      struct nameseq *nextf;
     2464      const char **targets, **target_pats;
     2465      unsigned int c;
     2466
     2467      if (pattern != 0)
     2468        fatal (flocp, _("mixed implicit and static pattern rules"));
     2469
     2470      /* Count the targets to create an array of target names.
     2471         We already have the first one.  */
     2472      nextf = filenames->next;
     2473      free_ns (filenames);
     2474      filenames = nextf;
     2475
     2476      for (c = 1; nextf; ++c, nextf = nextf->next)
     2477        ;
     2478      targets = xmalloc (c * sizeof (const char *));
     2479      target_pats = xmalloc (c * sizeof (const char *));
     2480
     2481      targets[0] = name;
     2482      target_pats[0] = implicit_percent;
     2483
     2484      c = 1;
     2485      while (filenames)
     2486        {
     2487          name = filenames->name;
     2488          implicit_percent = find_percent_cached (&name);
     2489
     2490          if (implicit_percent == 0)
     2491            fatal (flocp, _("mixed implicit and normal rules"));
     2492
     2493          targets[c] = name;
     2494          target_pats[c] = implicit_percent;
     2495          ++c;
     2496
     2497          nextf = filenames->next;
     2498          free_ns (filenames);
     2499          filenames = nextf;
     2500        }
     2501
     2502      create_pattern_rule (targets, target_pats, c, two_colon, deps, cmds, 1);
     2503
     2504      return;
     2505    }
     2506
     2507
     2508  /* Walk through each target and create it in the database.
     2509     We already set up the first target, above.  */
     2510  while (1)
     2511    {
     2512      struct nameseq *nextf = filenames->next;
    25822513      struct file *f;
    25832514      struct dep *this = 0;
    2584       const char *implicit_percent;
    2585 
    2586       nextf = filenames->next;
    2587 #ifndef CONFIG_WITH_ALLOC_CACHES
    2588       free (filenames);
    2589 #else
    2590       alloccache_free (&nameseq_cache, filenames);
    2591 #endif
     2515
     2516      free_ns (filenames);
    25922517
    25932518      /* Check for special targets.  Do it here instead of, say, snap_deps()
    25942519         so that we can immediately use the value.  */
    2595 
    25962520      if (streq (name, ".POSIX"))
    2597         posix_pedantic = 1;
     2521        {
     2522          posix_pedantic = 1;
     2523          define_variable_cname (".SHELLFLAGS", "-ec", o_default, 0);
     2524        }
    25982525      else if (streq (name, ".SECONDEXPANSION"))
    25992526        second_expansion = 1;
     
    26022529        second_target_expansion = 1;
    26032530#endif
    2604 
    2605       implicit_percent = find_percent_cached (&name);
    2606       implicit |= implicit_percent != 0;
    2607 
    2608       if (implicit)
    2609         {
    2610           if (pattern != 0)
    2611             fatal (flocp, _("mixed implicit and static pattern rules"));
    2612 
    2613           if (implicit_percent == 0)
    2614             fatal (flocp, _("mixed implicit and normal rules"));
    2615 
    2616           if (targets == 0)
    2617             {
    2618               max_targets = 5;
    2619               targets = xmalloc (5 * sizeof (char *));
    2620               target_percents = xmalloc (5 * sizeof (char *));
    2621               target_idx = 0;
    2622             }
    2623           else if (target_idx == max_targets - 1)
    2624             {
    2625               max_targets += 5;
    2626               targets = xrealloc ((void *)targets, max_targets * sizeof (char *));
    2627               target_percents = xrealloc ((void *)target_percents,
    2628                                           max_targets * sizeof (char *));
    2629             }
    2630           targets[target_idx] = name;
    2631           target_percents[target_idx] = implicit_percent;
    2632           ++target_idx;
    2633           continue;
    2634         }
     2531#if !defined(WINDOWS32) && !defined (__MSDOS__) && !defined (__EMX__)
     2532      else if (streq (name, ".ONESHELL"))
     2533        one_shell = 1;
     2534#endif
    26352535
    26362536#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     
    26702570                }
    26712571              multi_mode = name[1] == '\0' ? m_yes : m_yes_maybe;
    2672               continue;
     2572              goto l_next;
    26732573            }
    26742574        }
     
    26782578
    26792579      /* If this is a static pattern rule:
    2680          `targets: target%pattern: dep%pattern; cmds',
     2580         `targets: target%pattern: prereq%pattern; recipe',
    26812581         make sure the pattern matches this target name.  */
    26822582      if (pattern && !pattern_matches (pattern, pattern_percent, name))
    26832583        error (flocp, _("target `%s' doesn't match the target pattern"), name);
    26842584      else if (deps)
    2685         {
    2686           /* If there are multiple filenames, copy the chain DEPS for all but
    2687              the last one.  It is not safe for the same deps to go in more
    2688              than one place in the database.  */
    2689           this = nextf != 0 ? copy_dep_chain (deps) : deps;
    2690           this->need_2nd_expansion = (second_expansion
    2691                                       && strchr (this->name, '$'));
    2692         }
    2693 
     2585        /* If there are multiple targets, copy the chain DEPS for all but the
     2586           last one.  It is not safe for the same deps to go in more than one
     2587           place in the database.  */
     2588        this = nextf != 0 ? copy_dep_chain (deps) : deps;
     2589
     2590      /* Find or create an entry in the file database for this target.  */
    26942591      if (!two_colon)
    26952592        {
    2696           /* Single-colon.  Combine these dependencies
    2697              with others in file's existing record, if any.  */
     2593          /* Single-colon.  Combine this rule with the file's existing record,
     2594             if any.  */
    26982595#ifndef KMK
    26992596          f = enter_file (strcache_add (name));
     
    27012598          f = enter_file (name);
    27022599#endif
    2703 
    27042600          if (f->double_colon)
    27052601            fatal (flocp,
     
    27262622            }
    27272623
    2728           f->is_target = 1;
    2729 
    27302624          /* Defining .DEFAULT with no deps or cmds clears it.  */
    27312625          if (f == default_file && this == 0 && cmds == 0)
     
    27592653              free_dep_chain (f->deps);
    27602654              f->deps = 0;
    2761             }
    2762           else if (this != 0)
    2763             {
    2764               /* Add the file's old deps and the new ones in THIS together.  */
    2765 
    2766               if (f->deps != 0)
    2767                 {
    2768                   struct dep **d_ptr = &f->deps;
    2769 
    2770                   while ((*d_ptr)->next != 0)
    2771                     d_ptr = &(*d_ptr)->next;
    2772 
    2773                   if (cmds != 0)
    2774                     /* This is the rule with commands, so put its deps
    2775                        last. The rationale behind this is that $< expands to
    2776                        the first dep in the chain, and commands use $<
    2777                        expecting to get the dep that rule specifies.  However
    2778                        the second expansion algorithm reverses the order thus
    2779                        we need to make it last here.  */
    2780                     (*d_ptr)->next = this;
    2781                   else
    2782                     {
    2783                       /* This is the rule without commands. Put its
    2784                          dependencies at the end but before dependencies from
    2785                          the rule with commands (if any). This way everything
    2786                          appears in makefile order.  */
    2787 
    2788                       if (f->cmds != 0)
    2789                         {
    2790 #ifndef KMK /* bugfix: Don't chop the chain! */
    2791                           this->next = *d_ptr;
    2792                           *d_ptr = this;
    2793 #else   /* KMK */
    2794                           struct dep *this_last = this;
    2795                           while (this_last->next)
    2796                             this_last = this_last->next;
    2797                           this_last->next = *d_ptr;
    2798                           *d_ptr = this;
    2799 #endif  /* KMK */
    2800                         }
    2801                       else
    2802                         (*d_ptr)->next = this;
    2803                     }
    2804                 }
    2805               else
    2806                 f->deps = this;
    2807 
    2808               /* This is a hack. I need a way to communicate to snap_deps()
    2809                  that the last dependency line in this file came with commands
    2810                  (so that logic in snap_deps() can put it in front and all
    2811                  this $< -logic works). I cannot simply rely on file->cmds
    2812                  being not 0 because of the cases like the following:
    2813 
    2814                  foo: bar
    2815                  foo:
    2816                      ...
    2817 
    2818                  I am going to temporarily "borrow" UPDATING member in
    2819                  `struct file' for this.   */
    2820 
    2821               if (cmds != 0)
    2822                 f->updating = 1;
    28232655            }
    28242656        }
     
    28322664#endif /* CONFIG_WITH_STRCACHE2 */
    28332665
    2834           /* Check for both : and :: rules.  Check is_target so
    2835              we don't lose on default suffix rules or makefiles.  */
     2666          /* Check for both : and :: rules.  Check is_target so we don't lose
     2667             on default suffix rules or makefiles.  */
    28362668          if (f != 0 && f->is_target && !f->double_colon)
    28372669            fatal (flocp,
    28382670                   _("target file `%s' has both : and :: entries"), f->name);
     2671
    28392672#ifndef KMK
    28402673          f = enter_file (strcache_add (name));
     
    28502683               double_colon pointer to itself.  */
    28512684            f->double_colon = f;
    2852           f->is_target = 1;
    2853           f->deps = this;
     2685
    28542686          f->cmds = cmds;
    28552687        }
    28562688
     2689      f->is_target = 1;
     2690
    28572691      /* If this is a static pattern rule, set the stem to the part of its
    28582692         name that matched the `%' in the pattern, so you can use $* in the
    2859          commands.  */
     2693         commands.  If we didn't do it before, enter the prereqs now.  */
    28602694      if (pattern)
    28612695        {
     
    28692703          if (this)
    28702704            {
    2871               this->staticpattern = 1;
    2872               this->stem = f->stem;
     2705              if (! this->need_2nd_expansion)
     2706                this = enter_prereqs (this, f->stem);
     2707              else
     2708                this->stem = f->stem;
    28732709            }
    28742710        }
    28752711
     2712      /* Add the dependencies to this file entry.  */
     2713      if (this != 0)
     2714        {
     2715          /* Add the file's old deps and the new ones in THIS together.  */
     2716          if (f->deps == 0)
     2717            f->deps = this;
     2718          else if (cmds != 0)
     2719            {
     2720              struct dep *d = this;
     2721
     2722              /* If this rule has commands, put these deps first.  */
     2723              while (d->next != 0)
     2724                d = d->next;
     2725
     2726              d->next = f->deps;
     2727              f->deps = this;
     2728            }
     2729          else
     2730            {
     2731              struct dep *d = f->deps;
     2732
     2733              /* A rule without commands: put its prereqs at the end.  */
     2734              while (d->next != 0)
     2735                d = d->next;
     2736
     2737              d->next = this;
     2738            }
     2739        }
     2740
    28762741      name = f->name;
    28772742
    2878       /* If this target is a default target, update DEFAULT_GOAL_FILE.  */
    2879       if (streq (*default_goal_name, name)
    2880           && (default_goal_file == 0
    2881               || ! streq (default_goal_file->name, name)))
    2882         default_goal_file = f;
    2883     }
    2884 
    2885   if (implicit)
    2886     {
    2887       if (deps)
    2888         deps->need_2nd_expansion = second_expansion;
    2889       create_pattern_rule (targets, target_percents, target_idx,
    2890                            two_colon, deps, cmds, 1);
     2743#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     2744l_next:
     2745#endif
     2746      /* All done!  Set up for the next one.  */
     2747      if (nextf == 0)
     2748        break;
     2749
     2750      filenames = nextf;
     2751
     2752      /* Reduce escaped percents.  If there are any unescaped it's an error  */
     2753      name = filenames->name;
     2754      if (find_percent_cached (&name))
     2755        fatal (flocp, _("mixed implicit and normal rules"));
    28912756    }
    28922757}
     
    31112976
    31122977
    3113 /* Parse a string into a sequence of filenames represented as a
    3114    chain of struct nameseq's in reverse order and return that chain.
    3115 
    3116    The string is passed as STRINGP, the address of a string pointer.
    3117    The string pointer is updated to point at the first character
    3118    not parsed, which either is a null char or equals STOPCHAR.
    3119 
    3120    SIZE is how big to construct chain elements.
    3121    This is useful if we want them actually to be other structures
    3122    that have room for additional info.
    3123 
    3124    If STRIP is nonzero, strip `./'s off the beginning.  */
    3125 
    3126 #ifndef CONFIG_WITH_ALLOC_CACHES
    3127 struct nameseq *
    3128 parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip)
    3129 #else
    3130 struct nameseq *
    3131 parse_file_seq (char **stringp, int stopchar, struct alloccache *cache, int strip)
    3132 #endif
    3133 {
    3134   struct nameseq *new = 0;
    3135   struct nameseq *new1;
    3136 #ifndef NO_ARCHIVES /* bird: MSC warning */
    3137   struct nameseq *lastnew1;
    3138 #endif
    3139   char *p = *stringp;
    3140 
    3141 #ifdef VMS
    3142 # define VMS_COMMA ','
    3143 #else
    3144 # define VMS_COMMA 0
    3145 #endif
    3146 
    3147   while (1)
    3148     {
    3149       const char *name;
    3150       char *q;
    3151 
    3152       /* Skip whitespace; see if any more names are left.  */
    3153       p = next_token (p);
    3154       if (*p == '\0')
    3155         break;
    3156       if (*p == stopchar)
    3157         break;
    3158 
    3159       /* There are, so find the end of the next name.  */
    3160       q = p;
    3161       p = find_char_unquote (q, stopchar, VMS_COMMA, 1, 0);
    3162 #ifdef VMS
    3163         /* convert comma separated list to space separated */
    3164       if (p && *p == ',')
    3165         *p =' ';
    3166 #endif
    3167 #ifdef _AMIGA
    3168       if (stopchar == ':' && p && *p == ':'
    3169           && !(isspace ((unsigned char)p[1]) || !p[1]
    3170                || isspace ((unsigned char)p[-1])))
    3171         p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0);
    3172 #endif
    3173 #ifdef HAVE_DOS_PATHS
    3174     /* For DOS paths, skip a "C:\..." or a "C:/..." until we find the
    3175        first colon which isn't followed by a slash or a backslash.
    3176        Note that tokens separated by spaces should be treated as separate
    3177        tokens since make doesn't allow path names with spaces */
    3178     if (stopchar == ':')
    3179       while (p != 0 && !isspace ((unsigned char)*p) &&
    3180              (p[1] == '\\' || p[1] == '/') && isalpha ((unsigned char)p[-1]))
    3181         p = find_char_unquote (p + 1, stopchar, VMS_COMMA, 1, 0);
    3182 #endif
    3183       if (p == 0)
    3184         p = q + strlen (q);
    3185 
    3186       if (strip)
    3187 #ifdef VMS
    3188         /* Skip leading `[]'s.  */
    3189         while (p - q > 2 && q[0] == '[' && q[1] == ']')
    3190 #else
    3191         /* Skip leading `./'s.  */
    3192         while (p - q > 2 && q[0] == '.' && q[1] == '/')
    3193 #endif
    3194           {
    3195             q += 2;             /* Skip "./".  */
    3196             while (q < p && *q == '/')
    3197               /* Skip following slashes: ".//foo" is "foo", not "/foo".  */
    3198               ++q;
    3199           }
    3200 
    3201       /* Extract the filename just found, and skip it.  */
    3202 
    3203       if (q == p)
    3204         /* ".///" was stripped to "". */
    3205 #if defined(VMS)
    3206         continue;
    3207 #elif defined(_AMIGA)
    3208         name = "";
    3209 #else
    3210         name = "./";
    3211 #endif
    3212       else
    3213 #ifdef VMS
    3214 /* VMS filenames can have a ':' in them but they have to be '\'ed but we need
    3215  *  to remove this '\' before we can use the filename.
    3216  * Savestring called because q may be read-only string constant.
    3217  */
    3218         {
    3219           char *qbase = xstrdup (q);
    3220           char *pbase = qbase + (p-q);
    3221           char *q1 = qbase;
    3222           char *q2 = q1;
    3223           char *p1 = pbase;
    3224 
    3225           while (q1 != pbase)
    3226             {
    3227               if (*q1 == '\\' && *(q1+1) == ':')
    3228                 {
    3229                   q1++;
    3230                   p1--;
    3231                 }
    3232               *q2++ = *q1++;
    3233             }
    3234           name = strcache_add_len (qbase, p1 - qbase);
    3235           free (qbase);
    3236         }
    3237 #elif !defined (CONFIG_WITH_VALUE_LENGTH) || defined (CONFIG_WITH_STRCACHE2)
    3238         name = strcache_add_len (q, p - q);
    3239 #else  /* CONFIG_WITH_VALUE_LENGTH */
    3240        {
    3241          /* Make sure it's terminated, strcache_add_len has to make a
    3242             temp copy on the stack otherwise. */
    3243          char saved = *p;
    3244          if (!saved)
    3245            *p = '\0';
    3246          name = strcache_add_len (q, p - q);
    3247          if (saved)
    3248            *p = saved;
    3249        }
    3250 #endif /* CONFIG_WITH_VALUE_LENGTH */
    3251 
    3252       /* Add it to the front of the chain.  */
    3253 #ifndef CONFIG_WITH_ALLOC_CACHES
    3254       new1 = xmalloc (size);
    3255       memset (new1, '\0', size);
    3256 #else
    3257       new1 = (struct nameseq *) alloccache_calloc (cache);
    3258 #endif
    3259       new1->name = name;
    3260       new1->next = new;
    3261       new = new1;
    3262     }
    3263 
    3264 #ifndef NO_ARCHIVES
    3265 
    3266   /* Look for multi-word archive references.
    3267      They are indicated by a elt ending with an unmatched `)' and
    3268      an elt further down the chain (i.e., previous in the file list)
    3269      with an unmatched `(' (e.g., "lib(mem").  */
    3270 
    3271   new1 = new;
    3272   lastnew1 = 0;
    3273   while (new1 != 0)
    3274     if (new1->name[0] != '('    /* Don't catch "(%)" and suchlike.  */
    3275         && new1->name[strlen (new1->name) - 1] == ')'
    3276         && strchr (new1->name, '(') == 0)
    3277       {
    3278         /* NEW1 ends with a `)' but does not contain a `('.
    3279            Look back for an elt with an opening `(' but no closing `)'.  */
    3280 
    3281         struct nameseq *n = new1->next, *lastn = new1;
    3282         char *paren = 0;
    3283         while (n != 0 && (paren = strchr (n->name, '(')) == 0)
    3284           {
    3285             lastn = n;
    3286             n = n->next;
    3287           }
    3288         if (n != 0
    3289             /* Ignore something starting with `(', as that cannot actually
    3290                be an archive-member reference (and treating it as such
    3291                results in an empty file name, which causes much lossage).  */
    3292             && n->name[0] != '(')
    3293           {
    3294             /* N is the first element in the archive group.
    3295                Its name looks like "lib(mem" (with no closing `)').  */
    3296 
    3297             char *libname;
    3298 
    3299             /* Copy "lib(" into LIBNAME.  */
    3300             ++paren;
    3301             libname = alloca (paren - n->name + 1);
    3302             memcpy (libname, n->name, paren - n->name);
    3303             libname[paren - n->name] = '\0';
    3304 
    3305             if (*paren == '\0')
    3306               {
    3307                 /* N was just "lib(", part of something like "lib( a b)".
    3308                    Edit it out of the chain and free its storage.  */
    3309                 lastn->next = n->next;
    3310 #ifndef CONFIG_WITH_ALLOC_CACHES
    3311                 free (n);
    3312 #else
    3313                 alloccache_free (cache, n);
    3314 #endif
    3315                 /* LASTN->next is the new stopping elt for the loop below.  */
    3316                 n = lastn->next;
    3317               }
    3318             else
    3319               {
    3320                 /* Replace N's name with the full archive reference.  */
    3321                 n->name = strcache_add (concat (libname, paren, ")"));
    3322               }
    3323 
    3324             if (new1->name[1] == '\0')
    3325               {
    3326                 /* NEW1 is just ")", part of something like "lib(a b )".
    3327                    Omit it from the chain and free its storage.  */
    3328                 if (lastnew1 == 0)
    3329                   new = new1->next;
    3330                 else
    3331                   lastnew1->next = new1->next;
    3332                 lastn = new1;
    3333                 new1 = new1->next;
    3334 #ifndef CONFIG_WITH_ALLOC_CACHES
    3335                 free (lastn);
    3336 #else
    3337                 alloccache_free (cache, lastn);
    3338 #endif
    3339               }
    3340             else
    3341               {
    3342                 /* Replace also NEW1->name, which already has closing `)'.  */
    3343                 new1->name = strcache_add (concat (libname, new1->name, ""));
    3344                 new1 = new1->next;
    3345               }
    3346 
    3347             /* Trace back from NEW1 (the end of the list) until N
    3348                (the beginning of the list), rewriting each name
    3349                with the full archive reference.  */
    3350 
    3351             while (new1 != n)
    3352               {
    3353                 new1->name = strcache_add (concat (libname, new1->name, ")"));
    3354                 lastnew1 = new1;
    3355                 new1 = new1->next;
    3356               }
    3357           }
    3358         else
    3359           {
    3360             /* No frobnication happening.  Just step down the list.  */
    3361             lastnew1 = new1;
    3362             new1 = new1->next;
    3363           }
    3364       }
    3365     else
    3366       {
    3367         lastnew1 = new1;
    3368         new1 = new1->next;
    3369       }
    3370 
    3371 #endif
    3372 
    3373   *stringp = p;
    3374   return new;
    3375 }
    3376 
    3377 
    33782978/* Find the next line of text in an eval buffer, combining continuation lines
    33792979   into one line.
     
    34123012    {
    34133013      int backslash = 0;
    3414       char *bol = eol;
    3415       char *p;
     3014      const char *bol = eol;
     3015      const char *p;
    34163016
    34173017      /* Find the next newline.  At EOS, stop.  */
    34183018#ifndef CONFIG_WITH_VALUE_LENGTH
    3419       eol = p = strchr (eol , '\n');
     3019      p = eol = strchr (eol , '\n');
    34203020#else
    34213021      p = (char *)memchr (eol, '\n', end - eol);
    34223022      assert (!memchr (eol, '\0', p != 0 ? p - eol : end - eol));
    3423       eol = p;
     3023      eol = (char *)p;
    34243024#endif
    34253025      if (!eol)
     
    39333533      if (home_dir != 0)
    39343534        {
    3935           char *new = xstrdup (concat (home_dir, "", name + 1));
     3535          char *new = xstrdup (concat (2, home_dir, name + 1));
    39363536          if (is_variable)
    39373537            free (home_dir);
     
    39523552            return xstrdup (pwent->pw_dir);
    39533553          else
    3954             return xstrdup (concat (pwent->pw_dir, "/", userend + 1));
     3554            return xstrdup (concat (3, pwent->pw_dir, "/", userend + 1));
    39553555        }
    39563556      else if (userend != 0)
     
    39623562}
    39633563
    3964 /* Given a chain of struct nameseq's describing a sequence of filenames,
    3965    in reverse of the intended order, return a new chain describing the
    3966    result of globbing the filenames.  The new chain is in forward order.
    3967    The links of the old chain are freed or used in the new chain.
    3968    Likewise for the names in the old chain.
     3564
     3565/* Parse a string into a sequence of filenames represented as a chain of
     3566   struct nameseq's and return that chain.  Optionally expand the strings via
     3567   glob().
     3568
     3569   The string is passed as STRINGP, the address of a string pointer.
     3570   The string pointer is updated to point at the first character
     3571   not parsed, which either is a null char or equals STOPCHAR.
    39693572
    39703573   SIZE is how big to construct chain elements.
    39713574   This is useful if we want them actually to be other structures
    3972    that have room for additional info.  */
    3973 
     3575   that have room for additional info.
     3576
     3577   PREFIX, if non-null, is added to the beginning of each filename.
     3578
     3579   FLAGS allows one or more of the following bitflags to be set:
     3580        PARSEFS_NOSTRIP - Do no strip './'s off the beginning
     3581        PARSEFS_NOAR    - Do not check filenames for archive references
     3582        PARSEFS_NOGLOB  - Do not expand globbing characters
     3583        PARSEFS_EXISTS  - Only return globbed files that actually exist
     3584                          (cannot also set NOGLOB)
     3585        PARSEFS_NOCACHE - Do not add filenames to the strcache (caller frees)
     3586  */
     3587
     3588void *
     3589parse_file_seq (char **stringp, unsigned int size, int stopchar,
     3590                const char *prefix, int flags
     3591                IF_WITH_ALLOC_CACHES_PARAM(struct alloccache *alloc_cache) )
     3592{
     3593  extern void dir_setup_glob (glob_t *glob);
     3594
     3595  /* tmp points to tmpbuf after the prefix, if any.
     3596     tp is the end of the buffer. */
     3597  static char *tmpbuf = NULL;
     3598  static int tmpbuf_len = 0;
     3599
     3600  int cachep = (! (flags & PARSEFS_NOCACHE));
     3601
     3602  struct nameseq *new = 0;
     3603  struct nameseq **newp = &new;
    39743604#ifndef CONFIG_WITH_ALLOC_CACHES
    3975 struct nameseq *
    3976 multi_glob (struct nameseq *chain, unsigned int size)
    3977 #else
    3978 struct nameseq *
    3979 multi_glob (struct nameseq *chain, struct alloccache *cache)
    3980 #endif
    3981 {
    3982   void dir_setup_glob (glob_t *);
    3983   struct nameseq *new = 0;
    3984   struct nameseq *old;
    3985   struct nameseq *nexto;
     3605#define NEWELT(_n)  do { \
     3606                        const char *__n = (_n); \
     3607                        *newp = xcalloc (size); \
     3608                        (*newp)->name = (cachep ? strcache_add (__n) : xstrdup (__n)); \
     3609                        newp = &(*newp)->next; \
     3610                    } while(0)
     3611#else
     3612# define NEWELT(_n)  do { \
     3613                        const char *__n = (_n); \
     3614                        *newp = alloccache_calloc (alloc_cache); \
     3615                        (*newp)->name = (cachep ? strcache_add (__n) : xstrdup (__n)); \
     3616                        newp = &(*newp)->next; \
     3617                    } while(0)
     3618#endif
     3619
     3620  char *p;
    39863621  glob_t gl;
    3987 #if defined(KMK) || defined(__EMX__) /* speed optimization */
    3988   int rc;
    3989 #endif
    3990 
    3991   dir_setup_glob (&gl);
    3992 
    3993   for (old = chain; old != 0; old = nexto)
     3622  char *tp;
     3623
     3624#ifdef VMS
     3625# define VMS_COMMA ','
     3626#else
     3627# define VMS_COMMA 0
     3628#endif
     3629
     3630  if (size < sizeof (struct nameseq))
     3631    size = sizeof (struct nameseq);
     3632
     3633  if (! (flags & PARSEFS_NOGLOB))
     3634    dir_setup_glob (&gl);
     3635
     3636  /* Get enough temporary space to construct the largest possible target.  */
     3637  {
     3638    int l = strlen (*stringp) + 1;
     3639    if (l > tmpbuf_len)
     3640      {
     3641        tmpbuf = xrealloc (tmpbuf, l);
     3642        tmpbuf_len = l;
     3643      }
     3644  }
     3645  tp = tmpbuf;
     3646
     3647  /* Parse STRING.  P will always point to the end of the parsed content.  */
     3648  p = *stringp;
     3649  while (1)
    39943650    {
    3995       const char *gname;
     3651      const char *name;
     3652      const char **nlist = 0;
     3653      char *tildep = 0;
    39963654#ifndef NO_ARCHIVES
    39973655      char *arname = 0;
    39983656      char *memname = 0;
    39993657#endif
    4000       nexto = old->next;
    4001       gname = old->name;
    4002 
    4003       if (gname[0] == '~')
     3658      char *s;
     3659      int nlen;
     3660      int i;
     3661
     3662      /* Skip whitespace; at the end of the string or STOPCHAR we're done.  */
     3663      p = next_token (p);
     3664      if (*p == '\0' || *p == stopchar)
     3665        break;
     3666
     3667      /* There are names left, so find the end of the next name.
     3668         Throughout this iteration S points to the start.  */
     3669      s = p;
     3670      p = find_char_unquote (p, stopchar, VMS_COMMA, 1, 0);
     3671#ifdef VMS
     3672        /* convert comma separated list to space separated */
     3673      if (p && *p == ',')
     3674        *p =' ';
     3675#endif
     3676#ifdef _AMIGA
     3677      if (stopchar == ':' && p && *p == ':'
     3678          && !(isspace ((unsigned char)p[1]) || !p[1]
     3679               || isspace ((unsigned char)p[-1])))
     3680        p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0);
     3681#endif
     3682#ifdef HAVE_DOS_PATHS
     3683    /* For DOS paths, skip a "C:\..." or a "C:/..." until we find the
     3684       first colon which isn't followed by a slash or a backslash.
     3685       Note that tokens separated by spaces should be treated as separate
     3686       tokens since make doesn't allow path names with spaces */
     3687    if (stopchar == ':')
     3688      while (p != 0 && !isspace ((unsigned char)*p) &&
     3689             (p[1] == '\\' || p[1] == '/') && isalpha ((unsigned char)p[-1]))
     3690        p = find_char_unquote (p + 1, stopchar, VMS_COMMA, 1, 0);
     3691#endif
     3692      if (p == 0)
     3693        p = s + strlen (s);
     3694
     3695      /* Strip leading "this directory" references.  */
     3696      if (! (flags & PARSEFS_NOSTRIP))
     3697#ifdef VMS
     3698        /* Skip leading `[]'s.  */
     3699        while (p - s > 2 && s[0] == '[' && s[1] == ']')
     3700#else
     3701        /* Skip leading `./'s.  */
     3702        while (p - s > 2 && s[0] == '.' && s[1] == '/')
     3703#endif
     3704          {
     3705            /* Skip "./" and all following slashes.  */
     3706            s += 2;
     3707            while (*s == '/')
     3708              ++s;
     3709          }
     3710
     3711      /* Extract the filename just found, and skip it.
     3712         Set NAME to the string, and NLEN to its length.  */
     3713
     3714      if (s == p)
     3715        {
     3716        /* The name was stripped to empty ("./"). */
     3717#if defined(VMS)
     3718          continue;
     3719#elif defined(_AMIGA)
     3720          /* PDS-- This cannot be right!! */
     3721          tp[0] = '\0';
     3722          nlen = 0;
     3723#else
     3724          tp[0] = '.';
     3725          tp[1] = '/';
     3726          tp[2] = '\0';
     3727          nlen = 2;
     3728#endif
     3729        }
     3730      else
    40043731        {
    4005           char *newname = tilde_expand (old->name);
    4006           if (newname != 0)
    4007             gname = newname;
     3732#ifdef VMS
     3733/* VMS filenames can have a ':' in them but they have to be '\'ed but we need
     3734 *  to remove this '\' before we can use the filename.
     3735 * xstrdup called because S may be read-only string constant.
     3736 */
     3737          char *n = tp;
     3738          while (s < p)
     3739            {
     3740              if (s[0] == '\\' && s[1] == ':')
     3741                ++s;
     3742              *(n++) = *(s++);
     3743            }
     3744          n[0] = '\0';
     3745          nlen = strlen (tp);
     3746#else
     3747          nlen = p - s;
     3748          memcpy (tp, s, nlen);
     3749          tp[nlen] = '\0';
     3750#endif
     3751        }
     3752
     3753      /* At this point, TP points to the element and NLEN is its length.  */
     3754
     3755#ifndef NO_ARCHIVES
     3756      /* If this is the start of an archive group that isn't complete, set up
     3757         to add the archive prefix for future files.  A file list like:
     3758         "libf.a(x.o y.o z.o)" needs to be expanded as:
     3759         "libf.a(x.o) libf.a(y.o) libf.a(z.o)"
     3760
     3761         TP == TMP means we're not already in an archive group.  Ignore
     3762         something starting with `(', as that cannot actually be an
     3763         archive-member reference (and treating it as such results in an empty
     3764         file name, which causes much lossage).  Also if it ends in ")" then
     3765         it's a complete reference so we don't need to treat it specially.
     3766
     3767         Finally, note that archive groups must end with ')' as the last
     3768         character, so ensure there's some word ending like that before
     3769         considering this an archive group.  */
     3770      if (! (flags & PARSEFS_NOAR)
     3771          && tp == tmpbuf && tp[0] != '(' && tp[nlen-1] != ')')
     3772        {
     3773          char *n = strchr (tp, '(');
     3774          if (n)
     3775            {
     3776              /* This looks like the first element in an open archive group.
     3777                 A valid group MUST have ')' as the last character.  */
     3778              const char *e = p + nlen;
     3779              do
     3780                {
     3781                  e = next_token (e);
     3782                  /* Find the end of this word.  We don't want to unquote and
     3783                     we don't care about quoting since we're looking for the
     3784                     last char in the word. */
     3785                  while (*e != '\0' && *e != stopchar && *e != VMS_COMMA
     3786                         && ! isblank ((unsigned char) *e))
     3787                    ++e;
     3788                  if (e[-1] == ')')
     3789                    {
     3790                      /* Found the end, so this is the first element in an
     3791                         open archive group.  It looks like "lib(mem".
     3792                         Reset TP past the open paren.  */
     3793                      nlen -= (n + 1) - tp;
     3794                      tp = n + 1;
     3795
     3796                      /* If we have just "lib(", part of something like
     3797                         "lib( a b)", go to the next item.  */
     3798                      if (! nlen)
     3799                        continue;
     3800
     3801                      /* We can stop looking now.  */
     3802                      break;
     3803                    }
     3804                }
     3805              while (*e != '\0');
     3806            }
     3807        }
     3808
     3809      /* If we are inside an archive group, make sure it has an end.  */
     3810      if (tp > tmpbuf)
     3811        {
     3812          if (tp[nlen-1] == ')')
     3813            {
     3814              /* This is the natural end; reset TP.  */
     3815              tp = tmpbuf;
     3816
     3817              /* This is just ")", something like "lib(a b )": skip it.  */
     3818              if (nlen == 1)
     3819                continue;
     3820            }
     3821          else
     3822            {
     3823              /* Not the end, so add a "fake" end.  */
     3824              tp[nlen++] = ')';
     3825              tp[nlen] = '\0';
     3826            }
     3827        }
     3828#endif
     3829
     3830      /* If we're not globbing we're done: add it to the end of the chain.
     3831         Go to the next item in the string.  */
     3832      if (flags & PARSEFS_NOGLOB)
     3833        {
     3834          NEWELT (concat (2, prefix, tp));
     3835          continue;
     3836        }
     3837
     3838      /* If we get here we know we're doing glob expansion.
     3839         TP is a string in tmpbuf.  NLEN is no longer used.
     3840         We may need to do more work: after this NAME will be set.  */
     3841      name = tp;
     3842
     3843      /* Expand tilde if applicable.  */
     3844      if (tp[0] == '~')
     3845        {
     3846          tildep = tilde_expand (tp);
     3847          if (tildep != 0)
     3848            name = tildep;
    40083849        }
    40093850
    40103851#ifndef NO_ARCHIVES
    4011       if (ar_name (gname))
     3852      /* If NAME is an archive member reference replace it with the archive
     3853         file name, and save the member name in MEMNAME.  We will glob on the
     3854         archive name and then reattach MEMNAME later.  */
     3855      if (! (flags & PARSEFS_NOAR) && ar_name (name))
    40123856        {
    4013           /* OLD->name is an archive member reference.  Replace it with the
    4014              archive file name, and save the member name in MEMNAME.  We will
    4015              glob on the archive name and then reattach MEMNAME later.  */
    4016           ar_parse_name (gname, &arname, &memname);
    4017           gname = arname;
     3857          ar_parse_name (name, &arname, &memname);
     3858          name = arname;
    40183859        }
    40193860#endif /* !NO_ARCHIVES */
    40203861
    4021 #if defined(KMK) || defined(__EMX__) /* speed optimization */
    4022       if (!strpbrk(gname, "*?["))
    4023         {
    4024           gl.gl_pathc = 1;
    4025           gl.gl_pathv = (char **)&gname;
    4026           rc = 0;
    4027         }
    4028       else
    4029         rc = glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl);
    4030       switch (rc)
    4031 #else
    4032       switch (glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl))
    4033 #endif
     3862      switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
    40343863        {
    4035         case 0:                 /* Success.  */
    4036           {
    4037             int i = gl.gl_pathc;
    4038             while (i-- > 0)
    4039               {
    4040 #ifndef NO_ARCHIVES
    4041                 if (memname != 0)
    4042                   {
    4043                     /* Try to glob on MEMNAME within the archive.  */
    4044                     struct nameseq *found
    4045                       = ar_glob (gl.gl_pathv[i], memname, size);
    4046                     if (! found)
    4047                       {
    4048                         /* No matches.  Use MEMNAME as-is.  */
    4049                         unsigned int alen = strlen (gl.gl_pathv[i]);
    4050                         unsigned int mlen = strlen (memname);
    4051                         char *name;
    4052                         struct nameseq *elt = xmalloc (size);
    4053                         memset (elt, '\0', size);
    4054 
    4055                         name = alloca (alen + 1 + mlen + 2);
    4056                         memcpy (name, gl.gl_pathv[i], alen);
    4057                         name[alen] = '(';
    4058                         memcpy (name+alen+1, memname, mlen);
    4059                         name[alen + 1 + mlen] = ')';
    4060                         name[alen + 1 + mlen + 1] = '\0';
    4061                         elt->name = strcache_add (name);
    4062                         elt->next = new;
    4063                         new = elt;
    4064                       }
    4065                     else
    4066                       {
    4067                         /* Find the end of the FOUND chain.  */
    4068                         struct nameseq *f = found;
    4069                         while (f->next != 0)
    4070                           f = f->next;
    4071 
    4072                         /* Attach the chain being built to the end of the FOUND
    4073                            chain, and make FOUND the new NEW chain.  */
    4074                         f->next = new;
    4075                         new = found;
    4076                       }
    4077                   }
    4078                 else
    4079 #endif /* !NO_ARCHIVES */
    4080                   {
    4081 #ifndef CONFIG_WITH_ALLOC_CACHES
    4082                     struct nameseq *elt = xmalloc (size);
    4083                     memset (elt, '\0', size);
    4084 #else
    4085                     struct nameseq *elt = alloccache_calloc (cache);
    4086 #endif
    4087                     elt->name = strcache_add (gl.gl_pathv[i]);
    4088                     elt->next = new;
    4089                     new = elt;
    4090                   }
    4091               }
    4092 #if defined(KMK) || defined(__EMX__) /* speed optimization */
    4093             if (gl.gl_pathv != (char **)&gname)
    4094 #endif
    4095             globfree (&gl);
    4096 #ifndef CONFIG_WITH_ALLOC_CACHES
    4097             free (old);
    4098 #else
    4099             alloccache_free (cache, old);
    4100 #endif
    4101             break;
    4102           }
    4103 
    41043864        case GLOB_NOSPACE:
    41053865          fatal (NILF, _("virtual memory exhausted"));
    4106           break;
     3866
     3867        case 0:
     3868          /* Success.  */
     3869          i = gl.gl_pathc;
     3870          nlist = (const char **)gl.gl_pathv;
     3871          break;
     3872
     3873        case GLOB_NOMATCH:
     3874          /* If we want only existing items, skip this one.  */
     3875          if (flags & PARSEFS_EXISTS)
     3876            {
     3877              i = 0;
     3878              break;
     3879            }
     3880          /* FALLTHROUGH */
    41073881
    41083882        default:
    4109           old->next = new;
    4110           new = old;
    4111           break;
     3883          /* By default keep this name.  */
     3884          i = 1;
     3885          nlist = &name;
     3886          break;
    41123887        }
     3888
     3889      /* For each matched element, add it to the list.  */
     3890      while (i-- > 0)
     3891#ifndef NO_ARCHIVES
     3892        if (memname != 0)
     3893          {
     3894            /* Try to glob on MEMNAME within the archive.  */
     3895            struct nameseq *found = ar_glob (nlist[i], memname, size);
     3896            if (! found)
     3897              /* No matches.  Use MEMNAME as-is.  */
     3898              NEWELT (concat (5, prefix, nlist[i], "(", memname, ")"));
     3899            else
     3900              {
     3901                /* We got a chain of items.  Attach them.  */
     3902                (*newp)->next = found;
     3903
     3904                /* Find and set the new end.  Massage names if necessary.  */
     3905                while (1)
     3906                  {
     3907                    if (! cachep)
     3908                      found->name = xstrdup (concat (2, prefix, name));
     3909                    else if (prefix)
     3910                      found->name = strcache_add (concat (2, prefix, name));
     3911
     3912                    if (found->next == 0)
     3913                      break;
     3914
     3915                    found = found->next;
     3916                  }
     3917                newp = &found->next;
     3918              }
     3919          }
     3920        else
     3921#endif /* !NO_ARCHIVES */
     3922          NEWELT (concat (2, prefix, nlist[i]));
     3923
     3924        globfree (&gl);
    41133925
    41143926#ifndef NO_ARCHIVES
     
    41163928        free (arname);
    41173929#endif
     3930
     3931      if (tildep)
     3932        free (tildep);
    41183933    }
    41193934
     3935  *stringp = p;
    41203936  return new;
    41213937}
  • trunk/src/kmk/readme.vms

    r1993 r2591  
    11This is the VMS version of GNU Make, updated by Hartmut Becker
    22
    3 Changes are based on GNU make 3.80. Latest changes are for OpenVMS/I64
    4 and new VMS CRTLs.
    5 
    6 This version was tested on OpenVMS/I64 V8.2 (field test) with hp C
    7 X7.1-024 OpenVMS/Alpha V7.3-2 with Compaq C V6.5-001 and OpenVMS/VAX 7.1
    8 with Compaq C V6.2-003 There are still some warning and informational
    9 message issued by the compilers.
     3Changes are based on GNU make 3.82.
     4
     5This version was built and tested on OpenVMS V7.3 (VAX), V7.3-2 (Alpha) and
     6V8.3-1H1 (I64).
    107
    118Build instructions
    129Make a 1st version
    13        $ @makefile.com
     10       $ @makefile.com  ! ignore any compiler and/or linker warning
    1411       $ rena make.exe 1st-make.exe
    1512Use the 1st version to generate a 2nd version
     
    2118       $ mc sys$disk:[]2nd-make
    2219
    23 Changes:
     20Changes (3.81.90)
     21
     22Michael Gehre (at VISTEC-SEMI dot COM) supplied a fix for a problem with
     23timestamps of object modules in OLBs. The timestamps were not correctly
     24adjusted to GMT based time, if the local VMS time was using a daylight saving
     25algorithm and if daylight saving was switched off.
     26
     27John Eisenbraun (at HP dot COM) supplied fixes and and an enhancement to append
     28output redirection in action lines.
     29
     30Rework of ctrl+c and ctrl+y handling.
     31
     32Fix a problem with cached strings, which showed on case-insensitive file
     33systems.
     34
     35Build fixes for const-ified code in VMS specific sources.
     36
     37Build notes:
     38- Try to avoid HP C V7.2-001, which has an incompatible change
     39how __STDC__ is defined. This results at least in compile time warnings.
     40
     41- On V8.3-1H1, if you press Ctrl+C you may see a traceback, starting with
     42%SYSTEM-F-CONTROLC, operation completed under CTRL/C
     43%TRACE-F-TRACEBACK, symbolic stack dump follows
     44image     module    routine               line      rel PC           abs PC
     45
     46DECC$SHR  C$SIGNAL  gsignal              27991 0000000000001180
     47FFFFFFFF84AB2DA0
     48DECC$SHR  C$SIGNAL  raise                28048 0000000000001280
     49FFFFFFFF84AB2EA0
     50DECC$SHR  C$SIGPENDING  decc$$deliver_signals
     51                                         12475 0000000000000890
     52FFFFFFFF84C13690
     53...
     54This looks like an incompatibility to the Alpha and VAX behavior, so it looks
     55like a problem in I64 VMS version(s).
     56
     57- There is no clean build on VAX. In the environment I tested, I had to use GNU
     58make's alloca which produced a couple of compile time warnings. It seems too
     59much effort to work on a clean build on VAX.
     60
     61A note on appending the redirected output. With this change, a simple mechanism
     62is implemented to make ">>" work in action lines. In VMS there is no simple
     63feature like ">>" to have DCL command or program output redirected and appended
     64to a file. GNU make for VMS already implements the redirection of output. If
     65such a redirection is detected, an ">" on the action line, GNU make creates a
     66DCL command procedure to execute the action and to redirect its output. Based
     67on that, now ">>" is also recognized and a similar but different command
     68procedure is created to implement the append. The main idea here is to create a
     69temporary file which collects the output and which is appended to the wanted
     70output file. Then the temporary file is deleted. This is all done in the
     71command procedure to keep changes in make small and simple. This obviously has
     72some limitations but it seems good enough compared with the current ">"
     73implementation. (And in my opinion, redirection is not really what GNU make has
     74to do.) With this approach, it may happen that the temporary file is not yet
     75appended and is left in SYS$SCRATCH. The temporary file names look like
     76"CMDxxxxx.". Any time the created command procedure can not complete, this
     77happens. Pressing Ctrl+Y to abort make is one case. In case of Ctrl+Y the
     78associated command procedure is left in SYS$SCRATCH as well. Its name is
     79CMDxxxxx.COM.
     80
     81Change in the Ctrl+Y handling
     82
     83Ctrl+Y was: The CtrlY handler called $forcex for the current child.
     84
     85Ctrl+Y changed: The CtrlY handler uses $delprc to delete all children. This way
     86also actions with DCL commands will be stopped. As before Ctrl+Y then sends
     87SIGQUIT to itself, which is handled in common code.
     88
     89Change in deleteing temporary command files
     90
     91Temporary command files were deleted in the main line, after returning from the
     92vms child termination handler. If Ctrl+C was pressed, the handler is called but
     93did not return to main line.
     94
     95Now, temporary command files are deleted in the vms child termination
     96handler. That deletes the them even if a Ctrl+C was pressed.
     97
     98The behavior of pressing Ctrl+C is not changed. It still has only an effect,
     99after the current action is terminated. If that doesn't happen or takes too
     100long, Ctrl+Y should be used instead.
     101
     102
     103Changes (3.80)
    24104
    25105. In default.c define variable ARCH as IA64 for VMS on Itanium systems.
     
    300380-------------------------------------------------------------------------------
    301381Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    302 2006, 2007 Free Software Foundation, Inc.
     3822006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    303383This file is part of GNU Make.
    304384
  • trunk/src/kmk/remake.c

    r2100 r2591  
    11/* Basic dependency engine for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    9090{
    9191  int t = touch_flag, q = question_flag, n = just_print_flag;
    92   unsigned int j = job_slots;
    9392  int status = -1;
    9493
     
    142141              unsigned int ocommands_started;
    143142              int x;
     143
     144              file->dontcare = g->dontcare;
     145
    144146              check_renamed (file);
    145147              if (rebuilding_makefiles)
     
    215217              any_not_updated |= !file->updated;
    216218
     219              file->dontcare = 0;
     220
    217221              if (stop)
    218222                break;
     
    275279      question_flag = q;
    276280      just_print_flag = n;
    277       job_slots = j;
    278281    }
    279282
     
    308311  if (f->considered == considered)
    309312    {
    310       DBF (DB_VERBOSE, _("Pruning file `%s'.\n"));
    311       return f->command_state == cs_finished ? f->update_status : 0;
     313      /* Check for the case where a target has been tried and failed but
     314         the diagnostics hasn't been issued. If we need the diagnostics
     315         then we will have to continue. */
     316      if (!(f->updated && f->update_status > 0 && !f->dontcare && f->no_diag))
     317        {
     318          DBF (DB_VERBOSE, _("Pruning file `%s'.\n"));
     319          return f->command_state == cs_finished ? f->update_status : 0;
     320        }
    312321    }
    313322
     
    326335      /* If we got an error, don't bother with double_colon etc.  */
    327336      if (status != 0 && !keep_going_flag)
    328         return status;
     337        return status;
    329338
    330339      if (f->command_state == cs_running
     
    358367
    359368static void
    360 complain (const struct file *file)
     369complain (struct file *file)
    361370{
    362371  const char *msg_noparent
     
    365374    = _("%sNo rule to make target `%s', needed by `%s'%s");
    366375
     376  /* If this file has no_diag set then it means we tried to update it
     377     before in the dontcare mode and failed. The target that actually
     378     failed is not necessarily this file but could be one of its direct
     379     or indirect dependencies. So traverse this file's dependencies and
     380     find the one that actually caused the failure. */
     381
     382  struct dep *d;
     383
     384  for (d = file->deps; d != 0; d = d->next)
     385    {
     386      if (d->file->updated && d->file->update_status > 0 && file->no_diag)
     387        {
     388          complain (d->file);
     389          break;
     390        }
     391    }
     392
     393  if (d == 0)
     394    {
     395      /* Didn't find any dependencies to complain about. */
     396
    367397#ifdef KMK
    368   /* jokes */
    369   if (!keep_going_flag && file->parent == 0)
    370     {
    371       const char *msg_joke = 0;
    372       extern struct dep *goals;
    373 
    374       /* classics */
    375       if (!strcmp (file->name, "fire")
    376        || !strcmp (file->name, "Fire"))
    377         msg_joke = "No matches.\n";
    378       else if (!strcmp (file->name, "love")
    379             || !strcmp (file->name, "Love")
    380             || !strcmp (file->name, "peace")
    381             || !strcmp (file->name, "Peace"))
    382         msg_joke = "Not war.\n";
    383       else if (!strcmp (file->name, "war"))
    384         msg_joke = "Don't know how to make war.\n";
    385 
    386       /* http://xkcd.com/149/ - GNU Make bug #23273. */
    387       else if ((   !strcmp (file->name, "me")
    388                 && goals != 0
    389                 && !strcmp (dep_name(goals), "me")
    390                 && goals->next != 0
    391                 && !strcmp (dep_name(goals->next), "a")
    392                 && goals->next->next != 0)
    393             || !strncmp (file->name, "me a ", 5))
    394         msg_joke =
     398      /* jokes */
     399      if (!keep_going_flag && file->parent == 0)
     400        {
     401          const char *msg_joke = 0;
     402          extern struct dep *goals;
     403
     404          /* classics */
     405          if (!strcmp (file->name, "fire")
     406           || !strcmp (file->name, "Fire"))
     407            msg_joke = "No matches.\n";
     408          else if (!strcmp (file->name, "love")
     409                || !strcmp (file->name, "Love")
     410                || !strcmp (file->name, "peace")
     411                || !strcmp (file->name, "Peace"))
     412            msg_joke = "Not war.\n";
     413          else if (!strcmp (file->name, "war"))
     414            msg_joke = "Don't know how to make war.\n";
     415
     416          /* http://xkcd.com/149/ - GNU Make bug #23273. */
     417          else if ((   !strcmp (file->name, "me")
     418                    && goals != 0
     419                    && !strcmp (dep_name(goals), "me")
     420                    && goals->next != 0
     421                    && !strcmp (dep_name(goals->next), "a")
     422                    && goals->next->next != 0)
     423                || !strncmp (file->name, "me a ", 5))
     424            msg_joke =
    395425# ifdef HAVE_UNISTD_H
    396426                   getuid () == 0 ? "Okay.\n" :
    397427# endif
    398                    "What? Make it yourself!\n";
    399       if (msg_joke)
     428                       "What? Make it yourself!\n";
     429          if (msg_joke)
     430            {
     431              fputs (msg_joke, stderr);
     432              die (2);
     433            }
     434        }
     435#endif /* KMK */
     436
     437      if (!keep_going_flag)
    400438        {
    401           fputs (msg_joke, stderr);
    402           die (2);
     439          if (file->parent == 0)
     440            fatal (NILF, msg_noparent, "", file->name, "");
     441
     442          fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
    403443        }
    404     }
    405 #endif /* KMK */
    406 
    407   if (!keep_going_flag)
    408     {
     444
    409445      if (file->parent == 0)
    410         fatal (NILF, msg_noparent, "", file->name, "");
    411 
    412       fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
    413     }
    414 
    415   if (file->parent == 0)
    416     error (NILF, msg_noparent, "*** ", file->name, ".");
    417   else
    418     error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
     446        error (NILF, msg_noparent, "*** ", file->name, ".");
     447      else
     448        error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
     449
     450      file->no_diag = 0;
     451    }
    419452}
    420453
     
    424457update_file_1 (struct file *file, unsigned int depth)
    425458{
    426   register FILE_TIMESTAMP this_mtime;
     459  FILE_TIMESTAMP this_mtime;
    427460  int noexist, must_make, deps_changed;
    428461  int dep_status = 0;
    429   register struct dep *d, *lastd;
     462  struct file *ofile;
     463  struct dep *d, *ad;
     464  struct dep amake;
    430465  int running = 0;
    431466#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     467  struct file *org_file = file;
    432468  struct file *f2, *f3;
    433469
     
    438474      DBS (DB_VERBOSE, (_("Considering target file `%s' -> multi head `%s'.\n"),
    439475                          file->name, file->multi_head->name));
    440       file = file->multi_head;
     476      org_file = file = file->multi_head;
    441477    }
    442478  else
     
    451487               _("Recently tried and failed to update file `%s'.\n"));
    452488
    453           /* If the file we tried to make is marked dontcare then no message
     489          /* If the file we tried to make is marked no_diag then no message
    454490             was printed about it when it failed during the makefile rebuild.
    455491             If we're trying to build it again in the normal rebuild, print a
    456492             message now.  */
    457           if (file->dontcare && !rebuilding_makefiles)
    458             {
    459               file->dontcare = 0;
     493          if (file->no_diag && !file->dontcare)
    460494              complain (file);
    461             }
    462495
    463496          return file->update_status;
     
    483516    }
    484517
     518  /* Determine whether the diagnostics will be issued should this update
     519     fail. */
     520  file->no_diag = file->dontcare;
     521
    485522  ++depth;
    486523
    487524  /* Notice recursive update of the same file.  */
    488525  start_updating (file);
     526
     527  /* We might change file if we find a different one via vpath;
     528     remember this one to turn off updating.  */
     529  ofile = file;
    489530
    490531  /* Looking at the file's modtime beforehand allows the possibility
     
    554595    }
    555596
    556   /* Update all non-intermediate files we depend on, if necessary,
    557      and see whether any of them is more recent than this file.
    558      For explicit multitarget rules we must iterate all the output
     597  /* Update all non-intermediate files we depend on, if necessary, and see
     598     whether any of them is more recent than this file.  We need to walk our
     599     deps, AND the deps of any also_make targets to ensure everything happens
     600     in the correct order.
     601
     602     bird: For explicit multitarget rules we must iterate all the output
    559603     files to get the correct picture.  The special .MUST_MAKE
    560      target variable call is also done from this context.  */
     604     target variable call is also done from this context. */
    561605
    562606#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    563   for (f2 = file; f2; f2 = f2->multi_next)
    564     {
    565       lastd = 0;
    566       d = f2->deps;
    567 #else
    568       lastd = 0;
    569       d = file->deps;
    570 #endif
    571       while (d != 0)
     607 assert (file == org_file);
     608 for (f2 = file; f2; file = f2 = f2->multi_next)
     609 {
     610#endif
     611  amake.file = file;
     612  amake.next = file->also_make;
     613  ad = &amake;
     614  while (ad)
     615    {
     616      struct dep *lastd = 0;
     617
     618      /* Find the deps we're scanning */
     619      d = ad->file->deps;
     620      ad = ad->next;
     621
     622      while (d)
    572623        {
    573624          FILE_TIMESTAMP mtime;
     
    584635#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    585636              /* silently ignore the order-only dep hack. */
    586               if (f2->multi_maybe && d->file == file)
     637              if (file->multi_maybe && d->file == org_file)
    587638                {
    588639                  lastd = d;
     
    593644
    594645              error (NILF, _("Circular %s <- %s dependency dropped."),
    595 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    596                      f2->name, d->file->name);
    597 #else
    598646                     file->name, d->file->name);
    599 #endif
    600647              /* We cannot free D here because our the caller will still have
    601648                 a reference to it when we were called recursively via
    602649                 check_dep below.  */
    603650              if (lastd == 0)
    604 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    605                 f2->deps = d->next;
    606 #else
    607651                file->deps = d->next;
    608 #endif
    609652              else
    610653                lastd->next = d->next;
     
    613656            }
    614657
    615 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    616           d->file->parent = f2;
    617 #else
    618658          d->file->parent = file;
    619 #endif
    620659          maybe_make = must_make;
    621660
     
    626665              d->file->dontcare = file->dontcare;
    627666            }
    628 
    629667
    630668          dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
     
    664702          d = d->next;
    665703        }
     704    }
    666705
    667706#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    668       if (dep_status != 0 && !keep_going_flag)
    669         break;
    670     }
     707    if (dep_status != 0 && !keep_going_flag)
     708      break;
     709  }
     710  file = org_file;
    671711#endif
    672712
     
    677717# ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    678718  if (!must_make)
    679     for (f2 = file; f2 && !must_make; f2 = f2->multi_next)
     719    for (f2 = org_file; f2 && !must_make; f2 = f2->multi_next)
    680720      must_make = call_must_make_target_var (f2, depth);
    681721# else
     
    691731    {
    692732#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    693       for (f2 = file; f2; f2 = f2->multi_next)
    694         for (d = f2->deps; d != 0; d = d->next)
    695 #else
     733      for (file = f2 = org_file; f2; file = f2 = f2->multi_next)
     734#endif
    696735        for (d = file->deps; d != 0; d = d->next)
    697 #endif
    698736          if (d->file->intermediate)
    699737            {
     
    702740              FILE_TIMESTAMP mtime = file_mtime (d->file);
    703741              check_renamed (d->file);
    704 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    705               d->file->parent = f2;
    706 #else
    707742              d->file->parent = file;
    708 #endif
    709743
    710744              /* Inherit dontcare flag from our parent. */
     
    741775
    742776              if (!running)
    743 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    744                 d->changed = ((f2->phony && f2->cmds != 0)
    745 #else
    746777                d->changed = ((file->phony && file->cmds != 0)
    747 #endif
    748778                            || file_mtime (d->file) != mtime);
    749779            }
     780#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     781      file = org_file;
     782#endif
    750783    }
    751784
    752785  finish_updating (file);
     786  finish_updating (ofile);
    753787
    754788  DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));
     
    797831  deps_changed = 0;
    798832#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    799   for (f2 = file; f2; f2 = f2->multi_next)
     833  for (file = f2 = org_file; f2; file = f2 = f2->multi_next)
    800834#endif
    801835    for (d = file->deps; d != 0; d = d->next)
     
    803837        FILE_TIMESTAMP d_mtime = file_mtime (d->file);
    804838#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
    805         if (d->file == file && f2->multi_maybe)
     839        if (d->file == file && file->multi_maybe)
    806840          continue;
    807841#endif
     
    858892          }
    859893      }
     894#ifdef CONFIG_WITH_EXPLICIT_MULTITARGET
     895  file = org_file;
     896#endif
    860897
    861898  /* Here depth returns to the value it had when we were called.  */
     
    11701207         would have been updated. */
    11711208
    1172       if (question_flag || just_print_flag || touch_flag)
     1209      if ((question_flag || just_print_flag || touch_flag) && file->cmds)
    11731210        {
    11741211          for (i = file->cmds->ncommand_lines; i > 0; --i)
     
    12781315           FILE_TIMESTAMP this_mtime, int *must_make_ptr)
    12791316{
     1317  struct file *ofile;
    12801318  struct dep *d;
    12811319  int dep_status = 0;
     
    12831321  ++depth;
    12841322  start_updating (file);
     1323
     1324  /* We might change file if we find a different one via vpath;
     1325     remember this one to turn off updating.  */
     1326  ofile = file;
    12851327
    12861328  if (file->phony || !file->intermediate)
     
    13331375             necessary, and see whether any of them is more recent than the
    13341376             file on whose behalf we are checking.  */
    1335           struct dep *lastd;
     1377          struct dep *ld;
    13361378          int deps_running = 0;
    13371379
    1338           /* Reset this target's state so that we check it fresh.  It could be
    1339              that it's already been checked as part of an order-only
    1340              prerequisite and so wasn't rebuilt then, but should be now.
    1341 
    1342              bird: What if we're already running the recipe?  We don't wish
    1343                    it to be started once again do we?  This happens with the
    1344                    SECONDARY Test #9 here now... If the idea is to re-evaluate
    1345                    the target regardless of whether it's running or no, then
    1346                    perhaps saving and restoring is a better idea?
    1347                    See bug #15919.  */
    1348           if (file->command_state != cs_running) /* bird */
     1380          /* If this target is not running, set it's state so that we check it
     1381             fresh.  It could be it was checked as part of an order-only
     1382             prerequisite and so wasn't rebuilt then, but should be now.  */
     1383          if (file->command_state != cs_running)
    13491384            set_command_state (file, cs_not_started);
    13501385
    1351           lastd = 0;
     1386          ld = 0;
    13521387          d = file->deps;
    13531388          while (d != 0)
     
    13591394                  error (NILF, _("Circular %s <- %s dependency dropped."),
    13601395                         file->name, d->file->name);
    1361                   if (lastd == 0)
     1396                  if (ld == 0)
    13621397                    {
    13631398                      file->deps = d->next;
     
    13671402                  else
    13681403                    {
    1369                       lastd->next = d->next;
     1404                      ld->next = d->next;
    13701405                      free_dep (d);
    1371                       d = lastd->next;
     1406                      d = ld->next;
    13721407                    }
    13731408                  continue;
     
    13881423                deps_running = 1;
    13891424
    1390               lastd = d;
     1425              ld = d;
    13911426              d = d->next;
    13921427            }
     
    14011436
    14021437  finish_updating (file);
     1438  finish_updating (ofile);
     1439
    14031440  return dep_status;
    14041441}
     
    15881625        {
    15891626          /* If name_mtime failed, search VPATH.  */
    1590           const char *name = vpath_search (file->name, &mtime);
     1627          const char *name = vpath_search (file->name, &mtime, NULL, NULL);
    15911628          if (name
    15921629              /* Last resort, is it a library (-lxxx)?  */
     
    18391876    };
    18401877
    1841   static char *libpatterns = NULL;
    1842 
    1843   const char *libname = lib+2;  /* Name without the '-l'.  */
     1878  const char *file = 0;
     1879  char *libpatterns;
    18441880  FILE_TIMESTAMP mtime;
    18451881
     
    18481884  const char *p2;
    18491885  unsigned int len;
     1886  unsigned int liblen;
     1887
     1888  /* Information about the earliest (in the vpath sequence) match.  */
     1889  unsigned int best_vpath = 0, best_path = 0; /* bird: gcc maybe used uninitialized (both) */
     1890  unsigned int std_dirs = 0;
    18501891
    18511892  char **dp;
    18521893
    1853   /* If we don't have libpatterns, get it.  */
    1854   if (!libpatterns)
    1855     {
    1856       int save = warn_undefined_variables_flag;
    1857       warn_undefined_variables_flag = 0;
    1858 
    1859       libpatterns = xstrdup (variable_expand ("$(strip $(.LIBPATTERNS))"));
    1860 
    1861       warn_undefined_variables_flag = save;
    1862     }
    1863 
    1864   /* Loop through all the patterns in .LIBPATTERNS, and search on each one.  */
     1894  libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)"));
     1895
     1896  /* Skip the '-l'.  */
     1897  lib += 2;
     1898  liblen = strlen (lib);
     1899
     1900  /* Loop through all the patterns in .LIBPATTERNS, and search on each one.
     1901     To implement the linker-compatible behavior we have to search through
     1902     all entries in .LIBPATTERNS and choose the "earliest" one.  */
    18651903  p2 = libpatterns;
    18661904  while ((p = find_next_token (&p2, &len)) != 0)
     
    18721910      const size_t libbuf_offset = libbuf - variable_buffer; /* bird */
    18731911
    1874       /* Expand the pattern using LIBNAME as a replacement.  */
     1912      /* Expand the pattern using LIB as a replacement.  */
    18751913      {
    18761914        char c = p[len];
     
    18811919        if (!p3)
    18821920          {
    1883             /* Give a warning if there is no pattern, then remove the
    1884                pattern so it's ignored next time.  */
     1921            /* Give a warning if there is no pattern.  */
    18851922            error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p);
    1886             for (; len; --len, ++p)
    1887               *p = ' ';
    1888             *p = c;
     1923            p[len] = c;
    18891924            continue;
    18901925          }
    18911926        p4 = variable_buffer_output (libbuf, p, p3-p);
    1892         p4 = variable_buffer_output (p4, libname, strlen (libname));
     1927        p4 = variable_buffer_output (p4, lib, liblen);
    18931928        p4 = variable_buffer_output (p4, p3+1, len - (p3-p));
    18941929        p[len] = c;
     
    19021937          if (mtime_ptr != 0)
    19031938            *mtime_ptr = mtime;
    1904           return strcache_add (libbuf);
     1939          file = strcache_add (libbuf);
     1940          /* This by definition will have the best index, so stop now.  */
     1941          break;
    19051942        }
    19061943
     
    19081945
    19091946      {
    1910         const char *file = vpath_search (libbuf, mtime_ptr);
    1911         if (file)
    1912           return file;
     1947        unsigned int vpath_index, path_index;
     1948        const char* f = vpath_search (libbuf, mtime_ptr ? &mtime : NULL,
     1949                                      &vpath_index, &path_index);
     1950        if (f)
     1951          {
     1952            /* If we have a better match, record it.  */
     1953            if (file == 0 ||
     1954                vpath_index < best_vpath ||
     1955                (vpath_index == best_vpath && path_index < best_path))
     1956              {
     1957                file = f;
     1958                best_vpath = vpath_index;
     1959                best_path = path_index;
     1960
     1961                if (mtime_ptr != 0)
     1962                  *mtime_ptr = mtime;
     1963              }
     1964          }
    19131965      }
    19141966
     
    19161968
    19171969      if (!buflen)
    1918         {
    1919           for (dp = dirs; *dp != 0; ++dp)
    1920             {
    1921               int l = strlen (*dp);
    1922               if (l > libdir_maxlen)
    1923                 libdir_maxlen = l;
    1924             }
    1925           buflen = strlen (libbuf);
    1926           buf = xmalloc(libdir_maxlen + buflen + 2);
    1927         }
     1970        {
     1971          for (dp = dirs; *dp != 0; ++dp)
     1972            {
     1973              int l = strlen (*dp);
     1974              if (l > libdir_maxlen)
     1975                libdir_maxlen = l;
     1976              std_dirs++;
     1977            }
     1978          buflen = strlen (libbuf);
     1979          buf = xmalloc(libdir_maxlen + buflen + 2);
     1980        }
    19281981      else if (buflen < strlen (libbuf))
    1929         {
    1930           buflen = strlen (libbuf);
    1931           buf = xrealloc (buf, libdir_maxlen + buflen + 2);
    1932         }
    1933 
    1934       for (dp = dirs; *dp != 0; ++dp)
    1935         {
    1936           sprintf (buf, "%s/%s", *dp, libbuf);
    1937           mtime = name_mtime (buf);
    1938           if (mtime != NONEXISTENT_MTIME)
    1939             {
    1940               if (mtime_ptr != 0)
    1941                 *mtime_ptr = mtime;
    1942               return strcache_add (buf);
    1943             }
    1944         }
    1945     }
    1946 
    1947   return 0;
     1982        {
     1983          buflen = strlen (libbuf);
     1984          buf = xrealloc (buf, libdir_maxlen + buflen + 2);
     1985        }
     1986
     1987      {
     1988        /* Use the last std_dirs index for standard directories. This
     1989           was it will always be greater than the VPATH index.  */
     1990        unsigned int vpath_index = ~((unsigned int)0) - std_dirs;
     1991
     1992        for (dp = dirs; *dp != 0; ++dp)
     1993          {
     1994            sprintf (buf, "%s/%s", *dp, libbuf);
     1995            mtime = name_mtime (buf);
     1996            if (mtime != NONEXISTENT_MTIME)
     1997              {
     1998                if (file == 0 || vpath_index < best_vpath)
     1999                  {
     2000                    file = strcache_add (buf);
     2001                    best_vpath = vpath_index;
     2002
     2003                    if (mtime_ptr != 0)
     2004                      *mtime_ptr = mtime;
     2005                  }
     2006              }
     2007
     2008            vpath_index++;
     2009          }
     2010      }
     2011
     2012    }
     2013
     2014  free (libpatterns);
     2015  return file;
    19482016}
  • trunk/src/kmk/remote-cstms.c

    r1993 r2591  
    55
    66Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    7 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    8 Foundation, Inc.
     71998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     82010 Free Software Foundation, Inc.
    99This file is part of GNU Make.
    1010
  • trunk/src/kmk/remote-stub.c

    r1993 r2591  
    11/* Template for the remote job exportation interface to GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
  • trunk/src/kmk/rule.c

    r2137 r2591  
    11/* Pattern and suffix rule internals for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    9797      for (dep = rule->deps; dep != 0; dep = dep->next)
    9898        {
    99           unsigned int len = strlen (dep->name);
     99          const char *dname = dep_name (dep);
     100          unsigned int len = strlen (dname);
    100101
    101102#ifdef VMS
    102           const char *p = strrchr (dep->name, ']');
     103          const char *p = strrchr (dname, ']');
    103104          const char *p2;
    104105          if (p == 0)
    105             p = strrchr (dep->name, ':');
    106           p2 = p != 0 ? strchr (dep->name, '%') : 0;
     106            p = strrchr (dname, ':');
     107          p2 = p != 0 ? strchr (dname, '%') : 0;
    107108#else
    108           const char *p = strrchr (dep->name, '/');
    109           const char *p2 = p != 0 ? strchr (dep->name, '%') : 0;
     109          const char *p = strrchr (dname, '/');
     110          const char *p2 = p != 0 ? strchr (dname, '%') : 0;
    110111#endif
    111           ndeps++;
     112          ndeps++;
    112113
    113114          if (len > max_pattern_dep_length)
     
    118119              /* There is a slash before the % in the dep name.
    119120                 Extract the directory name.  */
    120               if (p == dep->name)
     121              if (p == dname)
    121122                ++p;
    122               if (p - dep->name > namelen)
     123              if (p - dname > namelen)
    123124                {
    124                   namelen = p - dep->name;
     125                  namelen = p - dname;
    125126                  name = xrealloc (name, namelen + 1);
    126127                }
    127               memcpy (name, dep->name, p - dep->name);
    128               name[p - dep->name] = '\0';
     128              memcpy (name, dname, p - dname);
     129              name[p - dname] = '\0';
    129130
    130131              /* In the deps of an implicit rule the `changed' flag
     
    380381
    381382  ptr = p->dep;
    382 #ifndef CONFIG_WITH_ALLOC_CACHES
    383   r->deps = (struct dep *) multi_glob (parse_file_seq (&ptr, '\0',
    384                                                        sizeof (struct dep), 1),
    385                                        sizeof (struct dep));
    386 #else
    387   r->deps = (struct dep *) multi_glob (parse_file_seq (&ptr, '\0',
    388                                                        &dep_cache, 1),
    389                                        &dep_cache);
    390 #endif
     383  r->deps = PARSE_FILE_SEQ (&ptr, struct dep, '\0', NULL, 0);
    391384
    392385  if (new_pattern_rule (r, 0))
     
    419412{
    420413  struct rule *next = rule->next;
    421   struct dep *dep;
    422 
    423   dep = rule->deps;
    424   while (dep)
    425     {
    426       struct dep *t = dep->next;
    427       free_dep (dep);
    428       dep = t;
    429     }
    430 
    431   free (rule->targets);
    432   free (rule->suffixes);
     414
     415  free_dep_chain (rule->deps);
     416
     417  /* MSVC erroneously warns without a cast here.  */
     418  free ((void *)rule->targets);
     419  free ((void *)rule->suffixes);
    433420  free (rule->lens);
    434421
     
    505492{
    506493  unsigned int i;
    507   struct dep *d;
    508494
    509495  for (i = 0; i < r->num; ++i)
     
    515501    putchar (':');
    516502
    517   for (d = r->deps; d != 0; d = d->next)
    518     printf (" %s", dep_name (d));
    519   putchar ('\n');
     503  print_prereqs (r->deps);
    520504
    521505  if (r->cmds != 0)
     
    564548         makefiles and thus count_implicit_rule_limits wasn't called yet.  */
    565549      if (num_pattern_rules != 0)
    566         fatal (NILF, _("BUG: num_pattern_rules wrong!  %u != %u"),
     550        fatal (NILF, _("BUG: num_pattern_rules is wrong!  %u != %u"),
    567551               num_pattern_rules, rules);
    568552    }
  • trunk/src/kmk/rule.h

    r1993 r2591  
    11/* Definitions for using pattern rules in GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
  • trunk/src/kmk/signame.c

    r1993 r2591  
    11/* Convert between signal names and numbers.
    22Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     32000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
     4Foundation, Inc.
    45This file is part of GNU Make.
    56
     
    229230
    230231char *
    231 strsignal (int signal)
     232strsignal (int sig)
    232233{
    233234  static char buf[] = "Signal 12345678901234567890";
     
    246247#endif
    247248
    248   if (signal > 0 || signal < NSIG)
    249     return (char *) sys_siglist[signal];
    250 
    251   sprintf (buf, "Signal %d", signal);
     249  if (sig > 0 || sig < NSIG)
     250    return (char *) sys_siglist[sig];
     251
     252  sprintf (buf, "Signal %d", sig);
    252253  return buf;
    253254}
  • trunk/src/kmk/strcache.c

    r1993 r2591  
    11/* Constant string caching for GNU Make.
    2 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
     2Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    33This file is part of GNU Make.
    44
  • trunk/src/kmk/subproc.bat

    r1993 r2591  
    11@echo off
    22rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    3 rem 2005, 2006, 2007 Free Software Foundation, Inc.
     3rem 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44rem This file is part of GNU Make.
    55rem
  • trunk/src/kmk/tests

    • Property svn:ignore
      --- 
      +++ 
      
  • trunk/src/kmk/tests/ChangeLog

    r1993 r2591  
     12010-07-28  Paul Smith  <[email protected]>
     2
     3        * scripts/targets/POSIX: Compatibility issues with Solaris (and
     4        Tru64?); "false" returns different exit codes, and set -x shows
     5        output with extra whitespace.  Run the commands by hand first to
     6        find out what the real shell would do, then compare what make does.
     7        * scripts/variables/SHELL: Ditto.
     8
     92010-07-12  Paul Smith  <[email protected]>
     10
     11        * test_driver.pl: Add a new $perl_name containing the path to Perl.
     12        * run_make_tests.pl (run_make_test): Replace the special string
     13        #PERL# in a makefile etc. with the path the Perl executable so
     14        makefiles can use it.
     15
     16        * scripts/targets/ONESHELL: Add a new set of regression tests for
     17        the .ONESHELL feature.
     18
     192010-07-06  Paul Smith  <[email protected]>
     20
     21        * scripts/variables/SHELL: Test the new .SHELLFLAGS variable.
     22
     23        * scripts/targets/POSIX: New file.  Test the .POSIX special target.
     24        Verify that enabling .POSIX changes the shell flags to set -e.
     25
     262010-07-01  Paul Smith  <[email protected]>
     27
     28        * scripts/features/recursion: Add a space to separate command-line
     29        args.  Fixes Savannah bug #29968.
     30
     312009-11-12  Boris Kolpackov  <[email protected]>
     32
     33        * scripts/features/vpath3: Test for the new library search
     34        behavior.
     35
     362009-10-06  Boris Kolpackov  <[email protected]>
     37
     38        * scripts/features/se_explicit: Enable the test for now fixed
     39        Savannah bug 25780.
     40
     412009-10-06  Boris Kolpackov  <[email protected]>
     42
     43        * scripts/variables/undefine: Tests for the new undefine feature.
     44
     452009-10-03  Paul Smith  <[email protected]>
     46
     47        * scripts/features/parallelism: Test for open Savannah bug #26846.
     48
     49        * scripts/variables/MAKE: Rewrite for new run_make_test() format.
     50
     51        * scripts/variables/MAKEFLAGS: Created.
     52        Add test for Savannah bug #2216 (still open).
     53
     54        * scripts/features/include: Test for Savannah bug #102 (still open).
     55
     562009-09-30  Boris Kolpackov  <[email protected]>
     57
     58        * scripts/features/include: Add diagnostics issuing tests for
     59        cases where targets have been updated and failed with the
     60        dontcare flag. Savannah bugs #15110, #25493, #12686, #17740.
     61
     622009-09-28  Paul Smith  <[email protected]>
     63
     64        * scripts/functions/shell: Add regression test for Savannah bug
     65        #20513 (still open).
     66
     67        * scripts/features/se_explicit: Add regression tests for Savannah
     68        bug #25780 (still open).
     69
     70        * run_make_tests.pl (valid_option): Add a new flag, -all([-_]?tests)?
     71        that runs tests we know will fail.  This allows us to add
     72        regression tests to the test suite for bugs that haven't been
     73        fixed yet.
     74
     752009-09-28  Boris Kolpackov  <[email protected]>
     76
     77        * scripts/features/patspecific_vars: Add a test for the shortest
     78        stem first order.
     79
     80        * scripts/features/patternrules: Add a test for the shortest stem
     81        first order.
     82
     832009-09-24  Paul Smith  <[email protected]>
     84
     85        * scripts/features/se_implicit: Add a test for order-only
     86        secondary expansion prerequisites.
     87
     882009-09-23  Paul Smith  <[email protected]>
     89
     90        * scripts/features/patternrules: Test that we can remove pattern
     91        rules, both single and multiple prerequisites.  Savannah bug #18622.
     92
     93        * scripts/features/echoing: Rework for run_make_test().
     94
     952009-06-14  Paul Smith  <[email protected]>
     96
     97        * scripts/features/vpath: Verify we don't get bogus circular
     98        dependency warnings if we choose a different file via vpath during
     99        update.  Savannah bug #13529.
     100
     1012009-06-13  Paul Smith  <[email protected]>
     102
     103        * scripts/variables/MAKEFILES: Verify that MAKEFILES included
     104        files (and files included by them) don't set the default goal.
     105        Savannah bug #13401.
     106
     107        * scripts/functions/wildcard: Test that wildcards with
     108        non-existent glob matchers return empty.
     109
     1102009-06-09  Paul Smith  <[email protected]>
     111
     112        * scripts/options/dash-B: Test the $? works correctly with -B.
     113        Savannah bug #17825.
     114
     115        * scripts/features/patternrules: Test that dependencies of
     116        "also_make" targets are created properly.  Savannah bug #19108.
     117
     118        * test_driver.pl (compare_output): Create a "run" file for failed
     119        tests containing the command that was run.
     120        (get_runfile): New function.
     121
     122        * run_make_tests.pl (valid_option): Enhanced support for valgrind:
     123        allow memcheck and massif tools.
     124
     125        * scripts/features/patternrules: Have to comment out a line in the
     126        first test due to backing out a change that broke the implicit
     127        rule search algorithm.  Savannah bug #17752.
     128        * scripts/misc/general4: Remove a test that is redundant with
     129        patternrules.
     130
     131        * scripts/features/parallelism: Add a test for re-exec with
     132        jobserver master override.  Savannah bug #18124.
     133
     1342009-06-08  Paul Smith  <[email protected]>
     135
     136        * scripts/features/targetvars: Add a test for continued target
     137        vars after a semicolon.  Savannah bug #17521.
     138
     1392009-06-07  Paul Smith  <[email protected]>
     140
     141        * scripts/features/se_explicit: Make sure we catch defining
     142        prereqs during snap_deps().  Savannah bug #24622.
     143
     144        * scripts/variables/automatic: Check prereq ordering when the
     145        target with the recipe has no prereqs.  Savannah bug #21198.
     146
     147        * scripts/variables/LIBPATTERNS: Add a new set of test for
     148        $(.LIBPATTERNS) (previously untested!)
     149
     1502009-06-04  Paul Smith  <[email protected]>
     151
     152        * scripts/variables/SHELL: The export target-specific SHELL test
     153        has an incorrect known-good-value.
     154
     155        * scripts/misc/general4: Check for whitespace (ffeed, vtab, etc.)
     156
     157        * scripts/features/se_explicit: Add tests for Savannah bug #24588.
     158
     1592009-05-31  Paul Smith  <[email protected]>
     160
     161        * scripts/variables/DEFAULT_GOAL: Add tests for Savannah bug #25697.
     162
     163        * scripts/features/targetvars: Add tests of overrides for Savannah
     164        bug #26207.
     165        * scripts/features/patspecific_vars: Ditto.
     166
     167        * scripts/features/patternrules: Add a test for Savannah bug #26593.
     168
     1692009-05-30  Paul Smith  <[email protected]>
     170
     171        * scripts/variables/flavors: Update with new variable flavor tests.
     172        * scripts/variables/define: Create a new set of tests for
     173        define/endef and move those aspects of the flavors suite here.
     174
     1752009-05-25  Paul Smith  <[email protected]>
     176
     177        * scripts/features/targetvars: Ditto.
     178
     179        * scripts/features/export: Test new variable parsing abilities.
     180
     1812009-02-23  Ramon Garcia  <[email protected]>
     182
     183        * scripts/variables/private: Create a new suite of tests for 'private'.
     184
    11852007-11-04  Paul Smith  <[email protected]>
    2186
     
    8811065
    8821066Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    883 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     10672002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    8841068This file is part of GNU Make.
    8851069
  • trunk/src/kmk/tests/NEWS

    r1993 r2591  
    165165-------------------------------------------------------------------------------
    166166Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    167 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     1672002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    168168This file is part of GNU Make.
    169169
  • trunk/src/kmk/tests/README

    r1993 r2591  
    99 -----------------------------------------------------------------------------
    1010 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    11  2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     11 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    1212 This file is part of GNU Make.
    1313
  • trunk/src/kmk/tests/mkshadow

    r1993 r2591  
    55#
    66# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    7 # 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     7# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
     8# Foundation, Inc.
    89# This file is part of GNU Make.
    910#
  • trunk/src/kmk/tests/run_make_tests.pl

    r1993 r2591  
    1313
    1414# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    15 # 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     15# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
     16# Foundation, Inc.
    1617# This file is part of GNU Make.
    1718#
     
    2930# this program.  If not, see <http://www.gnu.org/licenses/>.
    3031
     32
    3133$valgrind = 0;              # invoke make with valgrind
    32 $valgrind_args = '--num-callers=15 --tool=memcheck --leak-check=full';
     34$valgrind_args = '';
     35$memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full';
     36$massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup';
    3337$pure_log = undef;
     38
     39$command_string = '';
     40
     41$all_tests = 0;
    3442
    3543require "test_driver.pl";
     
    4452   local($option) = @_;
    4553
    46    if ($option =~ /^-make([-_]?path)?$/)
    47    {
    48       $make_path = shift @argv;
    49       if (!-f $make_path)
    50       {
    51          print "$option $make_path: Not found.\n";
    52          exit 0;
    53       }
    54       return 1;
    55    }
    56 
    57    if ($option =~ /^-valgrind$/i) {
    58      $valgrind = 1;
    59      return 1;
     54   if ($option =~ /^-make([-_]?path)?$/i) {
     55       $make_path = shift @argv;
     56       if (!-f $make_path) {
     57           print "$option $make_path: Not found.\n";
     58           exit 0;
     59       }
     60       return 1;
     61   }
     62
     63   if ($option =~ /^-all([-_]?tests)?$/i) {
     64       $all_tests = 1;
     65       return 1;
     66   }
     67
     68   if ($option =~ /^-(valgrind|memcheck)$/i) {
     69       $valgrind = 1;
     70       $valgrind_args = $memcheck_args;
     71       return 1;
     72   }
     73
     74   if ($option =~ /^-massif$/i) {
     75       $valgrind = 1;
     76       $valgrind_args = $massif_args;
     77       return 1;
    6078   }
    6179
     
    106124    $makestring =~ s/#MAKEPATH#/$mkpath/g;
    107125    $makestring =~ s/#MAKE#/$make_name/g;
     126    $makestring =~ s/#PERL#/$perl_name/g;
    108127    $makestring =~ s/#PWD#/$pwd/g;
    109128
     
    120139  $answer =~ s/#MAKEPATH#/$mkpath/g;
    121140  $answer =~ s/#MAKE#/$make_name/g;
     141  $answer =~ s/#PERL#/$perl_name/g;
    122142  $answer =~ s/#PWD#/$pwd/g;
    123143
     
    149169  }
    150170
     171  $command_string = "$command\n";
     172
    151173  if ($valgrind) {
    152174    print VALGRIND "\n\nExecuting: $command\n";
     
    156178  {
    157179      my $old_timeout = $test_timeout;
    158       $test_timeout = $timeout if $timeout;
     180      $timeout and $test_timeout = $timeout;
     181
     182      # If valgrind is enabled, turn off the timeout check
     183      $valgrind and $test_timeout = 0;
    159184
    160185      $code = &run_command_with_output($logname,$command);
     
    184209    print "Error running $make_path (expected $expected_code; got $code): $command\n";
    185210    $test_passed = 0;
     211    $runf = &get_runfile;
     212    &create_file (&get_runfile, $command_string);
    186213    # If it's a SIGINT, stop here
    187214    if ($code & 127) {
    188215      print STDERR "\nCaught signal ".($code & 127)."!\n";
    189       exit($code);
     216      ($code & 127) == 2 and exit($code);
    190217    }
    191218    return 0;
     
    196223  }
    197224
    198   1;
     225  return 1;
    199226}
    200227
     
    202229{
    203230   &print_standard_usage ("run_make_tests",
    204                           "[-make_path make_pathname] [-valgrind]",);
     231                          "[-make_path make_pathname] [-memcheck] [-massif]",);
    205232}
    206233
    207234sub print_help
    208235{
    209    &print_standard_help ("-make_path",
    210           "\tYou may specify the pathname of the copy of make to run.");
     236   &print_standard_help (
     237        "-make_path",
     238        "\tYou may specify the pathname of the copy of make to run.",
     239        "-valgrind",
     240        "-memcheck",
     241        "\tRun the test suite under valgrind's memcheck tool.",
     242        "\tChange the default valgrind args with the VALGRIND_ARGS env var.",
     243        "-massif",
     244        "\tRun the test suite under valgrind's massif toool.",
     245        "\tChange the default valgrind args with the VALGRIND_ARGS env var."
     246       );
    211247}
    212248
     
    336372
    337373   if ($valgrind) {
     374     my $args = $valgrind_args;
    338375     open(VALGRIND, "> valgrind.out")
    339376       || die "Cannot open valgrind.out: $!\n";
    340377     #  -q --leak-check=yes
    341      exists $ENV{VALGRIND_ARGS} and $valgrind_args = $ENV{VALGRIND_ARGS};
    342      $make_path = "valgrind --log-fd=".fileno(VALGRIND)." $valgrind_args $make_path";
     378     exists $ENV{VALGRIND_ARGS} and $args = $ENV{VALGRIND_ARGS};
     379     $make_path = "valgrind --log-fd=".fileno(VALGRIND)." $args $make_path";
    343380     # F_SETFD is 2
    344381     fcntl(VALGRIND, 2, 0) or die "fcntl(setfd) failed: $!\n";
  • trunk/src/kmk/tests/scripts/features/echoing

    r969 r2591  
    1 $description = "The following test creates a makefile to test command \n"
    2               ."echoing.  It tests that when a command line starts with \n"
    3               ."a '\@', the echoing of that line is suppressed.  It also \n"
    4               ."tests the -n option which tells make to ONLY echo the  \n"
    5               ."commands and no execution happens.  In this case, even \n"
    6               ."the commands with '\@' are printed. Lastly, it tests the \n"
    7               ."-s flag which tells make to prevent all echoing, as if \n"
    8               ."all commands started with a '\@'.";
     1#                                                                    -*-perl-*-
     2$description = "The following test creates a makefile to test command
     3echoing.  It tests that when a command line starts with
     4a '\@', the echoing of that line is suppressed.  It also
     5tests the -n option which tells make to ONLY echo the
     6commands and no execution happens.  In this case, even
     7the commands with '\@' are printed. Lastly, it tests the
     8-s flag which tells make to prevent all echoing, as if
     9all commands started with a '\@'.";
    910
    10 $details = "This test is similar to the 'clean' test except that a '\@' has\n"
    11           ."been placed in front of the delete command line.  Four tests \n"
    12           ."are run here.  First, make is run normally and the first echo\n"
    13           ."command should be executed.  In this case there is no '\@' so \n"
    14           ."we should expect make to display the command AND display the \n"
    15           ."echoed message.  Secondly, make is run with the clean target, \n"
    16           ."but since there is a '\@' at the beginning of the command, we\n"
    17           ."expect no output; just the deletion of a file which we check \n"
    18           ."for.  Third, we give the clean target again except this time\n"
    19           ."we give make the -n option.  We now expect the command to be \n"
    20           ."displayed but not to be executed.  In this case we need only \n"
    21           ."to check the output since an error message would be displayed\n"
    22           ."if it actually tried to run the delete command again and the \n"
    23           ."file didn't exist. Lastly, we run the first test again with \n"
    24           ."the -s option and check that make did not echo the echo \n"
    25           ."command before printing the message.";
     11$details = "This test is similar to the 'clean' test except that a '\@' has
     12been placed in front of the delete command line.  Four tests
     13are run here.  First, make is run normally and the first echo
     14command should be executed.  In this case there is no '\@' so
     15we should expect make to display the command AND display the
     16echoed message.  Secondly, make is run with the clean target,
     17but since there is a '\@' at the beginning of the command, we
     18expect no output; just the deletion of a file which we check
     19for.  Third, we give the clean target again except this time
     20we give make the -n option.  We now expect the command to be
     21displayed but not to be executed.  In this case we need only
     22to check the output since an error message would be displayed
     23if it actually tried to run the delete command again and the
     24file didn't exist. Lastly, we run the first test again with
     25the -s option and check that make did not echo the echo
     26command before printing the message.\n";
    2627
    2728$example = "EXAMPLE_FILE";
    2829
    29 open(MAKEFILE,"> $makefile");
    30 
    31 # The Contents of the MAKEFILE ...
    32 
    33 print MAKEFILE "all: \n";
    34 print MAKEFILE "\techo This makefile did not clean the dir... good\n";
    35 print MAKEFILE "clean: \n";
    36 print MAKEFILE "\t\@$delete_command $example\n";
    37 
    38 # END of Contents of MAKEFILE
    39 
    40 close(MAKEFILE);
    41 
    42 &touch($example);
     30touch($example);
    4331
    4432# TEST #1
    4533# -------
    4634
    47 &run_make_with_options($makefile,"",&get_logfile,0);
    48 $answer = "echo This makefile did not clean the dir... good\n"
    49          ."This makefile did not clean the dir... good\n";
    50 &compare_output($answer,&get_logfile(1));
    51 
     35run_make_test("
     36all:
     37\techo This makefile did not clean the dir... good
     38clean:
     39\t\@$delete_command $example\n",
     40              '', 'echo This makefile did not clean the dir... good
     41This makefile did not clean the dir... good');
    5242
    5343# TEST #2
    5444# -------
    5545
    56 &run_make_with_options($makefile,"clean",&get_logfile,0);
     46run_make_test(undef, 'clean', '');
    5747if (-f $example) {
    5848  $test_passed = 0;
     49  unlink($example);
    5950}
    60 &compare_output('',&get_logfile(1));
    6151
    6252# TEST #3
    6353# -------
    6454
    65 &run_make_with_options($makefile,"-n clean",&get_logfile,0);
    66 $answer = "$delete_command $example\n";
    67 &compare_output($answer,&get_logfile(1));
     55run_make_test(undef, '-n clean', "$delete_command $example\n");
    6856
    6957
     
    7159# -------
    7260
    73 &run_make_with_options($makefile,"-s",&get_logfile,0);
    74 $answer = "This makefile did not clean the dir... good\n";
    75 &compare_output($answer,&get_logfile(1));
     61run_make_test(undef, '-s', "This makefile did not clean the dir... good\n");
    7662
    7763
    78641;
    79 
    80 
    81 
    82 
    83 
    84 
    85 
    86 
    87 
  • trunk/src/kmk/tests/scripts/features/export

    r969 r2591  
    77# about that here.
    88
    9 open(MAKEFILE,"> $makefile");
    10 
    11 # The Contents of the MAKEFILE ...
    12 
    13 print MAKEFILE <<'EOMAKE';
    14 
     9&run_make_test('
    1510FOO = foo
    1611BAR = bar
     
    4136        @echo "FOO=$(FOO) BAR=$(BAR) BAZ=$(BAZ) BOZ=$(BOZ) BITZ=$(BITZ) BOTZ=$(BOTZ)"
    4237        @echo "FOO=$$FOO BAR=$$BAR BAZ=$$BAZ BOZ=$$BOZ BITZ=$$BITZ BOTZ=$$BOTZ"
    43 
    44 EOMAKE
    45 
    46 close(MAKEFILE);
    47 
    48 # TEST 0: basics
    49 
    50 &run_make_with_options($makefile,"",&get_logfile,0);
    51 
    52 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
    53 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
    54 
    55 &compare_output($answer,&get_logfile(1));
     38',
     39           '', "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
     40FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
    5641
    5742# TEST 1: make sure vars inherited from the parent are exported
     
    5944$extraENV{FOO} = 1;
    6045
    61 &run_make_with_options($makefile,"",&get_logfile,0);
    62 
    63 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
    64 FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
    65 
    66 &compare_output($answer,&get_logfile(1));
     46&run_make_test(undef, '', "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
     47FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
    6748
    6849# TEST 2: global export.  Explicit unexport takes precedence.
    6950
    70 &run_make_with_options($makefile,"EXPORT_ALL=1",&get_logfile,0);
    71 
    72 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
    73 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
    74 
    75 &compare_output($answer,&get_logfile(1));
     51run_make_test(undef, "EXPORT_ALL=1" ,
     52              "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
     53FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
    7654
    7755# TEST 3: global unexport.  Explicit export takes precedence.
    7856
    79 &run_make_with_options($makefile,"UNEXPORT_ALL=1",&get_logfile,0);
    80 
    81 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
    82 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
    83 
    84 &compare_output($answer,&get_logfile(1));
     57&run_make_test(undef, "UNEXPORT_ALL=1",
     58               "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
     59FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
    8560
    8661# TEST 4: both: in the above makefile the unexport comes last so that rules.
    8762
    88 &run_make_with_options($makefile,"EXPORT_ALL=1 UNEXPORT_ALL=1",&get_logfile,0);
    89 
    90 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
    91 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
    92 
    93 &compare_output($answer,&get_logfile(1));
     63&run_make_test(undef, "EXPORT_ALL=1 UNEXPORT_ALL=1",
     64               "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
     65FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
    9466
    9567# TEST 5: test the pseudo target.
    9668
    97 &run_make_with_options($makefile,"EXPORT_ALL_PSEUDO=1",&get_logfile,0);
    98 
    99 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
    100 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
    101 
    102 &compare_output($answer,&get_logfile(1));
    103 
     69&run_make_test(undef, "EXPORT_ALL_PSEUDO=1",
     70               "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
     71FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
    10472
    10573# TEST 6: Test the expansion of variables inside export
    10674
    107 $makefile2 = &get_tmpfile;
    108 
    109 open(MAKEFILE, "> $makefile2");
    110 
    111 print MAKEFILE <<'EOF';
    112 
     75&run_make_test('
    11376foo = f-ok
    11477bar = b-ok
     
    12689        @echo foo=$(foo) bar=$(bar)
    12790        @echo foo=$$foo bar=$$bar
    128 
    129 EOF
    130 
    131 close(MAKEFILE);
    132 
    133 &run_make_with_options($makefile2,"",&get_logfile,0);
    134 $answer = "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n";
    135 &compare_output($answer,&get_logfile(1));
    136 
     91',
     92             "", "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n");
    13793
    13894# TEST 7: Test the expansion of variables inside unexport
    13995
    140 $makefile3 = &get_tmpfile;
    141 
    142 open(MAKEFILE, "> $makefile3");
    143 
    144 print MAKEFILE <<'EOF';
    145 
     96&run_make_test('
    14697foo = f-ok
    14798bar = b-ok
     
    161112        @echo foo=$(foo) bar=$(bar)
    162113        @echo foo=$$foo bar=$$bar
    163 
    164 EOF
    165 
    166 close(MAKEFILE);
    167 
    168 &run_make_with_options($makefile3,"",&get_logfile,0);
    169 $answer = "foo=f-ok bar=b-ok\nfoo= bar=\n";
    170 &compare_output($answer,&get_logfile(1));
    171 
     114',
     115              '', "foo=f-ok bar=b-ok\nfoo= bar=\n");
    172116
    173117# TEST 7: Test exporting multiple variables on the same line
    174118
    175 $makefile4 = &get_tmpfile;
    176 
    177 open(MAKEFILE, "> $makefile4");
    178 
    179 print MAKEFILE <<'EOF';
    180 
     119&run_make_test('
    181120A = a
    182121B = b
     
    197136
    198137all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J
    199 EOF
    200 
    201 close(MAKEFILE);
    202 
    203 &run_make_with_options($makefile4,"",&get_logfile,0);
    204 $answer = "A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j\n";
    205 &compare_output($answer,&get_logfile(1));
    206 
     138',
     139               '', "A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j\n");
    207140
    208141# TEST 8: Test unexporting multiple variables on the same line
    209142
    210 $makefile5 = &get_tmpfile;
     143@extraENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
    211144
    212 open(MAKEFILE, "> $makefile5");
    213 
    214 print MAKEFILE <<'EOF';
    215 
     145&run_make_test('
    216146A = a
    217147B = b
     
    232162
    233163all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J
    234 EOF
     164',
     165               '', "A= B= C= D= E= F= G= H= I= J=\n");
    235166
    236 close(MAKEFILE);
     167# TEST 9: Check setting a variable named "export"
    237168
    238 @extraENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
     169&run_make_test('
     170export = 123
     171export export
     172export export = 456
     173a: ; @echo "\$$(export)=$(export) / \$$export=$$export"
     174',
     175               '', "\$(export)=456 / \$export=456\n");
    239176
    240 &run_make_with_options($makefile5,"",&get_logfile,0);
    241 $answer = "A= B= C= D= E= F= G= H= I= J=\n";
    242 &compare_output($answer,&get_logfile(1));
     177# TEST 9: Check "export" as a target
    243178
     179&run_make_test('
     180a: export
     181export: ; @echo "$@"
     182',
     183               '', "export\n");
    244184
    245185# This tells the test driver that the perl test script executed properly.
  • trunk/src/kmk/tests/scripts/features/include

    r969 r2591  
    9191', '', '');
    9292
    93 1;
    94 
    9593
    9694# Make sure that we don't die when the command fails but we dontcare.
     
    118116sinclude', '', '');
    119117
     118
     119# Test that the diagnostics is issued even if the target has been
     120# tried before with the dontcare flag (direct dependency case).
     121#
     122run_make_test('
     123-include foo
     124
     125all: bar
     126
     127foo: baz
     128bar: baz
     129',
     130'',
     131"#MAKE#: *** No rule to make target `baz', needed by `bar'.  Stop.\n",
     132512);
     133
     134# Test that the diagnostics is issued even if the target has been
     135# tried before with the dontcare flag (indirect dependency case).
     136#
     137run_make_test('
     138-include foo
     139
     140all: bar
     141
     142foo: baz
     143bar: baz
     144baz: end
     145',
     146'',
     147"#MAKE#: *** No rule to make target `end', needed by `baz'.  Stop.\n",
     148512);
     149
     150# Test that the diagnostics is issued even if the target has been
     151# tried before with the dontcare flag (include/-include case).
     152#
     153run_make_test('
     154include bar
     155-include foo
     156
     157all:
     158
     159foo: baz
     160bar: baz
     161baz: end
     162',
     163'',
     164"#MAKEFILE#:2: bar: No such file or directory
     165#MAKE#: *** No rule to make target `end', needed by `baz'.  Stop.\n",
     166512);
     167
     168if ($all_tests) {
     169    # Test that include of a rebuild-able file doesn't show a warning
     170    # Savannah bug #102
     171    run_make_test(q!
     172include foo
     173foo: ; @echo foo = bar > $@
     174!,
     175                  '', "#MAKE#: `foo' is up to date.\n");
     176    rmfiles('foo');
     177}
     178
    1201791;
  • trunk/src/kmk/tests/scripts/features/override

    r969 r2591  
    1 $description = "The following test creates a makefile to ...";
     1#                                                                    -*-perl-*-
     2
     3$description = "Test the override directive on variable assignments.";
    24
    35$details = "";
    46
    5 open(MAKEFILE,"> $makefile");
     7# TEST 0: Basic override
    68
    7 # The Contents of the MAKEFILE ...
     9run_make_test('
     10X = start
     11override recur = $(X)
     12override simple := $(X)
     13X = end
     14all: ; @echo "$(recur) $(simple)"
     15',
     16              'recur=I simple=J', "end start\n");
    817
    9 print MAKEFILE "override define foo\n"
    10               ."\@echo First comes the definition.\n"
    11               ."\@echo Then comes the override.\n"
    12               ."endef\n"
    13               ."all: \n"
    14               ."\t\$(foo)\n";
     18# TEST 1: Override with append
    1519
    16 # END of Contents of MAKEFILE
     20run_make_test('
     21X += X1
     22override X += X2
     23override Y += Y1
     24Y += Y2
     25all: ; @echo "$(X) $(Y)"
     26',
     27              '', "X1 X2 Y1\n");
    1728
    18 close(MAKEFILE);
     29# TEST 2: Override with append to the command line
    1930
    20 &run_make_with_options($makefile,"foo=Hello",&get_logfile);
     31run_make_test(undef, 'X=C Y=C', "C X2 C Y1\n");
    2132
    22 # Create the answer to what should be produced by this Makefile
    23 $answer = "First comes the definition.\n"
    24          ."Then comes the override.\n";
     33# Test override of define/endef
    2534
    26 &compare_output($answer,&get_logfile(1));
     35run_make_test('
     36override define foo
     37@echo First comes the definition.
     38@echo Then comes the override.
     39endef
     40all: ; $(foo)
     41',
     42              'foo=Hello', "First comes the definition.\nThen comes the override.\n");
     43
    2744
    28451;
    29 
    30 
    31 
    32 
    33 
    34 
  • trunk/src/kmk/tests/scripts/features/parallelism

    r2186 r2591  
    4444              "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
    4545
    46 unlink('1.inc', '2.inc');
     46rmfiles(qw(1.inc 2.inc));
    4747
    4848
     
    6363              "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n");
    6464
    65 unlink('1.inc', '2.inc');
     65rmfiles(qw(1.inc 2.inc));
    6666
    6767# Grant Taylor reports a problem where tokens can be lost (not written back
     
    153153.PHONY: phony
    154154phony: ; : phony', '-rR -j', ': phony');
    155 unlink('target');
    156 
     155rmfiles('target');
     156
     157# TEST #10: Don't put --jobserver-fds into a re-exec'd MAKEFLAGS.
     158# We can't test this directly because there's no way a makefile can
     159# show the value of MAKEFLAGS we were re-exec'd with.  We can intuit it
     160# by looking for "disabling jobserver mode" warnings; we should only
     161# get one from the original invocation and none from the re-exec.
     162# See Savannah bug #18124
     163
     164run_make_test(q!
     165-include inc.mk
     166recur:
     167#       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
     168        @rm -f inc.mk
     169        @$(MAKE) -j2 -f #MAKEFILE# all
     170all:
     171#       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
     172        @echo $@
     173inc.mk:
     174#       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
     175        @echo 'FOO = bar' > $@
     176!,
     177              '--no-print-directory -j2', "#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.\nall\n");
     178
     179rmfiles('inc.mk');
     180
     181if ($all_tests) {
     182    # Implicit files aren't properly recreated during parallel builds
     183    # Savannah bug #26864
     184
     185    # The first run works fine
     186    run_make_test(q!
     187%.bar: %.x foo.y ; cat $^ > $@
     188%.x: ; touch $@
     189foo.y: foo.y.in ; cp $< $@
     190foo.y.in: ; touch $@
     191!,
     192                  '-j2 main.bar',
     193                  "touch foo.y.in
     194touch main.x
     195cp foo.y.in foo.y
     196cat main.x foo.y > main.bar
     197rm main.x");
     198
     199    # Now we touch the .in file and make sure it still works
     200    touch('foo.y.in');
     201
     202    run_make_test(undef, '-j2 main.bar', "cp foo.y.in foo.y
     203touch main.x
     204cat main.x foo.y > main.bar
     205rm main.x");
     206
     207    # Clean up
     208    rmfiles(qw(foo.y foo.y.in main.bar));
     209}
     210
     211if ($all_tests) {
     212    # Jobserver FD handling is messed up in some way.
     213    # Savannah bug #28189
     214    # It doesn't look like that bug anymore but this is the code it runs
     215
     216    run_make_test(q!
     217ifdef EXTRA
     218vpath %.dst /
     219xxx.dst: ; true
     220yyy.dst: ; true
     221endif
     222
     223M := $(MAKE)
     224xx: ; $M --no-print-directory -j2 -f $(MAKEFILE_LIST) xxx.dst yyy.dst EXTRA=1
     225!,
     226                  '-j2',
     227                  '#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.
     228true
     229true
     230');
     231}
    157232
    158233# Make sure that all jobserver FDs are closed if we need to re-exec the
     
    183258#               'bar');
    184259
    185 # unlink('dependfile', 'output');
     260# rmfiles(qw(dependfile output));
    186261
    187262
     
    189264# run_make_test(undef, '-j2 recurse INCL=false', 'bar');
    190265
    191 # unlink('dependfile', 'output');
     266# rmfiles(qw(dependfile output));
    192267
    1932681;
  • trunk/src/kmk/tests/scripts/features/patspecific_vars

    r2173 r2591  
    121121pattrn: global: new $t pattern: good $t inherit: good $t;');
    122122
     123# TEST #8: override in pattern-specific variables
     124
     125run_make_test('
     126a%: override FOO += f1
     127a%: FOO += f2
     128ab: ; @echo "$(FOO)"
     129',
     130              '', "f1\n");
     131
     132run_make_test(undef, 'FOO=C', "C f1\n");
     133
     134# TEST #9: Test shortest stem selection in pattern-specific variables.
     135
     136run_make_test('
     137%-mt.x: x := two
     138%.x: x := one
     139
     140all: foo.x foo-mt.x
     141
     142foo.x: ;@echo $x
     143foo-mt.x: ;@echo $x
     144',
     145'',
     146"one\ntwo");
    123147
    1241481;
  • trunk/src/kmk/tests/scripts/features/patternrules

    • Property svn:keywords deleted
    r1952 r2591  
    1616#
    1717
    18 run_make_test('
     18run_make_test(q!
    1919.PHONY: all
    2020
    2121all: case.1 case.2 case.3
    22 a: void
     22
     23# We can't have this, due to "Implicit Rule Search Algorithm" step 5c
     24#xxx: void
    2325
    2426# 1 - existing file
     
    4244
    43453.implicit-phony:
    44 ',
    45 '',
    46 '');
     46!, '', '');
    4747
    4848# TEST #1: make sure files that are built via implicit rules are marked
     
    150150unlink('foo.in', 'foo.h', 'foo.c', 'foo.o');
    151151
     152# TEST #5: make sure both prefix and suffix patterns work with multiple
     153#          target patterns (Savannah bug #26593).
     154#
     155run_make_test('
     156all: foo.s1 foo.s2 p1.foo p2.foo
     157
     158p1.% p2.%: %.orig
     159        @echo $@
     160%.s1 %.s2: %.orig
     161        @echo $@
     162
     163.PHONY: foo.orig
     164',
     165              '', "foo.s1\np1.foo\n");
     166
     167# TEST 6: Make sure that non-target files are still eligible to be created
     168# as part of implicit rule chaining.  Savannah bug #17752.
     169
     170run_make_test(q!
     171BIN = xyz
     172COPY = $(BIN).cp
     173SRC = $(BIN).c
     174allbroken: $(COPY) $(BIN) ; @echo ok
     175$(SRC): ; @echo 'main(){}' > $@
     176%.cp: % ; @cp $< $@
     177% : %.c ; @cp $< $@
     178clean: ; @rm -rf $(SRC) $(COPY) $(BIN)
     179!,
     180              '', "ok\n");
     181
     182unlink(qw(xyz xyz.cp xyz.c));
     183
     184# TEST 7: Make sure that all prereqs of all "also_make" targets get created
     185# before any of the things that depend on any of them.  Savannah bug #19108.
     186
     187run_make_test(q!
     188final: x ; @echo $@
     189x: x.t1 x.t2 ; @echo $@
     190x.t2: dep
     191dep: ; @echo $@
     192%.t1 %.t2: ; @echo $*.t1 ; echo $*.t2
     193!,
     194              '', "dep\nx.t1\nx.t2\nx\nfinal\n");
     195
     196
     197# TEST 8: Verify we can remove pattern rules.  Savannah bug #18622.
     198
     199my @f = (qw(foo.w foo.ch));
     200touch(@f);
     201
     202run_make_test(q!
     203CWEAVE := :
     204
     205# Disable builtin rules
     206%.tex : %.w
     207%.tex : %.w %.ch
     208!,
     209              'foo.tex',
     210              "#MAKE#: *** No rule to make target `foo.tex'.  Stop.", 512);
     211
     212unlink(@f);
     213
     214# TEST #9: Test shortest stem selection in pattern rules.
     215
     216run_make_test('
     217%.x: ;@echo one
     218%-mt.x: ;@echo two
     219
     220all: foo.x foo-mt.x
     221',
     222'',
     223"one\ntwo");
     224
     2251;
     226
    152227# This tells the test driver that the perl test script executed properly.
    1532281;
  • trunk/src/kmk/tests/scripts/features/recursion

    r1956 r2591  
    1717        @echo THE END
    1818',
    19               ('CFLAGS=-O -w' . ($parallel_jobs ? '-j 2' : '')),
     19              ('CFLAGS=-O -w' . ($parallel_jobs ? ' -j 2' : '')),
    2020              ($vos
    2121               ? "#MAKE#: Entering directory `#PWD#'
  • trunk/src/kmk/tests/scripts/features/se_explicit

    • Property svn:keywords deleted
    r1981 r2591  
    2727# TEST #1: automatic variables.
    2828#
    29 run_make_test('
     29run_make_test(q!
    3030.SECONDEXPANSION:
    31 .DEFAULT: ; @echo $@
     31.DEFAULT: ; @echo '$@'
    3232
    3333foo: bar baz
     
    4242     $$*.6
    4343
    44 ',
     44!,
    4545'-j1',
    4646'bar
     
    6363# Test #2: target/pattern -specific variables.
    6464#
    65 run_make_test('
     65run_make_test(q!
    6666.SECONDEXPANSION:
    67 .DEFAULT: ; @echo $@
     67.DEFAULT: ; @echo '$@'
    6868
    6969foo.x: $$a $$b
     
    7272
    7373%.x: b := baz
    74 
    75 ',
     74!,
    7675'',
    7776'bar
     
    8281# Test #3: order of prerequisites.
    8382#
    84 run_make_test('
     83run_make_test(q!
    8584.SECONDEXPANSION:
    86 .DEFAULT: ; @echo $@
     85.DEFAULT: ; @echo '$@'
    8786
    8887all: foo bar baz
    8988
    9089# Subtest #1
    91 #
    9290foo: foo.1; @:
    93 
    9491foo: foo.2
    95 
    9692foo: foo.3
    9793
    98 
    9994# Subtest #2
    100 #
    10195bar: bar.2
    102 
    10396bar: bar.1; @:
    104 
    10597bar: bar.3
    10698
    107 
    10899# Subtest #3
    109 #
    110100baz: baz.1
    111 
    112101baz: baz.2
    113 
    114102baz: ; @:
    115 
    116 ',
     103!,
    117104'-j1',
    118105'foo.1
     
    126113');
    127114
     115# TEST #4: eval in a context where there is no reading_file
     116run_make_test(q!
     117.SECONDEXPANSION:
     118all : $$(eval $$(info test))
     119!,
     120            '', "test\n#MAKE#: Nothing to be done for `all'.\n");
     121
     122# TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new
     123# target/prereq relationships.
     124
     125run_make_test(q!
     126.SECONDEXPANSION:
     127proj1.exe : proj1.o $$(eval $$(test))
     128define test
     129proj1.o : proj1.c
     130proj1.c: proj1.h
     131endef
     132!,
     133              '', "#MAKE#: *** prerequisites cannot be defined in recipes.  Stop.\n", 512);
     134
     135
     136# Automatic $$+ variable expansion issue.  Savannah bug #25780
     137run_make_test(q!
     138all : foo foo
     139.SECONDEXPANSION:
     140all : $$+ ; @echo '$+'
     141foo : ;
     142!,
     143                  '', "foo foo foo foo\n");
     144
     145
     146# Automatic $$+ variable expansion issue.  Savannah bug #25780
     147run_make_test(q!
     148all : bar bar
     149bar : ;
     150q%x : ;
     151.SECONDEXPANSION:
     152a%l: q1x $$+ q2x ; @echo '$+'
     153!,
     154                  '', "q1x bar bar q2x bar bar\n");
     155
     156
    128157# This tells the test driver that the perl test script executed properly.
    1291581;
  • trunk/src/kmk/tests/scripts/features/se_implicit

    • Property svn:keywords deleted
    r1982 r2591  
    1212# Test #1: automatic variables.
    1313#
    14 run_make_test('
    15 .SECONDEXPANSION:
    16 .DEFAULT: ; @echo $@
     14run_make_test(q!
     15.SECONDEXPANSION:
     16.DEFAULT: ; @echo '$@'
    1717
    1818foo.a: bar baz
     
    38385.buz \
    39396.a:
    40         @echo $@
    41 
    42 ',
     40        @echo '$@'
     41
     42!,
    4343'-j1',
    4444'1.foo.a
     
    6161# Test #2: target/pattern -specific variables.
    6262#
    63 run_make_test('
     63run_make_test(q!
    6464.SECONDEXPANSION:
    6565foo.x:
     
    7272%.x: x_b := baz
    7373
    74 bar baz: ; @echo $@
    75 
    76 ',
    77 '',
    78 'bar
    79 baz
    80 ');
     74bar baz: ; @echo '$@'
     75!,
     76              '', "bar\nbaz\n");
    8177
    8278
    8379# Test #3: order of prerequisites.
    8480#
    85 run_make_test('
    86 .SECONDEXPANSION:
    87 .DEFAULT: ; @echo $@
     81run_make_test(q!
     82.SECONDEXPANSION:
     83.DEFAULT: ; @echo '$@'
    8884
    8985all: foo bar baz
     
    9894foo: foo.3
    9995
    100 foo.1: ; @echo $@
     96foo.1: ; @echo '$@'
    10197
    10298
     
    109105bar: bar.3
    110106
    111 bar.1: ; @echo $@
     107bar.1: ; @echo '$@'
    112108
    113109
     
    119115
    120116%az: ; @:
    121 
    122 ',
    123 '-j1',
     117!,
     118              '-j1',
    124119'foo.1
    125120foo.2
     
    135130# Test #4: stem splitting logic.
    136131#
    137 run_make_test('
     132run_make_test(q!
    138133.SECONDEXPANSION:
    139134$(dir)/tmp/bar.o:
    140135
    141 $(dir)/tmp/foo/bar.c: ; @echo $@
    142 $(dir)/tmp/bar/bar.c: ; @echo $@
    143 foo.h: ; @echo $@
     136$(dir)/tmp/foo/bar.c: ; @echo '$@'
     137$(dir)/tmp/bar/bar.c: ; @echo '$@'
     138foo.h: ; @echo '$@'
    144139
    145140%.o: $$(addsuffix /%.c,foo bar) foo.h
    146         @echo $@: {$<} $^
    147 
    148 ',
    149 "dir=$dir",
    150 "$dir/tmp/foo/bar.c
     141        @echo '$@: {$<} $^'
     142!,
     143              "dir=$dir", "$dir/tmp/foo/bar.c
    151144$dir/tmp/bar/bar.c
    152145foo.h
     
    157150# Test #5: stem splitting logic and order-only prerequisites.
    158151#
    159 run_make_test('
     152run_make_test(q!
    160153.SECONDEXPANSION:
    161154$(dir)/tmp/foo.o: $(dir)/tmp/foo.c
    162 $(dir)/tmp/foo.c: ; @echo $@
    163 bar.h: ; @echo $@
     155$(dir)/tmp/foo.c: ; @echo '$@'
     156bar.h: ; @echo '$@'
    164157
    165158%.o: %.c|bar.h
    166         @echo $@: {$<} {$|} $^
    167 
    168 ',
    169 "dir=$dir",
    170 "$dir/tmp/foo.c
     159        @echo '$@: {$<} {$|} $^'
     160
     161!,
     162              "dir=$dir", "$dir/tmp/foo.c
    171163bar.h
    172164$dir/tmp/foo.o: {$dir/tmp/foo.c} {bar.h} $dir/tmp/foo.c
     
    176168# Test #6: lack of implicit prerequisites.
    177169#
    178 run_make_test('
     170run_make_test(q!
    179171.SECONDEXPANSION:
    180172foo.o: foo.c
    181 foo.c: ; @echo $@
     173foo.c: ; @echo '$@'
    182174
    183175%.o:
    184         @echo $@: {$<} $^
    185 
    186 ',
    187 '',
    188 'foo.c
    189 foo.o: {foo.c} foo.c
    190 ');
     176        @echo '$@: {$<} $^'
     177!,
     178              '', "foo.c\nfoo.o: {foo.c} foo.c\n");
     179
    191180
    192181# Test #7: Test stem from the middle of the name.
    193182#
    194 run_make_test('
     183run_make_test(q!
    195184.SECONDEXPANSION:
    196185foobarbaz:
    197186
    198187foo%baz: % $$*.1
    199         @echo $*
     188        @echo '$*'
    200189
    201190bar bar.1:
    202         @echo $@
    203 
    204 ',
    205 '',
    206 'bar
    207 bar.1
    208 bar
    209 ');
     191        @echo '$@'
     192!,
     193              '', "bar\nbar.1\nbar\n");
     194
    210195
    211196# Test #8: Make sure stem triple-expansion does not happen.
    212197#
    213 run_make_test('
     198run_make_test(q!
    214199.SECONDEXPANSION:
    215200foo$$bar:
    216201
    217202f%r: % $$*.1
    218         @echo \'$*\'
     203        @echo '$*'
    219204
    220205oo$$ba oo$$ba.1:
    221         @echo \'$@\'
    222 
    223 ',
    224 '',
    225 'oo$ba
     206        @echo '$@'
     207!,
     208              '', 'oo$ba
    226209oo$ba.1
    227210oo$ba
    228211');
    229212
     213# Test #9: Check the value of $^
     214run_make_test(q!
     215.SECONDEXPANSION:
     216
     217%.so: | $$(extra) ; @echo $^
     218
     219foo.so: extra := foo.o
     220foo.so:
     221foo.o:
     222!,
     223              '', "\n");
    230224
    231225# This tells the test driver that the perl test script executed properly.
  • trunk/src/kmk/tests/scripts/features/se_statpat

    • Property svn:keywords deleted
    r1983 r2591  
    66# Test #1: automatic variables.
    77#
    8 run_make_test('
     8# bird: Had to add -j1 here earlier...
     9run_make_test(q!
    910.SECONDEXPANSION:
    10 .DEFAULT: ; @echo $@
     11.DEFAULT: ; @echo '$@'
    1112
    1213foo.a foo.b: foo.%: bar.% baz.%
    13 
    1414foo.a foo.b: foo.%: biz.% | buz.%
    1515
     
    2020                    $$|.5 \
    2121                    $$*.6
    22 
    23 ',
    24 '-j1',
    25 'bar.a
     22!,
     23              '', 'bar.a
    2624baz.a
    2725biz.a
     
    4240# Test #2: target/pattern -specific variables.
    4341#
    44 run_make_test('
     42run_make_test(q!
    4543.SECONDEXPANSION:
    46 .DEFAULT: ; @echo $@
     44.DEFAULT: ; @echo '$@'
    4745
    4846foo.x foo.y: foo.%: $$(%_a) $$($$*_b)
     
    5149
    5250%.x: x_b := baz
    53 
    54 
    55 ',
    56 '',
    57 'bar
    58 baz
    59 ');
     51!,
     52              '', "bar\nbaz\n");
    6053
    6154
    6255# Test #3: order of prerequisites.
    6356#
    64 run_make_test('
     57# bird: Had to add -j1 here earlier...
     58run_make_test(q!
    6559.SECONDEXPANSION:
    66 .DEFAULT: ; @echo $@
     60.DEFAULT: ; @echo '$@'
    6761
    6862all: foo.a bar.a baz.a
    6963
    7064# Subtest #1
    71 #
    7265foo.a foo.b: foo.%: foo.%.1; @:
    73 
    7466foo.a foo.b: foo.%: foo.%.2
    75 
    7667foo.a foo.b: foo.%: foo.%.3
    7768
    7869
    7970# Subtest #2
    80 #
    8171bar.a bar.b: bar.%: bar.%.2
    82 
    8372bar.a bar.b: bar.%: bar.%.1; @:
    84 
    8573bar.a bar.b: bar.%: bar.%.3
    8674
    8775
    8876# Subtest #3
    89 #
    9077baz.a baz.b: baz.%: baz.%.1
    91 
    9278baz.a baz.b: baz.%: baz.%.2
    93 
    9479baz.a baz.b: ; @:
    95 
    96 ',
    97 '-j1',
    98 'foo.a.1
     80!,
     81             '', 'foo.a.1
    9982foo.a.2
    10083foo.a.3
     
    10992# Test #4: Make sure stem triple-expansion does not happen.
    11093#
    111 run_make_test('
     94run_make_test(q!
    11295.SECONDEXPANSION:
    11396foo$$bar: f%r: % $$*.1
    114         @echo \'$*\'
     97        @echo '$*'
    11598
    11699oo$$ba oo$$ba.1:
    117         @echo \'$@\'
    118 
    119 ',
    120 '',
    121 'oo$ba
     100        @echo '$@'
     101!,
     102              '', 'oo$ba
    122103oo$ba.1
    123104oo$ba
  • trunk/src/kmk/tests/scripts/features/targetvars

    r2165 r2591  
    77rules, semicolon interference, etc.";
    88
    9 open(MAKEFILE,"> $makefile");
    10 
    11 print MAKEFILE <<'EOF';
     9run_make_test('
    1210SHELL = /bin/sh
    1311export FOO = foo
     
    1816three: ; BAR=1000
    1917        @echo $(FOO) $(BAR)
    20 # Some things that shouldn't be target vars
     18# Some things that shouldn not be target vars
    2119funk : override
    2220funk : override adelic
     
    2523four:FOO=x
    2624four:VAR$(FOO)=ok
    27 four: ; @echo '$(FOO) $(VAR$(FOO)) $(VAR) $(VARx)'
     25four: ; @echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx)"
    2826five:FOO=x
    2927five six : VAR$(FOO)=good
    30 five six: ;@echo '$(FOO) $(VAR$(FOO)) $(VAR) $(VARx) $(VARfoo)'
     28five six: ;@echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx) $(VARfoo)"
    3129# Test per-target variable inheritance
    3230seven: eight
     
    4240# Test = escaping
    4341EQ = =
    44 ten: one\=two
    45 ten: one \= two
     42ten: one$(EQ)two
     43ten: one $(EQ) two
    4644ten one$(EQ)two $(EQ):;@echo $@
    4745.PHONY: one two three four five six seven eight nine ten $(EQ) one$(EQ)two
     
    5553foo.r : RVAR += rvar
    5654foo.t : TVAR := $(QVAR)
    57 EOF
    58 
    59 close(MAKEFILE);
    60 
    61 # TEST #1
    62 
    63 &run_make_with_options($makefile, "-j1 one two three", &get_logfile);
    64 $answer = "one bar\nfoo two\nBAR=1000\nfoo bar\n";
    65 &compare_output($answer,&get_logfile(1));
     55',
     56                 "one two three", "one bar\nfoo two\nBAR=1000\nfoo bar\n");
    6657
    6758# TEST #2
    6859
    69 &run_make_with_options($makefile, "-j1 one two FOO=1 BAR=2", &get_logfile);
    70 $answer = "one 2\n1 2\n";
    71 &compare_output($answer,&get_logfile(1));
     60run_make_test(undef, "one two FOO=1 BAR=2", "one 2\n1 2\n");
    7261
    7362# TEST #3
    7463
    75 &run_make_with_options($makefile, "-j1 four", &get_logfile);
    76 $answer = "x ok  ok\n";
    77 &compare_output($answer,&get_logfile(1));
     64run_make_test(undef, "four", "x ok  ok\n");
    7865
    7966# TEST #4
    8067
    81 &run_make_with_options($makefile, "-j1 seven", &get_logfile);
    82 $answer = "eight: seven eight\nseven: seven seven\n";
    83 &compare_output($answer,&get_logfile(1));
     68run_make_test(undef, "seven", "eight: seven eight\nseven: seven seven\n");
    8469
    8570# TEST #5
    8671
    87 &run_make_with_options($makefile, "-j1 nine", &get_logfile);
    88 $answer = "wallace bar wallace bar\n";
    89 &compare_output($answer,&get_logfile(1));
     72run_make_test(undef, "nine", "wallace bar wallace bar\n");
    9073
    9174# TEST #5-a
    9275
    93 &run_make_with_options($makefile, "-j1 nine-a", &get_logfile);
    94 $answer = "baz\n";
    95 &compare_output($answer,&get_logfile(1));
     76run_make_test(undef, "nine-a", "baz\n");
    9677
    9778# TEST #6
    9879
    99 &run_make_with_options($makefile, "-j1 ten", &get_logfile);
    100 $answer = "one=two\none bar\n=\nfoo two\nten\n";
    101 &compare_output($answer,&get_logfile(1));
     80run_make_test(undef, "ten", "one=two\none bar\n=\nfoo two\nten\n");
    10281
    10382# TEST #6
    10483
    105 &run_make_with_options($makefile, "-j1 foo.q bar.q", &get_logfile);
    106 $answer = "qvar = rvar\nqvar =\n";
    107 &compare_output($answer,&get_logfile(1));
     84run_make_test(undef, "foo.q bar.q", "qvar = rvar\nqvar =\n");
    10885
    10986# TEST #7
    11087
    111 &run_make_with_options($makefile, "-j1 foo.t bar.s", &get_logfile);
    112 $answer = "qvar = qvar\nqvar =\n";
    113 &compare_output($answer,&get_logfile(1));
     88run_make_test(undef, "foo.t bar.s", "qvar = qvar\nqvar =\n");
    11489
    11590
     
    11792# For PR/1378: Target-specific vars don't inherit correctly
    11893
    119 $makefile2 = &get_tmpfile;
    120 
    121 open(MAKEFILE,"> $makefile2");
    122 print MAKEFILE <<'EOF';
     94run_make_test('
    12395foo: FOO = foo
    12496bar: BAR = bar
     
    12698bar: baz
    12799baz: ; @echo $(FOO) $(BAR)
    128 EOF
    129 close(MAKEFILE);
    130 
    131 &run_make_with_options("$makefile2", "", &get_logfile);
    132 $answer = "foo bar\n";
    133 &compare_output($answer, &get_logfile(1));
     100', "", "foo bar\n");
    134101
    135102# TEST #9
     
    137104# Also PR/1831
    138105
    139 $makefile3 = &get_tmpfile;
    140 
    141 open(MAKEFILE,"> $makefile3");
    142 print MAKEFILE <<'EOF';
     106run_make_test('
    143107.PHONY: all one
    144108all: FOO += baz
     
    150114one: FOO += boz
    151115one: ; @echo $(FOO)
    152 EOF
    153 close(MAKEFILE);
    154 
    155 &run_make_with_options("$makefile3", "", &get_logfile);
    156 $answer = "bar baz biz boz\nbar baz\n";
    157 &compare_output($answer, &get_logfile(1));
     116',
     117              '', "bar baz biz boz\nbar baz\n");
    158118
    159119# Test #10
    160120
    161 &run_make_with_options("$makefile3", "one", &get_logfile);
    162 $answer = "bar biz boz\n";
    163 &compare_output($answer, &get_logfile(1));
     121run_make_test(undef, 'one', "bar biz boz\n");
    164122
    165123# Test #11
    166124# PR/1709: Test semicolons in target-specific variable values
    167125
    168 $makefile4 = &get_tmpfile;
    169 
    170 open(MAKEFILE, "> $makefile4");
    171 print MAKEFILE <<'EOF';
     126run_make_test('
    172127foo : FOO = ; ok
    173 foo : ; @echo '$(FOO)'
    174 EOF
    175 close(MAKEFILE);
    176 
    177 &run_make_with_options("$makefile4", "", &get_logfile);
    178 $answer = "; ok\n";
    179 &compare_output($answer, &get_logfile(1));
     128foo : ; @echo "$(FOO)"
     129',
     130              '', "; ok\n");
    180131
    181132# Test #12
     
    183134# I nailed it this time :-/.
    184135
    185 $makefile5 = &get_tmpfile;
    186 
    187 open(MAKEFILE, "> $makefile5");
    188 print MAKEFILE <<'EOF';
     136run_make_test('
    189137.PHONY: a
    190138
     
    196144a: BLAH := bar
    197145a: COMMAND += snafu $(BLAH)
    198 EOF
    199 close(MAKEFILE);
    200 
    201 &run_make_with_options("$makefile5", "", &get_logfile);
    202 $answer = "bar snafu bar\n";
    203 &compare_output($answer, &get_logfile(1));
     146',
     147              '', "bar snafu bar\n");
    204148
    205149# Test #13
    206150# Test double-colon rules with target-specific variable values
    207151
    208 $makefile6 = &get_tmpfile;
    209 
    210 open(MAKEFILE, "> $makefile6");
    211 print MAKEFILE <<'EOF';
     152run_make_test('
    212153W = bad
    213154X = bad
     
    225166  fo% : Z = pat
    226167endif
    227 
    228 EOF
    229 close(MAKEFILE);
    230 
    231 &run_make_with_options("$makefile6", "foo", &get_logfile);
    232 $answer = "ok ok foo nopat\nok ok foo nopat\n";
    233 &compare_output($answer, &get_logfile(1));
     168',
     169             'foo', "ok ok foo nopat\nok ok foo nopat\n");
    234170
    235171# Test #14
     
    237173# inheritance
    238174
    239 &run_make_with_options("$makefile6", "bar", &get_logfile);
    240 $answer = "ok ok bar nopat\nok ok bar nopat\n";
    241 &compare_output($answer, &get_logfile(1));
     175run_make_test(undef, 'bar', "ok ok bar nopat\nok ok bar nopat\n");
    242176
    243177# Test #15
    244178# Test double-colon rules with pattern-specific variable values
    245179
    246 &run_make_with_options("$makefile6", "foo PATTERN=yes", &get_logfile);
    247 $answer = "ok ok foo pat\nok ok foo pat\n";
    248 &compare_output($answer, &get_logfile(1));
    249 
     180run_make_test(undef, 'foo PATTERN=yes', "ok ok foo pat\nok ok foo pat\n");
    250181
    251182# Test #16
     
    253184# (> make default buffer length)
    254185
    255 $makefile7 = &get_tmpfile;
    256 
    257 open(MAKEFILE, "> $makefile7");
    258 print MAKEFILE <<'EOF';
     186run_make_test('
    259187base_metals_fmd_reports.sun5 base_metals_fmd_reports CreateRealPositions        CreateMarginFunds deals_changed_since : BUILD_OBJ=$(shell if [ -f               "build_information.generate" ]; then echo "$(OBJ_DIR)/build_information.o"; else echo "no build information"; fi  )
    260188
    261189deals_changed_since: ; @echo $(BUILD_OBJ)
    262 
    263 EOF
    264 close(MAKEFILE);
    265 
    266 &run_make_with_options("$makefile7", '', &get_logfile);
    267 $answer = "no build information\n";
    268 &compare_output($answer, &get_logfile(1));
     190',
     191              '', "no build information\n");
    269192
    270193# TEST #17
     
    287210.INTERMEDIATE: foo.x rules.mk
    288211',
    289               '-I t1',
    290               'MYVAR= FOOVAR=bar ALLVAR=xxx');
     212              '-I t1', 'MYVAR= FOOVAR=bar ALLVAR=xxx');
    291213
    292214rmfiles('t1/rules.mk');
     
    298220# double-expansion.  See Savannah bug #15913.
    299221
    300 run_make_test("
    301 VAR := \$\$FOO
     222run_make_test('
     223VAR := $$FOO
    302224foo: VAR += BAR
    303 foo: ; \@echo '\$(VAR)'",
    304               '',
    305               '$FOO BAR');
     225foo: ; @echo '."'".'$(VAR)'."'".'
     226',
     227              '', '$FOO BAR');
     228
     229# TEST #19: Override with append variables
     230
     231run_make_test('
     232a: override FOO += f1
     233a: FOO += f2
     234a: ; @echo "$(FOO)"
     235',
     236              '', "f1\n");
     237
     238run_make_test(undef, 'FOO=C', "C f1\n");
     239
     240# TEST #20: Check for continuation after semicolons
     241
     242run_make_test(q!
     243a: A = 'hello; \
     244world'
     245a: ; @echo $(A)
     246!,
     247              '', "hello; world\n");
     248
     249# TEST #19: Test define/endef variables as target-specific vars
     250
     251# run_make_test('
     252# define b
     253# @echo global
     254# endef
     255# a: define b
     256# @echo local
     257# endef
     258
     259# a: ; $(b)
     260# ',
     261#               '', "local\n");
    306262
    3072631;
  • trunk/src/kmk/tests/scripts/features/vpath

    r2162 r2591  
     1#                                                                     -*-perl-*-
     2
    13$description = "The following test creates a makefile to test the \n"
    24              ."vpath directive which allows you to specify a search \n"
     
    6163}
    6264
     65# TEST 2: after vpath lookup ensure we don't get incorrect circular dependency
     66# warnings due to change of struct file ptr.  Savannah bug #13529.
     67
     68mkdir('vpath-d', 0777);
     69
     70run_make_test(q!
     71vpath %.te vpath-d/
     72.SECONDARY:
     73default: vpath-d/a vpath-d/b
     74vpath-d/a: fail.te
     75vpath-d/b : fail.te
     76vpath-d/fail.te:
     77!,
     78              '', "#MAKE#: Nothing to be done for `default'.\n");
     79
     80rmdir('vpath-d');
     81
    63821;
  • trunk/src/kmk/tests/scripts/functions/abspath

    • Property svn:keywords deleted
  • trunk/src/kmk/tests/scripts/functions/realpath

    • Property svn:keywords deleted
  • trunk/src/kmk/tests/scripts/functions/shell

    r969 r2591  
    1212
    1313
     14# Test unescaped comment characters in shells.  Savannah bug #20513
     15if ($all_tests) {
     16    run_make_test(q!
     17FOO := $(shell echo '#')
     18foo: ; echo '$(FOO)'
     19!,
     20              '', "#\n");
     21}
     22
    1423# Test shells inside exported environment variables.
    1524# This is the test that fails if we try to put make exported variables into
  • trunk/src/kmk/tests/scripts/functions/wildcard

    r969 r2591  
    8282&compare_output($answer,&get_logfile(1));
    8383
     84# TEST #4: Verify that failed wildcards don't return the pattern
     85
     86run_make_test(q!
     87all: ; @echo $(wildcard xz--y*.7)
     88!,
     89              '', "\n");
    8490
    85911;
    86 
    87 
    88 
    89 
    90 
    91 
    92 
    93 
    94 
  • trunk/src/kmk/tests/scripts/misc/general4

    r1963 r2591  
    3030!$is_kmk ? 0 : 512);
    3131unlink('foo.c');
    32 
    33 
    34 # Test other implicit rule searching
    35 
    36 &touch('bar');
    37 run_make_test('
    38 test.foo:
    39 %.foo : baz ; @echo done $<
    40 %.foo : bar ; @echo done $<
    41 fox: baz
    42 ',
    43               '',
    44               'done bar');
    45 unlink('bar');
    4632
    4733
     
    8470              '', "mkdir -p dir/subdir\ntouch dir/subdir/file.\$b\ncp dir/subdir/file.\$b dir/subdir/file.\$a\n");
    8571
     72# Test odd whitespace at the beginning of a line
     73
     74run_make_test("
     75all:
     76   \f
     77
     78    \\
     79 \f  \\
     80    \013 \\
     81all: ; \@echo hi
     82",
     83              '', "hi\n");
     84
    86851;
  • trunk/src/kmk/tests/scripts/options/dash-B

    r969 r2591  
    7171rmfiles('foo.x', 'blah.x');
    7272
     73# Test that $? is set properly with -B; all prerequisites will be newer!
     74
     75utouch(-10, 'x.b');
     76touch('x.a');
     77
     78run_make_test(q!
     79x.a: x.b ; @echo $?
     80!,
     81              '-B', "x.b\n");
     82
     83unlink(qw(x.a x.b));
     84
    73851;
  • trunk/src/kmk/tests/scripts/options/symlinks

    • Property svn:keywords deleted
  • trunk/src/kmk/tests/scripts/variables/DEFAULT_GOAL

    • Property svn:keywords deleted
    r969 r2591  
    7474'foo');
    7575
     76# TEST #5: .DEFAULT_GOAL containing just whitespace (Savannah bug #25697)
     77
     78run_make_test('
     79N =
     80.DEFAULT_GOAL = $N  $N  # Just whitespace
     81
     82foo: ; @echo "boo"
     83',
     84              '', "#MAKE#: *** No targets.  Stop.\n", 512);
    7685
    7786# This tells the test driver that the perl test script executed properly.
  • trunk/src/kmk/tests/scripts/variables/MAKE

    r969 r2591  
    11#                                                                    -*-perl-*-
    22
    3 $description = "The following test creates a makefile to test MAKE \n"
    4               ."(very generic)";
     3$description = "Test proper behavior of the MAKE variable";
    54
    65$details = "DETAILS";
    76
    8 open(MAKEFILE,"> $makefile");
     7run_make_test(q!
     8TMP  := $(MAKE)
     9MAKE := $(subst X=$(X),,$(MAKE))
     10all:
     11        @echo $(TMP)
     12        $(MAKE) -f #MAKEFILE# foo
    913
    10 # The Contents of the MAKEFILE ...
     14foo:
     15        @echo $(MAKE)
     16!,
     17              '',
     18              "#MAKEPATH#\n#MAKEPATH# -f #MAKEFILE# foo\n"
     19              . "#MAKE#[1]: Entering directory `#PWD#'\n"
     20              . "#MAKEPATH#\n#MAKE#[1]: Leaving directory `#PWD#'\n");
    1121
    12 print MAKEFILE "TMP  := \$(MAKE)\n";
    13 print MAKEFILE "MAKE := \$(subst X=\$(X),,\$(MAKE))\n\n";
    14 print MAKEFILE "all:\n";
    15 print MAKEFILE "\t\@echo \$(TMP)\n";
    16 print MAKEFILE "\t\$(MAKE) -f $makefile foo\n\n";
    17 print MAKEFILE "foo:\n";
    18 print MAKEFILE "\t\@echo \$(MAKE)\n";
    19 
    20 # END of Contents of MAKEFILE
    21 
    22 close(MAKEFILE);
    23 
    24 # Create the answer to what should be produced by this Makefile
    25 $answer = "$mkpath\n$mkpath -f $makefile foo\n"
    26         . "${make_name}[1]: Entering directory `$pwd'\n"
    27         . "$mkpath\n${make_name}[1]: Leaving directory `$pwd'\n";
    28 
    29 &run_make_with_options($makefile,"",&get_logfile,0);
    30 
    31 &rmfiles("foo");
    32 # COMPARE RESULTS
    33 &compare_output($answer,&get_logfile(1));
     22rmfiles("foo");
    3423
    35241;
  • trunk/src/kmk/tests/scripts/variables/MAKEFILES

    r969 r2591  
    3232&compare_output($answer,&get_logfile(1));
    3333
     34# TEST 2: Verify that included makefiles don't set the default goal.
     35# See Savannah bug #13401.
     36
     37create_file('xx-inc.mk', '
     38include_goal: ; @echo $@
     39include xx-ind.mk
     40');
     41
     42create_file('xx-ind.mk', '
     43indirect_goal: ; @echo $@
     44');
     45
     46run_make_test(q!
     47top: ; @echo $@
     48!,
     49              'MAKEFILES=xx-inc.mk', "top\n");
     50
     51unlink(qw(xx-inc.mk xx-ind.mk));
     52
    34531;
  • trunk/src/kmk/tests/scripts/variables/MFILE_LIST

    • Property svn:keywords deleted
  • trunk/src/kmk/tests/scripts/variables/SHELL

    • Property svn:keywords deleted
    r1969 r2591  
    5050$extraENV{SHELL} = $mshell;
    5151
    52 # bird: This was wrong, see Savannah bug #24655. Fixed in kBuild.
    53 run_make_test("all: export SHELL := /./$mshell\n".'
    54 all:;@echo "$(SHELL) $$SHELL"
    55 ', '', "/./$mshell /./$mshell");
     52# bird: This was wrong at some point, see Savannah bug #24655. Was first fixed in kBuild.
     53run_make_test("
     54SHELL := /././$mshell
     55one: two
     56two: export SHELL := /./$mshell\n".'
     57one two:;@echo "$@: $(SHELL) $$SHELL"
     58', '', "two: /./$mshell /./$mshell\none: /././$mshell $mshell\n");
     59
     60# Test .SHELLFLAGS
     61
     62# We don't know the output here: on Solaris for example, every line printed
     63# by the shell in -x mode has a trailing space (!!)
     64my $script = 'true; true';
     65my $flags = '-xc';
     66my $out = `/bin/sh $flags '$script' 2>&1`;
     67
     68run_make_test(qq!
     69.SHELLFLAGS = $flags
     70all: ; \@$script
     71!,
     72              '', $out);
     73
     74# We can't just use "false" because on different systems it provides a
     75# different exit code--once again Solaris: false exits with 255 not 1
     76$script = 'true; false; true';
     77$flags = '-xec';
     78$out = `/bin/sh $flags '$script' 2>&1`;
     79my $err = $? >> 8;
     80
     81run_make_test(qq!
     82.SHELLFLAGS = $flags
     83all: ; \@$script
     84!,
     85              '', "$out#MAKE#: *** [all] Error $err\n", 512);
    5686
    57871;
  • trunk/src/kmk/tests/scripts/variables/automatic

    r1984 r2591  
    108108unlink('foo');
    109109
     110# TEST #4: ensure prereq ordering is correct when the commmand target has none
     111# See Savannah bug #21198
     112
     113run_make_test('
     114all : A B
     115all : ; @echo $@ -- $^ -- $<
     116all : C D
     117all : E F
     118A B C D E F G H : ; @:
     119',
     120              '', "all -- A B C D E F -- A\n");
     121
    1101221;
  • trunk/src/kmk/tests/scripts/variables/flavors

    r1970 r2591  
    55$details = "";
    66
    7 open(MAKEFILE, "> $makefile");
     7# TEST 0: Recursive
    88
    9 # The Contents of the MAKEFILE ...
    10 
    11 print MAKEFILE <<'EOF';
     9run_make_test('
     10ugh = Goodbye
    1211foo = $(bar)
    1312bar = ${ugh}
    1413ugh = Hello
     14all: ; @echo $(foo)
     15',
     16              '', "Hello\n");
    1517
    16 all: multi ; @echo $(foo)
    17 
    18 multi: ; $(multi)
    19 
    20 x := foo
    21 y := $(x) bar
    22 x := later
    23 
    24 nullstring :=
    25 space := $(nullstring) $(nullstring)
    26 
    27 next: ; @echo $x$(space)$y
    28 
    29 define multi
    30 @echo hi
    31 echo there
    32 endef
    33 
    34 ifdef BOGUS
    35 define
    36 @echo error
    37 endef
    38 endif
    39 
    40 define outer
    41  define inner
    42   A = B
    43  endef
    44 endef
    45 
    46 $(eval $(outer))
    47 
    48 outer: ; @echo $(inner)
    49 
    50 EOF
    51 
    52 # END of Contents of MAKEFILE
    53 
    54 close(MAKEFILE);
    55 
    56 # TEST #1
    57 # -------
    58 
    59 &run_make_with_options($makefile, "", &get_logfile);
    60 $answer = "hi\necho there\nthere\nHello\n";
    61 &compare_output($answer, &get_logfile(1));
    62 
    63 # TEST #2
    64 # -------
    65 
    66 &run_make_with_options($makefile, "next", &get_logfile);
    67 $answer = "later foo bar\n";
    68 &compare_output($answer, &get_logfile(1));
    69 
    70 # TEST #3
    71 # -------
    72 
    73 &run_make_with_options($makefile, "BOGUS=true", &get_logfile, 512);
    74 $answer = "$makefile:24: *** empty variable name.  Stop.\n";
    75 &compare_output($answer, &get_logfile(1));
    76 
    77 # TEST #4
    78 # -------
    79 
    80 &run_make_with_options($makefile, "outer", &get_logfile);
    81 $answer = "A = B\n";
    82 &compare_output($answer, &get_logfile(1));
    83 
    84 # Clean up from "old style" testing.  If all the above tests are converted to
    85 # run_make_test() syntax than this line can be removed.
    86 $makefile = undef;
    87 
    88 # -------------------------
    89 # Make sure that prefix characters apply properly to define/endef values.
    90 #
    91 # There's a bit of oddness here if you try to use a variable to hold the
    92 # prefix character for a define.  Even though something like this:
    93 #
    94 #       define foo
    95 #       echo bar
    96 #       endef
    97 #
    98 #       all: ; $(V)$(foo)
    99 #
    100 # (where V=@) can be seen by the user to be obviously different than this:
    101 #
    102 #       define foo
    103 #       $(V)echo bar
    104 #       endef
    105 #
    106 #       all: ; $(foo)
    107 #
    108 # and the user thinks it should behave the same as when the "@" is literal
    109 # instead of in a variable, that can't happen because by the time make
    110 # expands the variables for the command line and sees it begins with a "@" it
    111 # can't know anymore whether the prefix character came before the variable
    112 # reference or was included in the first line of the variable reference.
    113 
    114 # TEST #5
    115 # -------
     18# TEST 1: Simple
    11619
    11720run_make_test('
    118 define FOO
    119 $(V1)echo hello
    120 $(V2)echo world
    121 endef
    122 all: ; @$(FOO)
    123 ', '', 'hello
    124 world');
     21bar = Goodbye
     22foo := $(bar)
     23bar = ${ugh}
     24ugh = Hello
     25all: ; @echo $(foo)
     26',
     27              '', "Goodbye\n");
    12528
    126 # TEST #6
    127 # -------
    128 
    129 run_make_test(undef, 'V1=@ V2=@', 'hello
    130 world');
    131 
    132 # TEST #7
    133 # -------
     29# TEST 2: Append to recursive
    13430
    13531run_make_test('
    136 define FOO
    137 $(V1)echo hello
    138 $(V2)echo world
    139 endef
    140 all: ; $(FOO)
    141 ', 'V1=@', 'hello
    142 echo world
    143 world');
     32foo = Hello
     33ugh = Goodbye
     34foo += $(bar)
     35bar = ${ugh}
     36ugh = Hello
     37all: ; @echo $(foo)
     38',
     39              '', "Hello Hello\n");
    14440
    145 # TEST #8
    146 # -------
    147 
    148 run_make_test(undef, 'V2=@', 'echo hello
    149 hello
    150 world');
    151 
    152 # TEST #9
    153 # -------
    154 
    155 run_make_test(undef, 'V1=@ V2=@', 'hello
    156 world');
    157 
    158 # TEST #10
    159 # -------
    160 # Test the basics; a "@" internally to the variable applies to only one line.
    161 # A "@" before the variable applies to the entire variable.
     41# TEST 3: Append to simple
    16242
    16343run_make_test('
    164 define FOO
    165 @echo hello
    166 echo world
    167 endef
    168 define BAR
    169 echo hello
    170 echo world
    171 endef
     44foo := Hello
     45ugh = Goodbye
     46bar = ${ugh}
     47foo += $(bar)
     48ugh = Hello
     49all: ; @echo $(foo)
     50',
     51              '', "Hello Goodbye\n");
    17252
    173 all: foo bar
    174 foo: ; $(FOO)
    175 bar: ; @$(BAR)
    176 ', '-j1', 'hello
    177 echo world
    178 world
    179 hello
    180 world
    181 ');
     53# TEST 4: Conditional pre-set
     54
     55run_make_test('
     56foo = Hello
     57ugh = Goodbye
     58bar = ${ugh}
     59foo ?= $(bar)
     60ugh = Hello
     61all: ; @echo $(foo)
     62',
     63              '', "Hello\n");
     64
     65# TEST 5: Conditional unset
     66
     67run_make_test('
     68ugh = Goodbye
     69bar = ${ugh}
     70foo ?= $(bar)
     71ugh = Hello
     72all: ; @echo $(foo)
     73',
     74              '', "Hello\n");
    18275
    183761;
  • trunk/src/kmk/tests/test_driver.pl

    r1993 r2591  
    77#
    88# Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
    9 # 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
     9# 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
     10# Foundation, Inc.
    1011# This file is part of GNU Make.
    1112#
     
    3031# variables and then calls &toplevel, which does all the real work.
    3132
    32 # $Id: test_driver.pl,v 1.24 2007/11/04 21:54:02 psmith Exp $
     33# $Id: test_driver.pl,v 1.30 2010/07/28 05:39:50 psmith Exp $
    3334
    3435
     
    5455$test_timeout = 5;
    5556
     57# Path to Perl
     58$perl_name = $^X;
    5659
    5760# %makeENV is the cleaned-out environment.
     
    239242{
    240243  # Set up an initial value.  In perl5 we can do it the easy way.
    241   #
    242244  $osname = defined($^O) ? $^O : '';
     245
     246  # Find a path to Perl
    243247
    244248  # See if the filesystem supports long file names with multiple
     
    276280    if ($osname =~ /not found/i)
    277281    {
    278         $osname = "(something unixy with no uname)";
     282        $osname = "(something posixy with no uname)";
    279283    }
    280284    elsif ($@ ne "" || $?)
     
    283287        if ($@ ne "" || $?)
    284288        {
    285             $osname = "(something unixy)";
     289            $osname = "(something posixy)";
    286290        }
    287291    }
     
    460464      $diffext = 'd';
    461465      $baseext = 'b';
     466      $runext = 'r';
    462467      $extext = '';
    463468    } else {
     
    465470      $diffext = 'diff';
    466471      $baseext = 'base';
     472      $runext = 'run';
    467473      $extext = '.';
    468474    }
     
    470476    $diff_filename = "$testpath.$diffext";
    471477    $base_filename = "$testpath.$baseext";
     478    $run_filename = "$testpath.$runext";
    472479    $tmp_filename = "$testpath.$tmpfilesuffix";
    473480
     
    483490    $tests_run = 0;
    484491    $tests_passed = 0;
     492
    485493    $code = do $perl_testname;
    486494
     
    716724
    717725    &create_file (&get_basefile, $answer);
     726    &create_file (&get_runfile, $command_string);
    718727
    719728    print "\nCreating Difference File ...\n" if $debug;
     
    723732    local($command) = "diff -c " . &get_basefile . " " . $logfile;
    724733    &run_command_with_output(&get_difffile,$command);
     734  } else {
     735      &rmfiles ();
    725736  }
    726737
     
    816827      local $SIG{ALRM} = sub { die "timeout\n"; };
    817828      alarm $test_timeout;
    818       $code = system @_;
     829      $code = system(@_);
    819830      alarm 0;
    820831  };
     
    853864  my $filename = shift;
    854865
    855   print "\nrun_command_with_output($filename): @_\n" if $debug;
     866  print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
    856867  &attach_default_output ($filename);
    857868  my $code = _run_command(@_);
     
    12261237}
    12271238
     1239# This subroutine returns a command filename with a number appended
     1240# to the end corresponding to how many logfiles (and thus command files)
     1241# have been created in the current running test.
     1242
     1243sub get_runfile
     1244{
     1245  return ($run_filename . &num_suffix ($num_of_logfiles));
     1246}
     1247
    12281248# just like logfile, only a generic tmp filename for use by the test.
    12291249# they are automatically cleaned up unless -keep was used, or the test fails.
  • trunk/src/kmk/variable.c

    r2554 r2591  
    11/* Internals of variables for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    4747static struct pattern_var *pattern_vars;
    4848
    49 /* Pointer to last struct in the chain, so we can add onto the end.  */
    50 
    51 static struct pattern_var *last_pattern_var;
    52 
    53 /* Create a new pattern-specific variable struct.  */
     49/* Pointer to the last struct in the pack of a specific size, from 1 to 255.*/
     50
     51static struct pattern_var *last_pattern_vars[256];
     52
     53/* Create a new pattern-specific variable struct. The new variable is
     54   inserted into the PATTERN_VARS list in the shortest patterns first
     55   order to support the shortest stem matching (the variables are
     56   matched in the reverse order so the ones with the longest pattern
     57   will be considered first). Variables with the same pattern length
     58   are inserted in the definition order. */
    5459
    5560struct pattern_var *
    5661create_pattern_var (const char *target, const char *suffix)
    5762{
     63  register unsigned int len = strlen (target);
    5864  register struct pattern_var *p = xmalloc (sizeof (struct pattern_var));
    5965
    60   if (last_pattern_var != 0)
    61     last_pattern_var->next = p;
     66  if (pattern_vars != 0)
     67    {
     68      if (len < 256 && last_pattern_vars[len] != 0)
     69        {
     70          p->next = last_pattern_vars[len]->next;
     71          last_pattern_vars[len]->next = p;
     72        }
     73      else
     74        {
     75          /* Find the position where we can insert this variable. */
     76          register struct pattern_var **v;
     77
     78          for (v = &pattern_vars; ; v = &(*v)->next)
     79            {
     80              /* Insert at the end of the pack so that patterns with the
     81                 same length appear in the order they were defined .*/
     82
     83              if (*v == 0 || (*v)->len > len)
     84                {
     85                  p->next = *v;
     86                  *v = p;
     87                  break;
     88                }
     89            }
     90        }
     91    }
    6292  else
    63     pattern_vars = p;
    64   last_pattern_var = p;
    65   p->next = 0;
     93    {
     94      pattern_vars = p;
     95      p->next = 0;
     96    }
    6697
    6798  p->target = target;
    68   p->len = strlen (target);
     99  p->len = len;
    69100  p->suffix = suffix + 1;
     101
     102  if (len < 256)
     103    last_pattern_vars[len] = p;
    70104
    71105  return p;
     
    170204static struct variable_set global_variable_set;
    171205static struct variable_set_list global_setlist
    172   = { 0, &global_variable_set };
     206  = { 0, &global_variable_set, 0 };
    173207struct variable_set_list *current_variable_set_list = &global_setlist;
    174208
     
    344378#endif
    345379#ifndef CONFIG_WITH_STRCACHE2
    346   v->name = savestring (name, length);
     380  v->name = xstrndup (name, length);
    347381#else
    348382  v->name = name; /* already cached. */
     
    387421  v->per_target = 0;
    388422  v->append = 0;
     423  v->private_var = 0;
    389424  v->export = v_default;
    390425  MAKE_STATS_2(v->changes = 0);
     
    414449}
    415450
     451
     452
     453/* Undefine variable named NAME in SET. LENGTH is the length of NAME, which
     454   does not need to be null-terminated. ORIGIN specifies the origin of the
     455   variable (makefile, command line or environment). */
     456
     457static void
     458free_variable_name_and_value (const void *item);
     459
     460void
     461undefine_variable_in_set (const char *name, unsigned int length,
     462                          enum variable_origin origin,
     463                          struct variable_set *set)
     464{
     465  struct variable *v;
     466  struct variable **var_slot;
     467  struct variable var_key;
     468
     469  if (set == NULL)
     470    set = &global_variable_set;
     471
     472  var_key.name = (char *) name;
     473  var_key.length = length;
     474  var_slot = (struct variable **) hash_find_slot (&set->table, &var_key);
     475
     476  if (env_overrides && origin == o_env)
     477    origin = o_env_override;
     478
     479  v = *var_slot;
     480  if (! HASH_VACANT (v))
     481    {
     482      if (env_overrides && v->origin == o_env)
     483        /* V came from in the environment.  Since it was defined
     484           before the switches were parsed, it wasn't affected by -e.  */
     485        v->origin = o_env_override;
     486
     487      /* If the definition is from a stronger source than this one, don't
     488         undefine it.  */
     489      if ((int) origin >= (int) v->origin)
     490        {
     491          hash_delete_at (&set->table, var_slot);
     492          free_variable_name_and_value (v);
     493        }
     494    }
     495}
    416496
    417497/* If the variable passed in is "special", handle its special nature.
     
    515595
    516596
    517 #ifdef KMK /* bird: speed */
     597#if 0 /*FIX THIS - def KMK*/ /* bird: speed */
    518598MY_INLINE struct variable *
    519599lookup_cached_variable (const char *name)
     
    646726lookup_variable (const char *name, unsigned int length)
    647727{
    648 #ifndef KMK
     728#if 1 /*FIX THIS - ndef KMK*/
    649729  const struct variable_set_list *setlist;
    650730  struct variable var_key;
     
    652732  struct variable *v;
    653733#endif /* KMK */
     734  int is_parent = 0;
    654735#ifdef CONFIG_WITH_STRCACHE2
    655736  const char *cached_name;
     
    662743  name = cached_name;
    663744#endif /* CONFIG_WITH_STRCACHE2 */
    664 #ifndef KMK
     745#if 1  /*FIX THIS - ndef KMK */
    665746
    666747  var_key.name = (char *) name;
     
    678759      v = (struct variable *) hash_find_item_strcached ((struct hash_table *) &set->table, &var_key);
    679760# endif /* CONFIG_WITH_STRCACHE2 */
    680       if (v)
     761      if (v && (!is_parent || !v->private_var))
    681762        return v->special ? lookup_special_var (v) : v;
     763
     764      is_parent |= setlist->next_is_parent;
    682765    }
    683766
     
    747830#endif /* VMS */
    748831
    749 #if !defined (KMK) || defined(VMS)
    750832  return 0;
    751 #endif
    752833}
    753834
     
    838919      initialize_file_variables (file->double_colon, reading);
    839920      l->next = file->double_colon->variables;
     921      l->next_is_parent = 0;
    840922      return;
    841923    }
     
    848930      l->next = file->parent->variables;
    849931    }
     932  l->next_is_parent = 1;
    850933
    851934  /* If we're not reading makefiles and we haven't looked yet, see if
     
    900983              v->per_target = p->variable.per_target;
    901984              v->export = p->variable.export;
     985              v->private_var = p->variable.private_var;
    902986            }
    903987          while ((p = lookup_pattern_var (p, file->name)) != 0);
     
    913997    {
    914998      file->pat_variables->next = l->next;
     999      file->pat_variables->next_is_parent = l->next_is_parent;
    9151000      l->next = file->pat_variables;
     1001      l->next_is_parent = 0;
    9161002    }
    9171003}
     
    9491035  setlist->set = set;
    9501036  setlist->next = current_variable_set_list;
     1037  setlist->next_is_parent = 0;
    9511038
    9521039  return setlist;
     
    10311118      global_setlist.set = setlist->set;
    10321119      global_setlist.next = setlist->next;
     1120      global_setlist.next_is_parent = setlist->next_is_parent;
    10331121    }
    10341122
     
    11691257
    11701258  sprintf (buf, "%u", makelevel);
    1171   (void) define_variable (MAKELEVEL_NAME, MAKELEVEL_LENGTH, buf, o_env, 0);
     1259  define_variable_cname (MAKELEVEL_NAME, buf, o_env, 0);
    11721260
    11731261  sprintf (buf, "%s%s%s",
     
    11781266           ? "" : remote_description);
    11791267#ifndef KMK
    1180   (void) define_variable ("MAKE_VERSION", 12, buf, o_default, 0);
     1268  define_variable_cname ("MAKE_VERSION", buf, o_default, 0);
    11811269#else /* KMK */
    11821270
    11831271  /* Define KMK_VERSION to indicate kMk. */
    1184   (void) define_variable ("KMK_VERSION", 11, buf, o_default, 0);
     1272  define_variable_cname ("KMK_VERSION", buf, o_default, 0);
    11851273
    11861274  /* Define KBUILD_VERSION* */
    11871275  sprintf (buf, "%d", KBUILD_VERSION_MAJOR);
    1188   define_variable ("KBUILD_VERSION_MAJOR", sizeof ("KBUILD_VERSION_MAJOR") - 1,
    1189                    buf, o_default, 0);
     1276  define_variable_cname ("KBUILD_VERSION_MAJOR", buf, o_default, 0);
    11901277  sprintf (buf, "%d", KBUILD_VERSION_MINOR);
    1191   define_variable ("KBUILD_VERSION_MINOR", sizeof("KBUILD_VERSION_MINOR") - 1,
    1192                    buf, o_default, 0);
     1278  define_variable_cname ("KBUILD_VERSION_MINOR", buf, o_default, 0);
    11931279  sprintf (buf, "%d", KBUILD_VERSION_PATCH);
    1194   define_variable ("KBUILD_VERSION_PATCH", sizeof ("KBUILD_VERSION_PATCH") - 1,
    1195                    buf, o_default, 0);
     1280  define_variable_cname ("KBUILD_VERSION_PATCH", buf, o_default, 0);
    11961281  sprintf (buf, "%d", KBUILD_SVN_REV);
    1197   define_variable ("KBUILD_KMK_REVISION", sizeof ("KBUILD_KMK_REVISION") - 1,
    1198                    buf, o_default, 0);
     1282  define_variable_cname ("KBUILD_KMK_REVISION", buf, o_default, 0);
    11991283
    12001284  sprintf (buf, "%d.%d.%d-r%d", KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR,
    12011285           KBUILD_VERSION_PATCH, KBUILD_SVN_REV);
    1202   define_variable ("KBUILD_VERSION", sizeof ("KBUILD_VERSION") - 1,
    1203                    buf, o_default, 0);
     1286  define_variable_cname ("KBUILD_VERSION", buf, o_default, 0);
    12041287
    12051288  /* The host defaults. The BUILD_* stuff will be replaced by KBUILD_* soon. */
     
    12101293    error (NULL, _("KBUILD_HOST and BUILD_PLATFORM differs, using KBUILD_HOST=%s."), val);
    12111294  if (!envvar1)
    1212     define_variable ("KBUILD_HOST", sizeof ("KBUILD_HOST") - 1,
    1213                      val, o_default, 0);
     1295    define_variable_cname ("KBUILD_HOST", val, o_default, 0);
    12141296  if (!envvar2)
    1215     define_variable ("BUILD_PLATFORM", sizeof ("BUILD_PLATFORM") - 1,
    1216                      val, o_default, 0);
     1297    define_variable_cname ("BUILD_PLATFORM", val, o_default, 0);
    12171298
    12181299  envvar1 = lookup_variable (STRING_SIZE_TUPLE ("KBUILD_HOST_ARCH"));
     
    12221303    error (NULL, _("KBUILD_HOST_ARCH and BUILD_PLATFORM_ARCH differs, using KBUILD_HOST_ARCH=%s."), val);
    12231304  if (!envvar1)
    1224     define_variable ("KBUILD_HOST_ARCH", sizeof ("KBUILD_HOST_ARCH") - 1,
    1225                      val, o_default, 0);
     1305    define_variable_cname ("KBUILD_HOST_ARCH", val, o_default, 0);
    12261306  if (!envvar2)
    1227     define_variable ("BUILD_PLATFORM_ARCH", sizeof ("BUILD_PLATFORM_ARCH") - 1,
    1228                      val, o_default, 0);
     1307    define_variable_cname ("BUILD_PLATFORM_ARCH", val, o_default, 0);
    12291308
    12301309  envvar1 = lookup_variable (STRING_SIZE_TUPLE ("KBUILD_HOST_CPU"));
     
    12341313    error (NULL, _("KBUILD_HOST_CPU and BUILD_PLATFORM_CPU differs, using KBUILD_HOST_CPU=%s."), val);
    12351314  if (!envvar1)
    1236     define_variable ("KBUILD_HOST_CPU", sizeof ("KBUILD_HOST_CPU") - 1,
    1237                      val, o_default, 0);
     1315    define_variable_cname ("KBUILD_HOST_CPU", val, o_default, 0);
    12381316  if (!envvar2)
    1239     define_variable ("BUILD_PLATFORM_CPU", sizeof ("BUILD_PLATFORM_CPU") - 1,
    1240                      val, o_default, 0);
     1317    define_variable_cname ("BUILD_PLATFORM_CPU", val, o_default, 0);
    12411318
    12421319  /* The host kernel version. */
     
    12771354
    12781355  sprintf (buf, "%lu.%lu.%lu.%lu", ulMajor, ulMinor, ulPatch, ul4th);
    1279   define_variable ("KBUILD_HOST_VERSION", sizeof ("KBUILD_HOST_VERSION") - 1,
    1280                    buf, o_default, 0);
     1356  define_variable_cname ("KBUILD_HOST_VERSION", buf, o_default, 0);
    12811357
    12821358  sprintf (buf, "%lu", ulMajor);
    1283   define_variable ("KBUILD_HOST_VERSION_MAJOR", sizeof ("KBUILD_HOST_VERSION_MAJOR") - 1,
    1284                    buf, o_default, 0);
     1359  define_variable_cname ("KBUILD_HOST_VERSION_MAJOR", buf, o_default, 0);
    12851360
    12861361  sprintf (buf, "%lu", ulMinor);
    1287   define_variable ("KBUILD_HOST_VERSION_MINOR", sizeof ("KBUILD_HOST_VERSION_MINOR") - 1,
    1288                    buf, o_default, 0);
     1362  define_variable_cname ("KBUILD_HOST_VERSION_MINOR", buf, o_default, 0);
    12891363
    12901364  sprintf (buf, "%lu", ulPatch);
    1291   define_variable ("KBUILD_HOST_VERSION_PATCH", sizeof ("KBUILD_HOST_VERSION_PATCH") - 1,
    1292                    buf, o_default, 0);
     1365  define_variable_cname ("KBUILD_HOST_VERSION_PATCH", buf, o_default, 0);
    12931366
    12941367  /* The kBuild locations. */
    1295   define_variable ("KBUILD_PATH", sizeof ("KBUILD_PATH") - 1,
    1296                    get_kbuild_path (), o_default, 0);
    1297   define_variable ("KBUILD_BIN_PATH", sizeof ("KBUILD_BIN_PATH") - 1,
    1298                    get_kbuild_bin_path (), o_default, 0);
    1299 
    1300   define_variable ("PATH_KBUILD", sizeof ("PATH_KBUILD") - 1,
    1301                    get_kbuild_path (), o_default, 0);
    1302   define_variable ("PATH_KBUILD_BIN", sizeof ("PATH_KBUILD_BIN") - 1,
    1303                    get_kbuild_bin_path (), o_default, 0);
     1368  define_variable_cname ("KBUILD_PATH", get_kbuild_path (), o_default, 0);
     1369  define_variable_cname ("KBUILD_BIN_PATH", get_kbuild_bin_path (), o_default, 0);
     1370
     1371  define_variable_cname ("PATH_KBUILD", get_kbuild_path (), o_default, 0);
     1372  define_variable_cname ("PATH_KBUILD_BIN", get_kbuild_bin_path (), o_default, 0);
    13041373
    13051374  /* Define KMK_FEATURES to indicate various working KMK features. */
     
    13301399  && defined (CONFIG_WITH_DEFINED_FUNCTIONS) \
    13311400  && defined (KMK_HELPERS)
    1332   (void) define_variable ("KMK_FEATURES", 12,
    1333                           "append-dash-n abspath includedep-queue install-hard-linking umask"
    1334                           " kBuild-define"
    1335                           " rsort"
    1336                           " abspathex"
    1337                           " toupper tolower"
    1338                           " defined"
    1339                           " comp-vars comp-cmds comp-cmds-ex"
    1340                           " stack"
    1341                           " math-int"
    1342                           " xargs"
    1343                           " explicit-multitarget"
    1344                           " dot-must-make"
    1345                           " prepend-assignment"
    1346                           " set-conditionals intersects"
    1347                           " date"
    1348                           " file-size"
    1349                           " expr if-expr select"
    1350                           " where"
    1351                           " which"
    1352                           " evalctx evalval evalvalctx evalcall evalcall2 eval-opt-var"
    1353                           " make-stats"
    1354                           " commands"
    1355                           " printf"
    1356                           " for while"
    1357                           " root"
    1358                           " length insert pos lastpos substr translate"
    1359                           " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl"
    1360                           " firstdefined lastdefined"
    1361                           , o_default, 0);
     1401  define_variable_cname ("KMK_FEATURES",
     1402                         "append-dash-n abspath includedep-queue install-hard-linking umask"
     1403                         " kBuild-define"
     1404                         " rsort"
     1405                         " abspathex"
     1406                         " toupper tolower"
     1407                         " defined"
     1408                         " comp-vars comp-cmds comp-cmds-ex"
     1409                         " stack"
     1410                         " math-int"
     1411                         " xargs"
     1412                         " explicit-multitarget"
     1413                         " dot-must-make"
     1414                         " prepend-assignment"
     1415                         " set-conditionals intersects"
     1416                         " date"
     1417                         " file-size"
     1418                         " expr if-expr select"
     1419                         " where"
     1420                         " which"
     1421                         " evalctx evalval evalvalctx evalcall evalcall2 eval-opt-var"
     1422                         " make-stats"
     1423                         " commands"
     1424                         " printf"
     1425                         " for while"
     1426                         " root"
     1427                         " length insert pos lastpos substr translate"
     1428                         " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl"
     1429                         " firstdefined lastdefined"
     1430                         , o_default, 0);
    13621431# else /* MSC can't deal with strings mixed with #if/#endif, thus the slow way. */
    13631432#  error "All features should be enabled by default!"
     
    14421511  strcat (buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl");
    14431512#  endif
    1444   (void) define_variable ("KMK_FEATURES", 12, buf, o_default, 0);
     1513  define_variable_cname ("KMK_FEATURES", buf, o_default, 0);
    14451514# endif
    14461515
     
    14491518#ifdef CONFIG_WITH_KMK_BUILTIN
    14501519  /* The supported kMk Builtin commands. */
    1451   (void) define_variable ("KMK_BUILTIN", 11, "append cat chmod cp cmp echo expr install kDepIDB ln md5sum mkdir mv printf rm rmdir sleep test", o_default, 0);
     1520  define_variable_cname ("KMK_BUILTIN", "append cat chmod cp cmp echo expr install kDepIDB ln md5sum mkdir mv printf rm rmdir sleep test", o_default, 0);
    14521521#endif
    14531522
     
    14611530    struct variable *comp = lookup_variable ("COMSPEC", 7);
    14621531
    1463     /* Make $MAKESHELL override $SHELL even if -e is in effect.  */
     1532    /* $(MAKESHELL) overrides $(SHELL) even if -e is in effect.  */
    14641533    if (mshp)
    14651534      (void) define_variable (shell_str, shlen,
     
    14671536    else if (comp)
    14681537      {
    1469         /* $COMSPEC shouldn't override $SHELL.  */
     1538        /* $(COMSPEC) shouldn't override $(SHELL).  */
    14701539        struct variable *shp = lookup_variable (shell_str, shlen);
    14711540
     
    15261595  /* This won't override any definition, but it will provide one if there
    15271596     isn't one there.  */
    1528   v = define_variable ("SHELL", 5, default_shell, o_default, 0);
     1597  v = define_variable_cname ("SHELL", default_shell, o_default, 0);
    15291598#ifdef __MSDOS__
    15301599  v->export = v_export;  /*  Export always SHELL.  */
     
    15551624
    15561625  /* Make sure MAKEFILES gets exported if it is set.  */
    1557   v = define_variable ("MAKEFILES", 9, "", o_default, 0);
     1626  v = define_variable_cname ("MAKEFILES", "", o_default, 0);
    15581627  v->export = v_ifset;
    15591628
     
    15621631
    15631632#ifdef VMS
    1564   define_variable ("@D", 2, "$(dir $@)", o_automatic, 1);
    1565   define_variable ("%D", 2, "$(dir $%)", o_automatic, 1);
    1566   define_variable ("*D", 2, "$(dir $*)", o_automatic, 1);
    1567   define_variable ("<D", 2, "$(dir $<)", o_automatic, 1);
    1568   define_variable ("?D", 2, "$(dir $?)", o_automatic, 1);
    1569   define_variable ("^D", 2, "$(dir $^)", o_automatic, 1);
    1570   define_variable ("+D", 2, "$(dir $+)", o_automatic, 1);
     1633  define_variable_cname ("@D", "$(dir $@)", o_automatic, 1);
     1634  define_variable_cname ("%D", "$(dir $%)", o_automatic, 1);
     1635  define_variable_cname ("*D", "$(dir $*)", o_automatic, 1);
     1636  define_variable_cname ("<D", "$(dir $<)", o_automatic, 1);
     1637  define_variable_cname ("?D", "$(dir $?)", o_automatic, 1);
     1638  define_variable_cname ("^D", "$(dir $^)", o_automatic, 1);
     1639  define_variable_cname ("+D", "$(dir $+)", o_automatic, 1);
    15711640#else
    1572   define_variable ("@D", 2, "$(patsubst %/,%,$(dir $@))", o_automatic, 1);
    1573   define_variable ("%D", 2, "$(patsubst %/,%,$(dir $%))", o_automatic, 1);
    1574   define_variable ("*D", 2, "$(patsubst %/,%,$(dir $*))", o_automatic, 1);
    1575   define_variable ("<D", 2, "$(patsubst %/,%,$(dir $<))", o_automatic, 1);
    1576   define_variable ("?D", 2, "$(patsubst %/,%,$(dir $?))", o_automatic, 1);
    1577   define_variable ("^D", 2, "$(patsubst %/,%,$(dir $^))", o_automatic, 1);
    1578   define_variable ("+D", 2, "$(patsubst %/,%,$(dir $+))", o_automatic, 1);
    1579 #endif
    1580   define_variable ("@F", 2, "$(notdir $@)", o_automatic, 1);
    1581   define_variable ("%F", 2, "$(notdir $%)", o_automatic, 1);
    1582   define_variable ("*F", 2, "$(notdir $*)", o_automatic, 1);
    1583   define_variable ("<F", 2, "$(notdir $<)", o_automatic, 1);
    1584   define_variable ("?F", 2, "$(notdir $?)", o_automatic, 1);
    1585   define_variable ("^F", 2, "$(notdir $^)", o_automatic, 1);
    1586   define_variable ("+F", 2, "$(notdir $+)", o_automatic, 1);
     1641  define_variable_cname ("@D", "$(patsubst %/,%,$(dir $@))", o_automatic, 1);
     1642  define_variable_cname ("%D", "$(patsubst %/,%,$(dir $%))", o_automatic, 1);
     1643  define_variable_cname ("*D", "$(patsubst %/,%,$(dir $*))", o_automatic, 1);
     1644  define_variable_cname ("<D", "$(patsubst %/,%,$(dir $<))", o_automatic, 1);
     1645  define_variable_cname ("?D", "$(patsubst %/,%,$(dir $?))", o_automatic, 1);
     1646  define_variable_cname ("^D", "$(patsubst %/,%,$(dir $^))", o_automatic, 1);
     1647  define_variable_cname ("+D", "$(patsubst %/,%,$(dir $+))", o_automatic, 1);
     1648#endif
     1649  define_variable_cname ("@F", "$(notdir $@)", o_automatic, 1);
     1650  define_variable_cname ("%F", "$(notdir $%)", o_automatic, 1);
     1651  define_variable_cname ("*F", "$(notdir $*)", o_automatic, 1);
     1652  define_variable_cname ("<F", "$(notdir $<)", o_automatic, 1);
     1653  define_variable_cname ("?F", "$(notdir $?)", o_automatic, 1);
     1654  define_variable_cname ("^F", "$(notdir $^)", o_automatic, 1);
     1655  define_variable_cname ("+F", "$(notdir $+)", o_automatic, 1);
    15871656#ifdef CONFIG_WITH_LAZY_DEPS_VARS
    15881657  define_variable ("^", 1, "$(deps $@)", o_automatic, 1);
     
    17531822              convert_Path_to_windows32(value, ';');
    17541823#endif
    1755             *result++ = xstrdup (concat (v->name, "=", value));
     1824            *result++ = xstrdup (concat (3, v->name, "=", value));
    17561825            free (value);
    17571826          }
     
    17631832              convert_Path_to_windows32(v->value, ';');
    17641833#endif
    1765             *result++ = xstrdup (concat (v->name, "=", v->value));
     1834            *result++ = xstrdup (concat (3, v->name, "=", v->value));
    17661835          }
    17671836      }
     
    19542023          value_len = strlen (value);
    19552024        if (!free_value)
    1956           p = alloc_value = savestring (value, value_len);
     2025          p = alloc_value = xstrndup (value, value_len);
    19572026        else
    19582027          {
     
    20482117            unsigned int oldlen, vallen;
    20492118            const char *val;
    2050             char *tp;
     2119            char *tp = NULL;
    20512120
    20522121            val = value;
     
    20612130                 memory for the expansion as we may still need the rest of the
    20622131                 buffer if we're looking at a target-specific variable.  */
    2063               val = alloc_value = allocated_variable_expand (val);
     2132              val = tp = allocated_variable_expand (val);
    20642133
    20652134            oldlen = strlen (v->value);
    20662135            vallen = strlen (val);
    2067             tp = alloca (oldlen + 1 + vallen + 1);
     2136            p = alloc_value = xmalloc (oldlen + 1 + vallen + 1);
    20682137# ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
    20692138            if (org_flavor == f_prepend)
    20702139              {
    2071                 memcpy (tp, val, vallen);
    2072                 tp[oldlen] = ' ';
    2073                 memcpy (&tp[oldlen + 1], v->value, oldlen + 1);
     2140                memcpy (alloc_value, val, vallen);
     2141                alloc_value[oldlen] = ' ';
     2142                memcpy (&alloc_value[oldlen + 1], v->value, oldlen + 1);
    20742143              }
    20752144            else
    20762145# endif /* CONFIG_WITH_PREPEND_ASSIGNMENT */
    20772146              {
    2078                 memcpy (tp, v->value, oldlen);
    2079                 tp[oldlen] = ' ';
    2080                 memcpy (&tp[oldlen + 1], val, vallen + 1);
     2147                memcpy (alloc_value, v->value, oldlen);
     2148                alloc_value[oldlen] = ' ';
     2149                memcpy (&alloc_value[oldlen + 1], val, vallen + 1);
    20812150              }
    2082             p = tp;
     2151
     2152            if (tp)
     2153              free (tp);
    20832154#endif /* !CONFIG_WITH_VALUE_LENGTH */
    20842155          }
     
    21932264      else
    21942265        {
    2195           if (alloc_value)
    2196             free (alloc_value);
     2266          char *tp = alloc_value;
    21972267
    21982268          alloc_value = allocated_variable_expand (p);
     2269
    21992270          if (find_and_set_default_shell (alloc_value))
    22002271            {
     
    22122283          else
    22132284            v = lookup_variable (varname, varname_len);
     2285
     2286          if (tp)
     2287            free (tp);
    22142288        }
    22152289    }
     
    22502324
    22512325
    2252 /* Try to interpret LINE (a null-terminated string) as a variable definition.
    2253 
    2254    ORIGIN may be o_file, o_override, o_env, o_env_override,
    2255    or o_command specifying that the variable definition comes
    2256    from a makefile, an override directive, the environment with
    2257    or without the -e switch, or the command line.
    2258 
    2259    See the comments for parse_variable_definition().
    2260 
    2261    If LINE was recognized as a variable definition, a pointer to its `struct
    2262    variable' is returned.  If LINE is not a variable definition, NULL is
    2263    returned.  */
    2264 
    2265 struct variable *
    2266 #ifndef CONFIG_WITH_VALUE_LENGTH
    2267 parse_variable_definition (struct variable *v, char *line)
    2268 #else
    2269 parse_variable_definition (struct variable *v, char *line, char *eos)
    2270 #endif
    2271 {
    2272   register int c;
    2273   register char *p = line;
    2274   register char *beg;
    2275   register char *end;
    2276   enum variable_flavor flavor = f_bogus;
    2277 #ifndef CONFIG_WITH_VALUE_LENGTH
    2278   char *name;
    2279 #endif
     2326/* Parse P (a null-terminated string) as a variable definition.
     2327
     2328   If it is not a variable definition, return NULL.
     2329
     2330   If it is a variable definition, return a pointer to the char after the
     2331   assignment token and set *FLAVOR to the type of variable assignment.  */
     2332
     2333char *
     2334parse_variable_definition (const char *p, enum variable_flavor *flavor)
     2335{
     2336  int wspace = 0;
     2337
     2338  p = next_token (p);
    22802339
    22812340  while (1)
    22822341    {
    2283       c = *p++;
     2342      int c = *p++;
     2343
     2344      /* If we find a comment or EOS, it's not a variable definition.  */
    22842345      if (c == '\0' || c == '#')
    2285         return 0;
    2286       if (c == '=')
     2346        return NULL;
     2347
     2348      if (c == '$')
    22872349        {
    2288           end = p - 1;
    2289           flavor = f_recursive;
    2290           break;
    2291         }
    2292       else if (c == ':')
    2293         if (*p == '=')
    2294           {
    2295             end = p++ - 1;
    2296             flavor = f_simple;
    2297             break;
    2298           }
    2299         else
    2300           /* A colon other than := is a rule line, not a variable defn.  */
    2301           return 0;
    2302       else if (c == '+' && *p == '=')
    2303         {
    2304           end = p++ - 1;
    2305           flavor = f_append;
    2306           break;
    2307         }
    2308 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
    2309       else if (c == '<' && *p == '=')
    2310         {
    2311           end = p++ - 1;
    2312           flavor = f_prepend;
    2313           break;
    2314         }
    2315 #endif
    2316       else if (c == '?' && *p == '=')
    2317         {
    2318           end = p++ - 1;
    2319           flavor = f_conditional;
    2320           break;
    2321         }
    2322       else if (c == '$')
    2323         {
    2324           /* This might begin a variable expansion reference.  Make sure we
    2325              don't misrecognize chars inside the reference as =, := or +=.  */
     2350          /* This begins a variable expansion reference.  Make sure we don't
     2351             treat chars inside the reference as assignment tokens.  */
    23262352          char closeparen;
    23272353          int count;
     
    23322358            closeparen = '}';
    23332359          else
    2334             continue;           /* Nope.  */
     2360            /* '$$' or '$X'.  Either way, nothing special to do here.  */
     2361            continue;
    23352362
    23362363          /* P now points past the opening paren or brace.
     
    23472374                }
    23482375            }
     2376          continue;
    23492377        }
    2350     }
    2351   v->flavor = flavor;
     2378
     2379      /* If we find whitespace skip it, and remember we found it.  */
     2380      if (isblank ((unsigned char)c))
     2381        {
     2382          wspace = 1;
     2383          p = next_token (p);
     2384          c = *p;
     2385          if (c == '\0')
     2386            return NULL;
     2387          ++p;
     2388        }
     2389
     2390
     2391      if (c == '=')
     2392        {
     2393          *flavor = f_recursive;
     2394          return (char *)p;
     2395        }
     2396
     2397      /* Match assignment variants (:=, +=, ?=)  */
     2398      if (*p == '=')
     2399        {
     2400          switch (c)
     2401            {
     2402              case ':':
     2403                *flavor = f_simple;
     2404                break;
     2405              case '+':
     2406                *flavor = f_append;
     2407                break;
     2408#ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
     2409              case '<':
     2410               *flavor = f_prepend;
     2411                break;
     2412#endif
     2413              case '?':
     2414                *flavor = f_conditional;
     2415                break;
     2416              default:
     2417                /* If we skipped whitespace, non-assignments means no var.  */
     2418                if (wspace)
     2419                  return NULL;
     2420
     2421                /* Might be assignment, or might be $= or #=.  Check.  */
     2422                continue;
     2423            }
     2424          return (char *)++p;
     2425        }
     2426      else if (c == ':')
     2427        /* A colon other than := is a rule line, not a variable defn.  */
     2428        return NULL;
     2429
     2430      /* If we skipped whitespace, non-assignments means no var.  */
     2431      if (wspace)
     2432        return NULL;
     2433    }
     2434
     2435  return (char *)p;
     2436}
     2437
     2438
     2439/* Try to interpret LINE (a null-terminated string) as a variable definition.
     2440
     2441   If LINE was recognized as a variable definition, a pointer to its `struct
     2442   variable' is returned.  If LINE is not a variable definition, NULL is
     2443   returned.  */
     2444
     2445struct variable *
     2446assign_variable_definition (struct variable *v, char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos))
     2447{
     2448  char *beg;
     2449  char *end;
     2450  enum variable_flavor flavor;
     2451#ifndef CONFIG_WITH_VALUE_LENGTH
     2452  char *name;
     2453#endif
    23522454
    23532455  beg = next_token (line);
     2456  line = parse_variable_definition (beg, &flavor);
     2457  if (!line)
     2458    return NULL;
     2459
     2460  end = line - (flavor == f_recursive ? 1 : 2);
    23542461  while (end > beg && isblank ((unsigned char)end[-1]))
    23552462    --end;
    2356   p = next_token (p);
    2357   v->value = p;
     2463  line = next_token (line);
     2464  v->value = line;
     2465  v->flavor = flavor;
    23582466#ifdef CONFIG_WITH_VALUE_LENGTH
    23592467  v->value_alloc_len = ~(unsigned int)0;
    2360   v->value_length = eos != NULL ? eos - p : -1;
    2361   assert (eos == NULL || strchr (p, '\0') == eos);
     2468  v->value_length = eos != NULL ? eos - line : -1;
     2469  assert (eos == NULL || strchr (line, '\0') == eos);
    23622470# ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE
    23632471  v->rdonly_val = 0;
     
    23892497   or without the -e switch, or the command line.
    23902498
    2391    See the comments for parse_variable_definition().
     2499   See the comments for assign_variable_definition().
    23922500
    23932501   If LINE was recognized as a variable definition, a pointer to its `struct
     
    23962504
    23972505struct variable *
    2398 #ifndef CONFIG_WITH_VALUE_LENGTH
    2399 try_variable_definition (const struct floc *flocp, char *line,
     2506try_variable_definition (const struct floc *flocp, char *line
     2507                         IF_WITH_VALUE_LENGTH_PARAM(char *eos),
    24002508                         enum variable_origin origin, int target_var)
    2401 #else
    2402 try_variable_definition (const struct floc *flocp, char *line, char *eos,
    2403                          enum variable_origin origin, int target_var)
    2404 #endif
    24052509{
    24062510  struct variable v;
     
    24132517
    24142518#ifndef CONFIG_WITH_VALUE_LENGTH
    2415   if (!parse_variable_definition (&v, line))
     2519  if (!assign_variable_definition (&v, line))
    24162520    return 0;
    24172521
     
    24192523                               origin, v.flavor, target_var);
    24202524#else
    2421   if (!parse_variable_definition (&v, line, eos))
     2525  if (!assign_variable_definition (&v, line, eos))
    24222526    return 0;
    24232527
     
    24862590  fputs ("# ", stdout);
    24872591  fputs (origin, stdout);
     2592  if (v->private_var)
     2593    fputs (" private", stdout);
    24882594  if (v->fileinfo.filenm)
    24892595    printf (_(" (from `%s', line %lu)"),
     
    25142620  else
    25152621    {
    2516       register char *p;
     2622      char *p;
    25172623
    25182624      printf ("%s %s= ", v->name, v->recursive ? v->append ? "+" : "" : ":");
     
    26602766   */
    26612767  convert_Path_to_windows32 (path, ';');
    2662   environ_path = xstrdup (concat ("PATH", "=", path));
     2768  environ_path = xstrdup (concat (3, "PATH", "=", path));
    26632769  putenv (environ_path);
    26642770  free (path);
  • trunk/src/kmk/variable.h

    r2005 r2591  
    8282                                   exported.  */
    8383    unsigned int expanding:1;   /* Nonzero if currently being expanded.  */
     84    unsigned int private_var:1; /* Nonzero avoids inheritance of this
     85                                   target-specific variable.  */
    8486    unsigned int exp_count:EXP_COUNT_BITS;
    8587                                /* If >1, allow this many self-referential
     
    122124    struct variable_set_list *next;     /* Link in the chain.  */
    123125    struct variable_set *set;           /* Variable set.  */
     126    int next_is_parent;                 /* True if next is a parent target.  */
    124127  };
    125128
     
    137140extern char *variable_buffer;
    138141extern struct variable_set_list *current_variable_set_list;
     142extern struct variable *default_goal_var;
     143
    139144#ifdef KMK
    140145extern unsigned int variable_buffer_length;
    141 #define VARIABLE_BUFFER_ZONE    5
     146# define VARIABLE_BUFFER_ZONE   5
    142147#endif
    143148
    144149/* expand.c */
    145150#ifndef KMK
    146 char *variable_buffer_output (char *ptr, const char *string, unsigned int length);
     151char *
     152variable_buffer_output (char *ptr, const char *string, unsigned int length);
    147153#else /* KMK */
    148154/* Subroutine of variable_expand and friends:
     
    209215char *expand_argument (const char *str, const char *end);
    210216#ifndef CONFIG_WITH_VALUE_LENGTH
    211 char *variable_expand_string (char *line, const char *string, long length);
     217char *
     218variable_expand_string (char *line, const char *string, long length);
    212219#else  /* CONFIG_WITH_VALUE_LENGTH */
    213 char *variable_expand_string_2 (char *line, const char *string, long length, char **eol);
     220char *
     221variable_expand_string_2 (char *line, const char *string, long length, char **eol);
    214222__inline static char *
    215223variable_expand_string (char *line, const char *string, long length)
     
    314322                                         enum variable_flavor flavor,
    315323                                         int target_var);
    316 struct variable *parse_variable_definition (struct variable *v, char *line);
    317 struct variable *try_variable_definition (const struct floc *flocp, char *line,
    318                                           enum variable_origin origin,
    319                                           int target_var);
    320324#else  /* CONFIG_WITH_VALUE_LENGTH */
    321325# define do_variable_definition(flocp, varname, value, origin, flavor, target_var) \
    322326    do_variable_definition_2 ((flocp), (varname), (value), ~0U, 0, NULL, \
    323327                              (origin), (flavor), (target_var))
    324 
    325328struct variable *do_variable_definition_2 (const struct floc *flocp,
    326329                                           const char *varname,
     
    331334                                           enum variable_flavor flavor,
    332335                                           int target_var);
    333 struct variable *parse_variable_definition (struct variable *v, char *line,
    334                                             char *eos);
    335 struct variable *try_variable_definition (const struct floc *flocp, char *line,
    336                                           char *eos,
     336#endif /* CONFIG_WITH_VALUE_LENGTH */
     337char *parse_variable_definition (const char *line,
     338                                          enum variable_flavor *flavor);
     339struct variable *assign_variable_definition (struct variable *v, char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos));
     340struct variable *try_variable_definition (const struct floc *flocp, char *line
     341                                          IF_WITH_VALUE_LENGTH_PARAM(char *eos),
    337342                                          enum variable_origin origin,
    338343                                          int target_var);
    339 #endif /* CONFIG_WITH_VALUE_LENGTH */
    340344void init_hash_global_variable_set (void);
    341345void hash_init_function_table (void);
     
    367371                                 current_variable_set_list->set,NILF)
    368372
     373/* Define a variable with a constant name in the current variable set.  */
     374
     375#define define_variable_cname(n,v,o,r) \
     376          define_variable_in_set((n),(sizeof (n) - 1),(v),~0U,1,(o),(r),\
     377                                 current_variable_set_list->set,NILF)
     378
    369379/* Define a variable with a location in the current variable set.  */
    370380
     
    401411                                 current_variable_set_list->set,NILF)           /* force merge conflict */
    402412
     413/* Define a variable with a constant name in the current variable set.  */
     414
     415#define define_variable_cname(n,v,o,r) \
     416          define_variable_in_set((n),(sizeof (n) - 1),(v),(o),(r),\
     417                                 current_variable_set_list->set,NILF)           /* force merge conflict */
     418
    403419/* Define a variable with a location in the current variable set.  */
    404420
     
    418434
    419435#endif /* !CONFIG_WITH_VALUE_LENGTH */
     436
     437void undefine_variable_in_set (const char *name, unsigned int length,
     438                                         enum variable_origin origin,
     439                                         struct variable_set *set);
     440
     441/* Remove variable from the current variable set. */
     442
     443#define undefine_variable_global(n,l,o) \
     444          undefine_variable_in_set((n),(l),(o),NULL)
    420445
    421446/* Warn that NAME is an undefined variable.  */
     
    444469#endif
    445470#define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1)
     471
  • trunk/src/kmk/version.c

    r1993 r2591  
    11/* Record version and build host architecture for GNU make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
  • trunk/src/kmk/vmsdir.h

    r1993 r2591  
    11/* dirent.h for vms
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/vmsfunctions.c

    r1993 r2591  
    11/* VMS functions
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    3535opendir (char *dspec)
    3636{
    37   struct DIR *dir  = (struct DIR *)xmalloc (sizeof (struct DIR));
    38   struct NAM *dnam = (struct NAM *)xmalloc (sizeof (struct NAM));
     37  struct DIR *dir  = xcalloc (sizeof (struct DIR));
     38  struct NAM *dnam = xmalloc (sizeof (struct NAM));
    3939  struct FAB *dfab = &dir->fab;
    4040  char *searchspec = xmalloc (MAXNAMLEN + 1);
    41 
    42   memset (dir, 0, sizeof *dir);
    4341
    4442  *dfab = cc$rms_fab;
     
    9290  if (!((i = sys$search (dfab)) & 1))
    9391    {
    94       DB (DB_VERBOSE, (_("sys$search failed with %d\n"), i));
     92      DB (DB_VERBOSE, (_("sys$search() failed with %d\n"), i));
    9593      return (NULL);
    9694    }
     
    142140}
    143141
     142#if 0
     143/*
     144 * Is this used? I don't see any reference, so I suggest to remove it.
     145 */
    144146int
    145147vms_stat (char *name, struct stat *buf)
     
    238240  return 0;
    239241}
     242#endif
    240243
    241244char *
  • trunk/src/kmk/vmsify.c

    r1993 r2591  
    11/* vmsify.c -- Module for vms <-> unix file name conversion
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    121121  char *s;
    122122
    123   INIT_DSC_CSTRING (name_dsc, name);
     123  /*
     124   * the string isn't changed, but there is no string descriptor with
     125   * "const char *dsc$a_pointer"
     126   */
     127  INIT_DSC_CSTRING (name_dsc, (char *)name);
    124128
    125129  stat = lib$sys_trnlog (&name_dsc, &resltlen, &reslt_dsc);
     
    228232  int as_dir;
    229233  int count;
     234  const char *s;
     235  const char *s1;
     236  const char *s2;
    230237
    231238  if (name == 0)
     
    240247  if (t != 0)
    241248    {
    242       const char *s1;
    243       const char *s2;
     249//      const char *s1;
     250//      const char *s2;
    244251
    245252      if (type == 1)
     
    273280  if (t != 0)
    274281    {
    275       const char *s;
    276       const char *s1 = strchr (t+1, '[');
     282//      const char *s;
     283//      const char *s1 = strchr (t+1, '[');
     284      s1 = strchr (t+1, '[');
    277285      if (s1 == 0)
    278286        {
     
    389397          case 3:                               /* '//' at start */
    390398            {
    391             const char *s;
    392             const char *s1;
     399//            const char *s;
     400//            const char *s1;
    393401            char *vp;
    394402            while (*fptr == '/')        /* collapse all '/' */
  • trunk/src/kmk/vmsjobs.c

    • Property svn:keywords deleted
    r1993 r2591  
    33
    44Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    5 2007 Free Software Foundation, Inc.
     52007, 2008, 2009, 2010 Free Software Foundation, Inc.
    66This file is part of GNU Make.
    77
     
    111111}
    112112
    113 /* This is called as an AST when a child process dies (it won't get
    114    interrupted by anything except a higher level AST).
     113static int ctrlYPressed= 0;
     114/* This is called at main or AST level. It is at AST level for DONTWAITFORCHILD
     115   and at main level otherwise. In any case it is called when a child process
     116   terminated. At AST level it won't get interrupted by anything except a
     117   inner mode level AST.
    115118*/
    116119int
     
    124127
    125128    lib$free_ef(&child->efn);
     129    if (child->comname)
     130      {
     131        if (!ISDB (DB_JOBS)&&!ctrlYPressed)
     132          unlink (child->comname);
     133        free (child->comname);
     134      }
    126135
    127136    (void) sigblock (fatal_signal_mask);
     
    220229static int oldCtrlMask;
    221230static int setupYAstTried= 0;
    222 static int pidToAbort= 0;
    223 static int chan= 0;
     231static unsigned short int chan= 0;
    224232
    225233static void
     
    229237}
    230238
    231 static void
    232 astHandler (void)
     239static int
     240astYHandler (void)
    233241{
    234         if (pidToAbort) {
    235                 sys$forcex (&pidToAbort, 0, SS$_ABORT);
    236                 pidToAbort= 0;
    237         }
     242        struct child *c;
     243        for (c = children; c != 0; c = c->next)
     244                sys$delprc (&c->pid, 0, 0);
     245        ctrlYPressed= 1;
    238246        kill (getpid(),SIGQUIT);
     247        return SS$_NORMAL;
    239248}
    240249
     
    248257                int     dvi;
    249258        } iosb;
     259        unsigned short int loc_chan;
    250260
    251261        setupYAstTried++;
    252262
    253         if (!chan) {
    254                 status= sys$assign(&inputDsc,&chan,0,0);
     263        if (chan)
     264          loc_chan= chan;
     265        else {
     266                status= sys$assign(&inputDsc,&loc_chan,0,0);
    255267                if (!(status&SS$_NORMAL)) {
    256268                        lib$signal(status);
     
    258270                }
    259271        }
    260         status= sys$qiow (0, chan, IO$_SETMODE|IO$M_CTRLYAST,&iosb,0,0,
    261                 astHandler,0,0,0,0,0);
    262         if (status==SS$_NORMAL)
    263                 status= iosb.status;
    264         if (status==SS$_ILLIOFUNC || status==SS$_NOPRIV) {
    265                 sys$dassgn(chan);
    266 #ifdef  CTRLY_ENABLED_ANYWAY
    267                 fprintf (stderr,
    268                          _("-warning, CTRL-Y will leave sub-process(es) around.\n"));
    269 #else
    270                 return;
    271 #endif
    272         }
    273         else if (!(status&SS$_NORMAL)) {
    274                 sys$dassgn(chan);
    275                 lib$signal(status);
     272        status= sys$qiow (0, loc_chan, IO$_SETMODE|IO$M_CTRLYAST,&iosb,0,0,
     273                          astYHandler,0,0,0,0,0);
     274        if (status==SS$_NORMAL)
     275                status= iosb.status;
     276        if (status!=SS$_NORMAL) {
     277                if (!chan)
     278                        sys$dassgn(loc_chan);
     279                if (status!=SS$_ILLIOFUNC && status!=SS$_NOPRIV)
     280                        lib$signal(status);
    276281                return;
    277282        }
     
    288293                return;
    289294        }
     295        if (!chan)
     296                chan = loc_chan;
    290297}
    291298
     
    300307  static struct dsc$descriptor_s efiledsc;
    301308  int have_redirection = 0;
     309  int have_append = 0;
    302310  int have_newline = 0;
    303311
     
    306314  char *cmd = alloca (strlen (argv) + 512), *p, *q;
    307315  char ifile[256], ofile[256], efile[256];
    308   char *comname = 0;
     316  int comnamelen;
    309317  char procname[100];
    310318  int in_string;
     
    315323  ofile[0] = 0;
    316324  efile[0] = 0;
     325  child->comname = NULL;
    317326
    318327  DB (DB_JOBS, ("child_execute_job (%s)\n", argv));
     
    384393            else
    385394              {
     395                if (*(p+1) == '>')
     396                  {
     397                    have_append = 1;
     398                    p += 1;
     399                  }
    386400                p = vms_redirect (&ofiledsc, ofile, p);
    387401              }
     
    482496        }
    483497
    484       outfile = open_tmpfile (&comname, "sys$scratch:CMDXXXXXX.COM");
     498      outfile = open_tmpfile (&child->comname, "sys$scratch:CMDXXXXXX.COM");
    485499      if (outfile == 0)
    486500        pfatal_with_name (_("fopen (temporary file)"));
     501      comnamelen = strlen (child->comname);
    487502
    488503      if (ifile[0])
     
    502517      if (ofile[0])
    503518        {
    504           fprintf (outfile, "$ define sys$output %s\n", ofile);
    505           DB (DB_JOBS, (_("Redirected output to %s\n"), ofile));
    506           ofiledsc.dsc$w_length = 0;
     519          if (have_append)
     520            {
     521              fprintf (outfile, "$ set noon\n");
     522              fprintf (outfile, "$ define sys$output %.*s\n", comnamelen-3, child->comname);
     523              DB (DB_JOBS, (_("Append output to %s\n"), ofile));
     524              ofiledsc.dsc$w_length = 0;
     525            }
     526          else
     527            {
     528              fprintf (outfile, "$ define sys$output %s\n", ofile);
     529              DB (DB_JOBS, (_("Redirected output to %s\n"), ofile));
     530              ofiledsc.dsc$w_length = 0;
     531            }
    507532        }
    508533
     
    559584        }
    560585
    561       fwrite (p, 1, q - p, outfile);
     586      if (*p)
     587        {
     588          fwrite (p, 1, --q - p, outfile);
    562589      fputc ('\n', outfile);
     590        }
     591
     592      if (have_append)
     593        {
     594          fprintf (outfile, "$ deassign sys$output ! 'f$verify(0)\n");
     595          fprintf (outfile, "$ append:=append\n");
     596          fprintf (outfile, "$ delete:=delete\n");
     597          fprintf (outfile, "$ append/new %.*s %s\n", comnamelen-3, child->comname, ofile);
     598          fprintf (outfile, "$ delete %.*s;*\n", comnamelen-3, child->comname);
     599          DB (DB_JOBS, (_("Append %.*s and cleanup\n"), comnamelen-3, child->comname));
     600        }
    563601
    564602      fclose (outfile);
    565603
    566       sprintf (cmd, "$ @%s", comname);
     604      sprintf (cmd, "$ @%s", child->comname);
    567605
    568606      DB (DB_JOBS, (_("Executing %s instead\n"), cmd));
     
    579617      status = lib$get_ef ((unsigned long *)&child->efn);
    580618      if (!(status & 1))
    581         return 0;
     619        {
     620          if (child->comname)
     621            {
     622              if (!ISDB (DB_JOBS))
     623                unlink (child->comname);
     624              free (child->comname);
     625            }
     626          return 0;
     627        }
    582628    }
    583629
     
    648694  if (status & 1)
    649695    {
    650       pidToAbort= child->pid;
    651696      status= sys$waitfr (child->efn);
    652       pidToAbort= 0;
    653697      vmsHandleChildTerm(child);
    654698    }
     
    678722    }
    679723
    680   if (comname && !ISDB (DB_JOBS))
    681     unlink (comname);
    682 
    683724  return (status & 1);
    684725}
  • trunk/src/kmk/vpath.c

    r1993 r2591  
    11/* Implementation of pattern-matching file search paths for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    150150
    151151
    152 /* Construct the VPATH listing for the pattern and searchpath given.
     152/* Construct the VPATH listing for the PATTERN and DIRPATH given.
    153153
    154154   This function is called to generate selective VPATH lists and also for
     
    158158   variable.
    159159
    160    If SEARCHPATH is nil, remove all previous listings with the same
     160   If DIRPATH is nil, remove all previous listings with the same
    161161   pattern.  If PATTERN is nil, remove all VPATH listings.  Existing
    162    and readable directories that are not "." given in the searchpath
     162   and readable directories that are not "." given in the DIRPATH
    163163   separated by the path element separator (defined in make.h) are
    164164   loaded into the directory hash table if they are not there already
     
    205205
    206206              /* Free its unused storage.  */
    207               free (path->searchpath);
     207              /* MSVC erroneously warns without a cast here.  */
     208              free ((void *)path->searchpath);
    208209              free (path);
    209210            }
     
    310311  else
    311312    /* There were no entries, so free whatever space we allocated.  */
    312     free (vpath);
     313    /* MSVC erroneously warns without a cast here.  */
     314    free ((void *)vpath);
    313315}
    314316
     
    335337   FILE exists.  If it is found, we return a cached name of the existing file
    336338   and set *MTIME_PTR (if MTIME_PTR is not NULL) to its modtime (or zero if no
    337    stat call was done).  Otherwise we return NULL.  */
     339   stat call was done). Also set the matching directory index in PATH_INDEX
     340   if it is not NULL. Otherwise we return NULL.  */
    338341
    339342static const char *
    340343selective_vpath_search (struct vpath *path, const char *file,
    341                         FILE_TIMESTAMP *mtime_ptr)
     344                        FILE_TIMESTAMP *mtime_ptr, unsigned int* path_index)
    342345{
    343346  int not_target;
     
    519522          /* Store the name we found and return it.  */
    520523
     524          if (path_index)
     525            *path_index = i;
     526
    521527          return strcache_add_len (name, (p + 1 - name) + flen);
    522528        }
     
    530536   exists.  If it is found, return the cached name of an existing file, and
    531537   set *MTIME_PTR (if MTIME_PTR is not NULL) to its modtime (or zero if no
    532    stat call was done).  Otherwise we return 0.  */
     538   stat call was done). Also set the matching directory index in VPATH_INDEX
     539   and PATH_INDEX if they are not NULL.  Otherwise we return 0.  */
    533540
    534541const char *
    535 vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr)
     542vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
     543              unsigned int* vpath_index, unsigned int* path_index)
    536544{
    537545  struct vpath *v;
     
    547555    return 0;
    548556
     557  if (vpath_index)
     558    {
     559      *vpath_index = 0;
     560      *path_index = 0;
     561    }
     562
    549563  for (v = vpaths; v != 0; v = v->next)
    550     if (pattern_matches (v->pattern, v->percent, file))
    551       {
    552         const char *p = selective_vpath_search (v, file, mtime_ptr);
    553         if (p)
    554           return p;
    555       }
     564    {
     565      if (pattern_matches (v->pattern, v->percent, file))
     566        {
     567          const char *p = selective_vpath_search (
     568            v, file, mtime_ptr, path_index);
     569          if (p)
     570            return p;
     571        }
     572
     573      if (vpath_index)
     574        ++*vpath_index;
     575    }
     576
    556577
    557578  if (general_vpath != 0)
    558579    {
    559       const char *p = selective_vpath_search (general_vpath, file, mtime_ptr);
     580      const char *p = selective_vpath_search (
     581        general_vpath, file, mtime_ptr, path_index);
    560582      if (p)
    561583        return p;
     
    564586  return 0;
    565587}
     588
     589
     590
    566591
    567592
  • trunk/src/kmk/w32

    • Property svn:ignore
      •  

        old new  
        11Makefile
        22Makefile.in
         3.deps
  • trunk/src/kmk/w32/Makefile.am

    • Property svn:keywords deleted
    r1993 r2591  
    11# Makefile.am to create libw32.a for mingw32 host.
    22# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 # 2007 Free Software Foundation, Inc.
     3# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44# This file is part of GNU Make.
    55#
  • trunk/src/kmk/w32/compat/dirent.c

    r1993 r2591  
    11/* Directory entry code for Window platforms.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    1717
    1818
    19 #ifdef KMK
    20 # include "config.h" /* my_stat */
    21 #endif
     19#include <config.h>
    2220#include <sys/types.h>
    2321#include <sys/stat.h>
     
    142140
    143141        /* fill in struct dirent values */
    144         pDir->dir_sdReturn.d_ino = -1;
     142        pDir->dir_sdReturn.d_ino = (ino_t)-1;
    145143        strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
    146144
  • trunk/src/kmk/w32/include/dirent.h

    r1993 r2591  
    11/* Windows version of dirent.h
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/w32/include/pathstuff.h

    r1993 r2591  
    11/* Definitions for Windows path manipulation.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/w32/include/sub_proc.h

    r1993 r2591  
    11/* Definitions for Windows process invocation.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    2222 * Component Name:
    2323 *
    24  * $Date: 2007/10/24 20:06:32 $
     24 * $Date: 2010/07/13 01:20:43 $
    2525 *
    2626 * $Source: /sources/make/make/w32/include/sub_proc.h,v $
    2727 *
    28  * $Id: sub_proc.h,v 1.10 2007/10/24 20:06:32 eliz Exp $
     28 * $Id: sub_proc.h,v 1.12 2010/07/13 01:20:43 psmith Exp $
    2929 */
    3030
  • trunk/src/kmk/w32/include/w32err.h

    r1993 r2591  
    11/* Definitions for Windows error handling.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/w32/pathstuff.c

    r2454 r2591  
    11/* Path conversion for Windows pathnames.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    3 2007, 2009 Free Software Foundation, Inc.
     32007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    1717
    1818#include <Windows.h> /* bird */
    19 #include <stdio.h>   /* bird */
     19#include "make.h"
    2020#include <string.h>
    2121#include <stdlib.h>
    22 #include "make.h"
    2322#include "pathstuff.h"
    2423
     
    8382                *etok = to_delim;
    8483                p = ++etok;
    85             } else
     84            } else
    8685                p += strlen(p);
    8786        } else {
  • trunk/src/kmk/w32/subproc/NMakefile

    r1993 r2591  
    33#
    44# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    5 # 2006, 2007 Free Software Foundation, Inc.
     5# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    66# This file is part of GNU Make.
    77#
  • trunk/src/kmk/w32/subproc/build.bat

    r1993 r2591  
    1919@echo off
    2020rem Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    21 rem 2005, 2006, 2007 Free Software Foundation, Inc.
     21rem 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    2222rem This file is part of GNU Make.
    2323rem
  • trunk/src/kmk/w32/subproc/misc.c

    r1993 r2591  
    11/* Process handling for Windows
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    1616this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1717
     18#include <config.h>
    1819#include <stddef.h>
    1920#include <stdlib.h>
     
    7879        }
    7980
    80         free(tmp);
     81        free(tmp);
    8182        return TRUE;
    8283}
  • trunk/src/kmk/w32/subproc/proc.h

    r1993 r2591  
    11/* Definitions for Windows
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
  • trunk/src/kmk/w32/subproc/sub_proc.c

    r1993 r2591  
    11/* Process handling for Windows.
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
     
    1616this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1717
     18#include <config.h>
    1819#include <stdlib.h>
    1920#include <stdio.h>
     21#ifdef _MSC_VER
     22# include <stddef.h>    /* for intptr_t */
     23#else
     24# include <stdint.h>
     25#endif
    2026#include <process.h>  /* for msvc _beginthreadex, _endthreadex */
    2127#include <signal.h>
     
    2531#include "proc.h"
    2632#include "w32err.h"
    27 #include "config.h"
    2833#include "debug.h"
    2934
    3035static char *make_command_line(char *shell_name, char *exec_path, char **argv);
     36extern char *xmalloc (unsigned int);
    3137
    3238typedef struct sub_process_t {
    33         int sv_stdin[2];
    34         int sv_stdout[2];
    35         int sv_stderr[2];
     39        intptr_t sv_stdin[2];
     40        intptr_t sv_stdout[2];
     41        intptr_t sv_stderr[2];
    3642        int using_pipes;
    3743        char *inp;
     
    4147        char * volatile errp;
    4248        volatile DWORD errcnt;
    43         int pid;
     49        pid_t pid;
    4450        int exit_code;
    4551        int signal;
     
    316322                return((HANDLE)pproc);
    317323        }
    318         pproc->sv_stdin[0]  = (int) stdin_pipes[0];
    319         pproc->sv_stdin[1]  = (int) stdin_pipes[1];
    320         pproc->sv_stdout[0] = (int) stdout_pipes[0];
    321         pproc->sv_stdout[1] = (int) stdout_pipes[1];
    322         pproc->sv_stderr[0] = (int) stderr_pipes[0];
    323         pproc->sv_stderr[1] = (int) stderr_pipes[1];
     324        pproc->sv_stdin[0]  = (intptr_t) stdin_pipes[0];
     325        pproc->sv_stdin[1]  = (intptr_t) stdin_pipes[1];
     326        pproc->sv_stdout[0] = (intptr_t) stdout_pipes[0];
     327        pproc->sv_stdout[1] = (intptr_t) stdout_pipes[1];
     328        pproc->sv_stderr[0] = (intptr_t) stderr_pipes[0];
     329        pproc->sv_stderr[1] = (intptr_t) stderr_pipes[1];
    324330
    325331        pproc->using_pipes = 1;
     
    343349         * pipe, bypassing pipes altogether.
    344350         */
    345         pproc->sv_stdin[1]  = (int) stdinh;
    346         pproc->sv_stdout[1] = (int) stdouth;
    347         pproc->sv_stderr[1] = (int) stderrh;
     351        pproc->sv_stdin[1]  = (intptr_t) stdinh;
     352        pproc->sv_stdout[1] = (intptr_t) stdouth;
     353        pproc->sv_stderr[1] = (intptr_t) stderrh;
    348354
    349355        pproc->last_err = pproc->lerrno = 0;
     
    354360
    355361static HANDLE
    356 find_file(char *exec_path, LPOFSTRUCT file_info)
     362find_file(const char *exec_path, const char *path_var,
     363          char *full_fname, DWORD full_len)
    357364{
    358365        HANDLE exec_handle;
    359366        char *fname;
    360367        char *ext;
    361 #ifdef KMK
    362         size_t exec_path_len;
    363 
    364         /*
    365          * if there is an .exe extension there already, don't waste time here.
    366          * If .exe scripts become common, they can be handled in a CreateProcess
    367          * failure path instead of here.
    368          */
    369         exec_path_len = strlen(exec_path);
    370         if (    exec_path_len > 4
    371                 &&      exec_path[exec_path_len - 4] == '.'
    372                 &&  !stricmp(exec_path + exec_path_len - 3, "exe")){
    373                 return((HANDLE)HFILE_ERROR);
    374         }
    375 
    376         fname = malloc(exec_path_len + 5);
    377 #else
    378         fname = malloc(strlen(exec_path) + 5);
    379 #endif
     368        DWORD req_len;
     369        int i;
     370        static const char *extensions[] =
     371          /* Should .com come before no-extension case?  */
     372          { ".exe", ".cmd", ".bat", "", ".com", NULL };
     373
     374        fname = xmalloc(strlen(exec_path) + 5);
    380375        strcpy(fname, exec_path);
    381376        ext = fname + strlen(fname);
    382377
    383         strcpy(ext, ".exe");
    384         if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
    385                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    386                 free(fname);
    387                 return(exec_handle);
    388         }
    389 
    390         strcpy(ext, ".cmd");
    391         if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
    392                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    393                 free(fname);
    394                 return(exec_handle);
    395         }
    396 
    397         strcpy(ext, ".bat");
    398         if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
    399                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    400                 free(fname);
    401                 return(exec_handle);
    402         }
    403 
    404         /* should .com come before this case? */
    405         if ((exec_handle = (HANDLE)OpenFile(exec_path, file_info,
    406                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    407                 free(fname);
    408                 return(exec_handle);
    409         }
    410 
    411         strcpy(ext, ".com");
    412         if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
    413                         OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
    414                 free(fname);
    415                 return(exec_handle);
     378        for (i = 0; extensions[i]; i++) {
     379                strcpy(ext, extensions[i]);
     380                if (((req_len = SearchPath (path_var, fname, NULL, full_len,
     381                                            full_fname, NULL)) > 0
     382                     /* For compatibility with previous code, which
     383                        used OpenFile, and with Windows operation in
     384                        general, also look in various default
     385                        locations, such as Windows directory and
     386                        Windows System directory.  Warning: this also
     387                        searches PATH in the Make's environment, which
     388                        might not be what the Makefile wants, but it
     389                        seems to be OK as a fallback, after the
     390                        previous SearchPath failed to find on child's
     391                        PATH.  */
     392                     || (req_len = SearchPath (NULL, fname, NULL, full_len,
     393                                               full_fname, NULL)) > 0)
     394                    && req_len <= full_len
     395                    && (exec_handle =
     396                                CreateFile(full_fname,
     397                                           GENERIC_READ,
     398                                           FILE_SHARE_READ | FILE_SHARE_WRITE,
     399                                           NULL,
     400                                           OPEN_EXISTING,
     401                                           FILE_ATTRIBUTE_NORMAL,
     402                                           NULL)) != INVALID_HANDLE_VALUE) {
     403                        free(fname);
     404                        return(exec_handle);
     405                }
    416406        }
    417407
    418408        free(fname);
    419         return(exec_handle);
     409        return INVALID_HANDLE_VALUE;
    420410}
    421411
     
    440430        int file_not_found=0;
    441431        HANDLE exec_handle;
     432        char exec_fname[MAX_PATH];
     433        const char *path_var = NULL;
     434        char **ep;
    442435        char buf[256];
    443436        DWORD bytes_returned;
     
    447440        PROCESS_INFORMATION procInfo;
    448441        char *envblk=NULL;
    449         OFSTRUCT file_info;
    450 
     442#ifdef KMK
     443        size_t exec_path_len;
     444#endif
     445
     446
     447        /*
     448         *  Shell script detection...  if the exec_path starts with #! then
     449         *  we want to exec shell-script-name exec-path, not just exec-path
     450         *  NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl.  We do not
     451         *  hard-code the path to the shell or perl or whatever:  Instead, we
     452         *  assume it's in the path somewhere (generally, the NT tools
     453         *  bin directory)
     454         */
     455
     456#ifdef KMK
     457        /* kmk performace: Don't bother looking for shell scripts in .exe files. */
     458        exec_path_len = strlen(exec_path);
     459        if (exec_path_len > 4
     460            && exec_path[exec_path_len - 4] == '.'
     461            && !stricmp(exec_path + exec_path_len - 3, "exe")) {
     462                exec_handle =  INVALID_HANDLE_VALUE;
     463        }
     464        else {
     465#endif /* KMK */
     466                /* Use the Makefile's value of PATH to look for the program to
     467                   execute, because it could be different from Make's PATH
     468                   (e.g., if the target sets its own value.  */
     469                if (envp)
     470                        for (ep = envp; *ep; ep++) {
     471                                if (strncmp (*ep, "PATH=", 5) == 0
     472                                    || strncmp (*ep, "Path=", 5) == 0) {
     473                                        path_var = *ep + 5;
     474                                        break;
     475                                }
     476                        }
     477                exec_handle = find_file(exec_path, path_var,
     478                                        exec_fname, sizeof(exec_fname));
     479#ifdef KMK
     480        }
     481#endif
    451482
    452483        /*
    453          *  Shell script detection...  if the exec_path starts with #! then
    454          *  we want to exec shell-script-name exec-path, not just exec-path
    455          *  NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl.  We do not
    456          *  hard-code the path to the shell or perl or whatever:  Instead, we
    457          *  assume it's in the path somewhere (generally, the NT tools
    458          *  bin directory)
    459          *  We use OpenFile here because it is capable of searching the Path.
     484         * If we couldn't open the file, just assume that Windows will be
     485         * somehow able to find and execute it.
    460486         */
    461 
    462         exec_handle = find_file(exec_path, &file_info);
    463 
    464         /*
    465          * If we couldn't open the file, just assume that Windows32 will be able
    466          * to find and execute it.
    467          */
    468         if (exec_handle == (HANDLE)HFILE_ERROR) {
     487        if (exec_handle == INVALID_HANDLE_VALUE) {
    469488                file_not_found++;
    470489        }
     
    520539                command_line = make_command_line( shell_name, exec_path, argv);
    521540        else
    522                 command_line = make_command_line( shell_name, file_info.szPathName,
    523                                  argv);
     541                command_line = make_command_line( shell_name, exec_fname, argv);
    524542
    525543        if ( command_line == NULL ) {
     
    541559                exec_path = 0;  /* Search for the program in %Path% */
    542560        } else {
    543                 exec_path = file_info.szPathName;
     561                exec_path = exec_fname;
    544562        }
    545563
     
    608626        }
    609627
    610         pproc->pid = (int)procInfo.hProcess;
     628        pproc->pid = (pid_t)procInfo.hProcess;
    611629        /* Close the thread handle -- we'll just watch the process */
    612630        CloseHandle(procInfo.hThread);
  • trunk/src/kmk/w32/subproc/w32err.c

    r1993 r2591  
    11/* Error handling for Windows
    22Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007 Free Software Foundation, Inc.
     32006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    44This file is part of GNU Make.
    55
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